
* { box-sizing: border-box; }
:root {
    /* Material Design 3 Tokens (Light - Blue) */
    color-scheme: light dark;
    --md-sys-color-primary: #0061a4;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d1e4ff;
    --md-sys-color-on-primary-container: #001d36;
    --md-sys-color-secondary-container: #dbe4f0;
    --md-sys-color-on-secondary-container: #101c2b;
    --md-sys-color-background: #eef7ff;
    --md-sys-color-on-background: #1c1b1f;
    --md-sys-color-surface: #fdfcff;
    --md-sys-color-surface-variant: #e1e2ec;
    --md-sys-color-on-surface: #1c1b1f;
    --md-sys-color-on-surface-variant: #44474f;
    --md-sys-color-outline: #74777f;
    --md-sys-shape-corner: 28px;
    --md-sys-shape-corner-small: 12px;
    --shadow-elevation: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px rgba(0, 0, 0, 0.3);
}

@media only screen and (max-width: 600px) {
html {
    min-width: 360px; 
}
}
body.dark-mode {
    /* Material Design 3 Tokens (Dark - Blue) */
    --md-sys-color-primary: #9ecaff;
    --md-sys-color-on-primary: #003258;
    --md-sys-color-primary-container: #00497d;
    --md-sys-color-on-primary-container: #d1e4ff;
    --md-sys-color-secondary-container: #3b4858;
    --md-sys-color-on-secondary-container: #dbe4f0;
    --md-sys-color-background: #0d1620;
    --md-sys-color-on-background: #e2e2e6;
    --md-sys-color-surface: #1a1c1e;
    --md-sys-color-surface-variant: #44474f;
    --md-sys-color-on-surface: #e2e2e6;
    --md-sys-color-on-surface-variant: #c4c6d0;
    --md-sys-color-outline: #8e9099;
    --shadow-elevation: 0px 4px 8px 3px rgba(0, 0, 0, 0.5);
}
body {
    font-family: 'Open Sans', 'Noto Color Emoji', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}
.container {
    background: var(--md-sys-color-surface);
    padding: 32px 48px;
    border-radius: var(--md-sys-shape-corner);
    box-shadow: var(--shadow-elevation);
    width: calc(100% - 30px);
    max-width: 600px;
    transition: background-color 0.3s;
    overflow: hidden;
}
.content-wrapper { width: 100%; }
.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
h1 { margin: 0; font-size: 28px; font-weight: 400; color: var(--md-sys-color-on-surface); }

/* Android Switch Toggle */
.switch { position: relative; display: inline-block; width: 52px; height: 32px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--md-sys-color-surface-variant);
    border: 2px solid var(--md-sys-color-outline);
    transition: .3s; border-radius: 32px;
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 6px; bottom: 6px;
    background-color: var(--md-sys-color-outline);
    transition: .3s; border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--md-sys-color-on-primary);
    height: 24px; width: 24px; bottom: 2px; left: 4px;
}

.input-group { display: flex; gap: 12px; margin-bottom: 24px; align-items: center; }
input[type="text"] {
    flex-grow: 1;
    padding: 16px;
    border: none;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border-radius: var(--md-sys-shape-corner-small);
    outline: none;
    font-size: 16px;
    transition: background-color 0.3s;
    border-bottom: 2px solid transparent;
}
input[type="text"]:focus { border-bottom-color: var(--md-sys-color-primary); }

input[type="date"] {
    padding: 16px;
    border: none;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border-radius: var(--md-sys-shape-corner-small);
    outline: none;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;
    border-bottom: 2px solid transparent;
    transition: background-color 0.3s;
}
input[type="date"]:focus { border-bottom-color: var(--md-sys-color-primary); }

button {
    padding: 10px 24px;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    font-weight: 500;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    letter-spacing: 0.5px;
    transition: opacity 0.2s, transform 0.1s;
    flex-shrink: 0;
}
button:active { transform: scale(0.98); }
button:hover { opacity: 0.92; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

#add-btn, #save-btn { 
    background-color: var(--md-sys-color-primary); 
    color: var(--md-sys-color-on-primary); 
}

.filters { display: flex; gap: 2px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.filter-btn { 
    background-color: var(--md-sys-color-surface-variant); 
    color: var(--md-sys-color-on-surface-variant); 
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
}
.filter-btn:nth-child(1) { border-radius: 20px 4px 4px 20px; }
.filter-btn:nth-child(2) { border-radius: 4px; }
.filter-btn:nth-child(3) { border-radius: 4px 20px 20px 4px; }
.filter-btn:nth-child(4) { 
    margin-left: auto; 
    border-radius: 20px; 
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}
.filter-btn.active { 
    background-color: var(--md-sys-color-primary); 
    color: var(--md-sys-color-on-primary);
}

ul { list-style: none; padding: 0; margin: 0; }
li {
    background: var(--md-sys-color-surface-variant);
    padding: 12px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px;
    margin-bottom: 4px;
    transition: background-color 0.2s;
}
li:hover { filter: brightness(0.96); }
li:active { background-color: var(--md-sys-color-outline); }

.todo-content { display: flex; align-items: center; gap: 12px; flex-grow: 1; overflow: hidden; }
.todo-text { cursor: pointer; font-size: 16px; word-break: break-word; }
.completed .todo-text { text-decoration: line-through; color: var(--md-sys-color-on-surface-variant); opacity: 0.6; }
.todo-date { font-size: 12px; color: var(--md-sys-color-primary); display: block; margin-top: 2px; }

.actions { display: flex; gap: 4px; margin-left: 10px; }
.action-btn { 
    background: transparent; 
    color: var(--md-sys-color-on-surface-variant); 
    padding: 8px; 
    font-size: 12px; 
    border: none;
    border-radius: 50%;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
}
.action-btn:hover { background-color: rgba(0,0,0,0.05); color: var(--md-sys-color-primary); }
.delete-btn:hover { color: var(--md-sys-color-error, #b3261e); }
.material-symbols-rounded { font-size: 20px; pointer-events: none; }
.sortable-ghost { opacity: 0.4; background-color: var(--md-sys-color-surface-variant); }

input[type="checkbox"] { 
    appearance: none; -webkit-appearance: none;
    cursor: pointer; width: 22px; height: 22px; 
    border: 2px solid var(--md-sys-color-outline);
    border-radius: 50%;
    margin: 0;
    position: relative;
    transition: 0.2s;
}
input[type="checkbox"]:checked {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
input[type="checkbox"]:checked::after {
    content: '✔'; color: var(--md-sys-color-on-primary);
    font-size: 14px; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
}

.stats-row { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; font-size: 14px; color: var(--md-sys-color-on-surface-variant); border-top: 1px solid var(--md-sys-color-outline); padding-top: 16px; opacity: 0.8; }
#clear-btn { background: none; color: var(--md-sys-color-primary); padding: 0; font-weight: 500; font-size: 14px; }
#clear-btn:hover { background: none; opacity: 0.8; box-shadow: none; }

footer { margin-top: 24px; font-size: 14px; color: var(--md-sys-color-on-surface-variant); opacity: 0.7; text-align: center; }
footer a { color: var(--md-sys-color-primary); text-decoration: none; font-weight: 500; }
footer a:hover { text-decoration: underline; }

/* Modal Styles */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.modal.open { display: flex; opacity: 1; }
.modal-content {
    background-color: var(--md-sys-color-surface); padding: 24px; border-radius: 28px;
    width: 90%; max-width: 400px; box-shadow: var(--shadow-elevation);
    transform: scale(0.9); transition: transform 0.2s;
}
.modal.open .modal-content { transform: scale(1); }
.modal-header { font-size: 24px; margin-bottom: 16px; color: var(--md-sys-color-on-surface); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.cancel-btn { background-color: transparent; color: var(--md-sys-color-primary); }
.cancel-btn:hover { background-color: rgba(0,0,0,0.05); box-shadow: none; }

/* Snackbar */
#snackbar {
    visibility: hidden; min-width: 250px; background-color: var(--md-sys-color-on-surface); color: var(--md-sys-color-surface);
    text-align: center; border-radius: 4px; padding: 14px; position: fixed; z-index: 1000;
    left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 14px;
    box-shadow: var(--shadow-elevation);
}
#snackbar.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }
@keyframes fadein { from { bottom: 0; opacity: 0; } to { bottom: 30px; opacity: 1; } }
@keyframes fadeout { from { bottom: 30px; opacity: 1; } to { bottom: 0; opacity: 0; } }

/* FAB */
.fab {
    position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px;
    border-radius: 16px; background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container); box-shadow: var(--shadow-elevation);
    display: flex; align-items: center; justify-content: center; z-index: 900;
    border: none; cursor: pointer; transition: transform 0.2s;
}
.fab:hover { transform: scale(1.05); }
.fab span { font-size: 24px; pointer-events: none; }

/* Bottom Navigation (Mobile) */
.bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; width: 100%;
    height: 80px;
    background-color: var(--md-sys-color-surface);
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 999;
}
@media (max-width: 600px) { .bottom-nav { display: flex; } }
.nav-item {
    background: none; border: none; padding: 0;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: var(--md-sys-color-on-surface-variant);
    width: 64px; border-radius: 0; height: auto;
}
.nav-item:hover { background: none; box-shadow: none; opacity: 1; }
.nav-item span { font-size: 12px; font-weight: 500; }
.nav-item .material-symbols-rounded {
    font-size: 24px; padding: 4px 20px; border-radius: 16px; transition: background-color 0.2s;
}
.nav-item.active .material-symbols-rounded {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.nav-item.active span { color: var(--md-sys-color-on-surface); font-weight: 700; }

@media (max-width: 600px) { 
    .container { 
        padding: 16px 16px 100px 16px; 
        width: 100%; max-width: 100%; 
        background: transparent; box-shadow: none; border-radius: 0;
    } 
    h1 { font-size: 24px; }
    .input-group { flex-wrap: wrap; }
    input[type="text"] { width: 100%; }
    input[type="date"] { flex-grow: 1; }
    .filters { display: none; }
    .fab { bottom: 100px; }
    .content-wrapper { padding: 0 12px; }
    .input-fields { flex-wrap: wrap; }
}
.expand-btn {
    width: 100%;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border: none;
    border-radius: 28px;
    padding: 16px 24px;
    text-align: left;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
    font-family: 'Open Sans', sans-serif;
}
.expand-btn:hover {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.input-wrapper {
    display: flex; width: 100%; gap: 12px; flex-direction: column;
    animation: expand 0.2s ease-out;
}
.input-fields { display: flex; width: 100%; gap: 12px; }
.input-actions { display: flex; width: 100%; justify-content: flex-end; gap: 8px; }
@keyframes expand {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}