:root {
    color-scheme: dark;
    --bg: #050816;
    --bg-soft: #0b1022;
    --card: rgba(15, 23, 42, 0.82);
    --card-strong: rgba(15, 23, 42, 0.96);
    --border: rgba(148, 163, 184, 0.22);
    --border-strong: rgba(34, 211, 238, 0.42);
    --text: #e5f0ff;
    --muted: #b6c2d4;
    --primary: #22d3ee;
    --primary-hover: #67e8f9;
    --accent: #a78bfa;
    --accent-2: #34d399;
    --danger: #fb7185;
    --success: #4ade80;
    --done-bg: rgba(16, 185, 129, 0.12);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(34, 211, 238, 0.18), transparent 34rem),
        radial-gradient(circle at 88% 12%, rgba(167, 139, 250, 0.16), transparent 32rem),
        linear-gradient(135deg, #050816 0%, #07111f 52%, #08111a 100%);
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.32;
    background-image:
        linear-gradient(rgba(34, 211, 238, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 211, 238, 0.08) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, black, transparent 72%);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(180deg, rgba(255,255,255,0.025) 0, rgba(255,255,255,0.025) 1px, transparent 1px, transparent 5px);
    opacity: 0.22;
}

button, input, textarea { font: inherit; }

a { color: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem clamp(1rem, 3vw, 2rem);
    background: rgba(5, 8, 22, 0.76);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 1rem;
    color: var(--primary);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(167, 139, 250, 0.12));
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.12), inset 0 0 24px rgba(34, 211, 238, 0.08);
}

.topbar h1 { font-size: 1.05rem; margin: 0; letter-spacing: -0.02em; }
.topbar p { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.8rem; }

.logout-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.65);
}
.logout-link:hover { color: var(--text); border-color: var(--border-strong); }

.container {
    position: relative;
    z-index: 1;
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 4rem;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.25rem;
    align-items: stretch;
    margin-bottom: 1.25rem;
}

.hero-card,
.stats-card,
.add-form,
.task-board,
.auth-box {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.72));
    border: 1px solid var(--border);
    border-radius: 1.35rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card { padding: clamp(1.2rem, 3vw, 2rem); overflow: hidden; position: relative; }
.hero-card::after {
    content: "";
    position: absolute;
    right: -6rem;
    top: -7rem;
    width: 17rem;
    height: 17rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(34,211,238,0.22), transparent 62%);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.7rem;
    color: var(--primary-hover);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.date-title {
    margin: 0;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 0.95;
    letter-spacing: -0.07em;
}

.date-subtitle { margin: 0.85rem 0 0; color: var(--muted); font-size: 1rem; }

.stats-card {
    min-width: 270px;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.stat {
    padding: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 1rem;
    background: rgba(2, 6, 23, 0.36);
}
.stat strong { display: block; font-size: 1.65rem; line-height: 1; color: var(--primary-hover); }
.stat span { display: block; margin-top: 0.35rem; color: var(--muted); font-size: 0.78rem; }

.progress-track {
    grid-column: 1 / -1;
    overflow: hidden;
    height: 0.6rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
}
.progress-fill {
    height: 100%;
    width: var(--progress, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--accent-2));
    box-shadow: 0 0 22px rgba(34, 211, 238, 0.28);
}

.day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.day-nav-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.52);
}

.muted { color: var(--muted); font-size: 0.9rem; }

.btn,
.add-form button,
.auth-box button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.6rem;
    padding: 0.62rem 0.95rem;
    background: rgba(15, 23, 42, 0.76);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.btn:hover,
.add-form button:hover,
.auth-box button:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: rgba(34, 211, 238, 0.12);
    box-shadow: 0 0 22px rgba(34, 211, 238, 0.12);
}
.btn-small { min-height: 2rem; padding: 0.35rem 0.65rem; font-size: 0.8rem; }

input[type="date"],
input[type="text"],
input[type="password"],
textarea {
    color: var(--text);
    background: rgba(2, 6, 23, 0.56);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
input:focus,
textarea:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.1);
    background: rgba(2, 6, 23, 0.82);
}

.add-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.8rem;
}

.add-form input[type="text"] { width: 100%; padding: 0.85rem 1rem; font-size: 1rem; }
.add-form button,
.auth-box button { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #020617; border: 0; font-weight: 800; }

.task-board { padding: 0.85rem; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }

.task {
    position: relative;
    background: rgba(15, 23, 42, 0.74);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 1.15rem;
    padding: 0.75rem;
    transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}
.task:hover { transform: translateY(-1px); border-color: rgba(34, 211, 238, 0.28); background: rgba(15, 23, 42, 0.9); }
.task.done { background: rgba(16, 185, 129, 0.09); border-color: rgba(52, 211, 153, 0.22); }
.task.done::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: 1.15rem 0 0 1.15rem;
    background: var(--accent-2);
}

.task-row { display: flex; align-items: center; gap: 0.75rem; }
.task-toggle { width: 1.25rem; height: 1.25rem; flex-shrink: 0; cursor: pointer; accent-color: var(--accent-2); }
.task-title { flex: 1; word-break: break-word; font-weight: 650; letter-spacing: -0.01em; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }

.task-actions { display: flex; gap: 0.2rem; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn {
    display: inline-grid;
    place-items: center;
    min-width: 2.35rem;
    min-height: 2.35rem;
    background: rgba(2, 6, 23, 0.38);
    border: 1px solid transparent;
    color: var(--muted);
    font-size: 1rem;
    padding: 0.25rem 0.45rem;
    cursor: pointer;
    border-radius: 0.85rem;
    line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--border); background: rgba(34, 211, 238, 0.1); }
.icon-btn.has-note { color: var(--primary-hover); border-color: rgba(34, 211, 238, 0.25); background: rgba(34, 211, 238, 0.1); }
.delete-task:hover { color: var(--danger); border-color: rgba(251, 113, 133, 0.28); background: rgba(251, 113, 133, 0.1); }

.task-note {
    display: none;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}
.task-note.open { display: block; }
.note-text { width: 100%; min-height: 5.2rem; resize: vertical; padding: 0.75rem 0.85rem; font-size: 0.92rem; }
.note-controls { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.note-saved { font-size: 0.8rem; color: var(--success); }
.empty {
    text-align: center;
    padding: 3rem 1rem;
    border: 1px dashed rgba(148, 163, 184, 0.24);
    border-radius: 1rem;
    background: rgba(2, 6, 23, 0.28);
}
.empty strong { display: block; color: var(--text); font-size: 1.1rem; margin-bottom: 0.35rem; }
.error, .success {
    padding: 0.75rem 0.9rem;
    border-radius: 0.9rem;
    font-weight: 700;
}
.error { color: #fecdd3; background: rgba(251, 113, 133, 0.12); border: 1px solid rgba(251, 113, 133, 0.22); }
.success { color: #bbf7d0; background: rgba(74, 222, 128, 0.12); border: 1px solid rgba(74, 222, 128, 0.22); }

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.auth-box { position: relative; z-index: 1; width: 100%; max-width: 430px; padding: 2rem; }
.auth-box h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.06em; }
.auth-box .auth-subtitle { margin: 0.55rem 0 1.25rem; color: var(--muted); line-height: 1.55; }
.auth-box form { display: flex; flex-direction: column; gap: 0.95rem; margin-top: 1.15rem; }
.auth-box label { display: flex; flex-direction: column; gap: 0.38rem; color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.auth-box input { padding: 0.75rem 0.85rem; font-size: 1rem; }
.auth-box button { width: 100%; margin-top: 0.2rem; }

@media (max-width: 760px) {
    .hero-panel { grid-template-columns: 1fr; }
    .stats-card { min-width: 0; }
    .day-nav { align-items: stretch; }
    .day-nav > .btn { flex: 1; }
    .day-nav-center { width: 100%; order: -1; border-radius: 1rem; }
    .add-form { grid-template-columns: 1fr; }
    .task-row { align-items: flex-start; }
    .task-actions { width: 100%; margin-top: 0.65rem; padding-left: 2rem; justify-content: flex-start; }
}
