:root {
    --bg: #f6f7f5;
    --surface: #ffffff;
    --surface-2: #f1f3f0;
    --border: #e2e5e0;
    --text: #1c2321;
    --muted: #66706c;
    --accent: #0f766e;
    --accent-soft: #e0f2ef;
    --good: #15803d;
    --good-soft: #e3f4e8;
    --warn: #b45309;
    --warn-soft: #fdf1e1;
    --bad: #b91c1c;
    --bad-soft: #fbe6e6;
    --info: #1d4ed8;
    --info-soft: #e6edfb;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 1px 8px rgba(16, 24, 20, .04);
    --cat-work: #2563eb; --cat-study: #7c3aed; --cat-gym: #dc2626; --cat-trading: #d97706;
    --cat-health: #059669; --cat-personal: #db2777; --cat-diet: #0f766e;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111614; --surface: #181f1c; --surface-2: #202825; --border: #2c3632;
        --text: #e6ebe8; --muted: #95a29c; --accent: #2dd4bf; --accent-soft: #123a35;
        --good: #4ade80; --good-soft: #14301f; --warn: #fbbf24; --warn-soft: #3a2c10;
        --bad: #f87171; --bad-soft: #3d1717; --info: #93b4ff; --info-soft: #172442;
        --shadow: none;
        --cat-work: #60a5fa; --cat-study: #a78bfa; --cat-gym: #f87171; --cat-trading: #fbbf24;
        --cat-health: #34d399; --cat-personal: #f472b6; --cat-diet: #2dd4bf;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.1rem; } h3 { font-size: .95rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem; }
.nav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: .4rem .75rem; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; display: flex; align-items: center; gap: .35rem; }
.nav .ni { font-size: .9rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.logout { margin: 0; }


.wrap { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.wrap.narrow { max-width: 440px; padding-top: 10vh; }
.wrap.medium { max-width: 880px; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* Forms */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; min-width: 0; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.form-grid .full { grid-column: 1 / -1; }
.error { color: var(--bad); font-size: .85rem; margin: 0; }
.hint { font-size: .78rem; color: var(--muted); font-weight: 400; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600; font-size: .88rem; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: .25rem .55rem; font-size: .8rem; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: .2rem .35rem; border-radius: 6px; font-size: .95rem; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.flash { padding: .65rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: var(--good-soft); color: var(--good); }
.flash.err { background: var(--bad-soft); color: var(--bad); }

/* Chips & badges */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.cat { color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 14%, transparent); }
.cat-work { --c: var(--cat-work); } .cat-study { --c: var(--cat-study); } .cat-gym { --c: var(--cat-gym); }
.cat-trading { --c: var(--cat-trading); } .cat-health { --c: var(--cat-health); } .cat-personal { --c: var(--cat-personal); } .cat-diet { --c: var(--cat-diet); }
.lvl-good { color: var(--good); background: var(--good-soft); } .lvl-warn { color: var(--warn); background: var(--warn-soft); }
.lvl-bad { color: var(--bad); background: var(--bad-soft); } .lvl-info { color: var(--info); background: var(--info-soft); }

/* Progress */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar.over > span { background: var(--warn); }
.bar.low > span { background: var(--bad); }
.bar .ghost-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 999px; }

/* Macro tiles */
.macros { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 640px) { .macros { grid-template-columns: repeat(2, minmax(0, 1fr)); } .macros .macro:first-child { grid-column: 1 / -1; } }
.macro .lbl { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.macro .val { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.macro .val small { font-size: .78rem; color: var(--muted); font-weight: 500; }
.macro .bar { margin-top: .3rem; }
.macro .eaten { font-size: .74rem; color: var(--muted); margin-top: .2rem; }

/* Day header */
.daynav { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.daynav input[type=date] { width: auto; }
.focus-input { font-size: 1rem; font-weight: 500; border-style: dashed; }
.score-ring { --p: 0; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem;
    background: radial-gradient(closest-side, var(--surface) 76%, transparent 78% 100%), conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); }

/* Meals */
.meal { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .75rem; overflow: hidden; }
.meal.st-skipped { opacity: .65; }
.meal-head { display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem; background: var(--surface-2); flex-wrap: wrap; }
.meal-head .t { width: 125px; flex: none; padding: .25rem .4rem; }
.meal-head .label { font-weight: 700; border: 0; background: transparent; padding: .2rem .3rem; flex: 1; min-width: 100px; }
.meal-head .totals { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.status-group button { border: 0; background: var(--surface); color: var(--muted); font: inherit; font-size: .75rem; font-weight: 600; padding: .2rem .5rem; cursor: pointer; }
.status-group button + button { border-left: 1px solid var(--border); }
.status-group button.on-done { background: var(--good-soft); color: var(--good); }
.status-group button.on-partial { background: var(--warn-soft); color: var(--warn); }
.status-group button.on-skip { background: var(--bad-soft); color: var(--bad); }
.items { width: 100%; border-collapse: collapse; font-size: .88rem; }
.items td { padding: .35rem .4rem; border-top: 1px solid var(--border); vertical-align: middle; }
.items td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.items td.n strong { color: var(--text); font-weight: 600; }
.items .qty { display: flex; gap: .25rem; }
.items .qty input { width: 64px; padding: .2rem .35rem; }
.items .qty select { width: auto; padding: .2rem .3rem; }
.items .name { min-width: 120px; }
.items .acts { white-space: nowrap; text-align: right; width: 1%; }
@media (max-width: 560px) {
    .items tr { display: grid; grid-template-columns: auto 1fr auto auto; gap: .25rem .6rem; align-items: center; padding: .45rem .6rem; border-top: 1px solid var(--border); }
    .items td { border: 0; padding: 0; }
    .items td.name { grid-column: 1 / -1; font-weight: 600; }
    .items td.n { text-align: right; }
    .items td.acts { grid-column: auto; }
    .items tr td:nth-child(3) { grid-column: 2; }
    .meal-head .label { min-width: 0; flex-basis: calc(100% - 140px); }
    .meal-head .totals { order: 3; flex: 1; }
}
.add-item { display: flex; gap: .4rem; padding: .5rem .65rem; border-top: 1px solid var(--border); flex-wrap: wrap; position: relative; }
.add-item .search { flex: 1 1 180px; }
.add-item input.q { width: 80px; flex: none; }
.add-item select { width: auto; flex: none; }
.suggest { position: absolute; z-index: 30; top: calc(100% - 4px); left: .65rem; right: .65rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.12); max-height: 300px; overflow: auto; }
.suggest button { display: flex; justify-content: space-between; gap: .5rem; width: 100%; text-align: left; border: 0; background: transparent; padding: .5rem .7rem; font: inherit; color: var(--text); cursor: pointer; }
.suggest button:hover, .suggest button.hl { background: var(--surface-2); }
.suggest .meta { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.quick { display: flex; gap: .4rem; padding: 0 .65rem .6rem; }
.quick input { flex: 1; font-size: .85rem; }

/* Alternatives popover */
.alt-box { margin: .25rem .65rem .6rem; padding: .6rem; border-radius: 10px; background: var(--info-soft); font-size: .85rem; }
.alt-box h4 { margin: 0 0 .4rem; font-size: .82rem; color: var(--info); }
.alt-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .3rem 0; border-top: 1px solid color-mix(in srgb, var(--info) 15%, transparent); }
.alt-row:first-of-type { border-top: 0; }
.delta-up { color: var(--warn); } .delta-down { color: var(--good); }

/* Tasks */
.task-group h3 { display: flex; align-items: center; gap: .4rem; margin: .75rem 0 .35rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; padding: .45rem .5rem; border: 1px solid var(--border); border-radius: 10px; margin-bottom: .4rem; background: var(--surface); }
.task.st-done { background: var(--good-soft); border-color: transparent; }
.task.st-done .title { text-decoration: line-through; color: var(--muted); }
.task.st-skipped { background: var(--bad-soft); border-color: transparent; }
.task.st-partial { background: var(--warn-soft); border-color: transparent; }
.task .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: #fff; font-size: .8rem; padding: 0; }
.task.st-done .check { background: var(--good); border-color: var(--good); }
.task .title { font-weight: 600; }
.task .meta { font-size: .78rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; }
.task .actual { width: 70px; padding: .15rem .35rem; font-size: .8rem; }
.task-form { display: grid; grid-template-columns: 120px 1fr; gap: .5rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.task-form .more { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.task-form .full { grid-column: 1 / -1; }

/* Checks */
.check-item { display: grid; grid-template-columns: auto 1fr; gap: .6rem; padding: .55rem .6rem; border-radius: 10px; margin-bottom: .45rem; }
.check-item .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; }
.check-item.lvl-good { background: transparent; border: 1px solid var(--border); color: inherit; }
.check-item .ttl { font-weight: 600; font-size: .9rem; }
.check-item .det { font-size: .83rem; color: var(--text); opacity: .85; }
.check-item ul { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .83rem; }
.dot-good { background: var(--good); color: #fff; } .dot-warn { background: var(--warn); color: #fff; }
.dot-bad { background: var(--bad); color: #fff; } .dot-info { background: var(--info); color: #fff; }
.checks-summary { display: flex; gap: .35rem; flex-wrap: wrap; }

.ai-panel { background: linear-gradient(135deg, var(--accent-soft), var(--info-soft)); border: 0; }
.ai-panel ul { margin: .25rem 0 .6rem; padding-left: 1.1rem; }
.ai-panel h3 { margin-top: .6rem; }

/* Journal */
.review-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem .75rem; padding: .7rem 0; border-top: 1px solid var(--border); align-items: center; }
.review-row:first-of-type { border-top: 0; }
.review-row .why { grid-column: 1 / -1; display: grid; grid-template-columns: 220px 1fr; gap: .5rem; }
.review-row .why[hidden] { display: none; }
@media (max-width: 560px) { .review-row { grid-template-columns: 1fr; } .review-row .why { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg label { flex-direction: row; font-size: .8rem; font-weight: 600; color: var(--muted); padding: .3rem .6rem; cursor: pointer; margin: 0; }
.seg label + label { border-left: 1px solid var(--border); }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.seg label.s-done:has(input:checked), .seg label.s-eaten:has(input:checked) { background: var(--good-soft); color: var(--good); }
.seg label.s-partial:has(input:checked), .seg label.s-swapped:has(input:checked) { background: var(--warn-soft); color: var(--warn); }
.seg label.s-skipped:has(input:checked) { background: var(--bad-soft); color: var(--bad); }
.scale { display: flex; gap: .3rem; }
.scale label { flex: 1; flex-direction: row; justify-content: center; padding: .35rem 0; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 1.05rem; }
.scale input { display: none; }
.scale label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }

/* Report */
.stat { text-align: left; }
.stat .big { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .lbl { font-size: .78rem; color: var(--muted); font-weight: 600; }
.days-table { width: 100%; border-collapse: collapse; font-size: .86rem; font-variant-numeric: tabular-nums; }
.days-table th, .days-table td { padding: .45rem .4rem; border-top: 1px solid var(--border); text-align: right; }
.days-table th:first-child, .days-table td:first-child { text-align: left; }
.days-table th { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-top: 0; }
.table-scroll { overflow-x: auto; }
.cat-row { display: grid; grid-template-columns: 90px 1fr 48px; gap: .6rem; align-items: center; margin: .4rem 0; font-size: .88rem; }
.insight { display: flex; gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--border); font-size: .9rem; }
.insight:first-child { border-top: 0; }
.list { margin: 0; padding-left: 1.1rem; } .list li { margin: .25rem 0; }
.grade { font-size: 2rem; font-weight: 800; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #fff; flex: none; }

/* Simple tables */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: .45rem .5rem; border-top: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-top: 0; }
.table td.n, .table th.n { text-align: right; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 1.5rem; color: var(--muted); }
.goal-card .bar { margin: .5rem 0 .25rem; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .55rem 1rem; border-radius: 10px; font-size: .88rem; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 2rem); }
.loading { opacity: .6; pointer-events: none; }
details summary { cursor: pointer; font-weight: 600; }
.auth h1 { display: flex; align-items: center; gap: .5rem; }

/* ---------- Foods ---------- */
.veg-mark { display: inline-block; width: 13px; height: 13px; border: 1.5px solid; border-radius: 2px; position: relative; flex: none; vertical-align: -1px; }
.veg-mark::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: currentColor; }
.veg-mark.veg { color: #16a34a; }
.veg-mark.nonveg { color: #b91c1c; }
.veg-mark.nonveg::after { inset: auto; left: 50%; top: 50%; transform: translate(-50%, -60%); width: 0; height: 0; border-radius: 0; background: none; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-bottom: 6px solid currentColor; }

.tabs { display: flex; gap: .35rem; margin-bottom: .75rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .85rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-n { font-size: .74rem; opacity: .75; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input { flex: 1 1 200px; width: auto; }
.filters select { width: auto; }

.food-list { padding: 0; overflow: hidden; }
.food-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px 52px 58px 52px 46px 46px 16px; gap: .5rem; align-items: center; padding: .6rem .9rem; border-top: 1px solid var(--border); color: var(--text); font-size: .88rem; }
.food-row:hover, .food-row[aria-current] { background: var(--surface-2); }
.food-head { border-top: 0; font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); }
.food-row .n { text-align: right; font-variant-numeric: tabular-nums; }
.food-row .fname { display: flex; gap: .55rem; align-items: flex-start; min-width: 0; }
.food-row .fname .veg-mark { margin-top: 3px; }
.food-row .fmeta { display: block; font-size: .76rem; }
.sticky-form { position: sticky; top: 70px; }

.pager { display: flex; align-items: center; gap: .35rem; margin-top: .9rem; flex-wrap: wrap; justify-content: center; }
.pager-pages { display: flex; gap: .2rem; flex-wrap: wrap; }
.pager [aria-disabled] { opacity: .4; pointer-events: none; }
.pager-gap { padding: 0 .3rem; color: var(--muted); }
.pager-info { width: 100%; text-align: center; }

/* ---------- Goals ---------- */
.field-label { font-size: .8rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: .03em; }
.chips-pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips-pick label { flex-direction: row; margin: 0; }
.chips-pick input { display: none; }
.chips-pick span { display: inline-block; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: .88rem; color: var(--text); cursor: pointer; background: var(--surface); }
.chips-pick input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.seg-full { display: flex; width: 100%; }
.seg-full label { flex: 1; justify-content: center; text-align: center; padding: .45rem .4rem; }
.goal-preview { font-weight: 600; color: var(--accent); min-height: 1.2em; }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.goal-grid .card + .card { margin-top: 0; }
.goal-title { margin: .55rem 0 .15rem; font-size: 1.05rem; }
.status-select { width: auto; padding: .2rem .4rem; font-size: .78rem; }
.day-dots { display: flex; gap: .3rem; margin: .65rem 0 .35rem; }
.dd { flex: 1; max-width: 38px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.dd-hit { background: var(--good); color: #fff; }
.dd-miss { background: var(--bad-soft); color: var(--bad); }
.dd-open { border: 1.5px dashed var(--border); background: transparent; }
.dd-future { opacity: .45; }

/* Day page goal strip */
.goal-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.goal-pill { display: flex; flex-direction: column; gap: .35rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); }
.goal-pill:hover { border-color: var(--accent); }
.goal-pill.ok { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.goal-pill.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.gp-top { display: flex; gap: .4rem; align-items: center; font-size: .88rem; }
.gp-title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-period { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.gp-line { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.goals-card { margin-bottom: 1rem; }

/* ---------- Phone ---------- */
@media (max-width: 720px) {
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    input, select, textarea { font-size: 16px; } /* stops iOS zooming into fields */
    .topbar { padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top)); }
    .logout { margin-left: auto; }
    .nav { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
        padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); gap: 0; justify-content: space-around; overflow: visible; }
    .nav a { flex: 1; flex-direction: column; gap: .1rem; padding: .3rem 0; font-size: .68rem; border-radius: 10px; }
    .nav .ni { font-size: 1.2rem; line-height: 1; }
    .nav a.on { background: transparent; color: var(--accent); }
    .nav a.on .ni { transform: scale(1.1); }

    .wrap { padding: .9rem .75rem 2rem; }
    .card { padding: .85rem; }
    .page-head { margin-bottom: .75rem; gap: .6rem; }
    .page-head h1 { font-size: 1.2rem; }
    .daynav { width: 100%; }
    .daynav input[type=date] { flex: 1; }
    .journal-btn { margin-left: auto; }
    .btn.sm { padding: .4rem .65rem; }
    .icon-btn { padding: .35rem .45rem; font-size: 1.05rem; }

    /* Day: meal header & add row */
    .meal-head { gap: .4rem; }
    .meal-head .t { width: 118px; }
    .add-item .search { flex-basis: 100%; }
    .add-item input.q { flex: 1; width: auto; }
    .quick { flex-wrap: wrap; }
    .task { grid-template-columns: auto 1fr; }
    .task > .row { grid-column: 1 / -1; justify-content: flex-end; }
    .task .actual { width: 80px; }
    .task-form { grid-template-columns: 1fr; }
    .task-form .more { grid-template-columns: 1fr 1fr; }
    .score-ring { width: 46px; height: 46px; font-size: .85rem; flex: none; }
    #copyRow > span:last-child { margin-left: 0 !important; width: 100%; }
    #copyRow input[type=date] { flex: 1; }
    .goal-strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -.85rem; padding: 0 .85rem; }
    .goal-strip::-webkit-scrollbar { display: none; }
    .goal-pill { flex: 0 0 78%; scroll-snap-align: start; }

    /* Foods as cards */
    .food-row.food-head { display: none; }
    .card.food-list { padding: 0; }
    .food-row { display: flex; flex-wrap: wrap; gap: .25rem .75rem; padding: .7rem .85rem; }
    .food-row .fname { flex-basis: 100%; }
    .food-row .n { text-align: left; font-size: .8rem; white-space: nowrap; }
    .food-row .n[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: .68rem; font-weight: 700; }
    .food-row .n[data-l=per]::before { content: "per "; }
    .food-row .n[data-l=kcal]::before { content: none; }
    .food-row .n[data-l=kcal]::after { content: " kcal"; color: var(--muted); font-size: .72rem; }
    .food-row .n[data-l=per] { order: 9; }
    .food-row > .n:last-child { display: none; }
    .food-row .fname .veg-mark, .food-row .n:first-of-type { margin-left: 0; }
    .food-row .n[data-l=kcal] { margin-left: calc(13px + .55rem); }
    .sticky-form { position: static; }
    .filters input { flex-basis: 100%; }
    .filters select, .filters .btn { flex: 1; }

    .goal-grid { grid-template-columns: 1fr; gap: .75rem; }
    .chips-pick span { padding: .5rem .75rem; }
    .grid-4 { gap: .6rem; }
    .stat .big { font-size: 1.35rem; }
    .scale label { padding: .5rem 0; font-size: 1.2rem; }
    .review-row .seg { width: 100%; }
    .review-row .seg label { flex: 1; justify-content: center; }
    .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* Goal type picker */
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.tpl-card { margin: 0; flex-direction: row; cursor: pointer; }
.tpl-card input { display: none; }
.tpl-card span { display: flex; flex-direction: column; gap: .1rem; width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.tpl-card strong { font-size: .9rem; }
.tpl-card small { font-size: .76rem; color: var(--muted); font-weight: 400; line-height: 1.35; }
.tpl-card input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tpl-card input:checked + span strong { color: var(--accent); }

/* Journal check-in */
.checkin-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: .4rem .75rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--border); }
.checkin-row:first-of-type { border-top: 0; }
.checkin-row .q { font-weight: 600; font-size: .9rem; }
.checkin-row .for { font-size: .76rem; color: var(--muted); }
.checkin-row .seg { justify-self: end; }
@media (max-width: 560px) {
    .tpl-pick { grid-template-columns: 1fr 1fr; }
    .checkin-row { grid-template-columns: 1fr; }
    .checkin-row .seg { justify-self: stretch; display: flex; }
    .checkin-row .seg label { flex: 1; justify-content: center; }
}

/* ---------- Programs ---------- */
.mob-only { display: none !important; }
@media (max-width: 720px) { .mob-only { display: flex !important; } .desk-only { display: none !important; } .nav a { font-size: .62rem; } }
.neg { color: var(--bad); } .pos { color: var(--good); }
.program-card { display: block; }
.program-card:hover { border-color: var(--accent); }
.prog-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .7rem; }
.prog-stats .lbl { display: block; font-size: .7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.prog-stats strong { font-variant-numeric: tabular-nums; }

.legend { display: flex; align-items: center; gap: .35rem; color: var(--muted); flex-wrap: wrap; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: .3rem; }
.lg.done { background: var(--good); } .lg.missed { background: var(--bad); } .lg.off { background: var(--surface-2); border: 1px solid var(--border); } .lg.unmarked { border: 2px solid var(--warn); }
.cal-month { display: flex; justify-content: space-between; margin: 1rem 0 .4rem; font-size: .9rem; }
.cal-month:first-of-type { margin-top: 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dn { text-align: center; font-size: .68rem; color: var(--muted); font-weight: 700; }
.cal-day { aspect-ratio: 1 / .9; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0; min-width: 0; }
.cal-day .dnum { font-size: .8rem; font-weight: 600; line-height: 1; }
.cal-day .dval { font-size: .62rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cal-day.st-done { background: var(--good); border-color: var(--good); color: #fff; }
.cal-day.st-missed { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.cal-day.st-off { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 4px, var(--surface) 4px, var(--surface) 8px); color: var(--muted); }
.cal-day.st-unmarked { border: 2px solid var(--warn); }
.cal-day.st-today { border: 2px solid var(--accent); }
.cal-day.st-weekend { opacity: .3; cursor: default; background: transparent; }
.cal-day.st-future { opacity: .55; cursor: default; }
.cal-day.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
.dp-item { padding: .65rem 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .45rem; }
.dp-item:first-child { border-top: 0; }
.dp-title { font-weight: 650; }
.dp-why { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.dp-why[hidden] { display: none; }

.week { padding: 0; }
.week + .week { margin-top: 0; }
.week-head { display: flex; align-items: center; gap: .5rem; padding: .85rem 1rem; cursor: pointer; list-style: none; flex-wrap: wrap; }
.week-head::-webkit-details-marker { display: none; }
.week-head::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.week[open] > .week-head::before { transform: rotate(90deg); }
.week-title { font-weight: 700; flex: 1; min-width: 200px; }
.topic { border-top: 1px solid var(--border); padding: .65rem 1rem; }
.topic-head { display: flex; gap: .6rem; align-items: flex-start; }
.topic .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; color: #fff; font-size: .8rem; flex: none; margin-top: 1px; padding: 0; }
.topic.st-done .check { background: var(--good); border-color: var(--good); }
.topic.st-done .topic-title { text-decoration: line-through; color: var(--muted); }
.topic.st-skipped { opacity: .65; }
.topic-title { font-weight: 600; }
.topic-notes { margin: .4rem 0 0 calc(22px + .6rem); }
.topic-notes summary { color: var(--accent); }
.notes { font-size: .88rem; line-height: 1.55; margin-top: .35rem; }
.notes h4 { margin: .6rem 0 .2rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.notes ul { margin: .2rem 0; padding-left: 1.2rem; }
.notes p { margin: .3rem 0; }
.notes code { background: var(--surface-2); padding: 0 .3rem; border-radius: 4px; font-size: .85em; }
.resources { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: .5rem; font-size: .85rem; }

.tpl-meal { border: 1px solid var(--border); border-radius: 10px; padding: .65rem; display: flex; flex-direction: column; gap: .5rem; }
.tpl-opt { display: grid; grid-template-columns: auto 200px 1fr; gap: .4rem .5rem; align-items: start; }
.tpl-opt .opt-macros { grid-column: 2 / -1; margin-top: -.2rem; }
.tpl-opt textarea { min-height: 42px; }
@media (max-width: 720px) {
    .tpl-opt { grid-template-columns: auto 1fr; }
    .tpl-opt .opt-text, .tpl-opt .opt-macros { grid-column: 1 / -1; }
    .dp-why { grid-template-columns: 1fr; }
    .prog-stats { grid-template-columns: 1fr 1fr 1fr; }
    .topic-notes { margin-left: 0; }
}

/* Day page checklist */
.checklist-card { margin-bottom: 1rem; }
.cl-group + .cl-group { margin-top: .9rem; padding-top: .9rem; border-top: 1px dashed var(--border); }
.cl-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; font-weight: 700; font-size: .9rem; flex-wrap: wrap; }
.cl-head a:first-child { color: var(--text); }
.cl-item { border: 1px solid var(--border); border-radius: 10px; padding: .5rem .6rem; margin-bottom: .4rem; display: flex; flex-direction: column; gap: .45rem; }
.cl-item.st-done { background: var(--good-soft); border-color: transparent; }
.cl-item.st-missed { background: var(--bad-soft); border-color: transparent; }
.cl-item.st-off { opacity: .6; }
.cl-row { display: flex; align-items: center; gap: .5rem; justify-content: space-between; }
.cl-title { font-weight: 600; font-size: .9rem; }
.cl-val { flex-direction: row; align-items: center; gap: .5rem; }
.cl-val input { max-width: 160px; }
.cl-why { display: grid; grid-template-columns: 220px 1fr; gap: .4rem; }
.cl-sub { margin: .5rem 0 .3rem; font-weight: 600; }
.cl-task { display: flex; gap: .55rem; align-items: flex-start; padding: .35rem 0; }
.cl-task .check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; flex: none; padding: 0; }
.opt-switch { width: auto; max-width: 190px; padding: .2rem .4rem; font-size: .8rem; }
@media (max-width: 720px) { .cl-why { grid-template-columns: 1fr; } .opt-switch { max-width: none; flex-basis: 100%; } }

.more-list { padding: 0; }
.more-list a, .more-list button { display: block; width: 100%; text-align: left; padding: 1rem; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.more-list > :first-child { border-top: 0; }
.more-list form { margin: 0; }
.cl-row .cl-title { min-width: 0; flex: 1; }
.cl-row .status-group { flex: none; }
.lg.holiday { background: var(--info-soft); border: 1px dashed var(--info); }
.cal-day.st-holiday { background: var(--info-soft); border: 1px dashed var(--info); color: var(--info); }
.tpl-opt { grid-template-columns: auto 200px 1fr auto; }
.tpl-opt .opt-acts { display: flex; gap: .1rem; }
.tpl-opt .opt-why { grid-column: 2 / -1; color: var(--info); margin-top: -.3rem; }
.tpl-opt.fresh textarea, .tpl-opt.fresh input { border-color: var(--accent); }
@media (max-width: 720px) { .tpl-opt { grid-template-columns: auto 1fr auto; } }

/* DSA roadmap */
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dsa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; margin-bottom: .75rem; }
.dsa-grid.hide-done .all-done { display: none; }
.dsa-day { border: 1.5px solid var(--pc); border-radius: 10px; background: color-mix(in srgb, var(--pc) 5%, var(--surface)); overflow: hidden; }
.dsa-day.all-done { opacity: .6; }
.dsa-day.is-today { box-shadow: 0 0 0 3px var(--accent); }
.dsa-day.is-late .dsa-head::after { content: "LATE"; margin-left: .4rem; background: #fff; color: var(--bad); border-radius: 4px; padding: 0 .3rem; font-size: .62rem; }
.dsa-head { display: flex; justify-content: space-between; gap: .4rem; background: var(--pc); color: #fff; font-size: .72rem; font-weight: 800; padding: .35rem .55rem; letter-spacing: .02em; }
.dsa-date { opacity: .8; font-weight: 600; margin-left: .25rem; }
.dsa-row { display: flex; align-items: center; gap: .45rem; padding: .35rem .55rem; font-size: .82rem; }
.dsa-row + .dsa-row { border-top: 1px solid color-mix(in srgb, var(--pc) 15%, transparent); }
.dsa-row .check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; color: #fff; font-size: .7rem; padding: 0; flex: none; }
.dsa-row.st-done .check { background: var(--good); border-color: var(--good); }
.dsa-row.st-done .dsa-title { text-decoration: line-through; color: var(--muted); }
.dsa-row.st-skipped .dsa-title { color: var(--muted); }
.dsa-title { flex: 1; min-width: 0; color: var(--text); }
a.dsa-title:hover { color: var(--accent); text-decoration: underline; }
.dsa-skip { padding: 0 .55rem .35rem 2.1rem; }
.diff { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
.diff-easy { background: var(--good); } .diff-medium { background: var(--warn); } .diff-hard { background: var(--bad); }
.topic-notes summary .pdot { vertical-align: -1px; }
@media (max-width: 720px) { .dsa-grid { grid-template-columns: 1fr; } }
