/* Meals — Apple's shape (large cards on grey, a floating tab bar), a tomato accent. Light is the base; dark is a
 * token swap.
 *
 * ~/claude/IOS.md §25 THE STAGE (Music's v34 recipe, measured on iOS 27): the document never scrolls; #app is a
 * screen tall (100lvh installed); the screens scroll inside #page; the tab bar (.foot) and the sheet are its
 * SIBLINGS, absolute in the stage — so a tap on a tab is never eaten by a page still coasting after a flick.
 * Nothing is position: fixed (a fixed layer is clipped under the status bar). §24: no backdrop-filter, no
 * transitions on the shell; the bars are solid. The root's colour tints the status bar, so it is the page's own.
 */
:root {
  --bg:      #f2f2f7;
  --panel:   #ffffff;
  --panel-2: #f6f6f9;
  --line:    rgba(60, 60, 67, .16);
  --ink:     #000000;
  --ink-2:   #3c3c43;
  --dim:     #8a8a8e;
  --pill:    #e5e5ea;
  --accent:  #d9431f;
  --on-accent: #ffffff;
  --bad:     #e5322b;
  --good:    #1f9d55;
  --gold:    #e0a100;
  --p:       #2f7bf6;   /* protein */
  --c:       #e0a100;   /* carbs   */
  --f:       #d9431f;   /* fat     */
  --shadow:  0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.06);
  --r-card: 18px; --r-mid: 12px;
  --font: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-num: ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --sb: 0px;
  --foot-h: 0px; --kb: 0px;
  --side: 16px;
  --col: 720px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --panel: #1c1c1e; --panel-2: #2c2c2e; --line: rgba(84, 84, 88, .48);
    --ink: #ffffff; --ink-2: #d7d7db; --dim: #98989f; --pill: #2c2c2e;
    --accent: #ff7a50; --on-accent: #2a0a00; --bad: #ff453a; --good: #30d158; --gold: #ffd60a;
    --p: #5e9bff; --c: #ffd60a; --f: #ff7a50;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; overflow: hidden; overscroll-behavior: none; }
html, body { background: var(--bg); color: var(--ink); margin: 0; }
body { position: relative; height: 100vh; height: 100dvh; overflow: hidden;
       font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
@media (display-mode: standalone) {
  :root { --sb: calc(100lvh - 100dvh); }
  body { height: 100vh; height: 100lvh; }
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── the door ─────────────────────────────────────────────────────────── */
.door { position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
        justify-content: center; text-align: center; padding: calc(var(--sb) + 24px) 28px calc(var(--safe-b) + 24px); }
.doormark { width: 84px; height: 84px; border-radius: 19px; box-shadow: var(--shadow); }
.lockup { margin: 18px 0 26px; font-weight: 800; letter-spacing: -.03em; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.lockup .lm { font-size: 17px; color: var(--dim); font-weight: 700; letter-spacing: -.01em; }
.lockup .lc { color: var(--accent); }
.lockup .ls { font-size: 44px; }
.note { color: var(--dim); max-width: 340px; font-size: 14px; margin: 16px auto 0; }

/* ── the stage ────────────────────────────────────────────────────────── */
#app { position: absolute; inset: 0; }
#page { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
        display: flex; flex-direction: column; }
#page.locked { overflow: hidden; }
.top { position: sticky; top: 0; z-index: 20; background: var(--bg);
       padding: calc(var(--safe-t) + var(--sb)) calc(var(--side) + var(--safe-r)) 0 calc(var(--side) + var(--safe-l)); }
.top.scrolled { box-shadow: 0 1px 0 var(--line); }
.bar { max-width: var(--col); margin: 0 auto; min-height: 52px; display: flex; align-items: center; gap: 4px; }
.bar h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar.sub h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; text-align: center; }
.ibtn { width: 40px; height: 40px; border: 0; border-radius: 20px; background: transparent; color: var(--accent);
        display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; }
.ibtn svg { width: 24px; height: 24px; }
.ibtn:active { background: var(--pill); }
.ibtn.spacer { visibility: hidden; }

main { flex: 1 0 auto; width: 100%; max-width: var(--col); margin: 0 auto;
       padding: 4px calc(var(--side) + var(--safe-r)) calc(var(--foot-h) + var(--kb) + 24px) calc(var(--side) + var(--safe-l)); }

/* ── the foot: the tab bar ────────────────────────────────────────────── */
.foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; gap: 8px;
        pointer-events: none; padding: 8px calc(14px + var(--safe-r)) calc(6px + max(0px, var(--safe-b) - 12px)) calc(14px + var(--safe-l)); }
.foot > * { pointer-events: auto; }
.tabbar { display: flex; width: 100%; max-width: 520px; height: 60px; padding: 4px; border-radius: 999px; background: var(--panel);
          border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent); box-shadow: 0 6px 24px rgba(0,0,0,.14); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 999px;
            color: var(--ink); font-size: 10.5px; font-weight: 600; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.toast { max-width: 100%; padding: 10px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 550;
         box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }

/* ── the sheet (absolute in the stage, never fixed) ───────────────────── */
.sheet { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.38); }
.sheetbox { position: relative; background: var(--bg); border-radius: 22px 22px 0 0; max-height: calc(100% - var(--sb) - 30px); overflow-y: auto;
            overscroll-behavior: contain; width: 100%; max-width: 620px; margin: 0 auto;
            padding: 8px calc(var(--side) + var(--safe-r)) calc(var(--safe-b) + var(--kb) + 18px) calc(var(--side) + var(--safe-l)); }
.sheetbox .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--pill); margin: 0 auto 8px; }
.sheetbox h2 { font-size: 20px; margin: 4px 0 6px; letter-spacing: -.02em; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn { border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 650; padding: 10px 18px; min-height: 44px;
       display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.big { font-size: 17px; padding: 13px 30px; min-width: 220px; }
.btn.wide { width: 100%; }
.btn.quiet { background: var(--pill); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); }
.btn:disabled { opacity: .5; }
.btn:active { filter: brightness(.92); }
.btn svg { width: 20px; height: 20px; }
.btnrow { display: flex; gap: 10px; margin: 12px 0; }
.btnrow > .btn { flex: 1; padding-left: 10px; padding-right: 10px; }

/* ── cards, rows ──────────────────────────────────────────────────────── */
.card { background: var(--panel); border-radius: var(--r-card); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 17px; }
h2.sec { font-size: 20px; font-weight: 750; letter-spacing: -.02em; margin: 22px 2px 8px; display: flex; align-items: baseline; gap: 8px; }
h2.sec .act { margin-left: auto; font-size: 15px; font-weight: 600; background: none; border: 0; color: var(--accent); padding: 4px 2px; }
h3.sec { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin: 22px 16px 6px; }
.rows { background: var(--panel); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 16px; border: 0; background: none; text-align: left;
       color: var(--ink); position: relative; }
.rows > .row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.rows > a.row:active, .rows > button.row:active { background: var(--panel-2); }
.row-k { flex: 1; min-width: 0; }
.row-k small { display: block; color: var(--dim); font-size: 13px; }
.row-v { color: var(--dim); text-align: right; flex: none; }
.chev { color: var(--dim); font-size: 20px; line-height: 1; }
.row.danger .row-k { color: var(--bad); }
.fineprint { color: var(--dim); font-size: 12px; text-align: center; margin: 18px 0 0; }
.addr { color: var(--dim); font-size: 13px; text-align: center; margin: 20px 0 0; }
.lockrow { font-weight: 800; letter-spacing: -.02em; }
.lockrow .lc { color: var(--accent); }
.err { color: var(--bad); margin: 10px 0 0; font-size: 14px; }
.empty { text-align: center; color: var(--dim); padding: 40px 12px; }
.empty b { display: block; color: var(--ink); font-size: 19px; margin-bottom: 6px; }

/* ── forms ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field > label, .lbl { color: var(--dim); font-size: 13px; font-weight: 600; }
select, input[type=text], input[type=number], input[type=search], input[type=datetime-local], textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-mid); border: 1px solid var(--line); background: var(--panel-2); font-size: 17px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.35; }
.seg { display: flex; background: var(--pill); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 7px 4px; font-weight: 600; font-size: 14px; min-height: 36px; color: var(--ink); }
.seg button.on { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper button { flex: none; width: 48px; height: 44px; border-radius: var(--r-mid); border: 0; background: var(--pill); font-size: 22px; font-weight: 700; }
.switchrow { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.switchrow span { flex: 1; font-weight: 600; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--pill); position: relative; flex: none; margin: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips button, .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--pill); border: 0; font-weight: 600; font-size: 13px; padding: 4px 10px; }
.chip.low { color: var(--bad); }
.search { margin: 4px 0 10px; }

/* ── the meals list ───────────────────────────────────────────────────── */
.newcard { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; text-align: left; background: var(--accent); color: var(--on-accent);
           border-radius: var(--r-card); padding: 16px; margin: 6px 0 12px; font-weight: 650; font-size: 17px; }
.newcard svg { width: 34px; height: 34px; flex: none; }
.newcard small { display: block; font-weight: 500; font-size: 14px; opacity: .88; }
.meal-row { gap: 12px; }
.thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; background: var(--pill); display: flex; align-items: center; justify-content: center; color: var(--dim); }
.thumb svg { width: 28px; height: 28px; }
.meal-row b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-row .mac { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.star { border: 0; background: none; width: 40px; height: 40px; padding: 8px; color: var(--dim); flex: none; }
.star svg { width: 100%; height: 100%; }
.star.on { color: var(--gold); }
.spin { width: 18px; height: 18px; border: 2.5px solid var(--pill); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── a new meal ───────────────────────────────────────────────────────── */
.preview { position: relative; margin: 10px 0; }
.preview img { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--r-card); }
.preview button { position: absolute; top: 8px; right: 8px; border: 0; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; padding: 6px 12px; font-weight: 600; }
.left { color: var(--dim); font-size: 13px; text-align: center; margin: 8px 0 0; }

/* ── a meal ───────────────────────────────────────────────────────────── */
.hero { width: 100%; aspect-ratio: 4 / 3; max-height: 380px; object-fit: cover; border-radius: var(--r-card); margin: 4px 0 10px; background: var(--pill); }
.mtitle { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin: 6px 0 4px; line-height: 1.15; display: flex; align-items: flex-start; gap: 6px; }
.mtitle span { flex: 1; }
.msum { color: var(--ink-2); margin: 0 0 8px; }
.working { display: flex; align-items: center; gap: 12px; }
.working b { display: block; }
.working small { color: var(--dim); }
.macros .kcal { font-family: var(--font-num); font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.macros .kcal small { font-size: 16px; color: var(--dim); font-weight: 650; letter-spacing: 0; margin-left: 4px; }
.macros .head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.macros .head .seg { width: 210px; }
.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--pill); margin: 4px 0 12px; }
.split i { display: block; height: 100%; }
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mgrid.four { grid-template-columns: repeat(4, 1fr); }
.mgrid.four div b { font-size: 19px; }
.mgrid div b { display: block; font-family: var(--font-num); font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.mgrid div span { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.more { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; }
.more div { display: flex; justify-content: space-between; }
.more span { color: var(--dim); }
.estimate { color: var(--dim); font-size: 12.5px; margin: 10px 0 0; }
.ing { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.ing:first-child { border-top: 0; }
.ing .amt { width: 92px; flex: none; font-weight: 650; font-variant-numeric: tabular-nums; }
.ing .nm { flex: 1; min-width: 0; }
.ing .nm small { display: block; color: var(--dim); font-size: 12.5px; }
.ing .kc { color: var(--dim); font-size: 13px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.ing.edit { display: grid; grid-template-columns: 1fr 96px 40px; gap: 6px; align-items: center; }
.ing.edit input[data-f="name"] { grid-column: 1 / -1; font-weight: 600; }
.ing.edit input, .ing.edit select { min-height: 40px; padding: 6px 8px; font-size: 16px; }
.ing.edit .x { border: 0; background: var(--pill); border-radius: 10px; height: 40px; font-size: 18px; color: var(--dim); }
.ing.edit small { grid-column: 1 / -1; color: var(--dim); font-size: 12.5px; margin-top: -2px; }
ol.steps { margin: 0; padding-left: 22px; }
ol.steps li { margin: 0 0 10px; padding-left: 4px; }
ul.plain { margin: 0; padding-left: 20px; color: var(--ink-2); }
ul.plain li { margin: 0 0 6px; }
.seen { color: var(--ink-2); font-style: italic; margin: 0; }
.fixrow { display: flex; gap: 8px; }
.fixrow input { flex: 1; }
.hist .row { min-height: 44px; }

/* ── the log ──────────────────────────────────────────────────────────── */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; }
.daynav b { font-size: 17px; }
.daynav button { border: 0; background: var(--pill); border-radius: 999px; width: 40px; height: 36px; font-size: 20px; font-weight: 700; color: var(--ink); }
.daynav button:disabled { opacity: .35; }
.bars { display: grid; gap: 10px; }
.tbar span { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); margin-bottom: 4px; }
.tbar span b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.tbar i { display: block; height: 8px; border-radius: 4px; background: var(--pill); overflow: hidden; }
.tbar i em { display: block; height: 100%; border-radius: 4px; }
.tbar.over span b { color: var(--bad); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 90px; margin-top: 6px; }
.week button { border: 0; background: none; padding: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--dim); font-weight: 600; }
.week button i { display: block; width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px; background: color-mix(in srgb, var(--accent) 55%, transparent); min-height: 3px; }
.week button.on { color: var(--ink); }
.week button.on i { background: var(--accent); }
.entry .row-v { font-variant-numeric: tabular-nums; }
.del { border: 0; background: var(--pill); color: var(--dim); border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 600; flex: none; }
.del.sure { background: var(--bad); color: #fff; }

/* ── groceries ────────────────────────────────────────────────────────── */
.addrow { display: flex; gap: 8px; margin: 4px 0 6px; }
.addrow input { flex: 1; }
.gitem { gap: 12px; }
.box { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--dim); flex: none; display: flex; align-items: center; justify-content: center; color: transparent; }
.box svg { width: 16px; height: 16px; }
.gitem.done .box { background: var(--good); border-color: var(--good); color: #fff; }
.gitem.done .row-k { color: var(--dim); text-decoration: line-through; }
.gitem .row-k small { text-decoration: none; }

/* ── You ──────────────────────────────────────────────────────────────── */
.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details.card summary { display: flex; align-items: center; list-style: none; cursor: pointer; font-weight: 600; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary .chev { margin-left: auto; transition: transform .2s; }
details.card[open] summary .chev { transform: rotate(90deg); }
dl.kv { margin: 10px 0 0; font-size: 13px; }
dl.kv div { display: flex; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
dl.kv dt { color: var(--dim); width: 110px; flex: none; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

@media (min-width: 700px) {
  .bar h1 { font-size: 34px; }
}

/* ── the menu (2026-10-12): the top of the Meals tab when there is one ─── */
.menu-row { align-items: flex-start; cursor: pointer; }
.menu-row b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-row .row-k small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mbtns { display: flex; gap: 8px; margin-top: 8px; }
.btn.small { flex: 1; min-height: 36px; padding: 6px 12px; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.mbtns .btn.small[data-up], .mbtns .btn.small[data-down] { flex: none; width: 48px; }
.btn.small svg { width: 16px; height: 16px; }
.btn.done { background: color-mix(in srgb, var(--good) 16%, var(--panel)); color: var(--good); }
.btn.small.danger { background: transparent; color: var(--bad); }
.tonight { margin: 0 4px 10px; font-size: 15px; color: var(--ink-2); }
.tonight b { color: var(--ink); font-weight: 650; }
.tonight .dim, .tonight.dim { color: var(--dim); }
.weekline { margin: 10px 4px 0; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.toast .tact { margin-left: 10px; border: 0; background: none; color: inherit; font: inherit; font-weight: 750; text-decoration: underline; padding: 4px 2px; }
