/* Tupper Rescue — tokens from the approved canvas (light + dark). */
:root {
  --bg: #F5F5F0; --surface: #FFFFFF; --field: #F5F5F0; --field2: #EBEBE5; --line: #EFEFE9;
  --border: rgba(0,0,0,0.05); --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.03);
  --text: #0A0A0A; --text2: #5E5E57; --text3: #8C8C82; --olive: #6E6E2C; --olive-icon: #8A8A40;
  --lime: #E6E640; --lime-ink: #0A0A0A; --lime-soft: rgba(230,230,64,0.2);
  --sel: #0A0A0A; --sel-ink: #FFFFFF; --done-bg: #0A0A0A; --done-ink: #E6E640;
  --warn: #A4500B; --warn-soft: #FBEBD3; --danger: #B42318;
  --p: #F08C6C; --c: #CFCF2E; --g: #A99BF0;
  --bar-track: #E6E6DE; --bar-edge: rgba(110,110,44,0.35); --tab: #FFFFFF; --scrim: rgba(10,10,10,0.35);
  --radius: 24px; --radius-sm: 16px; --radius-xs: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12120E; --surface: #1C1C17; --field: #25251F; --field2: #2F2F28; --line: #2A2A23;
    --border: rgba(255,255,255,0.04); --shadow: none;
    --text: #F5F5F0; --text2: #A9A99F; --text3: #7A7A70; --olive: #C9C970; --olive-icon: #C9C970;
    --lime-soft: rgba(230,230,64,0.12); --sel: #F5F5F0; --sel-ink: #0A0A0A; --done-bg: #E6E640; --done-ink: #0A0A0A;
    --warn: #F2A65A; --warn-soft: #2E2416; --danger: #F97066;
    --p: #F4A088; --c: #E6E640; --g: #B7ABF5;
    --bar-track: #2F2F28; --bar-edge: transparent; --tab: #16160F; --scrim: rgba(0,0,0,0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12120E; --surface: #1C1C17; --field: #25251F; --field2: #2F2F28; --line: #2A2A23;
  --border: rgba(255,255,255,0.04); --shadow: none;
  --text: #F5F5F0; --text2: #A9A99F; --text3: #7A7A70; --olive: #C9C970; --olive-icon: #C9C970;
  --lime-soft: rgba(230,230,64,0.12); --sel: #F5F5F0; --sel-ink: #0A0A0A; --done-bg: #E6E640; --done-ink: #0A0A0A;
  --warn: #F2A65A; --warn-soft: #2E2416; --danger: #F97066;
  --p: #F4A088; --c: #E6E640; --g: #B7ABF5;
  --bar-track: #2F2F28; --bar-edge: transparent; --tab: #16160F; --scrim: rgba(0,0,0,0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-size: 15px; line-height: 1.35; min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 112px); }
.screen.no-tabs { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }

/* Typography */
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--olive); }
.label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text3); }
h1.title { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.045em; line-height: 1.02; }
h1.title .olive { color: var(--olive); }
h2.sub { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.muted { color: var(--text2); }
.faint { color: var(--text3); }
.small { font-size: 13px; }
p { margin: 0; }
.head { display: flex; flex-direction: column; gap: 8px; padding: 0 4px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin: -6px -8px 0; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px; background: none; border: 0;
  font-size: 16px; font-weight: 500; color: var(--text2); text-decoration: none; }
.pill { padding: 5px 10px; border-radius: 10px; background: var(--sel); color: var(--sel-ink); font-size: 13px; font-weight: 700; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: #0A0A0A; color: #E6E640; display: flex; align-items: center; justify-content: center; flex: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--field2); color: var(--text2);
  display: inline-flex; align-items: center; justify-content: center; flex: none; text-decoration: none; }
.icon-btn.lime { width: 48px; height: 48px; border-radius: 16px; background: var(--lime); color: var(--lime-ink); }

/* Cards & lists */
.card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 0; text-decoration: none; color: inherit; width: 100%;
  background: none; border: 0; text-align: left; }
.item .name { font-size: 15px; font-weight: 500; }
.qty { padding: 3px 8px; border-radius: 8px; background: var(--field); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.section-title { margin: 0 0 4px; }

/* Inputs */
.field { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 14px; height: 48px; color: var(--text3); }
.field.focus-lime { box-shadow: 0 0 0 2px var(--lime); border-color: transparent; }
.field input { border: 0; outline: 0; background: transparent; flex: 1; font-size: 16px; color: var(--text); min-width: 0; }
.input { height: 44px; border: 0; border-radius: var(--radius-xs); padding: 0 12px; background: var(--field); font-size: 16px; color: var(--text); width: 100%; }
.input.warn { box-shadow: inset 0 0 0 2px var(--warn); background: var(--surface); }
label.stack { display: flex; flex-direction: column; gap: 4px; }
.num-input { width: 72px; height: 34px; border: 0; border-radius: 8px; padding: 0 8px; background: var(--field); text-align: right;
  font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.num-input.warn { box-shadow: inset 0 0 0 2px var(--warn); background: var(--surface); }
.big-number { border: 0; outline: 0; background: transparent; font-size: 52px; font-weight: 700; letter-spacing: -0.045em; width: 160px;
  text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

/* Choice controls */
.seg { display: grid; gap: 6px; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.seg button, .chip { height: 42px; border: 0; border-radius: 12px; background: var(--field); color: var(--text2); font-size: 14px; font-weight: 600; padding: 0 12px; white-space: nowrap; }
.seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--sel); color: var(--sel-ink); font-weight: 700; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 36px; background: var(--field2); flex: none; }
.switch { width: 50px; height: 30px; border-radius: 10px; background: var(--field2); position: relative; flex: none; border: 0; padding: 0; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 8px; background: #FFF;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--lime); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: #0A0A0A; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 58px; border-radius: 18px; border: 0;
  background: var(--lime); color: var(--lime-ink); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: -0.01em;
  text-decoration: none; width: 100%; }
.btn[disabled] { opacity: 0.5; }
.btn.dark { background: var(--sel); color: var(--sel-ink); text-transform: none; font-size: 15px; height: 46px; border-radius: 14px; width: auto; padding: 0 18px; }
.btn.ghost { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); text-transform: none; font-size: 15px; font-weight: 600; width: auto; padding: 0 18px; }
.btn.soft { background: var(--field); color: var(--text); text-transform: none; font-size: 15px; font-weight: 600; height: 46px; border-radius: 16px; }
.link { background: none; border: 0; padding: 0; min-height: 32px; font-size: 14px; font-weight: 700; color: var(--olive); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.cta-bar { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 86px); padding-top: 8px; display: flex; gap: 8px; }
.no-tabs .cta-bar { bottom: calc(env(safe-area-inset-bottom) + 12px); }

/* Status markers */
.check { width: 24px; height: 24px; border-radius: 8px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; padding: 0; }
.check.done { background: var(--done-bg); color: var(--done-ink); }
.check.next { box-sizing: border-box; border: 2.5px solid var(--text); background: transparent; }
.check.todo { box-sizing: border-box; border: 2px solid var(--field2); background: transparent; }
.check.round { border-radius: 16px; width: 32px; height: 32px; font-size: 14px; font-weight: 700; }
.dot { width: 7px; height: 7px; border-radius: 4px; display: inline-block; flex: none; }
.macros { display: flex; gap: 12px; font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }
.macros span { display: inline-flex; align-items: center; gap: 5px; }

/* Day bar (option C, approved) */
.daybar { height: 12px; border-radius: 6px; background: var(--bar-track); overflow: hidden; }
.daybar > div { height: 100%; border-radius: 6px; background: var(--lime); box-shadow: inset 0 0 0 1px var(--bar-edge); transition: width .3s; }
.daybar.over > div { background: var(--warn); }
.macrobar { height: 8px; border-radius: 4px; background: var(--bar-track); display: flex; gap: 2px; overflow: hidden; }

/* Meal list on Hoy */
.meal { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 18px; }
.meal.is-next { background: var(--lime-soft); padding: 12px 10px; }
.meal .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.meal.is-eaten .dish, .meal.is-eaten .kc { color: var(--text2); }
.extra { display: flex; align-items: center; gap: 10px; margin: 0 0 4px 46px; padding: 4px 0 4px 10px; border-radius: 14px; background: var(--field); }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--tab); border-top: 1px solid var(--line);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); }
.tabbar nav { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; color: var(--text3); font-size: 11px; font-weight: 600; }
.tabbar a .ic { width: 56px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.tabbar a[aria-current="page"] { color: var(--text); font-weight: 700; }
.tabbar a[aria-current="page"] .ic { background: var(--lime); color: var(--lime-ink); }

/* Sheet */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade .15s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 520px; margin: 0 auto; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; gap: 14px; animation: up .2s ease-out; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--field2); align-self: center; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim { animation: none; } .switch::after, .daybar > div { transition: none; } }

/* Callouts */
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; }
.callout.warn { background: var(--warn-soft); }
.callout.warn svg { color: var(--warn); }
.callout.ok { background: var(--lime-soft); }
.meanwhile { padding: 10px 12px; border-left: 3px solid var(--lime); border-radius: 0 12px 12px 0; background: var(--lime-soft); }

/* Camera */
.camera { position: fixed; inset: 0; z-index: 50; background: #0A0A0A; color: #F5F5F0; display: flex; flex-direction: column; }
.camera .view { flex: 1; margin: 0 10px; border-radius: 28px; background: #1A1A16; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera .frame { position: relative; width: 78%; max-width: 300px; aspect-ratio: 2/1; }
.camera .frame.tall { aspect-ratio: 3/4; }
.camera .frame i { position: absolute; width: 30px; height: 30px; border: 4px solid #E6E640; }
.camera .frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.camera .frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.camera .frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.camera .frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.camera .hint { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 9px 14px; border-radius: 14px; background: #0A0A0A; font-size: 14px; }
.camera .modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 16px; background: #1F1F1A; }
.camera .modes button { height: 40px; border: 0; border-radius: 12px; background: transparent; color: #A9A99F; font-weight: 500; }
.camera .modes button[aria-pressed="true"] { background: #E6E640; color: #0A0A0A; font-weight: 700; }
.shutter { width: 72px; height: 72px; border-radius: 36px; border: 4px solid #F5F5F0; background: #E6E640; }

/* Misc */
.empty { text-align: center; padding: 32px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translateX(-50%); z-index: 60;
  background: var(--sel); color: var(--sel-ink); padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.toast.error { background: var(--danger); color: #FFF; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--field2); border-top-color: var(--olive-icon); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 48px 0; }
.seal { width: 58px; height: 58px; flex: none; background: #0A0A0A; color: #FFF; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; line-height: 1.1; text-align: center; clip-path: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%); }
.nut-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); gap: 6px; align-items: center; min-height: 44px; border-top: 1px solid var(--line); }
.nut-grid > :nth-child(n+2) { justify-self: end; }
.daytabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.daytabs button { height: 60px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.daytabs button .d { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.daytabs button[aria-selected="true"] { background: var(--sel); color: var(--sel-ink); }
.daytabs button[aria-selected="true"] .label { color: inherit; opacity: .7; }
.receipt-raw { align-self: flex-start; padding: 2px 6px; border-radius: 6px; background: var(--field); font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11px; color: var(--text3); }
select.input { appearance: none; }
