/* ADHD Tracker — "Mix": Ledger structure. Light = ink on porcelain; dark = Moonlit palette.
   Same bones in both themes; only the tokens change. */

:root {
    --bg: #f6f6f2;
    --paper: #fdfdfb;
    --line: #e0e1da;
    --ink: #1d1f24;
    --dim: #75777e;
    --accent: #1d1f24;      /* light theme: the "ink" is the accent */
    --accent-contrast: #fdfdfb;
    --cellfill: #1d1f24;
    --work: #3b6fd4; --health: #2f9e6e; --home: #d98a2b; --social: #c65b8a;
    --must: #c0392b; --should: #b07818; --want: #2e7fb0;
    --danger: #c0392b;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0e1a;
        --paper: #131a2e;
        --line: #232c4a;
        --ink: #e9ecfa;
        --dim: #8b93b8;
        --accent: #a9b4ff;   /* moon */
        --accent-contrast: #0b0e1a;
        --cellfill: #a9b4ff;
        --work: #6fa8ff; --health: #5fd4a2; --home: #ffb86b; --social: #ff8fb1;
        --must: #ff7a6b; --should: #ffc46b; --want: #7fd4ff;
        --danger: #ff7a6b;
    }
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
    min-height: 100dvh;
}

a { color: inherit; }

/* ---------- responsive shell ---------- */
.shell { display: block; }
.sidebar, .rail { display: none; }
.center { display: flex; flex-direction: column; min-height: 100dvh; }

main {
    flex: 1;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    padding: 0 16px calc(84px + env(safe-area-inset-bottom));
}

.topbar { display: none; }

@media (min-width: 900px) {
    .shell {
        display: grid;
        grid-template-columns: 224px minmax(0, 1fr) 272px;
        max-width: 1280px;
        margin: 0 auto;
        min-height: 100dvh;
    }
    .tabbar { display: none !important; }
    .mobile-only { display: none !important; }
    main { padding-bottom: 40px; max-width: 660px; }
    .sidebar {
        display: flex; flex-direction: column;
        border-right: 1px solid var(--line);
        background: var(--paper);
        padding: 22px 0;
        position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    }
    .rail {
        display: block;
        border-left: 1px solid var(--line);
        background: var(--paper);
        padding: 24px 18px;
        position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    }
}

/* ---------- header (serif italic date — the identity) ---------- */
.apphead { padding: 22px 0 10px; border-bottom: 2px solid var(--accent); margin-bottom: 4px; }
.apphead .day { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.apphead .day a { color: var(--dim); text-decoration: none; }
.apphead .date { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; font-style: italic; font-weight: 600; font-size: 1.55rem; }
.apphead .area-tint { color: var(--area, var(--ink)); }
.week-nav { display: flex; gap: 12px; align-items: baseline; }
.week-nav a { font-size: 1.1rem; text-decoration: none; color: var(--accent); }

/* ---------- budget cells ---------- */
.budget { display: flex; gap: 8px; align-items: center; padding: 12px 0 4px; }
.budget .lbl { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); min-width: 34px; }
.budget .cells { display: flex; gap: 4px; flex-wrap: wrap; }
.budget .cell { width: 22px; height: 10px; background: var(--paper); border: 1px solid var(--line); }
.budget .cell.f { background: var(--cellfill); border-color: var(--cellfill); }
.budget .cell.warn { background: var(--should); border-color: var(--should); }
.budget .cell.hot { background: var(--must); border-color: var(--must); }
.budget .frac { margin-left: auto; font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--dim); white-space: nowrap; }
.budget.over .frac { color: var(--must); font-weight: 700; }

/* ---------- section labels ---------- */
.sect {
    font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
    padding: 18px 2px 6px; display: flex; justify-content: space-between; align-items: baseline;
}
.sect .wip { font-weight: 700; letter-spacing: .02em; text-transform: none; }
.sect .wip.hot { color: var(--must); }

/* ---------- task rows ---------- */
.rows { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.row {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px 11px 14px;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.row:last-child { border-bottom: 0; }
.row.off { opacity: .55; }
.row.started { box-shadow: inset 0 0 0 1.5px var(--accent); border-radius: 6px; }
.tick { position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; }

.box {
    width: 19px; height: 19px; flex-shrink: 0;
    border: 1.6px solid var(--dim); border-radius: 4px;
    background: transparent; cursor: pointer; padding: 0;
}
.box.done { background: var(--accent); border-color: var(--accent); position: relative; }
.box.done::after { content: "✓"; color: var(--accent-contrast); position: absolute; inset: 0; display: grid; place-items: center; font-size: .7rem; }

.r-body { flex: 1; min-width: 0; text-decoration: none; }
.r-name { display: block; font-weight: 600; font-size: .92rem; }
.r-name.strike { text-decoration: line-through; color: var(--dim); font-weight: 500; }
.r-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .7rem; color: var(--dim); margin-top: 1px; }
.mot { font-weight: 700; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }
.mot.must { color: var(--must); }
.mot.should { color: var(--should); }
.mot.want { color: var(--want); }
.due { color: var(--must); }
.est { font-size: .74rem; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.est.live { color: var(--accent); font-weight: 700; }

.startbtn {
    background: none; border: 1.4px solid var(--line); border-radius: 6px;
    color: var(--dim); width: 28px; height: 28px; cursor: pointer; font-size: .8rem;
}
.startbtn:hover { color: var(--accent); border-color: var(--accent); }

.later-fold {
    display: flex; justify-content: space-between; align-items: center;
    border: 1px dashed var(--line); border-radius: 6px;
    padding: 11px 14px; margin-top: 16px;
    font-size: .84rem; color: var(--dim); text-decoration: none;
}
.later-fold b { color: var(--ink); }

.later-item { border-bottom: 1px solid var(--line); }
.later-item:last-child { border-bottom: 0; }
.later-item .row { border-bottom: 0; }
.later-actions { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 10px 46px; }
.later-actions .age { font-size: .7rem; color: var(--dim); }

/* ---------- goals ---------- */
.goalhead { display: flex; align-items: baseline; gap: 10px; padding: 18px 2px 6px; }
.goalhead .g-name { font-weight: 700; font-size: .94rem; }
.goalhead .g-name.muted { color: var(--dim); font-weight: 600; }
.goalhead .g-frac { font-size: .72rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.goalhead .g-del { margin-left: auto; }
.goalhead.today .g-name { color: var(--accent); }
.g-underline { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 0 2px 8px; }
.g-underline i { display: block; height: 100%; background: var(--accent); }

/* ---------- areas ---------- */
.area-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 14px; }
.area-card {
    background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--area);
    border-radius: 6px; padding: 16px 14px; text-decoration: none;
}
.area-card .a-name { display: block; font-weight: 700; font-size: 1rem; }
.area-card .a-meta { font-size: .72rem; color: var(--dim); }

.addbar { display: flex; gap: 10px; margin-top: 20px; align-items: flex-start; }
.newgoal summary { list-style: none; cursor: pointer; }
.newgoal summary::-webkit-details-marker { display: none; }
.newgoal .form { margin-top: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.newgoal .form input[type="text"] { margin-bottom: 8px; }

/* ---------- habits ---------- */
.habitline { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.hpill {
    border: 1.4px solid var(--dim); border-radius: 20px; padding: 6px 13px;
    font-size: .8rem; font-weight: 600; background: var(--paper); color: var(--ink); cursor: pointer;
}
.hpill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.hpill small { font-weight: 400; opacity: .75; }

.habit-card { margin-top: 12px; }
.habit-card .habit-name { font-weight: 700; }
.habit-week { display: flex; gap: 6px; margin-top: 10px; }
.day-dot {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1.5px solid var(--line); background: var(--bg); color: var(--dim);
    font-size: .68rem; cursor: pointer;
}
.day-dot.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.habit-delete { text-align: right; margin-top: 6px; }
.streak { font-size: .8rem; color: var(--should); }

/* ---------- mood ---------- */
.mood-strip { display: flex; gap: 6px; padding: 8px 0; }
.mood-strip form { flex: 1; }
.mood-btn {
    width: 100%; text-align: center; font-size: 1.25rem; padding: 7px 0;
    background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
    cursor: pointer; filter: grayscale(.85);
}
.mood-btn.on { filter: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.mood-bars { display: flex; gap: 3px; align-items: flex-end; height: 70px; }
.mood-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; background: var(--bg); border-radius: 3px; overflow: hidden; }
.mood-bar .fill { width: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- sidebar (desktop) ---------- */
.brand { font-family: Georgia, serif; font-style: italic; font-size: 1.05rem; padding: 0 20px 16px; }
.snav { display: flex; flex-direction: column; }
.snav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 20px; font-size: .87rem; font-weight: 600;
    color: var(--dim); text-decoration: none;
}
.snav a:hover { color: var(--ink); }
.snav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.s-sect { font-size: .64rem; letter-spacing: .13em; text-transform: uppercase; color: var(--dim); padding: 20px 20px 6px; }
.s-area {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 20px; font-size: .86rem; font-weight: 600;
    color: var(--ink); text-decoration: none;
}
.s-area .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.s-area .n { margin-left: auto; font-size: .7rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.s-goal { display: block; padding: 3px 20px 3px 37px; font-size: .78rem; color: var(--dim); text-decoration: none; }
.s-goal:hover { color: var(--ink); }
.s-bottom { margin-top: auto; padding: 16px 20px 0; font-size: .82rem; }
.s-bottom a { color: var(--dim); text-decoration: none; }

/* ---------- rail (desktop) ---------- */
.rail h3 { font-size: .66rem; letter-spacing: .13em; text-transform: uppercase; color: var(--dim); margin: 20px 0 6px; }
.rail h3:first-child { margin-top: 0; }
.rail .hint { font-size: .74rem; }

/* ---------- mobile tab bar ---------- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    display: flex; justify-content: space-around;
    background: var(--paper); border-top: 1px solid var(--line);
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: .62rem; font-weight: 600; color: var(--dim);
    text-decoration: none; min-width: 54px; padding: 3px 2px;
}
.tabbar a.on { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- generic UI ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 14px; margin: 14px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.banner { border-radius: 6px; padding: 10px 14px; margin: 12px 0; font-size: .88rem; border: 1px solid; }
.banner.warn { color: var(--must); border-color: var(--must); background: color-mix(in srgb, var(--must) 8%, var(--paper)); }
.banner.ok { color: var(--health); border-color: var(--health); background: color-mix(in srgb, var(--health) 8%, var(--paper)); }

.empty { color: var(--dim); text-align: center; padding: 14px 0; }
.empty.small { padding: 8px 2px; font-size: .84rem; text-align: left; }
.hint { color: var(--dim); font-size: .82rem; margin: 8px 0 0; }
.hint a { color: var(--accent); }

.btn {
    display: inline-block; background: var(--accent); color: var(--accent-contrast);
    border: none; border-radius: 6px; padding: 11px 18px;
    font-size: .92rem; font-weight: 700; text-align: center; text-decoration: none;
    cursor: pointer; margin: 8px 0;
}
.btn.ghost { background: var(--paper); color: var(--ink); border: 1.4px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1.4px solid var(--danger); }
.btn.wide { display: block; width: 100%; }

.link { background: none; border: none; color: var(--accent); font-size: .82rem; cursor: pointer; padding: 4px 0; text-decoration: none; }
.link.danger { color: var(--danger); }

/* ---------- forms ---------- */
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%;
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
}
@media (prefers-color-scheme: dark) {
    input, select, textarea { color-scheme: dark; }
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.form .field { display: block; margin-bottom: 12px; min-width: 0; }
.form .field .label { display: block; margin-bottom: 4px; }
.field-pair { display: flex; gap: 10px; }
.field-pair .field { flex: 1; }
.label { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }

.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; width: 0; }
.seg span {
    display: block; text-align: center;
    background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
    padding: 9px 4px; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.seg input:checked + span.m-must { background: var(--must); border-color: var(--must); color: #fff; }
.seg input:checked + span.m-should { background: var(--should); border-color: var(--should); color: #fff; }
.seg input:checked + span.m-want { background: var(--want); border-color: var(--want); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.quickadd { display: flex; gap: 8px; margin: 14px 0 4px; }
.quickadd button {
    flex: 0 0 46px; background: var(--accent); color: var(--accent-contrast);
    border: none; border-radius: 6px; font-size: 1.3rem; cursor: pointer;
}

.area-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.area-row input[type="color"] { flex: 0 0 36px; width: 36px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.area-row input[type="text"] { flex: 1; }
.area-row .link { flex-shrink: 0; }

.more-list { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; }
.more-link {
    display: flex; justify-content: space-between;
    background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
    padding: 14px; font-weight: 600; text-decoration: none;
}
.more-link span { color: var(--dim); }
.logout { margin-top: 28px; }
.danger-zone { margin-top: 22px; }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px; background: var(--bg); color: var(--ink); font: 15px/1.5 "Segoe UI", system-ui, sans-serif; }
.login-box { width: 100%; max-width: 320px; text-align: center; }
.login-box .date { font-family: Georgia, serif; font-style: italic; font-size: 1.4rem; margin-bottom: 18px; }
.login-box input { margin-bottom: 10px; text-align: center; font-size: 1.15rem; }

@media (prefers-reduced-motion: no-preference) {
    .hpill, .box, .mood-btn, .startbtn { transition: background .12s, border-color .12s, color .12s; }
}
