/* Design system (step 4, 2026-11). Every colour, size, space and radius below comes from the tokens.
   Colour: OKLCH, warm neutrals and one gold (the logo's #F7A800). Light = shadow + hairline for depth; dark = lighter surfaces, no shadows.
   Borders are alpha colours so they work on any surface. Nested radius = outer radius minus the padding between. */
@font-face {
  font-family: "Atkinson Hyperlegible";
  font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  font-weight: 700; font-style: normal; font-display: swap;
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/fraunces-latin-600-normal.woff2") format("woff2");
}
:root {
  color-scheme: light dark;
  /* surfaces and text */
  --bg: oklch(97.6% 0.008 85);
  --surface: oklch(99.6% 0.004 85);
  --surface-2: oklch(94.8% 0.01 85);          /* sunken: the switcher track, skeletons */
  --raised: var(--surface);                    /* the chosen button on a sunken track */
  --text: oklch(23% 0.015 150);
  --muted: oklch(46% 0.014 150);
  --line: oklch(23% 0.02 150 / 0.13);          /* hairlines */
  --line-strong: oklch(23% 0.02 150 / 0.58);   /* field borders: 3:1 against the page */
  /* the one accent */
  /* gold fails contrast as text on the page (2.4:1), so it only fills buttons, under dark text; links, labels and lines use the dark shade */
  --brand: #F7A800;
  --brand-press: oklch(74% 0.16 78);
  --on-accent: oklch(23% 0.03 75);
  --accent: oklch(46% 0.105 78);
  --tint: oklch(94.5% 0.04 85);
  --warn: oklch(45% 0.1 70);
  --bad: oklch(47% 0.17 28);
  --shadow-sm: 0 1px 2px oklch(23% 0.02 150 / 0.07), 0 2px 8px oklch(23% 0.02 150 / 0.05);
  --scrim: oklch(23% 0.02 150 / 0.5);

  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  /* five levels: page title (xl, serif), section heading (lg, serif), group label (xs, bold, gray), item (base, bold), detail (sm, gray) */
  --text-xs: 0.875rem; --text-sm: 0.9375rem; --text-base: 1rem; --text-lg: 1.375rem; --text-xl: 1.875rem; --text-brand: 1.5rem;
  --leading-tight: 1.2; --leading: 1.5;

  /* spacing: 4 / 8 / 12 / 16 / 24 / 32 / 48 px. 12 inside rows, 16 inside panels, 24 between sections. */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem;
  /* radius: a control is --r-sm; anything holding controls at --pad-card from its edge is controls + padding */
  /* --r-fit is the exact sum (box corner less the gap). A small corner inside a big one looks sharper than
     it measures, so controls are drawn 2 rounder than that; boxes are still built from the exact value. */
  --r-fit: 0.5rem; --r-sm: calc(var(--r-fit) + 0.125rem); --pad-card: 1rem; --r-card: calc(var(--r-fit) + var(--pad-card));
  --tap: 2.75rem; --pad-y: var(--space-2); --tap-sm: 2.25rem; --bar: 56px; --top: 3.5rem; --nav-icon: 24px; --column: 76rem; --rail: 20rem; --gutter: var(--space-4);
  --border: 1px; --ring: 3px;
}
/* with a mouse a button is 36 tall, so it sits closer to the text beside it; a finger keeps 44 */
@media (min-width: 45rem) { :root { --tap: 2.25rem; --pad-y: var(--space-1); } }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(17% 0.008 150);
    --surface: oklch(22% 0.01 150);
    --surface-2: oklch(26.5% 0.012 150);
    --raised: oklch(35% 0.014 150);
    --text: oklch(94% 0.008 90);
    --muted: oklch(73% 0.012 150);
    --line: oklch(100% 0 0 / 0.1);
    --line-strong: oklch(100% 0 0 / 0.42);
    --brand: #F7A800;
    --brand-press: oklch(86% 0.14 84);
    --on-accent: oklch(20% 0.04 75);
    --accent: oklch(81% 0.16 80);
    --tint: oklch(29% 0.045 80);
    --warn: oklch(82% 0.12 80);
    --bad: oklch(77% 0.13 25);
    --shadow-sm: none;
    --scrim: oklch(0% 0 0 / 0.55);
  }
}
@media (min-width: 45rem) { :root { --text-xl: 2.5rem; --text-brand: 1.75rem; --gutter: var(--space-5); } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  -webkit-text-size-adjust: 100%; scroll-padding-bottom: calc(var(--bar) + var(--space-4));
  scrollbar-gutter: stable;
}
/* every box that scrolls gets the same thin bar in the theme's own gray (the width is not inherited, so it is set on everything) */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 0.75rem; height: 0.75rem; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
::selection { background: var(--tint); color: var(--text); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--text-base)/var(--leading) var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
  padding-bottom: calc(var(--bar) + var(--space-4) + env(safe-area-inset-bottom));  /* room for the bottom bar */
}
main { max-width: var(--column); margin: 0 auto; padding: var(--space-5) var(--gutter) var(--space-6); }
/* one frame for every screen: the same width and left edge as the top bar. A screen with a side panel
   (.page with a .rail) puts it on the right from 62rem and under the main column on a phone. */
main[data-view="signin"] { max-width: calc(26rem + 2 * var(--gutter)); padding-block: var(--space-4); }
/* signed out there is no top bar, and the card sits in the middle of the window with the legal links at the foot, so nothing needs scrolling */
#chrome:has(#top[hidden]) { display: none; }
body:has(main[data-view="signin"]) { display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
body:has(main[data-view="signin"]) main { width: 100%; margin-block: auto; }
body:has(main[data-view="signin"]) .legal { margin-block: var(--space-2) var(--space-4); }
.page { display: grid; gap: var(--space-5); align-items: start; }
.page > * { min-width: 0; }
.rail { display: grid; gap: var(--space-4); }
.rail > .card { margin: 0; }
@media (min-width: 62rem) {
  .page { grid-template-columns: minmax(0, 1fr) var(--rail); gap: var(--space-6); }
  .page > * { grid-column: 1; grid-row: 1; }
  .page > .rail { grid-column: 2; }  /* on the right, wherever it sits in the phone order */
}
/* a screen with one short block (a form, an empty state) keeps a readable width at the same left edge */
.measure { max-width: 44rem; }
.brand-title { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-1); }
.brand-title img { flex: none; }
/* the three steps under the sign-in card: a serif number, then a short line */
.how { list-style: none; margin: var(--space-4) 0 0; padding: 0 var(--pad-card); display: grid; gap: var(--space-2); color: var(--muted); }
/* a short window keeps the sign-in card and drops the three steps, so it still fits without scrolling */
@media (max-height: 41rem) { .how { display: none; } }
.brand-title + h2 { margin-top: var(--space-3); }
.how li { display: flex; align-items: baseline; gap: var(--space-3); }
.how b { flex: none; width: 1.25rem; font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; color: var(--accent); text-align: center; }
p > button.link:first-child { padding-inline-start: 0; }
/* sections that sit side by side when there is room (settings, rules, menus) */
/* cards of different heights flow down columns, each one right under the card above it (no rows, so no gaps) */
.cols { columns: 22rem; column-gap: var(--space-4); }
.cols > .card { margin: 0 0 var(--space-4); break-inside: avoid; }
h1, h2 { font-family: var(--font-display); font-weight: 600; line-height: var(--leading-tight); letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: var(--text-xl); margin: 0 0 var(--space-4); }
h2 { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-3); }
h2:first-child { margin-top: 0; }
/* a group label ("Breakfast · 3"): small, bold and gray, so it never reads as one of the items under it */
h3, .label { font-family: var(--font); font-size: var(--text-xs); font-weight: 700; line-height: var(--leading); letter-spacing: 0; color: var(--muted); margin: 0 0 var(--space-1); }
.count { font-weight: 400; }
p { margin: var(--space-2) 0; }
a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }

/* ---- navigation. Phone: the name and gear on top, four tabs in a bar at the bottom.
   Desktop: one slim row, name left, four links, gear right. The bar's labels keep a fixed size so large text never wraps it. ---- */
#chrome { display: contents; }
header {
  position: fixed; inset: auto 0 0 0; z-index: 3;
  background: var(--surface); border-top: var(--border) solid var(--line);
  padding: 0 0 env(safe-area-inset-bottom);
  max-height: 70dvh; overflow-y: auto;
}
#top {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between;
  min-height: var(--top); background: var(--bg); border-bottom: var(--border) solid var(--line); padding: 0 var(--space-2) 0 var(--gutter);
}
#top .brand { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 600; font-size: var(--text-brand); line-height: 1; letter-spacing: -0.015em; }
#top .brand img { width: 1.75rem; height: 1.75rem; flex: none; }
#gear { border: 0; background: none; min-width: var(--tap); min-height: var(--tap); padding: 0; display: grid; place-items: center; border-radius: var(--r-sm); }
#gear .icon { margin: 0; }
#gear:hover { background: var(--surface-2); }
#gear[aria-current="page"] { color: var(--accent); background: var(--tint); }
nav { display: flex; flex-direction: column; }
.bar { display: flex; }
.bar button {
  flex: 1 1 0; min-width: 0; min-height: var(--bar); border: 0; border-radius: 0; background: none; color: var(--muted);
  padding: var(--space-2) 0; font-size: 0.875rem; font-weight: 400; line-height: var(--leading-tight); white-space: nowrap;
}
nav button .icon, #gear .icon {
  display: block; width: var(--nav-icon); height: var(--nav-icon); background: currentColor;
  mask-position: center; mask-size: contain; mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat;
}
nav button .icon { margin: 0 auto var(--space-1); }
.icon-today { mask-image: url("icons/menu-today.svg"); -webkit-mask-image: url("icons/menu-today.svg"); }
.icon-plan { mask-image: url("icons/menu-plan.svg"); -webkit-mask-image: url("icons/menu-plan.svg"); }
.icon-shop { mask-image: url("icons/menu-shop.svg"); -webkit-mask-image: url("icons/menu-shop.svg"); }
.icon-pantry { mask-image: url("icons/menu-pantry.svg"); -webkit-mask-image: url("icons/menu-pantry.svg"); }
.icon-recipes { mask-image: url("icons/menu-recipes.svg"); -webkit-mask-image: url("icons/menu-recipes.svg"); }
.icon-settings { mask-image: url("icons/menu-settings.svg"); -webkit-mask-image: url("icons/menu-settings.svg"); }
nav button[aria-current="page"] { font-weight: 700; color: var(--accent); }
nav button:active { background: var(--tint); }

/* the switcher: related screens inside one tab, as a segmented control (track radius = button radius + track padding) */
.switcher {
  display: flex; gap: var(--space-1); overflow-x: auto; margin: 0 0 var(--space-5); padding: var(--space-1);
  background: var(--surface-2); border-radius: calc(var(--r-fit) + var(--space-1)); width: fit-content; max-width: 100%;
  scrollbar-width: none;
}
.switcher::-webkit-scrollbar { display: none; }
.switcher button {
  flex: 0 0 auto; min-height: var(--tap-sm); border: 0; border-radius: var(--r-sm); background: none; color: var(--muted);
  padding: var(--space-1) var(--space-4); font-weight: 400; white-space: nowrap;
}
.switcher button:hover { color: var(--text); }
.switcher button[aria-current="page"] { background: var(--raised); color: var(--text); font-weight: 700; box-shadow: var(--shadow-sm); }
/* on a phone the row is as wide as the page and its buttons share it, so all of them show (four fit at 360px) */
@media (max-width: 44.99rem) {
  .switcher { width: 100%; }
  .switcher button { flex: 1 1 auto; padding-inline: var(--space-2); }
}

@media (min-width: 45rem) {
  #chrome {
    display: flex; align-items: center; gap: var(--space-5); position: sticky; top: 0; z-index: 3;
    padding: 0 max(var(--gutter), calc((100% - var(--column)) / 2 + var(--gutter)));
    background: var(--bg); border-bottom: var(--border) solid var(--line); min-height: var(--top);
  }
  #top, header, nav, .bar { display: contents; }
  #top .brand { order: 0; margin-right: var(--space-4); }
  .bar button { order: 1; flex: none; display: inline-flex; align-items: center; min-height: var(--tap-sm); padding: var(--space-1) var(--space-4); border-radius: 999px; font-size: var(--text-base); color: var(--text); }
  .bar button:hover { background: var(--surface-2); }
  .bar button[aria-current="page"] { background: var(--tint); color: var(--accent); }
  nav button .icon { display: none; }
  #gear { order: 3; margin-left: auto; }
  body { padding-bottom: var(--space-4); }
  #status { top: var(--top); }
}

/* ---- buttons and fields: one height family (44px for a finger, 36px with a mouse), one radius, one padding ---- */
button, input, select, textarea {
  font: inherit; color: inherit; min-height: var(--tap); padding: var(--pad-y) var(--space-4); max-width: 100%;
  border: var(--border) solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
}
select { padding-inline: var(--space-3); }
button { cursor: pointer; font-weight: 700; touch-action: manipulation; transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
button:hover:not(:disabled) { background: var(--surface-2); }
button:active:not(:disabled) { transform: translateY(1px); background: var(--tint); }  /* a tap always shows */
button.primary { background: var(--brand); color: var(--on-accent); border-color: var(--brand); }
button.primary:hover:not(:disabled), button.primary:active:not(:disabled) { background: var(--brand-press); border-color: var(--brand-press); }
/* the one filled button a screen leads with (Today's next step) */
button.hero { display: block; width: 100%; min-height: 3.5rem; font-size: var(--text-lg); margin: 0 0 var(--space-5); }
button.hero:has(+ .hero-hint) { margin-bottom: var(--space-2); }
.hero-hint { margin: 0 0 var(--space-5); }
/* a welcome, not a screen to scan: one narrow block in the middle of the window (every other screen keeps the left edge) */
.first-run { max-width: 34rem; margin-inline: auto; text-align: center; padding-top: clamp(var(--space-6), 12dvh, 7rem); }
.first-run p { font-size: var(--text-lg); margin-bottom: var(--space-5); }
button.link { border: 0; background: none; color: var(--accent); font-weight: 400; text-decoration: underline; padding-inline: var(--space-2); }
button.link:hover:not(:disabled) { background: none; }
/* the way back from a screen opened on top of another: a quiet link above the title, never a boxed button */
button.back { display: inline-flex; align-items: center; gap: var(--space-2); padding-inline-start: 0; color: var(--muted); text-decoration: none; }
button.back::before { content: "←"; }
button.back:hover:not(:disabled) { color: var(--text); }
.method ol { padding-inline-start: 1.25rem; max-width: 46rem; }
.method li { margin-block: var(--space-3); line-height: 1.5; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.on { background: var(--tint); border-color: var(--accent); }
button:disabled, button[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; }
:focus-visible { outline: var(--ring) solid var(--accent); outline-offset: 2px; }
/* a tick box is 20px, the usual size beside text; the row around it is the 44px tap target (.tick) */
input[type="checkbox"], input[type="radio"] { width: 1.25rem; height: 1.25rem; min-height: 0; padding: 0; margin: 0; flex: none; vertical-align: middle; accent-color: var(--accent); }
input:user-invalid, [aria-invalid="true"] { border: 2px solid var(--bad); }
input, select, textarea { scroll-margin-block: var(--space-6); }  /* focus scrolls the field clear of the keyboard */
label { display: block; margin: var(--space-4) 0 var(--space-1); font-weight: 700; }
label.tick, .tick label { font-weight: 400; }
.tick label { margin: 0; }
textarea { width: 100%; min-height: 6rem; font-family: var(--font-mono); font-size: var(--text-sm); }
.field input, .field select { width: 100%; }
form.card input:not([type="checkbox"]):not([type="radio"]), form.card select { width: 100%; }  /* a label above a full-width box */

/* ---- cards, rows, lists ---- */
.card {
  background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-sm); padding: var(--pad-card); margin: var(--space-4) 0;
}
.card .card { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-3); }
.row > label, .row > .row { margin: 0; }  /* beside a box, not above it: no gap of its own, so it is level with the box */
.grow { flex: 1 1 9rem; }
.muted { color: var(--muted); font-size: var(--text-sm); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.tick { display: flex; gap: var(--space-3); align-items: center; margin: 0; padding: var(--space-1) 0; min-height: var(--tap); }
.add-bar { position: sticky; bottom: calc(var(--bar) + var(--space-3) + env(safe-area-inset-bottom)); z-index: 2; margin: var(--space-4) 0; }
.add-bar button { width: 100%; box-shadow: var(--shadow-sm); }
button.icon-btn { min-height: var(--tap-sm); min-width: var(--tap-sm); padding: 0; font-size: var(--text-lg); line-height: 1; flex: none; border-color: transparent; background: none; color: var(--muted); }
button.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

/* one row design for every list: name on the left, one gray detail line, the action on the right, more on tap */
.item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-3) 0; border-bottom: var(--border) solid var(--line); min-width: 0; }
.items, .added-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: var(--space-3); align-items: stretch; }
.item-main, .item-text { flex: 1 1 0; min-width: 0; }
/* a meal left from last week: on a phone the name gets its own line above its two buttons */
@media (max-width: 44.99rem) { .left-over .item-main { flex-basis: 100%; } }
.item-text { display: block; text-align: left; color: inherit; border: 0; background: none; padding: 0; min-height: var(--tap); font-weight: 400; }
.item-text:hover:not(:disabled) { background: none; }
.name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-weight: 700; }
.detail { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: var(--text-sm); }
.detail.wrap { white-space: normal; overflow: visible; text-overflow: clip; }
.item .add { flex: none; min-width: 6rem; }
.item .add.on { background: var(--tint); border-color: var(--accent); color: var(--accent); }
/* a shopping line: tick, name and amount on one line; Details sits on the right and opens full width */
.item.line > .tick { flex: 1 1 0; min-width: 0; }
.item.line .name { display: inline; margin-right: var(--space-2); }
.item.line details { margin: 0; flex: none; }
.item.line details[open] { flex-basis: 100%; }
article.item.line details { flex-basis: 100%; }  /* a planned meal: Ingredients has its own line, so it does not jump when opened */
/* the question takes the full row; the reading-width cap on wide screens (main p) would keep it beside the item */
.item.line > .warn { max-width: none; }
.item.line > .warn, .item.line > .row { flex-basis: 100%; margin: 0; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
label.btn { display: inline-flex; align-items: center; margin: 0; min-height: var(--tap); padding: var(--pad-y) var(--space-4); border: var(--border) solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); font-weight: 700; cursor: pointer; }
.file-input:focus-visible + label.btn { outline: var(--ring) solid var(--accent); outline-offset: 2px; }
.check-tag { flex: none; color: var(--warn); font-weight: 700; }
/* one pantry item is one line: its name, the amount, the date, then Nutrition at the right. The amount is
   a box to type over; its buttons drop below. With several amounts the line shows the total and a
   button that unfolds one line per amount. */
/* the button is space-2 from the top, the bottom and the side of its box, and the box's corner is the
   button's corner plus that gap, so the two curves share a centre */
.pantry-item { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-2); padding: 0 var(--space-2) 0 var(--space-3); margin: var(--space-2) 0; border-radius: calc(var(--r-fit) + var(--space-2)); }  /* the name is text, so it stands a little further in than a button */
/* on the narrowest phones the clock goes, so the row has room to stay one line whatever the phone's own
   number font is; the date still reads as a date, and screen readers still hear "use by" */
@media (max-width: 23.99rem) { .pantry-item .i-clock { display: none; } }
section.pantry-item > h2 { font-family: var(--font); font-size: var(--text-base); font-weight: 700; letter-spacing: 0; margin: 0; line-height: var(--leading); }
.pantry-item > ul.plain { flex: 1 1 auto; min-width: 0; margin: 0; order: 2; }
.pantry-item > .opener { order: 3; width: 5.75rem; }
.pantry-item > .item-more { order: 4; padding-bottom: var(--space-3); }  /* clear of the box's round corner */
.pantry-item .item { padding: var(--space-1) 0; }
.pantry-item .item-main { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
.pantry-item .item-main .detail { display: inline-flex; align-items: center; gap: var(--space-1); }
.opener { flex: none; min-height: var(--tap-sm); padding: 0; font-size: var(--text-sm); font-weight: 400; }
.opener.fold { display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); }
.pantry-item .grams { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: 700; white-space: nowrap; }
input.amount { width: calc(var(--digits) * 1ch + 1.25rem); min-height: var(--tap-sm); padding: 0 var(--space-2); font-weight: 700; appearance: textfield; -moz-appearance: textfield; }
input.amount::-webkit-inner-spin-button, input.amount::-webkit-outer-spin-button { appearance: none; margin: 0; }
.opener[aria-expanded="true"] { background: var(--tint); border-color: var(--accent); color: var(--accent); }
.opener .chev { display: inline-block; }
.pantry-item .item-more .item:last-child { border-bottom: 0; }
.pantry-item .stats { margin: var(--space-2) 0; }
.opener .i-chart { display: none; }
/* a phone keeps the one line by making each part smaller: Nutrition is a picture, and
   only a name too long for what is left runs onto a second line */
@media (max-width: 44.99rem) {
  .pantry-item { display: grid; grid-template-columns: auto 1fr auto; column-gap: var(--space-2); }
  .pantry-item > h2 { overflow-wrap: anywhere; }
  .pantry-item > ul.plain { min-width: max-content; }
  .pantry-item > .item-more { grid-column: 1 / -1; }
  section.pantry-item > h2, .pantry-item .grams { font-size: var(--text-sm); }
  input.amount { width: calc(var(--digits) * 1ch + 0.875rem); padding: 0 0.375rem; }  /* its text stays full size: a phone zooms in on a box with smaller text */
  .opener.fold { gap: var(--space-1); padding: 0 0.375rem; }
  .pantry-item .item-main { flex-wrap: nowrap; gap: var(--space-1); }
  .pantry-item .item-main .detail { white-space: nowrap; font-size: var(--text-xs); }
  .pantry-item > .opener { width: var(--tap-sm); }
  .opener .word, .opener.fold .chev { display: none; }
  .opener .i-chart { display: inline-block; vertical-align: middle; }
}
.item-more { flex-basis: 100%; padding: 0 0 var(--space-2); }

/* the Recipes page as a cart */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* Recipes in zones: ready-made lists in their own band, then one toolbar, then the results */
.band { background: var(--surface-2); border-radius: var(--r-card); padding: var(--pad-card); margin: 0 0 var(--space-5); }
.band > .row { margin-top: var(--space-3); }
.band > .row:not(:has(> :not([hidden]))) { display: none; }
.band .chip:not(.on) { background: var(--surface); }
.toolbar { border-block: var(--border) solid var(--line); padding: var(--space-3) 0; margin: 0 0 var(--space-3); }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filters input[type="search"] { flex: 1 1 12rem; min-width: 0; }
.filters select { flex: 0 1 auto; min-width: 0; }
.active { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.active:empty { display: none; }
.active .chip { min-height: var(--tap-sm); padding: 0 var(--space-3); font-size: var(--text-sm); display: inline-flex; align-items: center; gap: var(--space-2); }
.results-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-3); margin: 0 0 var(--space-3); }
.results-head p { margin: 0; }
/* small drawn icons, in the colour of the words beside them */
.i { display: inline-block; flex: none; width: 1rem; height: 1rem; background: currentColor; vertical-align: -0.125em;
  mask: var(--i) center / contain no-repeat; -webkit-mask: var(--i) center / contain no-repeat; }
.i-clock { --i: url("icons/clock.svg"); } .i-plus { --i: url("icons/plus.svg"); } .i-check { --i: url("icons/check.svg"); } .i-x { --i: url("icons/x.svg"); } .i-chart { --i: url("icons/chart.svg"); }
/* how hard a recipe is: one to three filled dots (the word sits beside them, so nobody has to guess what the dots mean) */
.dots { display: inline-flex; gap: 3px; vertical-align: 0.1em; }
.dots i { width: 0.4375rem; height: 0.4375rem; border-radius: 999px; border: 1px solid var(--muted); }
.dots i.on { background: var(--muted); }
.chip { border-radius: 999px; font-weight: 400; padding-inline: var(--space-4); }
.chip.on { background: var(--tint); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.cart-bar { position: fixed; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; left: var(--gutter); right: var(--gutter); bottom: calc(var(--bar) + var(--space-3) + env(safe-area-inset-bottom)); z-index: 2; background: var(--brand); color: var(--on-accent); border-color: var(--brand); box-shadow: var(--shadow-sm); }
.cart-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); text-align: left; }
.cart-bar > span:first-child { display: grid; min-width: 0; }
.cart-bar strong, .cart-bar small { overflow: hidden; text-overflow: ellipsis; }
.cart-bar small { font-size: var(--text-xs); font-weight: 400; }
.cart-go { flex: none; text-decoration: underline; }
.cart-go::after { content: "Show"; }
.cart-bar[aria-expanded="true"] .cart-go::after { content: "Hide"; }
.set-head { display: flex; align-items: center; justify-content: space-between; }
.set-head h2 { margin: 0; }
.set-panel { display: none; }
.set-panel.open { display: block; position: fixed; inset: 0 0 calc(var(--bar) + env(safe-area-inset-bottom)) 0; z-index: 3; overflow-y: auto; background: var(--bg); padding: var(--gutter); }
.set-cols { display: block; }
@media (min-width: 900px) {
  .cart { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); gap: var(--space-6); align-items: start; }
  .cart-bar, .set-close { display: none; }
  /* the set scrolls inside its panel: room for the bar is kept on both sides, so the padding is even and the x buttons never sit under it */
  .set-panel {
    display: block; position: sticky; top: calc(var(--top) + var(--space-4)); max-height: calc(100dvh - var(--top) - 2 * var(--space-4)); overflow-y: auto;
    scrollbar-gutter: stable both-edges; padding: var(--pad-card) var(--space-2);
    background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-sm);
  }
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--space-3) var(--space-4); align-items: start; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; border-bottom: var(--border) solid var(--line); }
.price-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--space-3); }
@media (min-width: 900px) { main p, main .muted { max-width: 45rem; } }
ul.plain { list-style: none; margin: var(--space-1) 0; padding: 0; }
ul.plain > li:not(.card) { padding: var(--space-2) 0; border-bottom: var(--border) solid var(--line); }
ul.plain > li:not(.card):last-child { border-bottom: 0; }
details { margin: var(--space-2) 0; }
details > details:last-child { margin-bottom: 0; }  /* a fold that ends another adds no room under it */
summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; gap: var(--space-2); color: var(--accent); font-weight: 700; }
summary::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin: 0 var(--space-1); transition: transform 0.12s; }
details[open]:not([data-shutting]) > summary::before { transform: rotate(45deg); }
summary::before { transition: transform 0.15s; }
.banner { background: var(--tint); border: var(--border) solid var(--line); border-radius: var(--r-card); padding: var(--pad-card); }
.blocked { opacity: 0.65; }
.done { text-decoration: line-through; color: var(--muted); }

/* ---- messages: an error is a tinted bar with a mark and words, never colour alone ---- */
#status { position: sticky; top: var(--top); z-index: 4; }
#status .msg { display: flex; gap: var(--space-2); align-items: baseline; padding: var(--space-3) var(--gutter); background: var(--surface-2); border-bottom: var(--border) solid var(--line); }
#status .msg.error { color: var(--bad); font-weight: 700; }
#status .msg.error::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 999px; background: var(--bad); color: var(--bg); font-size: var(--text-sm); }

/* ---- loading and empty states ---- */
.skeleton { display: block; min-height: 1.25rem; margin: var(--space-2) 0; border-radius: var(--r-sm); background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
.skeleton.title { width: 50%; min-height: 2rem; }
.skeleton.block { min-height: 6rem; border-radius: var(--r-card); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.empty { padding: var(--pad-card); background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--r-card); margin: var(--space-4) 0; }
.empty p { margin-top: 0; }
.empty.problem p { color: var(--text); }
.skip { position: absolute; left: var(--space-2); top: -4rem; z-index: 5; background: var(--surface); padding: var(--space-2) var(--space-4); border-radius: var(--r-sm); }
.skip:focus { top: var(--space-2); }

.legal { margin: var(--space-6) var(--gutter) var(--space-4); font-size: var(--text-sm); color: var(--muted); text-align: center; }
.legal a { color: inherit; }
.doc { max-width: 40rem; margin: 0 auto; padding: var(--space-4) var(--gutter); }
.doc li { margin: var(--space-2) 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
main:focus { outline: none; }

/* a tappable row: the whole line opens, a small arrow on the right says so */
.tick > .item-text { display: flex; align-items: center; gap: var(--space-2); flex: 1 1 0; }
.tick > .item-text .name { display: block; }
/* the same line arrow as a fold's: it points right when shut and turns down when open */
.chev { flex: none; width: 0.5rem; height: 0.5rem; margin: 0 var(--space-1); border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
[aria-expanded="true"] > .chev { transform: rotate(45deg); }
/* a shopping line is one line: the name, then the amount beside it. Where there is room the list runs in
   two columns, so a row is not mostly empty. */
main[data-view="list"] .tick > .item-text .item-main { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--space-2); }
/* each line is its own box, like a pantry item, so what it opens plainly belongs to it */
main[data-view="list"] li.item.line { padding: 0 var(--space-2) 0 var(--space-3); margin: var(--space-2) 0; background: var(--surface); border: var(--border) solid var(--line); border-radius: calc(var(--r-fit) + var(--space-2)); }
main[data-view="list"] li.item.line > .row, main[data-view="list"] li.item.line > .item-more { padding-bottom: var(--space-3); }  /* clear of the box's round corner */
main[data-view="list"] .page { margin-top: var(--space-5); }  /* the list starts clear of the buttons above it */
main[data-view="list"] .cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); column-gap: var(--space-6); align-items: start; }

/* Recipes on a phone: the four choices hide behind one Filters button */
.filters-toggle { display: none; }
@media (max-width: 1199px) {
  .filters-toggle { display: inline-flex; align-items: center; }
  .filters:not(.open) select { display: none; }
}
summary.chev-only { min-width: var(--tap); justify-content: center; }

/* ---- toasts: on a phone a small note in the top bar, so it never covers the tab bar or a field and the page never moves ---- */
#toasts { position: fixed; z-index: 6; top: 0; left: 0; right: 0; height: var(--top); display: flex; align-items: center; justify-content: center; pointer-events: none; padding: 0 var(--space-8, 3.5rem); }
.toast { pointer-events: auto; display: inline-flex; align-items: center; gap: var(--space-3); max-width: 100%; padding: var(--space-2) var(--space-4); background: var(--text); color: var(--bg); border-radius: 999px; font-size: var(--text-sm); font-weight: 700; animation: toast-in 0.15s ease-out; }
.toast .link { color: inherit; min-height: var(--tap-sm); padding-block: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-0.5rem); } }
/* on a phone the note takes the top bar for its few seconds, so it never sits half over the name */
@media (max-width: 44.99rem) { body:has(#toasts .toast) #top .brand { visibility: hidden; } }
/* wide screens: the bottom right corner, clear of the menu (Jake, 2026-11-23: in the top bar it read as part of the menu) */
@media (min-width: 45rem) {
  #toasts { top: auto; bottom: var(--space-5); height: auto; left: auto; right: max(var(--gutter), calc((100% - var(--column)) / 2 + var(--gutter))); width: auto; justify-content: flex-end; padding: 0; }
  .toast { padding: var(--space-3) var(--space-5); font-size: var(--text-base); box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.25); animation-name: toast-up; }
}
@keyframes toast-up { from { opacity: 0; transform: translateY(0.5rem); } }

/* ---- Recipes: fixed-height cards. The name is the only bold text; time, how hard and cuisine share one gray line;
   allergens are small tags across the bottom; Add is a square button in the top corner, so it never moves. ---- */
.recipe-row {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--tap); grid-template-rows: auto minmax(0, 1fr); gap: var(--space-2) var(--space-3);
  padding: var(--space-3); background: var(--surface); border: var(--border) solid var(--line); border-radius: calc(var(--r-fit) + var(--space-3)); box-shadow: var(--shadow-sm);  /* its buttons sit 12 from the edge */
}
.recipe-row { contain: layout; }  /* a card's inside never depends on its neighbours, so a slide above the long list stays smooth on a slow phone */
.recipe-row:not(.open) { min-height: 8rem; }  /* a two-line name, the facts and one line of tags; cards in a row stretch to match */
.recipe-row.open { grid-column: 1 / -1; grid-template-rows: auto auto auto; }
.recipe-row > .item-text { grid-column: 1; grid-row: 1; align-self: start; min-height: 0; }
.recipe-row > .add { grid-column: 2; grid-row: 1; align-self: start; min-width: 0; width: var(--tap); padding: 0; display: grid; place-items: center; }
.recipe-row > .add .i { width: 1.25rem; height: 1.25rem; }
.recipe-row > .allergens { grid-column: 1 / -1; grid-row: 2; align-self: end; }
.recipe-row > .item-more { grid-column: 1 / -1; grid-row: 3; padding-bottom: 0; }
.recipe-row .name { -webkit-line-clamp: 2; line-height: 1.35; font-size: var(--text-base); }
.recipe-row .detail { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-1); min-height: 1.4em; }
.recipe-row .detail > span { display: inline-flex; align-items: center; gap: var(--space-1); flex: none; }
.recipe-row .detail > .cuisine { flex: 0 1 auto; min-width: 0; display: block; overflow: hidden; text-overflow: ellipsis; }
.allergens { display: flex; flex-wrap: wrap; gap: var(--space-1); align-content: flex-start; }
.tag { display: inline-block; padding: 0 var(--space-2); background: var(--surface-2); border-radius: 999px; font-size: var(--text-xs); color: var(--muted); line-height: 1.5; }
.added-group { margin-top: var(--space-5); }
.set-row { height: 3rem; min-height: 3rem; flex-wrap: nowrap; padding: 0; }
.set-row .name { flex: 1 1 0; min-width: 0; display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-weight: 400; }
.limits { margin: var(--space-2) 0; }
/* a variety rule: its name as a group label, the recipes it keeps apart as small tags under it */
.rule { margin: var(--space-3) 0; }
.rule .allergens { margin-top: var(--space-1); }
.rule-card h2 { font-size: var(--text-base); font-family: var(--font); font-weight: 700; letter-spacing: 0; margin: 0 0 var(--space-1); }
.rule-card .allergens { margin-top: var(--space-3); }
.goal-row { padding: var(--space-3) 0; border-bottom: var(--border) solid var(--line); }
.goal-row:first-child { padding-top: 0; }
.goal-row:last-child { border-bottom: 0; padding-bottom: 0; }
.goal-row > input { max-width: 12rem; }
.goal-row > label { margin-top: 0; }
.goal-row > p { margin: var(--space-1) 0 0; font-size: var(--text-sm); }
.goal-row > details { margin: 0; }
.goal-row .goal { margin-top: 0; }
.goal input { flex: 1 1 5rem; width: 5rem; min-width: 0; }  /* a goal's four boxes stay on one line beside the helper */
.rule .tag, .rule-card .tag { border-radius: var(--r-sm); }  /* recipe names can run to two lines */
.alike { padding: var(--space-3) 0; border-top: var(--border) solid var(--line); }
.alike .row { margin-top: var(--space-2); }

/* ---- the side panel on Today: the week at a glance ---- */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-1); margin: var(--space-3) 0 var(--space-2); text-align: center; }
.week-strip .day { display: grid; justify-items: center; gap: var(--space-1); padding: var(--space-2) 0; border-radius: var(--r-sm); font-size: var(--text-xs); color: var(--muted); }
.week-strip .day b { font-size: var(--text-base); color: var(--text); font-weight: 400; }
.week-strip .day.today { background: var(--tint); }
.week-strip .day.today b { font-weight: 700; color: var(--accent); }
.week-strip .dots { flex-direction: column; }
.week-strip .dots i { border-color: var(--line-strong); }
.week-strip .dots i.on { background: var(--accent); border-color: var(--accent); }
.card > h2 { margin-bottom: var(--space-2); }
.card ul.plain { margin-bottom: 0; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: var(--border) solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv > :first-child { min-width: 0; }
.kv > :last-child { color: var(--muted); font-size: var(--text-sm); text-align: right; flex: none; }

/* ---- a table-like list (past weeks): one row per week, the same columns on every row ---- */
.week-row { display: grid; grid-template-columns: 12rem minmax(0, 1fr) auto; gap: var(--space-1) var(--space-4); align-items: baseline; width: 100%; text-align: left;
  padding: var(--space-3) var(--space-2); border: 0; border-bottom: var(--border) solid var(--line); border-radius: 0; background: none; font-weight: 400; }
.week-row .name { -webkit-line-clamp: 1; }
.week-row .detail { white-space: normal; }
@media (max-width: 44.99rem) { .week-row { grid-template-columns: minmax(0, 1fr) auto; } .week-row .detail { grid-column: 1 / -1; grid-row: 2; } }


/* a page title with its main action on the right */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.page-head h1 { margin: 0; }
/* the week at a glance: a strip of days, the day's numbers as tiles, a bar for each target */
.week-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.pill { font: 400 var(--text-xs) var(--font); color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: var(--space-1) var(--space-3); }
.week-sum { display: grid; gap: var(--space-4); margin-bottom: var(--space-4); max-width: 45rem; }
.week-sum p { margin: 0 0 var(--space-2); }
.week-sum > p:empty, #week-nutrition:empty { display: none; }
.daystrip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.daystrip i { font-style: normal; font-size: var(--text-xs); min-width: 2.5rem; padding: var(--space-1) 0; text-align: center; border-radius: var(--r-sm); border: var(--border) dashed var(--line-strong); color: var(--muted); }
.daystrip i.on { border-style: solid; border-color: var(--accent); background: var(--tint); color: var(--accent); font-weight: 700; }
.daystrip span { margin-left: var(--space-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: var(--space-2); margin: 0; }
.stats > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--r-sm); padding: var(--space-2) var(--space-3); }
.stats dt { color: var(--muted); font-size: var(--text-xs); }
.stats dd { margin: 0; white-space: nowrap; font-size: var(--text-lg); font-weight: 700; line-height: var(--leading-tight); }
.stats dd small { font-size: var(--text-sm); font-weight: 400; color: var(--muted); }
#week-nutrition { display: grid; gap: var(--space-2); }
.goalbar { display: grid; grid-template-columns: 5rem minmax(3rem, 1fr) auto; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
progress { appearance: none; width: 100%; height: 0.5rem; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
/* a planned meal is a card */
.meals { padding-block: var(--space-1); }
article.item { padding: var(--space-3) 0; }
article.item:last-child { border-bottom: 0; }
article.item > .row { flex-basis: 100%; margin-top: 0; }
article.item > .item-more:empty { display: none; }
/* the three choices under a planned meal stay on one line on a phone */
.meals .row button { padding-inline: var(--space-3); font-size: var(--text-sm); }
.set-head { margin-bottom: var(--space-2); }
.set-cols h3 { margin: var(--space-4) 0 0; }
/* the "Days" picker beside a draft meal's buttons: the word and the box on one line */
label.days { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-weight: 400; }
