/* ============================================================
   Design tokens.

   Built greyscale-first: the hierarchy is carried by value, not
   by hue. Desaturate this page and it still reads. Colour does
   three jobs and no others:

     herb  - the system's own voice (active state, structure)
     clay  - emphasis and attention, used sparingly
     ink   - everything that has to be read

   Red and green never carry a health verdict on their own.
   Every safety state has a word, a shape and an icon as well.
   ============================================================ */

:root {
  /* Surfaces, warm neutral rather than grey */
  --canvas:        #F6F2EA;
  --surface:       #FFFDF8;
  --surface-sunk:  #EFE8DC;
  --surface-warm:  #FBF4EA;

  /* Ink. All body values tested at or above 4.5:1 on --canvas */
  --ink:           #1E2A23;
  --ink-2:         #3E4E45;
  --ink-3:         #5A6A60;
  --ink-on-dark:   #F6F2EA;

  --line:          #DDD3C4;
  --line-strong:   #C6B9A6;

  /* Accents */
  --herb:          #47694C;
  --herb-deep:     #2F4A35;
  --herb-soft:     #E4EBE1;
  --clay:          #A0512C;
  --clay-soft:     #F5E3D7;
  --amber:         #7E5711;
  --amber-soft:    #F6EBD4;

  /* Elevation: two shadows, one light direction (above-left) */
  --lift-1: 0 1px 1px rgba(45,35,22,.05), 0 2px 6px rgba(45,35,22,.05);
  --lift-2: 0 1px 2px rgba(45,35,22,.06), 0 8px 22px rgba(45,35,22,.07);
  --lift-3: 0 2px 4px rgba(45,35,22,.08), 0 22px 48px rgba(45,35,22,.12);

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;

  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: #E7E0D3;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.larger-text { font-size: 18px; }

/* ---------- The phone frame ---------- */

.frame {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  /* Installed on a phone there is no browser chrome, so the app
     owes itself the status bar inset. */
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--canvas);
  box-shadow: var(--lift-3);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 900px) {
  body { padding: 24px 0; }
  .frame { min-height: calc(100vh - 48px); border-radius: 20px; overflow: hidden; }
}

.hub {
  flex: 1;
  padding: var(--sp-5) var(--sp-4) 96px;
  display: none;
}
.hub.active { display: block; }

/* ---------- Type ---------- */

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.2; }
h1 { font-size: 1.65rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 var(--sp-3); max-width: 62ch; }
p:last-child { margin-bottom: 0; }

.lede { color: var(--ink-2); }

/* Monospace micro-labels. Used for anything measured:
   prices, timestamps, versions, quantities. Reads as precision. */
.micro {
  font-family: var(--mono);
  font-size: .69rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Explanatory prose. Quiet, but still a sentence: the micro style
   is for labels and measured values, never for something to read. */
.note {
  font-size: .82rem;
  line-height: 1.5;
  color: var(--ink-3);
  margin: var(--sp-3) 0 0;
  max-width: 60ch;
}

.hub-head { margin-bottom: var(--sp-5); }
.hub-head .micro { display: block; margin-bottom: var(--sp-1); }
.hub-head p { margin-top: var(--sp-2); color: var(--ink-2); }

.section { margin-top: var(--sp-6); }
.section > h2 { margin-bottom: var(--sp-1); }
.section > .sub { color: var(--ink-3); font-size: .9rem; margin-bottom: var(--sp-3); }

/* ---------- Progressive disclosure ----------
   The current decision stays visible. Supporting information uses
   native details so keyboard and screen-reader behavior is built in. */

details.reveal {
  background: transparent;
  border-top: 1px solid var(--line-strong);
}
details.reveal > summary {
  list-style: none;
  min-height: 64px;
  padding: var(--sp-3) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  cursor: pointer;
}
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > summary::after {
  content: '\203A';
  flex: none;
  color: var(--herb-deep);
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform .15s ease-out;
}
details.reveal[open] > summary::after { transform: rotate(90deg); }
.reveal-title {
  display: block;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
.reveal-sub {
  display: -webkit-box;
  margin-top: 3px;
  color: var(--ink-3);
  font-size: .82rem;
  line-height: 1.4;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.reveal-body { padding: 0 0 var(--sp-4); }
.reveal-body > .card:last-child { margin-bottom: 0; }
.next-reveal { margin: var(--sp-3) 0; }
.next-reveal .micro { display: block; margin-bottom: 3px; }
.next-reveal .reveal-body > .lede { margin: 0 0 var(--sp-3); }
.priority-why { margin: calc(var(--sp-3) * -1) 0 var(--sp-3); border-top: 0; }
.today-actions { margin-top: var(--sp-5); }

/* ---------- Cards ----------
   A card is only for a distinct actionable object: a meal, a
   product, a myth, a list row. Headings and running text are
   not put in boxes.                                            */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--lift-1);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.card.raised { box-shadow: var(--lift-2); }
.card.flat { box-shadow: none; background: var(--surface-warm); }

.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
.card h3 { margin-bottom: var(--sp-1); }

/* ---------- The now card ---------- */

.now-card { border-color: var(--line-strong); box-shadow: var(--lift-2); }
.now-card .slot-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-2);
}
.now-card h2 { margin: var(--sp-1) 0 var(--sp-2); }

.portion {
  background: var(--herb-soft);
  border-left: 3px solid var(--herb);
  padding: var(--sp-2) var(--sp-3);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: .95rem;
  color: var(--ink-2);
  margin: var(--sp-3) 0;
}

.figures { display: flex; gap: var(--sp-5); margin: var(--sp-3) 0; }
.figure .micro { display: block; }
.figure .val { font-family: var(--mono); font-size: 1.1rem; color: var(--ink); }

.cost-row {
  display: flex; align-items: baseline; gap: var(--sp-2);
  padding-top: var(--sp-3); border-top: 1px solid var(--line);
  margin-top: var(--sp-3);
}
.cost-row .price { font-family: var(--mono); font-size: 1.05rem; }

/* ---------- Priority chip ---------- */

.chip-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .88rem;
  color: var(--ink-2);
  cursor: pointer;
  min-height: 38px;
  font-family: inherit;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--herb); flex: none; }
.chip:hover { border-color: var(--herb); }
.chip.on { background: var(--herb-soft); border-color: var(--herb); color: var(--herb-deep); }

.chip-reason { font-size: .85rem; color: var(--ink-3); margin: calc(var(--sp-2) * -1) 0 var(--sp-4); }

/* ---------- Buttons ---------- */

.btn {
  font-family: inherit; font-size: .95rem;
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
}
.btn:hover { border-color: var(--herb); }
.btn:focus-visible { outline: 3px solid var(--herb); outline-offset: 2px; }

.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--herb-deep); border-color: var(--herb-deep); color: var(--ink-on-dark); }
.btn.primary:hover { background: var(--herb); border-color: var(--herb); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 0 var(--sp-2); }
.btn.wide { width: 100%; }
.btn.small { min-height: 34px; font-size: .85rem; padding: 0 var(--sp-3); }

.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }

/* ---------- Details disclosure ----------
   Consistently placed on every card that carries a health claim.
   It hides nuance. It never hides danger.                       */

details.why { margin-top: var(--sp-3); border-top: 1px solid var(--line); padding-top: var(--sp-3); }
details.why > summary {
  cursor: pointer; font-size: .9rem; color: var(--herb-deep);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px;
}
details.why > summary::-webkit-details-marker { display: none; }
details.why > summary::after { content: '\203A'; transform: rotate(90deg); display: inline-block; transition: transform .18s ease; }
details.why[open] > summary::after { transform: rotate(-90deg); }
details.why .body { margin-top: var(--sp-3); font-size: .92rem; color: var(--ink-2); }
details.why .body ul { margin: 0 0 var(--sp-3); padding-left: 1.1em; }
details.why .body li { margin-bottom: var(--sp-2); }

/* ---------- Safety and status notices ----------
   Four visual states. Each carries a word and a mark, so the
   colour is never the only signal.                             */

.notice {
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  font-size: .9rem;
  display: flex; gap: var(--sp-3); align-items: flex-start;
  margin: var(--sp-3) 0;
  line-height: 1.45;
}
.notice .mark { font-weight: 700; flex: none; width: 20px; text-align: center; font-family: var(--mono); }
.notice strong { display: block; margin-bottom: 2px; }

.notice.block     { background: var(--clay-soft); border: 1px solid var(--clay); color: #4A2413; }
.notice.block .mark { color: var(--clay); }
.notice.caution   { background: var(--amber-soft); border: 1px solid #D8B978; color: #4A3608; }
.notice.caution .mark { color: var(--amber); }
.notice.unknown   { background: var(--surface-sunk); border: 1px dashed var(--line-strong); color: var(--ink-2); }
.notice.good      { background: var(--herb-soft); border: 1px solid var(--herb); color: var(--herb-deep); }
.notice.plain     { background: var(--surface-warm); border: 1px solid var(--line); color: var(--ink-2); }

/* ---------- Swaps ---------- */

.swap {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-warm);
  margin-bottom: var(--sp-2);
}
.swap .swap-name { font-size: .95rem; }
.swap .swap-meta { font-size: .8rem; color: var(--ink-3); font-family: var(--mono); }

/* ---------- Tab bar ----------
   Text label plus icon, always. Selection never depends on
   colour alone: the active tab also carries a top rule and
   heavier weight.                                             */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 430px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -2px 12px rgba(45,35,22,.06);
  z-index: 40;
}
.tab {
  border: none; background: none; cursor: pointer;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  min-height: 58px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: inherit; font-size: .72rem; color: var(--ink-3);
  border-top: 3px solid transparent;
  margin-top: -1px;
}
.tab svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tab.on { color: var(--herb-deep); border-top-color: var(--herb); font-weight: 600; }
.tab .badge {
  position: absolute; transform: translate(14px, -6px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--clay);
}

/* ---------- Sheet (native modal) ---------- */

.sheet {
  position: fixed; inset: auto 0 0;
  width: 100%; max-width: 430px; margin: 0 auto;
  background: var(--canvas);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border: 0;
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
  max-height: 86dvh; overflow-y: auto;
  z-index: 60;
  box-shadow: 0 -2px 6px rgba(45,35,22,.08), 0 -18px 44px rgba(45,35,22,.16);
  color: var(--ink);
}
.sheet::backdrop { background: rgba(30,42,35,.42); }
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: -8px auto var(--sp-4); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.sheet h2 { margin: 0; }

/* ---------- Toast with undo ---------- */

.toast {
  position: fixed; bottom: 74px; left: 12px; right: 12px;
  max-width: 406px; margin: 0 auto;
  background: var(--ink); color: var(--ink-on-dark);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: none; align-items: center; justify-content: space-between; gap: var(--sp-3);
  z-index: 70; font-size: .9rem;
  box-shadow: var(--lift-3);
}
.toast.show { display: flex; }
.toast button {
  background: none; border: 1px solid rgba(246,242,234,.4); color: inherit;
  border-radius: var(--r-sm); padding: 7px 12px; font-family: inherit; font-size: .85rem; cursor: pointer;
  min-height: 34px;
}

/* ---------- Lists ---------- */

.row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .r-main { flex: 1; }
.row .r-name { font-size: .95rem; }
.row .r-meta { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.row .r-right { text-align: right; font-family: var(--mono); font-size: .9rem; white-space: nowrap; }

.dept { margin-bottom: var(--sp-5); }
.dept > .micro { display: block; padding-bottom: var(--sp-2); border-bottom: 2px solid var(--line-strong); margin-bottom: var(--sp-1); }

.check {
  width: 24px; height: 24px; border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm); flex: none; cursor: pointer; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.check.on { background: var(--herb); border-color: var(--herb); color: #fff; }
.row.done .r-name { text-decoration: line-through; color: var(--ink-3); }

/* ---------- Budget meter ----------
   One repeated mark, one varying parameter.                    */

.meter { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-sunk); margin: var(--sp-3) 0 var(--sp-2); }
.meter span { display: block; height: 100%; }
.meter .spent   { background: var(--herb-deep); }
.meter .planned { background: var(--herb); opacity: .45; }
.meter .buffer  { background: var(--line-strong); }

.legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: .78rem; color: var(--ink-3); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.budget-main { display: flex; align-items: baseline; gap: var(--sp-2); margin-top: var(--sp-2); }
.budget-main .price { font-family: var(--mono); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.budget-main > span:last-child { color: var(--ink-3); font-size: .85rem; }

/* ---------- Week view ---------- */

.week-day {
  display: grid; grid-template-columns: 46px 1fr; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line);
}
.week-day:last-child { border-bottom: none; }
.week-day .d { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); text-transform: uppercase; padding-top: 2px; }
.week-day.is-today .d { color: var(--clay); font-weight: 700; }
.week-day .m { font-size: .92rem; margin-bottom: 3px; }
.week-day .tagline { font-size: .78rem; color: var(--ink-3); }
.pin { font-size: .72rem; color: var(--clay); font-family: var(--mono); }

/* ---------- Cook mode ---------- */

.cook { position: fixed; inset: 0; max-width: 430px; margin: 0 auto; background: var(--canvas); z-index: 80; display: none; flex-direction: column; }
.cook.open { display: flex; }
.cook header { padding: var(--sp-4); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; background: var(--surface); }
.cook .cook-title { font-family: var(--serif); font-size: 1rem; line-height: 1.25; padding-right: var(--sp-3); }
.cook .body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-4); }
.cook .step-now { font-family: var(--serif); font-size: 1.5rem; line-height: 1.32; margin-bottom: var(--sp-4); }
.cook .step-next { background: var(--surface-warm); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); color: var(--ink-2); font-size: .92rem; }
.cook footer { padding: var(--sp-3) var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: var(--sp-2); }
.cook footer .btn { flex: 1; }

.timer { font-family: var(--mono); font-size: 2.6rem; text-align: center; margin: var(--sp-4) 0; color: var(--herb-deep); font-variant-numeric: tabular-nums; }

.progress-dots { display: flex; gap: 5px; margin-bottom: var(--sp-4); }
.progress-dots i { flex: 1; height: 3px; border-radius: 2px; background: var(--line-strong); }
.progress-dots i.on { background: var(--herb); }

/* ---------- Scanner ---------- */

.scan-target {
  border: 2px dashed var(--line-strong); border-radius: var(--r-md);
  padding: var(--sp-4); color: var(--ink-3);
  background: var(--surface-warm); margin-bottom: var(--sp-4);
}
.barcode-form label { display: block; color: var(--ink); font-weight: 650; margin-bottom: var(--sp-2); }
.barcode-entry { display: flex; gap: var(--sp-2); }
.barcode-entry input {
  min-width: 0; flex: 1; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 1rem var(--mono);
}
.barcode-entry input:focus-visible { outline: 3px solid var(--herb); outline-offset: 2px; }
.barcode-form .note { margin: var(--sp-2) 0 0; }
.barcode-form .micro { min-height: 1.2em; margin: var(--sp-2) 0 0; }
.label-capture { border-top: 1px solid var(--line); margin-top: var(--sp-4); padding-top: var(--sp-4); }
.label-capture p { margin: 0 0 var(--sp-2); }
.label-capture .btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.label-capture .micro { display: block; min-height: 1.2em; margin-top: var(--sp-2); }

.label-review { display: grid; gap: var(--sp-3); }
.label-review .field { display: grid; gap: 6px; }
.label-review .field > span, .label-review legend { color: var(--ink); font-weight: 650; }
.label-review input[type="text"],
.label-review input[type="number"],
.label-review textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit;
}
.label-review textarea { min-height: 92px; resize: vertical; }
.label-review input:focus-visible, .label-review textarea:focus-visible {
  outline: 3px solid var(--herb); outline-offset: 2px;
}
.label-review fieldset { margin: 0; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); }
.label-review legend { padding: 0 6px; }
.allergen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: var(--sp-2); }
.allergen-grid label, .confirm-row { display: flex; align-items: flex-start; gap: 9px; min-height: 36px; }
.allergen-grid input, .confirm-row input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--herb); }
.label-preview { width: 100%; max-height: 210px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-sunk); }
.form-error { min-height: 1.2em; color: var(--clay); margin: 0; }

/* ---------- Toggle ---------- */

.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .t-main { flex: 1; }
.toggle-row .t-name { font-size: .95rem; }
.toggle-row .t-meta { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }

.switch { width: 48px; height: 28px; border-radius: 14px; background: var(--line-strong); border: none; position: relative; cursor: pointer; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--lift-1); transition: transform .18s ease; }
.switch.on { background: var(--herb); }
.switch.on::after { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid var(--herb); outline-offset: 2px; }

/* ---------- Empty and stopped states ---------- */

.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--ink-3); }
.end-of-screen { text-align: center; padding: var(--sp-5) 0 0; color: var(--ink-3); font-size: .85rem; border-top: 1px solid var(--line); margin-top: var(--sp-5); }

.tag {
  display: inline-block; font-family: var(--mono); font-size: .66rem; text-transform: uppercase;
  letter-spacing: .04em; padding: 3px 7px; border-radius: 4px; vertical-align: middle;
}
.tag.assumed { background: var(--surface-sunk); color: var(--ink-3); border: 1px dashed var(--line-strong); }
.tag.stale   { background: var(--amber-soft); color: var(--amber); border: 1px solid #D8B978; }
.tag.locked  { background: var(--surface-sunk); color: var(--ink-3); }
.tag.herb    { background: var(--herb-soft); color: var(--herb-deep); }
.tag.clay    { background: var(--clay-soft); color: var(--clay); }

/* ---------- Motion ----------
   Brief and functional only: confirming a swap, revealing a
   detail, updating the plan, completing a list item.          */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  transition: none !important; animation: none !important;
}

.settle { animation: settle .22s cubic-bezier(.32,.72,0,1); }
@keyframes settle { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Focus, always visible ---------- */

a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--herb); outline-offset: 2px; border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   First run.

   Same visual system, one question at a time. Deliberately
   quieter than the app: this screen is a conversation, not a
   dashboard, so there are no cards and no dense rows.
   ============================================================ */

.onboarding {
  position: fixed; inset: 0; z-index: 90;
  background: var(--canvas);
  display: none;
  overflow-y: auto;
}
.onboarding.open { display: block; }

.ob-inner {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(var(--sp-5) + env(safe-area-inset-top, 0px)) var(--sp-4) var(--sp-7);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-height: 100dvh;
}

.ob-progress-row { display: flex; align-items: center; gap: var(--sp-3); }
.ob-progress {
  height: 3px; border-radius: 2px; background: var(--surface-sunk);
  overflow: hidden; flex: 1;
}
.ob-progress i {
  display: block; height: 100%; background: var(--herb);
  transition: width .3s cubic-bezier(.32,.72,0,1);
}

.ob-title { font-family: var(--serif); font-size: 1.55rem; line-height: 1.2; margin: 0; text-wrap: balance; }
.ob-why { color: var(--ink-2); font-size: .95rem; margin: 0; max-width: 52ch; }

#ob-back { align-self: flex-start; margin: 0; padding: 0; }

/* Single choice. Full-width targets, easy to hit one-handed. */
.ob-options { display: flex; flex-direction: column; gap: var(--sp-2); }
.ob-option {
  font-family: inherit; text-align: left; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  min-height: 60px;
  display: flex; flex-direction: column; gap: 3px;
  box-shadow: var(--lift-1);
}
.ob-option:hover { border-color: var(--herb); }
.ob-label { font-size: 1.02rem; color: var(--ink); }
.ob-note { font-size: .85rem; color: var(--ink-3); }

/* Multi select. */
.ob-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ob-chip {
  font-family: inherit; font-size: .92rem; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  color: var(--ink);
}
.ob-chip:hover { border-color: var(--herb); }
/* Selection is carried by weight and a mark, not colour alone. */
.ob-chip.on {
  background: var(--herb-soft);
  border-color: var(--herb);
  color: var(--herb-deep);
  font-weight: 600;
}
.ob-chip.on::before { content: '\2713'; margin-right: 6px; }

.pantry-picker { display: grid; gap: var(--sp-3); }
.pantry-picker-tools {
  display: grid;
  gap: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--line);
}
.pantry-search { display: grid; gap: 6px; color: var(--ink); font-weight: 650; }
.pantry-search input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.pantry-search input:focus-visible { outline: 3px solid var(--herb); outline-offset: 2px; }
.pantry-picker-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  color: var(--ink-3);
  font-size: .84rem;
  font-variant-numeric: tabular-nums;
}
.pantry-picker-meta strong { color: var(--herb-deep); }
.pantry-picker-empty { margin: 0; }
.pantry-groups {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.pantry-group {
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: clip;
}
.pantry-group > summary {
  min-height: 48px;
  padding: 0 var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  cursor: pointer;
  color: var(--ink);
  font-weight: 650;
}
.pantry-group[open] > summary { border-bottom: 1px solid var(--line); }
.pantry-group > .ob-chips { padding: var(--sp-3); }

/* Number stepper. */
.ob-number {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  box-shadow: var(--lift-1);
}
.ob-step {
  width: 52px; height: 52px; flex: none; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--canvas); color: var(--ink);
  font-size: 1.5rem; font-family: inherit; line-height: 1;
}
.ob-step:hover { border-color: var(--herb); }
.ob-value { text-align: center; flex: 1; }
.ob-value span:first-child {
  display: block; font-family: var(--mono); font-size: 1.9rem;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.ob-unit { font-size: .8rem; color: var(--ink-3); }

/* The plan visibly forming while the questions are answered. */
.forming {
  margin-top: var(--sp-2);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
.forming-bits { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.forming .bit {
  font-size: .8rem; color: var(--ink-2);
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 10px;
}

/* The data dump behind "Export everything". */
.dump {
  font-family: var(--mono); font-size: .75rem; line-height: 1.5;
  background: var(--surface-sunk); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--sp-3);
  overflow-x: auto; white-space: pre; color: var(--ink-2);
  max-height: 40vh; overflow-y: auto;
}

.ob-minimum {
  font-size: .85rem; color: var(--clay);
  margin: 0; padding: var(--sp-2) var(--sp-3);
  background: var(--clay-soft); border-radius: var(--r-sm);
}

/* ---------- Touch targets ----------
   The mark stays small because a 44px tick looks clumsy, but the
   thing you actually hit is 44px. Blueprint asks for large touch
   areas on every primary control, not just the obvious buttons. */

.check { position: relative; }
.check::after {
  content: ''; position: absolute; inset: -10px;
}

.switch::before {
  content: ''; position: absolute; inset: -8px -4px;
}

/* Secondary controls sit at 40px rather than the 44px --tap used by
   primary ones. That is a deliberate compromise: 44 everywhere makes
   the swap rows and chip lists clumsy, and 40 still clears the WCAG
   2.2 AA minimum of 24 by a wide margin. Expanding the hit area with
   a pseudo-element instead would overlap neighbours in tight rows. */

.btn.small { min-height: 40px; }
details.why > summary { min-height: 40px; }
.chip { min-height: 40px; }

/* Data status stays with shopping, where source and price trust matter. */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-3); }
.data-status {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: var(--sp-2);
  width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-3); margin-top: var(--sp-3); min-height: 48px;
  color: var(--ink-2); font-size: .82rem;
}
.data-status > span:first-child {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 1px solid var(--herb); border-radius: 50%;
  color: var(--herb-deep); font-weight: 700; font-family: var(--serif);
}
.data-status strong {
  color: var(--herb-deep); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
  white-space: nowrap;
}
.data-status:hover { border-color: var(--herb); }
.data-status:focus-visible { outline: 3px solid var(--herb); outline-offset: 2px; }

#shopping-list-section, #product-check-section { scroll-margin-top: var(--sp-4); }

/* ---------- Language ----------
   Above the hub content because it changes every word below it.
   The pair reads as one control, so the pressed state carries a
   border and weight, not colour alone. */

.langbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4) 0;
  flex: none;
}

.lang {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .06em;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.lang:hover { color: var(--ink); }
.lang.on {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--herb-deep);
  font-weight: 700;
  box-shadow: var(--lift-1);
}
.lang:focus-visible { outline: 3px solid var(--herb); outline-offset: 2px; }

/* In the first-run screen it sits at the top of the same column. */
.onboarding .langbar { padding: var(--sp-2) 0 0; max-width: 430px; margin: 0 auto; }

/* ---------- Photographs ----------
   Full bleed to the card edge: a photo inset inside padding reads as
   an illustration pasted in, edge to edge reads as the card being
   about that meal.

   aspect-ratio holds the space before the file arrives, so the
   buttons below never move under a thumb that is already reaching
   for them. */

.card.has-shot { padding-top: 0; overflow: hidden; }

.shot {
  margin: 0 calc(var(--sp-4) * -1) var(--sp-4);
  aspect-ratio: 3 / 2;
  background: var(--surface-sunk);
  overflow: hidden;
  position: relative;
}
.shot.short { aspect-ratio: 5 / 2; }

.shot img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* A hairline over the image so a pale photo still separates from the
   card, and a whisper of warmth so it belongs to this palette. */
.shot::after {
  content: '';
  position: absolute; inset: 0;
  box-shadow: inset 0 -1px 0 var(--line), inset 0 0 0 1px rgba(45,35,22,.04);
  pointer-events: none;
}

.swap-shot {
  width: 48px; height: 48px; flex: none;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
}
