/* ============================================================================
   Plate&Plan stylesheet
   ----------------------------------------------------------------------------
   Three layers, in cascade order. Keep them in this order and in this file:

     1. TOKENS      — the only place raw values are allowed to appear.
     2. BASE        — element defaults + accessibility guarantees.
     3. COMPONENTS  — one class per repeated UI pattern.

   Conventions
   -----------
   * Loaded via <helmet><link> in index.html, so the dc runtime hoists it into
     <head> once. Plain CSS — no build step, no preprocessor, no dependency.
   * Naming is block__element--variant (BEM-ish). Flat, one level of nesting max.
   * Inline `style=` is reserved for values that are *data*: a person's chosen
     colour, a meal's tint, a computed offset. Pass those in as custom
     properties (`style="--chip-tint:{{ g.tint }}"`) and let the class own
     every structural declaration. Anything static belongs in here.
   * Adding a raw hex, px radius, or font stack below the TOKENS section is a
     bug. test_a11y.py enforces the parts of this that are machine-checkable.
   ========================================================================== */


/* ============================================================================
   1. TOKENS
   ========================================================================== */

:root {
  /* --- Type ------------------------------------------------------------ */
  --font-display: 'Ribeye', Georgia, serif;
  --font-body: 'Poppins', system-ui, -apple-system, sans-serif;

  /* Ramp floor is 11px deliberately: below that, small-print UI copy stops
     being readable at arm's length on a phone. test_a11y.py holds the floor. */
  --fs-2xs: 11px;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-lg: 14.5px;
  --fs-xl: 17px;
  --fs-2xl: 19px;
  --fs-3xl: 24px;
  /* The smallest text a form field may have on a touch screen. Below 16px,
     iOS Safari zooms the page in when the field is focused and leaves it
     zoomed after — see the touch-field rule in the base layer. */
  --fs-field-touch: 16px;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-heavy: 800;

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-normal: 1.45;
  --lh-relaxed: 1.6;

  --tracking-caps: 0.05em;

  /* --- Colour: surfaces ------------------------------------------------ */
  --surface: #fff;              /* cards, menus, modals                    */
  --surface-warm: #FFFDF7;      /* note cards — "paper"                    */
  --surface-sunken: #faebe6;    /* page background, inputs, quiet pills    */
  --surface-muted: #F1EEE6;     /* side rows, filter panel, small chips    */
  /* Toggles read as controls, not as surface, so they sit one step deeper than
     the page rather than on it. They used to be neutral grey, which was the one
     cold family on an otherwise warm page; they are now the same rose as
     --surface-sunken, a shade darker so a track still reads as a trough against
     the page and against a white card. Both are non-text: --toggle-off is the
     switch's off fill, --toggle-track the trough behind segmented/viewbar
     options. --text-muted on --toggle-track measures 4.6:1, so the inactive
     option labels still clear AA. */
  --toggle-track: #F4E1DB;
  --toggle-off: #D5B3AA;

  /* --- Colour: borders (light → heavy) --------------------------------- */
  --border-faint: #EFEAE0;      /* hairline dividers, card edges           */
  --border-soft: #E8E2D6;       /* inputs at rest, date nav                */
  --border: #E2DCD0;            /* menus, primary input borders            */
  --border-strong: #D3CCBE;     /* dashed affordances, drag handles        */

  /* --- Colour: text ----------------------------------------------------
     Every value here clears WCAG 2.1 AA (4.5:1) on --surface AND
     --surface-sunken, except --text-faint, which is documented below and is
     verified against the 3:1 non-text threshold instead. The old palette had
     six greys between #9a948a and #cfc8ba used for real copy at 1.4:1–3.0:1;
     they all collapse onto --text-muted. See CSS-ARCHITECTURE.md. */
  --text: #0d2504;              /* headings, primary copy      14.1:1      */
  --text-body: #4a463f;         /* long-form body copy          8.1:1      */
  --text-muted: #6b655c;        /* meta, labels, secondary      5.0:1      */

  /* NON-TEXT ONLY. 3.2:1 on cream — clears 1.4.11 for icon glyphs and
     control boundaries, does NOT clear 1.4.3 for text. If you are about to
     put a word in this colour, use --text-muted. */
  --text-faint: #8a847a;

  --text-inverse: #fff;

  /* --- Colour: semantic ----------------------------------------------- */
  --success: #2FA862;           /* switch-on fill (non-text)               */
  --success-text: #1E7A46;      /* "✓ saved" copy               5.6:1      */
  --danger: #C0392B;            /* destructive label            4.7:1      */
  --danger-border: #E6B4AD;
  --warning: #F2960C;
  --warning-surface: #FFF3E0;
  --warning-text: #9A5800;      /* on --warning-surface         5.0:1      */

  /* Accent is user-configurable (props + per-person colour pickers), so it
     arrives from the logic script; this is the fallback only.

     Every accent option is dark enough to clear 4.5:1 against white, which is
     one condition doing two jobs: the accent is used as a button/badge *fill*
     with white text on it, and as the active tab's *text* colour on a white
     card. Both directions measure the same accent-vs-white contrast, so an
     accent light enough to look bright fails both at once. The whole swatch
     set sits at ~5.05:1. test_a11y.py holds the line. */
  --accent: #e00000;

  /* --- Radius --------------------------------------------------------- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 18px;
  --r-pill: 20px;
  --r-round: 50%;

  /* --- Space ---------------------------------------------------------- */
  /* Width of the schedule view's hover/swipe action column. Anything that must
     stay clear of it measures itself against this rather than against 58. */
  --swipe-actions-w: 58px;
  /* The phone's bottom bar, not counting the home-indicator inset under it.
     The page reserves exactly this much so nothing scrolls out of reach. */
  --tabbar-h: 58px;
  /* What sits under the bar. `env()` is the home indicator's own inset (34px
     on a Face ID iPhone, and only non-zero because the viewport meta asks for
     `viewport-fit=cover`); the floor keeps the icons off the very edge when
     there is no inset to lean on, so a tap is never read as iOS's swipe up. */
  --tabbar-inset: max(env(safe-area-inset-bottom, 0px), var(--sp-3));

  --sp-1: 4px;
  --sp-2: 6px;
  --sp-3: 8px;
  --sp-4: 11px;
  --sp-5: 14px;
  --sp-xl: 16px;    /* out of numeric sequence: the form/modal gutter, which the
                       design uses at 16px and nowhere else on the 4/6/8 ramp */
  --sp-6: 18px;
  --sp-7: 22px;

  /* --- Elevation ------------------------------------------------------ */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .03);
  --shadow-raised: 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-menu: 0 4px 16px rgba(0, 0, 0, .10);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, .25);
  --shadow-knob: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-fab: 0 6px 16px rgba(0, 0, 0, .24);
  /* Cast upward by the phone's bottom bar onto the page scrolling under it. */
  --shadow-bar: 0 -1px 8px rgba(0, 0, 0, .06);
  /* Cast sideways by a sticky column onto the content sliding under it. */
  --shadow-pinned: 6px 0 8px -6px rgba(0, 0, 0, .18);

  --scrim: rgba(40, 38, 34, .45);

  /* --- Motion --------------------------------------------------------- */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur-fast: .15s;
  --dur-base: .25s;

  /* --- Accessibility -------------------------------------------------- */
  --focus-ring: #0d2504;
  --focus-ring-offset: 2px;
  --tap-min: 44px;              /* WCAG 2.5.8 target size (minimum) is 24px;
                                   44px is the Apple/Material guidance we aim
                                   for on primary controls. */
}


/* ============================================================================
   2. BASE
   ========================================================================== */

* { box-sizing: border-box; }

/* The one horizontal scroll this app wants is `.planner__grid`, which owns a
   week that genuinely does not fit. Anything else reaching past the viewport is
   a bug, and on a phone it is an invisible one — you find it by the page
   drifting sideways under your thumb, not by seeing what caused it. Clipping at
   the root turns those into a layout mistake you can see instead of a scroll
   you cannot explain. `overflow-x` alone keeps the viewport as the scroll
   container, so `position: sticky` still resolves against it. */
html { overflow-x: hidden; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--surface-sunken);
  color: var(--text);
}

textarea, input, select, button { font-family: inherit; }

/* --- Focus -----------------------------------------------------------------
   The `!important` is a guard rail, not a fix for anything currently broken.
   The template used to carry inline `outline:none` on ~15 inputs; those are all
   gone now, but an inline declaration outranks any selector, so a single
   reintroduced `outline:none` would silently make the app unusable by keyboard.
   `!important` is the only thing that beats inline, so it stays. test_a11y.py
   asserts both halves: that this rule keeps its !important, and that no inline
   `outline:none` comes back. */
:focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: var(--focus-ring-offset) !important;
}

/* Elements the template makes clickable with onClick but which are not
   natively focusable get the same ring once they are given tabindex. */
[role="button"]:focus-visible,
[role="switch"]:focus-visible,
[role="checkbox"]:focus-visible,
[role="tab"]:focus-visible { border-radius: var(--r-xs); }

/* --- Motion ----------------------------------------------------------------
   Respect the OS "reduce motion" setting. The drawer slide, the schedule
   day-in animation, and the switch knob all become instant rather than
   disappearing, so nothing loses its state cue. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Touch: fields never trigger a zoom -----------------------------------
   iOS Safari zooms the whole page in whenever a text field under 16px gets
   focus, and does not zoom back out when you leave it. Every field in the app
   was 11-13.5px, so on an iPhone the first tap — the household name on the
   login screen — left the app magnified, and the only way out was a pinch the
   person should never have needed.

   The usual cure, `maximum-scale=1` in the viewport tag, also stops people
   pinch-zooming on purpose; test_zoom_is_not_blocked rules it out. So the
   fields grow instead, on touch screens only — a mouse never triggers it, so
   desktop keeps its compact 12.5-13.5px fields. `pointer: coarse` rather than
   `.app--mobile` because the login form sits outside the app, and an iPad
   zooms exactly the same way.

   `!important` because the size rules this overrides are spread across a dozen
   component classes (.field--sm, .note-box__input, .settings-row__meta, ...),
   and a new one should not be able to reintroduce the zoom by accident.
   test_a11y.py holds the rule in place. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]),
  select,
  textarea {
    font-size: var(--fs-field-touch) !important;
  }
}

/* --- Screen-reader-only text ---------------------------------------------
   For accessible names on icon-only controls: <span class="sr-only">Close</span>
   Stays in the accessibility tree; takes no visual space. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Scrollbars ----------------------------------------------------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-sm); }
::-webkit-scrollbar-track { background: transparent; }

/* --- Print confirm dialog -------------------------------------------------
   Printing used to be one click with no way back. This asks the one question
   the user cannot answer from the menu — which week — and says where the
   result will appear. */

.modal--ask { max-width: 380px; padding: var(--sp-6); }

.print-ask__title {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  margin: 0 0 var(--sp-2);
  color: var(--text);
}

.print-ask__hint {
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.45;
}

.print-ask__field { display: flex; flex-direction: column; gap: var(--sp-2); }

/* The range is the confirmation: the date box takes a Monday, this says which
   week that turned out to be. */
.print-ask__range {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-sm);
  color: var(--text-body);
}

.print-ask__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
}


/* --- Print ---------------------------------------------------------------- */
/* Lives in print.css, linked with media="print". Nothing print-only here. */


/* ============================================================================
   3. COMPONENTS
   ========================================================================== */

/* --- Surfaces ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}

.card--note {
  background: var(--surface-warm);
  border-color: var(--border-faint);
  border-radius: var(--r-lg);
  box-shadow: none;
}

.panel {
  background: var(--surface-muted);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}

/* Scroll regions. Height comes from --scroll-max at the call site because it
   differs per pane; the gutter compensation does not.

   The call-site caps are flat pixels, so on any viewport shorter than cap plus
   chrome the pane ran past the fold and pushed the footer with it. `min()`
   keeps each pane's own ceiling and adds a second one: never taller than what
   is left between the toolbar and the footer. The pane gives up height first,
   and the footer only leaves the view once the chrome alone fills the screen.
   The 200px floor is where that trade stops being worth making: below it the
   pane shows nothing useful, so the page goes back to scrolling instead.
   ponytail: --scroll-fit's chrome is measured per breakpoint, not derived. The
   flex chain that would compute it exactly runs through the mobile sheet and
   the infinite-scroll observers' root, and is not worth re-plumbing for ~10px
   of accuracy. */
.scroll-y {
  max-height: min(var(--scroll-max, 560px), max(200px, var(--scroll-fit, 100dvh)));
  overflow: auto;
  padding-right: 3px;
  margin-right: -3px;
}


/* --- Labels and rules ----------------------------------------------------- */

/* The small uppercase section label. Was 17 near-identical inline copies. */
.eyebrow {
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-muted);
  white-space: nowrap;
}

.eyebrow--block {
  display: block;
  margin: 0 0 var(--sp-2);
}

/* Horizontal hairline that fills the gap in a section header row. */
.rule {
  flex: 1;
  height: 1px;
  background: var(--border-faint);
  border: 0;
}

.divider {
  height: 1px;
  background: var(--border-faint);
  margin: var(--sp-1) 0;
}

.section-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}


/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
  line-height: 1;
  padding: var(--sp-3) var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.btn--primary {
  background: var(--btn-bg, var(--text));
  color: var(--text-inverse);
  border-color: transparent;
}

.btn--secondary {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

.btn--danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn--dashed {
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-4);
}

.btn[disabled], .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .6; }

/* Square icon-only control. Always needs an accessible name — either
   aria-label or a .sr-only child. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-faint);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
}

.icon-btn--boxed {
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  border-radius: 7px;
}

.icon-btn--tinted {
  background: var(--surface-muted);
  width: 22px;
  height: 22px;
  border-radius: var(--r-xs);
}

.icon-btn--sm { width: 22px; height: 22px; font-size: var(--fs-lg); }


/* --- Pills / tags --------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-4);
  background: var(--pill-bg, var(--surface-sunken));
  color: var(--pill-fg, var(--text-muted));
  border: 1px solid var(--pill-bd, var(--border-soft));
  white-space: nowrap;
}

/* Selectable filter pill — same shell, but it is a control. The display face is
   a decorative serif; filter labels are scanned, not read, so they take the
   body face like every other label in the panel. */
.pill--action {
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
}

.pill--tag {
  font-size: var(--fs-2xs);
  padding: 2px var(--sp-3);
  border-color: var(--border-faint);
}

.pill--plain {
  background: var(--surface-muted);
  border-color: transparent;
}

/* Small colour swatch inside a pill or list row. */
.dot {
  width: var(--dot-size, 8px);
  height: var(--dot-size, 8px);
  border-radius: var(--r-round);
  background: var(--dot-color, var(--text-faint));
  flex: none;
}

.dot--sm { --dot-size: 6px; }
.dot--lg { --dot-size: 7px; }

/* Count badge (e.g. active filter count). */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 var(--sp-1);
  border-radius: 9px;
  background: var(--badge-bg, var(--accent));
  color: var(--badge-fg, var(--text-inverse));
  font-size: var(--fs-2xs);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--avatar-size, 26px);
  height: var(--avatar-size, 26px);
  border-radius: var(--r-round);
  background: var(--avatar-bg, var(--border-soft));
  color: var(--avatar-fg, var(--text-inverse));
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
  line-height: 1;
}

.avatar--sm { --avatar-size: 18px; }
.avatar--md { --avatar-size: 20px; }
.avatar--lg { --avatar-size: 34px; font-size: var(--fs-lg); }


/* --- Form fields ---------------------------------------------------------- */

/* Every text input, number input, select and textarea. Note: no
   `outline:none` — the base focus rule needs somewhere to land. */
.field {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  padding: 9px var(--sp-4);
  font-size: var(--fs-md);
  color: var(--text);
}

.field--sunken {
  background: var(--surface-sunken);
  border-color: var(--border-soft);
}

.field--sm { padding: var(--sp-3) 9px; font-size: var(--fs-sm); border-radius: var(--r-sm); }

.field--bare {
  border: 0;
  background: transparent;
  padding: 0;
}

.field--numeric { text-align: right; }

.field::placeholder, .field--bare::placeholder { color: var(--text-muted); opacity: 1; }

textarea.field { resize: vertical; line-height: var(--lh-normal); }


/* --- Switch (the pill toggle in the view menus) --------------------------- */

.switch {
  position: relative;
  display: inline-block;
  flex: none;
  width: 30px;
  height: 17px;
  border-radius: 9px;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--toggle-off);
  transition: background var(--dur-fast);
}

.switch[aria-checked="true"] { background: var(--success); }

.switch__knob {
  position: absolute;
  top: 1px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: var(--r-round);
  background: var(--surface);
  box-shadow: var(--shadow-knob);
  transition: left var(--dur-fast);
}

.switch[aria-checked="true"] .switch__knob { left: 17px; }

/* Row that wraps a label + switch in the dropdown menus. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  padding: 7px var(--sp-4);
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: var(--fs-md);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}


/* --- Segmented control (week count, card style, shopping mode) ------------ */

.segmented {
  display: flex;
  gap: 2px;
  background: var(--toggle-track);
  border-radius: 9px;
  padding: 3px;
}

.segmented__opt {
  flex: 1;
  text-align: center;
  padding: var(--sp-1) var(--sp-3);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  white-space: nowrap;
  cursor: pointer;
}

.segmented__opt[aria-pressed="true"], .segmented__opt[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-raised);
}

/* Dark-fill variant used by the shopping/inventory switcher. */
.segmented--solid { background: var(--toggle-track); gap: 2px; padding: 2px; }
.segmented--solid .segmented__opt {
  font-family: var(--font-body);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  border-radius: var(--r-xs);
}
.segmented--solid .segmented__opt[aria-pressed="true"] {
  background: var(--text);
  color: var(--text-inverse);
}


/* --- Menus / popovers ----------------------------------------------------- */

.menu {
  position: absolute;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-menu);
  padding: var(--sp-2);
  z-index: 200;
}

.menu--wide { min-width: 230px; border-radius: var(--r-lg); padding: var(--sp-3); }

/* Each popover hangs below its own trigger, so the offset is per-menu. */
.menu--profile { top: 40px; }
.menu--view { top: 38px; min-width: 180px; }
.menu--list { top: 34px; min-width: 170px; }

.menu__item {
  display: block;
  width: 100%;
  padding: 7px var(--sp-4);
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: var(--fs-md);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu__item:hover { background: var(--surface-sunken); }

.menu__sep { margin: var(--sp-2) var(--sp-2); border: 0; border-top: 1px solid var(--border-faint); }

.menu__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-1) var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.menu__row:hover { background: var(--surface-sunken); }


/* --- Tabs (sidebar) ------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--sp-6);
  margin-bottom: 13px;
  border-bottom: 2px solid var(--border-faint);
  padding-bottom: var(--sp-3);
}

.tab {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-xl);
  line-height: 1;
  color: var(--text-muted);
  transition: color var(--dur-fast);
}

.tab[aria-selected="true"] { color: var(--tab-active, var(--accent)); }


/* --- Meal chip (schedule + planner) --------------------------------------
   Driven by three custom properties set inline from the meal's own palette:
   --chip-tint (background), --chip-accent (left rule), --chip-text. */

.chip {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--chip-tint, var(--surface-muted));
  border-left: 3px solid var(--chip-accent, var(--border));
  color: var(--chip-text, var(--text));
  cursor: grab;
  text-align: left;
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
}

/* Content-hugging: the .slot's own 110px floor sets the cell height, so the
   chip stacks title then meta at the top and lets the rest collapse. */
.chip--grid {
  flex: 1;
  padding: var(--sp-3) 9px;
}

.chip__title {
  font-family: var(--font-body);
  font-weight: var(--fw-heavy);
  font-size: var(--fs-md);
  line-height: var(--lh-tight);
  color: inherit;
  /* A single long recipe name is otherwise enough to widen the whole pane. */
  overflow-wrap: anywhere;
}

.chip__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1);
  width: 100%;
}

/* The card wrapper stays clickable for mouse/drag, but the title is a real
   button so the slot is reachable and activatable by keyboard. Nesting a
   <button> inside another <button> is invalid, which is why the wrapper is a
   plain div rather than a button itself. */
.chip__title--btn,
.idea__name--btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  max-width: 100%;
}

/* nowrap so a narrow column breaks the row, not "30 / min". */
.chip__meta { font-size: var(--fs-2xs); color: inherit; opacity: .8; white-space: nowrap; }

/* Meta row (outline + calendar): assignment then prep, packed left so the hover
   swipe actions on the right edge never sit on top of the assignment control.
   Wraps rather than squeezing in the calendar's narrower columns. */
.chip__row--meta { justify-content: flex-start; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); }

.chip__variant {
  font-size: var(--fs-2xs);
  color: inherit;
  opacity: .75;
  margin-top: 2px;
  font-style: italic;
}

/* The small × that clears a slot. Inherits the chip's text colour. */
.chip__clear {
  flex: none;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: .6;
  font-size: var(--fs-lg);
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

/* "+ who" — assign a person to this meal. */
.chip__assign {
  flex: none;
  border: 1px dashed currentColor;
  background: transparent;
  color: inherit;
  opacity: .75;
  border-radius: var(--r-pill);
  padding: 1px var(--sp-2);
  font-size: var(--fs-2xs);
  cursor: pointer;
}

/* Empty planner cell. */
.slot-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 96px;
  border: 1.5px dashed var(--border-faint);
  border-radius: 9px;
  background: transparent;
  color: var(--text-faint);
  font-size: var(--fs-2xl);
  cursor: pointer;
}

/* Placeholder standing in for a main that hasn't been chosen: it shares the
   empty slot's dashed frame but sits above the sides rather than filling. */
.slot-empty--ph {
  flex: 1;
  height: auto;
  min-height: 44px;
  font-size: var(--fs-lg);
}

.slot {
  min-height: 110px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border-faint);
  padding: 5px;
}


/* --- Side dishes ---------------------------------------------------------- */

/* Sides read as part of the meal above them, so they take that meal's tint and
   rule rather than a neutral grey. Falls back to --surface-muted where the
   chip vars are not set. */
.side-row {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-2);
  background: var(--chip-tint, var(--surface-muted));
  border-left: 3px solid var(--chip-accent, var(--border));
  color: var(--chip-text, var(--text));
  border-radius: var(--r-xs);
  cursor: grab;
}

.side-row__name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--fs-2xs);
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dashed border uses --text-faint, not --border-strong: this is an interactive
   control, so its boundary needs 3:1 (WCAG 1.4.11), which --border-strong
   (1.7:1 on white) does not clear. */
.side-add {
  display: block;
  width: 100%;
  text-align: center;
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px var(--sp-1);
  border: 1px dashed var(--text-faint);
  border-radius: 5px;
  background: transparent;
}

/* Pinned to the chip's inner bottom by its own auto margin: the chip is a flex
   column that stretches with the row, and the title and meta flow from the top.
   Colour inherits the chip's own text colour instead of --text-muted, since it
   now sits on the chip's tint. */
.side-add--in-chip {
  margin-top: auto;
  color: inherit;
  opacity: .7;
  border-color: currentColor;
}

/* Change what a dish is FOR THIS MEAL: ↗ takes a side up to the main, ↘ sends
   the main down to the sides. One control in two places, so the gesture reads the
   same wherever it appears. Colour is inherited from the chip or row it sits on,
   which is already contrast-checked against the meal tint — a token picked here
   would be picked against a surface that changes per meal. */
.role-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: inherit;
  opacity: .7;
  font-size: var(--fs-2xs);
  cursor: pointer;
}
.role-btn:hover,
.role-btn:focus-visible { opacity: 1; }

/* In the chip's title row rather than beside a name, so it needs to be pushed
   to the trailing edge itself. */
.role-btn--in-chip { margin-left: auto; }




/* --- Idea cards (sidebar list) -------------------------------------------- */

.idea {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--idea-border, var(--border-faint));
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  cursor: var(--idea-cursor, pointer);
}

.idea:hover { border-color: var(--border-strong); box-shadow: 0 2px 8px rgba(0, 0, 0, .05); }

.idea--compact {
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
}

/* The ingredient amounts (Settings > Ingredients) are the one thing a compact
   card carries below its row, so they wrap to a line of their own. */
.idea--compact { flex-wrap: wrap; }
.idea--compact .idea__qtys { flex: 0 0 100%; margin-top: 0; }

.idea__name {
  font-family: var(--font-body);
  font-weight: var(--fw-heavy);
  font-size: var(--fs-lg);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.idea__preview {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 5px;
  line-height: var(--lh-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Meal designators: the letter squares (B/L/D), a dot for a side, and the
   favourite star — one strip sitting after the recipe title. */
.marks { display: flex; align-items: center; gap: 3px; flex: none; }

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--mark-bg, var(--surface-muted));
  color: var(--mark-fg, var(--text));
  font-family: var(--font-body);
  font-weight: var(--fw-bold);
  font-size: var(--fs-2xs);
  line-height: 1;
}

/* A side is a garnish on the plan, not a fourth meal, so it reads as a dot. */
.mark--dot { width: 9px; height: 9px; border-radius: var(--r-round); }

.mark--fav {
  width: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  font-size: var(--fs-lg);
  color: var(--fav-color, var(--text-faint));
}


/* --- Shopping list -------------------------------------------------------- */

.shop-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-1) 2px;
}

.shop-check {
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-xs);
  border: 2px solid var(--check-border, var(--border-strong));
  background: var(--check-bg, transparent);
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  cursor: pointer;
}

.inventory-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 2px;
  border-bottom: 1px solid var(--border-faint);
}


/* --- Drawer (mobile sheet) ----------------------------------------------- */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  z-index: 40;
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease);
}

.drawer.open { transform: translateX(0); }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base);
}

.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 0 auto var(--sp-5);
}


/* --- Modal --------------------------------------------------------------- */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7);
}

.modal {
  background: var(--surface);
  border-radius: var(--r-2xl);
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow-modal);
}

.modal__close {
  flex: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: var(--fs-3xl);
  line-height: 1;
  color: var(--text-faint);
}


/* --- Animation ----------------------------------------------------------- */

@keyframes schedNewDay {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}


/* ============================================================================
   4. LAYOUT
   One-off structural rules for named regions of the page. These are not
   reusable components — they exist so that page scaffolding stops living in
   inline `style` attributes where nothing can find or diff it.
   ========================================================================== */

/* Breakpoint comes from the logic script's own isMobile/isTablet state (it
   drives layout branching too, not just padding), so these are classes rather
   than media queries. */
/* A column, so the page can hand its own height down to whichever region wants
   to absorb the slack — see `.planner__grid` and the small-screen block below.
   `dvh` after `vh` because on iOS `100vh` is the height the viewport has once
   the URL bar has retracted, which is taller than what you are looking at; the
   difference is exactly enough to push the footer off screen. */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--sp-5) 8px 16px;
  /* Everything the content is not allowed to eat if the footer is to stay in
     view: --layout-fit reserves the page padding, the header and the footer;
     --scroll-fit reserves the card's own chrome on top of that (toolbar or
     tabs + search, plus the card inset). See .scroll-y and .sidebar. */
  --layout-fit: calc(100dvh - 165px);
  --scroll-fit: calc(100dvh - 290px);
}
.app--tablet { padding: var(--sp-5) var(--sp-5) 40px; }
.app--mobile { padding: var(--sp-3) var(--sp-3) 40px; --scroll-fit: calc(100dvh - 195px); }

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.app-header__profile {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  position: relative;
}

.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.brand__mark { width: 32px; height: 32px; border-radius: 9px; display: block; }
.brand__name {
  font-family: var(--font-display);
  font-weight: var(--fw-regular);
  font-size: var(--sp-7);
  color: var(--text);
  letter-spacing: -.01em;
}

.print-title {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: 25px;
  margin: 0 0 var(--sp-5);
  color: var(--text);
}

/* `flex: 1` takes the page's leftover height; `align-items: flex-start` then
   declines to pass it on, which is what desktop wants — a sticky sidebar next
   to a main column that ends where its content ends. The small-screen block
   flips `align-items` to hand the height through. */
.layout { display: flex; gap: 20px; align-items: flex-start; flex: 1; min-height: 0; }
.layout__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.card--pad { padding: var(--sp-5) var(--sp-6) var(--sp-6); }
.card--sidebar { padding: var(--sp-5); }
/* Settings sits beside the sidebar as an equal, not as the plan grid, so it
   takes the sidebar's even padding — the two cards line up on all four edges. */
.card--pad:has(> .settings) { padding: var(--sp-5); }

/* Drop-to-remove target: hidden until a planned chip is dragged (body class),
   then it covers the sidebar with a dashed frame and a discard cue. */
.sidebar-remove { display: none; }
body.dragging-plan-item .sidebar-remove {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  position: absolute;
  inset: 0;
  z-index: 5;
  border: 2px dashed var(--accent);
  border-radius: var(--r-2xl);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  text-align: center;
  padding: var(--sp-5);
}
/* Pointer feedback while a chip hovers the zone. */
.sidebar-remove:hover { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.sidebar-remove > * { pointer-events: none; }

.sidebar { width: 340px; flex: none; position: sticky; top: var(--sp-5); }

/* Desktop fills the window rather than shrink-wrapping the content: the same
   trick the phone block uses (`align-items: stretch`, then a chain of
   `flex: 1; min-height: 0` down to `.planner__grid`), so the calendar's day
   cells absorb the slack instead of leaving whitespace under the card. The
   sidebar is stretched to the same row height so the two cards line up top and
   bottom; `top` still holds because the sticky element now spans the row.
   `:only-child` scopes the grid stretch to the one-week view — two stacked
   weeks already fill the screen and stretching both would push the second
   below the fold. */
.app--desktop .layout { align-items: stretch; }

.app--desktop .layout__main > .card--pad {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app--desktop .planner { flex: 1; min-height: 0; }

.app--desktop .planner__week:only-child {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app--desktop .planner__week:only-child .planner__grid { flex: 1; }

/* ponytail: the schedule list keeps its --scroll-fit cap here rather than
   flexing like the planner, so ~70px of card sits empty under it on a tall
   window. `flex: 1; max-height: none` is the obvious fix and is wrong: nothing
   bounds this row's height (the sidebar's cap binds only the sidebar), so the
   list grows to its content — 60,000px of it — and takes the page with it.
   Bounding the row is the real fix, whenever the dead space is worth it. */

/* The sidebar card fills its stretched column, and the scrolling list inside
   takes the leftover instead of stopping at its own --scroll-max. Its cap used
   to subtract only the page padding, so the tallest column on the page was
   ~150px taller than the space above the footer — and since both columns stretch
   to the tallest, capping the panes alone did nothing. --layout-fit is the same
   budget the panes use, minus one card's worth of chrome. */
/* The list inside scrolls its own overflow, but a sticky box still reports that
   overflow in its own scrollable area, and `overflow: visible` hands it up to
   the viewport. On the ideas tab that grew the page by ~1300px of empty scroll
   (the ingredients list is short enough to fit, so it did not) — and the page
   scrollbar that appeared on one tab and vanished on the other resized every
   column with it. That is the frame shift you see when switching tabs.
   `clip` contains the phantom overflow without making this a scroll container,
   so the sticky positioning and the pane's own scrolling both still work; the
   clip margin leaves room for the card's shadow to paint. */
.app--desktop .sidebar {
  display: flex;
  flex-direction: column;
  max-height: var(--layout-fit);
  overflow: clip;
  overflow-clip-margin: 8px;
}
.app--desktop .card--sidebar { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app--desktop .card--sidebar > .scroll-y { flex: 1; max-height: none; }

/* Same deal for settings: each tab's list takes the leftover height instead of
   its own cap, so People, Tags and Ingredients all end where the sidebar ends
   rather than each sizing the card — and the page — to its own content. */
/* The cap is what makes the flex chain below bind: `.layout__main` stretches to
   the row, so nothing above bounds the card and `max-height: none` on the list
   would otherwise let it grow to its content. Same budget the sidebar uses. */
.app--desktop .layout__main > .card--pad:has(> .settings) { max-height: var(--layout-fit); }
.app--desktop .layout__main > .card--pad > .settings { flex: 1; min-height: 0; flex-wrap: nowrap; align-items: stretch; }
.app--desktop .settings__panel { display: flex; flex-direction: column; min-height: 0; }
.app--desktop .settings__panel > .scroll-y { flex: 1; max-height: none; }

.sidebar--sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  width: auto;
  top: auto;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface-sunken);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-5) var(--sp-5) 28px;
}

/* --- Sheet: search at the thumb, results stacking up from it ----------------
   The sheet grows from a pinned bottom edge, so with the search row on top,
   every keystroke that changed the result count resized the sheet and slid the
   box out from under the thumb aiming at it. Ordering the search row last
   parks it against that pinned edge instead: the list now grows and shrinks
   upward, and the input does not move at all.

   `column-reverse` on the list then does two jobs at once — it packs results
   against the bottom, next to the input, and paints them best-match-first from
   there upward. Ranking stays in the logic script; there is no second ordering
   here to keep in sync with it.

   Keyed off `.sidebar--sheet` rather than `.app--mobile`: the bottom edge is
   what forces this, not the screen, so small tablets get it by being sheets.
   Docked drawers keep the search row on top, where it never moves anyway.

   Tabs and the pick banner keep the default order:0 and stay on top. */
.sidebar--sheet .card--sidebar { display: flex; flex-direction: column; }
.sidebar--sheet .card--sidebar > .idea-list { order: 1; flex-direction: column-reverse; }
.sidebar--sheet .card--sidebar > .suggest { order: 2; margin: var(--sp-3) 0 0; }
.sidebar--sheet .card--sidebar > .filters { order: 3; margin: var(--sp-3) 0 0; }
.sidebar--sheet .card--sidebar > .search-row { order: 4; margin: var(--sp-3) 0 0; }

.sheet-scrim { position: fixed; inset: 0; z-index: 49; background: var(--scrim); }

/* --- Floating action button ------------------------------------------------
   Material's 56px FAB, sized to clear the 44px tap-target minimum on its own.
   z-index sits below .sheet-scrim (49) on purpose: when the sheet is up, the
   scrim covers the FAB and a scrim tap is the way back out. */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 48;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--fab-bg, var(--accent));
  color: var(--fab-fg, var(--text-inverse));
  box-shadow: var(--shadow-fab);
  cursor: pointer;
}

.fab__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  --badge-bg: var(--surface);
  --badge-fg: var(--text);
  border: 1px solid var(--border-faint);
}

.sentinel { height: 1px; }

/* --- Bottom tab bar (phones) ----------------------------------------------
   Four tabs, icon over label, pinned to the bottom edge with the home
   indicator's inset added underneath rather than eaten out of the tap area.
   z-index sits below .sheet-scrim (49) for the same reason as the FAB: a pick
   sheet is a question asked over the page, and the bar is part of the page. */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--tabbar-inset));
  padding-bottom: var(--tabbar-inset);
  background: var(--surface);
  border-top: 1px solid var(--border-faint);
  box-shadow: var(--shadow-bar);
}

.tabbar__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tap-min);
  padding: var(--sp-1) 0 0;
  background: none;
  border: 0;
  font: inherit;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tabbar__tab[aria-current="page"] { color: var(--tab-active, var(--accent)); }
.tabbar__tab[aria-current="page"] svg { stroke-width: 2.3; }

.tabbar__icon { position: relative; display: flex; }
.tabbar__badge {
  position: absolute;
  top: -4px;
  left: 15px;
  --badge-bg: var(--tab-active, var(--accent));
  --badge-fg: var(--text-inverse);
  border: 2px solid var(--surface);
}

/* The keyboard is up: see the focusin handler in index.html. */
body.typing .tabbar { display: none; }

/* --- Pull-to-refresh (phones) ----------------------------------------------
   A round chip that drops in from the top edge as the page is pulled down,
   turning with the pull, and goes accent-coloured once letting go would
   refresh. `--ptr-y`, `--ptr-turn` and `--ptr-o` are written by the touch
   handlers in index.html (setupPullToRefresh). It eases back on its own when a
   pull is let go short; while the finger is down it follows with no lag. */
.ptr { display: none; }
.app--tabbed .ptr {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  z-index: 46;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  border-radius: var(--r-round);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-menu);
  pointer-events: none;
  opacity: var(--ptr-o, 0);
  transform: translateY(calc(var(--ptr-y, 0px) - 40px)) rotate(var(--ptr-turn, 0deg));
  transition: transform .2s ease, opacity .2s ease, color .15s ease;
}
.app--tabbed .ptr[data-state="pulling"],
.app--tabbed .ptr[data-state="armed"] { transition: color .15s ease; }
.app--tabbed .ptr[data-state="armed"],
.app--tabbed .ptr[data-state="busy"] { color: var(--accent); }
.app--tabbed .ptr[data-state="busy"] svg { animation: ptrSpin .8s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* --- Today (phones) -------------------------------------------------------
   A reading view, so it spends its space on type rather than on controls:
   one card per meal, and the next one coming up by the clock drawn larger.
   Cards carry the meal's own tint and accent, like chips on the plan. */
.today { display: flex; flex-direction: column; gap: var(--sp-7); padding: 0 var(--sp-3); }

.today-day { display: flex; flex-direction: column; gap: var(--sp-3); }

.today-day__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: 0 2px var(--sp-1);
}

.today-day__title {
  font-family: var(--font-display);
  font-weight: var(--fw-regular);
  font-size: var(--fs-3xl);
  color: var(--text);
}

.today-day__date { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); }

.today-day__note {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-warm);
  border: 1px solid var(--border-faint);
  font-size: var(--fs-md);
  color: var(--text-body);
  white-space: pre-wrap;
}

.today-meal {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: 0;
  border-left: 4px solid var(--chip-accent, var(--border));
  border-radius: var(--r-lg);
  background: var(--chip-tint, var(--surface));
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.today-meal__meal {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--chip-text, var(--text-muted));
}

.today-meal__name { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-snug); color: var(--chip-text, var(--text)); }
.today-meal__sides { font-size: var(--fs-md); color: var(--text-body); }

.today-meal__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-4);
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--text-body);
}

.today-meal__cook { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-semibold); }
.today-meal__empty { font-size: var(--fs-md); color: var(--text-muted); }

/* An open slot is a gap, not a meal: no fill, a dashed edge in the meal's
   colour, one short line. It should read as quieter than anything planned. */
.today-meal--empty {
  flex-direction: row;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-left: 4px solid var(--chip-accent, var(--border));
}

/* Up next: bigger type and a lift, nothing else — it is the same card. */
.today-meal--next { padding: var(--sp-6) var(--sp-6) var(--sp-5); box-shadow: var(--shadow-menu); }
.today-meal--next .today-meal__name { font-size: var(--fs-3xl); line-height: var(--lh-tight); }
.today-meal--next .today-meal__meta { font-size: var(--fs-md); }
.today-meal--next .avatar { --avatar-size: 24px; }
.today-meal__next { color: var(--chip-text, var(--text)); }

/* The day a list starts: what is still to buy, tickable in place. */
.today-shop {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
}

.today-shop__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  border: 0;
  background: transparent;
  padding: 0 0 var(--sp-1);
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.today-shop__title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.today-shop__range { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }

.today-shop__more {
  align-self: flex-start;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}


/* --- Eyebrow variants --------------------------------------------------- */

.eyebrow--md { font-size: var(--fs-sm); }
.eyebrow--body { font-family: var(--font-body); font-weight: var(--fw-bold); }
/* Uses the meal's `text` shade, not its `color`. The saturated fill hues are
   built for backgrounds — dinner's orange is 2.7:1 on white and side's yellow
   is 1.6:1, so using --meal-color here made the section labels unreadable.
   Each meal in the MEALS map already carries a `text` shade for exactly this. */
.eyebrow--meal { color: var(--meal-text, var(--text-muted)); }

.section-head--roomy { margin-bottom: var(--sp-4); }
/* No negative side margins: inside #schedule-scroller (overflow:auto) they made
   the header 8px wider than the pane, which is all it takes to give the whole
   agenda a horizontal scrollbar. */
.section-head--meal {
  margin: var(--sp-4) 0 var(--sp-2);
  padding: 2px var(--sp-1);
  border-radius: var(--r-xs);
  cursor: pointer;
  gap: 7px;
}


/* --- Empty states and prose -------------------------------------------- */

.empty-note {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding: var(--sp-5) var(--sp-3);
}

.empty-note--roomy { padding: var(--sp-6) var(--sp-3); }

.empty-state { padding: var(--sp-5) var(--sp-3); text-align: center; }
.empty-state .empty-note { padding: 0 0 var(--sp-3); }

.prose {
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
  color: var(--text-body);
  margin: 0 0 20px;
}

.callout {
  margin: 0 0 20px;
  padding: var(--sp-5);
  background: var(--surface-sunken);
  border-radius: var(--r-md);
  text-align: center;
  font-size: var(--fs-md);
  color: var(--text-muted);
  font-style: italic;
}

.link-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-decoration: underline;
}


/* --- Profile view ------------------------------------------------------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.profile-head__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--text);
}

.profile-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-xl); }

.profile-dropzone {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 90px;
  border-radius: var(--r-md);
  padding: var(--sp-1);
}

.profile-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
}

.profile-item__name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-weight: var(--fw-heavy);
  font-size: var(--fs-md);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-item__meta { flex: none; font-size: var(--fs-2xs); color: var(--text-muted); }


/* --- Placing banner ---------------------------------------------------- */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  background: var(--warning-surface);
  border: 1px solid var(--warning);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
  margin-bottom: var(--sp-4);
}

.banner__text {
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--fs-lg);
  color: var(--warning-text);
}

.banner__cancel {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--warning-text);
  white-space: nowrap;
  text-decoration: underline;
}


/* --- Toolbar / view switcher ------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: var(--sp-4);
}

/* One capsule: step arrows | view toggle | caret. The track lives on the
   capsule so the segments read as parts of a single control, divided by
   hairlines rather than gaps. */
.viewbar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--toggle-track);
  border-radius: 9px;
  padding: 3px;
}

.viewbar__nav, .viewbar__group { display: flex; }

.viewbar__step {
  width: 26px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
}

.viewbar__group,
.viewbar__caret {
  margin-left: 3px;
  padding-left: 3px;
  border-left: 1px solid var(--toggle-off);
}

.viewbar__opt {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.viewbar__opt[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-raised);
}

.viewbar__caret {
  width: 24px;
  height: 28px;
  border-width: 0 0 0 1px;
  border-style: solid;
  border-radius: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: var(--fs-2xs);
  cursor: pointer;
}

.menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-1) var(--sp-2) var(--sp-3);
}

.menu__label { display: block; padding: var(--sp-1) var(--sp-4); }

.menu__row-label {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-md);
  color: var(--text);
  padding: 3px var(--sp-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu__row-chevron { flex: none; color: var(--text-faint); font-size: var(--fs-md); }

/* Inside a menu the options sit among body-font rows, so they take the body
   face rather than the display face the standalone segmented control uses. */
.segmented--inset { border-radius: 7px; padding: 2px; margin: 0 var(--sp-1) var(--sp-2); }
.segmented--inset .segmented__opt { font-family: var(--font-body); }
.segmented--spaced { margin-bottom: var(--sp-4); }

.pill--micro { font-size: var(--fs-2xs); padding: 2px 7px; border-radius: var(--r-xs); }

/* Header hamburger. Bigger than a stock .icon-btn because it is the only
   control on its side of the header and the primary way into settings. */
.menu-btn { width: 36px; height: 36px; color: var(--text-body); }

.color-swatch {
  flex: none;
  width: 22px;
  height: 22px;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

.field--inline { flex: 1; min-width: 0; width: auto; cursor: text; }


/* --- Schedule view ----------------------------------------------------- */

.sched-day { margin-bottom: 20px; }

/* Centred and a size up from the meal labels: in a continuous agenda the date
   is the only thing marking where one day ends and the next begins. */
.sched-day__label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--text);
}

.note-box { padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); }
.note-box__input { min-height: 40px; resize: vertical; font-size: var(--fs-md); color: var(--text); }

/* min-height carries the two stacked action buttons (24px each + gap + inset)
   without the outlines crowding the row they sit on. */
.chip--stacked { flex: 1; min-width: 0; width: auto; min-height: 60px; border-radius: var(--r-sm); }
.chip__row--top { align-items: flex-start; }
.chip__titles { min-width: 0; }

.side-row__caret { font-size: var(--fs-2xs); color: inherit; flex: none; opacity: .7; }

/* Outline rows are taller and share the chip's radius; the tint and rule come
   from .side-row itself. */
.side-row--spaced {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
}

/* Swipe-to-act row: the actions are always in the DOM (so hover, focus and
   assistive tech can reach them) but hidden until the row is swiped open,
   hovered, or holds focus. Neutral grey rather than the danger red, which
   fought with every meal hue it sat next to.

   Two presentations, keyed off the pointer rather than the viewport, because
   this is about the input, not the width: a touch device slides them in as the
   row is dragged (the motion IS the gesture's feedback), while a mouse just
   shows them, instantly and on top of the row, so hovering down a day's meals
   doesn't set every row reflowing under the cursor. */
.swipe {
  display: flex;
  align-items: stretch;
  margin-bottom: var(--sp-1);
}

.swipe__actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
  width: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  transition: width .16s ease, opacity .16s ease, margin .16s ease;
}

.swipe--open .swipe__actions,
.swipe:focus-within .swipe__actions {
  width: var(--swipe-actions-w);
  margin-left: var(--sp-2);
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .swipe { position: relative; }

  /* Overlaid on the row's own right edge: nothing moves when it appears, so
     there is no slide to track and no layout shift. `pointer-events` rather
     than `visibility`, which would take the buttons out of the tab order. */
  .swipe__actions,
  .swipe--open .swipe__actions,
  .swipe:focus-within .swipe__actions {
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    width: var(--swipe-actions-w);
    margin: 0;
    pointer-events: none;
    /* No slide and no reflow — only the fade, long enough to register as an
       appearance rather than a flicker as the cursor crosses rows. */
    transition: opacity .3s ease;
  }

  .swipe:hover .swipe__actions,
  .swipe:focus-within .swipe__actions {
    opacity: 1;
    pointer-events: auto;
  }

  /* The actions are overlaid on the row's right edge here, so anything the row
     puts at that edge would sit under them and stop being clickable on hover.
     Only the schedule view's rows carry this; the planner has no overlay. */
  .swipe .role-btn--lead { margin-right: calc(var(--swipe-actions-w) + var(--sp-2)); }
}

/* Tint and accent inherited from .swipe, so each button wears the hue of the
   meal it belongs to and reads as part of that row rather than a grey graft. */
.swipe__action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 24px;
  padding: 0 2px;
  border: 1px solid var(--chip-accent, var(--border));
  border-radius: var(--r-sm);
  background: var(--chip-tint, var(--surface-muted));
  color: var(--chip-text, var(--text));
  font-family: var(--font-body);
  font-size: var(--fs-2xs);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

/* Doubling the outline inward, so hover doesn't disturb the row's height. */
.swipe__action:hover { box-shadow: inset 0 0 0 1px var(--chip-accent, var(--border)); }

/* Vertical panning still belongs to the scroller; horizontal is ours. */
.swipe > .chip,
.swipe > .side-row { touch-action: pan-y; }

@media (prefers-reduced-motion: reduce) {
  .swipe__actions { transition: none; }
}


/* --- Planner grid ------------------------------------------------------ */

.planner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.planner__week-label {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  color: var(--text-muted);
}

/* Two things here are load-bearing.
   `grid-template-rows: min-content` pins only the day-head row to its content.
   Every row after it is an implicit `auto` track, and grid's stretch step
   divides spare height equally between `auto` tracks — so when the small-screen
   block gives this grid a height to fill, the meal rows grow into it instead of
   leaving the footer floating above a screenful of nothing. `auto` keeps its
   content minimum too, so a row with a tall chip in it still wins.

   `overflow-x` sits on the grid rather than on `.planner` around it, which is
   what makes the pinned meal column possible: a sticky grid item is clamped to
   its own grid area, so it cannot travel when the scrollport is an ancestor of
   the grid — but when the grid *is* the scrollport, the areas move with the
   content and `left: 0` finally has somewhere to hold. The cost is that a
   two-week view scrolls each week separately rather than as one sheet.
   `overscroll-behavior-x` keeps a swipe past Sunday from turning into the
   browser's back gesture. */
.planner__grid {
  display: grid;
  grid-template-columns: var(--planner-cols, 30px repeat(7, minmax(110px, 1fr)));
  grid-template-rows: min-content;
  gap: 7px;
  /* The containing block for the day heads' absolutely positioned .sr-only
     "Today". Without it that span is placed against the page, so when today's
     column sits off to the right it widens the whole document — on a phone the
     layout viewport grows to match and every fixed element (the bottom bar, the
     FAB) is pinned to an edge you cannot see. */
  position: relative;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.planner__week { min-width: 0; }

.day-head { text-align: center; padding: var(--sp-2) var(--sp-1); border-radius: var(--r-md); }

.day-head__dow {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.day-head__date {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--text);
  line-height: 1.15;
}

/* Today, in both views: a tinted accent pill around the whole day heading.
   Planner and schedule share the treatment so the day reads the same either
   way — the old 3px underline / 6px dot were easy to miss on a full week. */
.day-head.is-today {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 30%, transparent);
}
.day-head.is-today .day-head__dow,
.day-head.is-today .day-head__date { color: var(--accent); }

.sched-day__label.is-today {
  width: fit-content;
  margin-inline: auto;
  padding: 2px 18px;
  border-radius: var(--r-pill);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* The meal column pins to the left edge of the planner's horizontal scroll.
   Seven days do not fit on a phone, and the labels were the first thing to
   leave — which loses the only cue for which row you are scrolling through.
   The negative margin lets the cell's background bleed across the 7px grid gap
   so cells pass behind it rather than through it. */
.row-label,
.planner__corner {
  position: sticky;
  left: 0;
  z-index: 2;
  margin-right: -7px;
  padding-right: 7px;
  background: var(--surface);
}

.row-label { display: flex; align-items: stretch; justify-content: center; min-height: 110px; }

.row-label__bar {
  width: 26px;
  border-radius: var(--r-sm);
  background: var(--meal-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-label__text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  color: var(--meal-text, var(--text-inverse));
  letter-spacing: .03em;
  white-space: nowrap;
}

.slot__stack { display: flex; flex-direction: column; gap: 3px; height: 100%; }

/* Flex, not a fixed-height textarea, so the field grows with the row once the
   grid starts stretching. At the row's minimum the two agree: 72px + 8px of
   padding is the 80px floor, which is what it measured before. */
.note-cell {
  display: flex;
  min-height: 80px;
  border-radius: 11px;
  background: var(--chip-tint, var(--surface-muted));
  border: 1px solid var(--border-soft);
  padding: var(--sp-1);
}

.note-cell__input {
  flex: 1;
  min-height: 72px;
  resize: none;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--chip-text, var(--text));
  padding: var(--sp-1);
}


/* --- Sidebar: pick banner, search, filters ---------------------------- */

.pick-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  background: var(--pick-bg);
  border-radius: var(--r-md);
  padding: 9px var(--sp-4);
}

.pick-banner__title {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  color: var(--pick-fg);
}

.pick-banner__hint { font-size: var(--fs-xs); color: var(--pick-sub); margin-top: 1px; }

.pick-banner__close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: var(--fs-2xl);
  color: var(--pick-sub);
  line-height: 1;
  padding: 2px var(--sp-1);
}

.search-row { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.search-row__input { flex: 1; min-width: 0; }

/* Square icon button sized to the search field beside it (9px padding + 13.5px
   line = 36px), so the row reads as one control strip. */
.btn--square {
  position: relative;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 9px;
  background: var(--surface-sunken);
  border-color: var(--border-soft);
  color: var(--text-body);
}

/* Open but nothing selected yet: the trough fill says "this is the control the
   panel belongs to" without competing with the active (dark) state below. */
.btn--filter[aria-expanded="true"] { background: var(--toggle-track); border-color: var(--border); }

.btn--filter[aria-pressed="true"] {
  background: var(--text);
  color: var(--text-inverse);
  border-color: var(--text);
}

/* The one additive action in the row; accent-tinted so it does not read as a
   third way to narrow the list. */
.btn--new { color: var(--new-fg, var(--text-body)); }

.badge--corner { position: absolute; top: -5px; right: -5px; }

.btn--accent { background: var(--btn-bg); color: var(--btn-fg, var(--text-inverse)); }
.btn--quiet {
  background: var(--surface-sunken);
  border-color: var(--border-strong);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  padding: 5px var(--sp-4);
  border-radius: var(--r-sm);
}
.btn--link { font-size: var(--fs-md); padding: var(--sp-3) var(--sp-5); color: var(--text); }
.btn--primary { cursor: var(--btn-cursor, pointer); }

/* The panel sat on the same warm muted fill as the pills it contains, so the
   groups blurred together. White card + a real border reads as a surface the
   controls sit *on*, and the inactive pills take the sunken fill so each one has
   an edge without needing a heavier border. */
.filters {
  margin-bottom: var(--sp-4);
  border-radius: 11px;
  background: var(--surface);
  border-color: var(--border);
}
.filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-faint);
}
.filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
/* Last control in the panel — the trailing gap is the panel's own padding. */
.segmented--last { margin-bottom: 0; }

/* Our book vs the whole book. Sits between the search row and the list, so it
   reads as "which recipes am I searching", not as another filter. */
.scope-row { margin: calc(var(--sp-2) * -1) 0 var(--sp-3); }

/* Tags worth adding, drawn from the results you are looking at. */
.suggest {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.pill--suggest {
  font-size: var(--fs-2xs);
  padding: 2px var(--sp-3);
  background: var(--surface);
  border-style: dashed;
  border-color: var(--border-strong);
  color: var(--text-body);
}
.pill__n { color: var(--text-muted); font-weight: var(--fw-regular); }


/* --- Sidebar: idea list ------------------------------------------------ */

.idea-list { display: flex; flex-direction: column; gap: var(--sp-3); }

/* Add-to-plan button, title, then the meal marks — the same left-to-right order
   on every card style, so the eye lands in the same place on each. */
.idea__top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.idea__qtys { display: flex; align-items: center; gap: 5px; margin-top: var(--sp-2); flex-wrap: wrap; }
.pill--qty { --pill-bg: var(--warning-surface); --pill-fg: var(--text); --pill-bd: var(--warning); }
/* Shrink-only, so the marks sit right after the title instead of being shoved
   into the far corner by a title that grows to fill the row. */
.idea__name--flex { flex: 0 1 auto; min-width: 0; font-size: var(--fs-lg); }
.idea__meta { flex: none; margin-left: auto; font-size: var(--fs-2xs); color: var(--text-muted); }

.idea__tags {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  flex-wrap: wrap;
}

.icon-btn--xs { width: 20px; height: 20px; border-radius: 5px; font-size: var(--fs-md); }
.icon-btn--solid {
  background: var(--text);
  color: var(--text-inverse);
  border-radius: 5px;
  width: 22px;
  height: 22px;
  font-size: var(--fs-lg);
}


/* --- Sidebar: shopping / inventory ------------------------------------ */

.shop-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.shop-head__range {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.shop-head__menu-wrap { position: relative; }

/* The trip's dates. Wraps under the heading on a narrow sidebar rather than
   squeezing the two date fields. */
.shop-trip {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
  min-width: 0;
}

.shop-trip__label {
  flex-basis: 100%;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-body);
}

.shop-trip__date { flex: 1 1 0; width: auto; min-width: 0; }

.shop-trip-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.shop-trip-bar--done {
  justify-content: space-between;
  background: var(--surface-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
}

.shop-trip-bar__btn { font-size: var(--fs-sm); padding: var(--sp-2) var(--sp-4); }
.shop-trip-bar__hint { font-size: var(--fs-sm); color: var(--text-muted); }

.shop-trip__label { display: flex; justify-content: space-between; align-items: baseline; }

.shop-trip__all {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  cursor: pointer;
}

/* Picker: the household's lists, one card each. */
.shop-picker { display: flex; flex-direction: column; gap: var(--sp-3); }

.shop-picker__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin: 0;
}

.shop-pick {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  color: var(--text);
}

.shop-pick--covers { border-color: var(--border-strong); box-shadow: var(--shadow-menu); }
.shop-pick__range { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.shop-pick__status { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.shop-picker__new { width: 100%; font-size: var(--fs-md); padding: var(--sp-3) var(--sp-4); }

.banner--compact { padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-3); }
.banner--compact .banner__text { font-size: var(--fs-sm); }

.shop-list { display: flex; flex-direction: column; gap: var(--sp-5); }

.add-row {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
  background: var(--surface-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  padding: var(--sp-1) var(--sp-2);
}

.add-row__input { flex: 1; width: auto; font-size: var(--fs-sm); }

.shop-item__body { flex: 1; min-width: 0; }

.shop-item__name {
  font-size: var(--fs-md);
  line-height: var(--lh-tight);
  text-decoration: var(--item-deco, none);
  color: var(--item-color, var(--text));
}

.shop-item__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: 1px;
}

.shop-item__qty { font-size: var(--fs-2xs); color: var(--text-muted); }
.shop-item__stocked { font-size: var(--fs-2xs); color: var(--stocked-color, var(--text-muted)); font-style: italic; }

.inventory-row__label { width: 90px; flex: none; min-width: 0; }

.inventory-row__name {
  font-size: var(--fs-md);
  line-height: var(--lh-tight);
  text-decoration: var(--item-deco, none);
  color: var(--item-color, var(--text));
}

.inventory-row__need { font-size: var(--fs-2xs); color: var(--text-muted); margin-top: 1px; }
.inventory-row__slider { flex: 1; accent-color: var(--item-color, var(--accent)); }
.inventory-row__qty { width: 46px; flex: none; color: var(--item-color, var(--text)); }


/* --- Modal: context strip and header ---------------------------------- */

.modal-ctx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  background: var(--ctx-tint);
  border-bottom: 2px solid var(--ctx-color);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: var(--sp-3) var(--sp-7);
  color: var(--ctx-text);
}

.modal-ctx__where { display: flex; align-items: center; gap: var(--sp-3); }

.modal-ctx__meal {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  color: inherit;
}

.modal-ctx__sep { font-size: var(--fs-sm); color: inherit; opacity: .75; }
.modal-ctx__day { font-size: var(--fs-sm); color: inherit; }
.modal-ctx__remove {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: var(--sp-2);
  border: 1px solid color-mix(in srgb, var(--ctx-color) 45%, transparent);
  background: rgba(255, 255, 255, .5);
  color: inherit;
  border-radius: var(--r-pill);
  padding: 2px var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-2xs);
  cursor: pointer;
}
.modal-ctx__remove:hover { background: rgba(255, 255, 255, .85); }
.modal-ctx__servings { display: flex; align-items: center; gap: var(--sp-2); }
.modal-ctx__label { font-size: var(--fs-sm); color: inherit; opacity: .85; }

.stepper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .6);
  border: 1px solid var(--ctx-color);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.stepper__btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 3px 9px;
  font-size: var(--fs-lg);
  color: inherit;
  line-height: 1;
  font-weight: var(--fw-semibold);
  user-select: none;
}

.stepper__value {
  padding: 3px var(--sp-3);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  color: inherit;
  border-left: 1px solid var(--ctx-color);
  border-right: 1px solid var(--ctx-color);
}

.modal-head { padding: 20px var(--sp-7) var(--sp-6); border-bottom: 1px solid var(--border-faint); }

.modal-head__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

/* The header action keeps its full width; the title beside it is what wraps. */
.modal-head__top > .btn { flex: none; }

.modal-head__top--edit { align-items: center; margin-bottom: var(--sp-xl); }
.modal-head__titles { min-width: 0; }

.modal-head__meals {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.modal-head__name {
  margin: 0;
  font-family: var(--font-body);
  font-weight: var(--fw-heavy);
  font-size: var(--fs-3xl);
  color: var(--text);
  line-height: 1.1;
}

.modal-head__facts {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: 13px;
  flex-wrap: wrap;
}

.pill--meal {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  padding: 3px var(--sp-3);
  border-color: transparent;
}

.pill--lg { font-size: var(--fs-sm); padding: var(--sp-2) var(--sp-4); }

.pill--dashed {
  border-style: dashed;
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-sm);
}

/* A pill that hosts its own buttons (version chip: select / edit / delete). */
.pill--group { gap: 3px; padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-4); }

.pill__label {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  color: inherit;
}

/* A version's standing in the Versions bar: "Standard" for the shipped recipe,
   a star for this household's default. Most versions are neither, so it has to
   collapse rather than leave a gap between the label and the actions. */
.pill__badge {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  opacity: .75;
  margin-left: var(--sp-1);
}

.pill__badge:empty { display: none; }

.pill__act {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  opacity: .75;
  font-size: var(--fs-sm);
  line-height: 1;
  padding: 0 var(--sp-1);
}


/* --- Modal: versions bar ---------------------------------------------- */

.versions {
  padding: var(--sp-3) var(--sp-7) var(--sp-4);
  border-bottom: 1px solid var(--border-faint);
  background: var(--surface-warm);
}

.versions__row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* The label is its own line, not the first thing in the chip row: sharing the
   row let one long version name wrap the chips around the heading, and the bar
   read as a paragraph of controls rather than a heading with a row under it. */
.versions__label { display: inline-block; margin-bottom: var(--sp-2); }

/* The one question the bar asks, inline where the chips are: it appears only
   when the pick differs from what is cooked, and takes one real button plus a
   text-weight way out. */
.versions__confirm {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
}

.versions__confirm-q { font-size: var(--fs-sm); color: var(--text); }
.versions__ok { padding: 3px var(--sp-4); }

/* v0 wears an icon instead of its name; it has to sit on the line its name
   would have taken, so the badge beside it stays on the same line. */
.pill__icon { display: inline-block; vertical-align: -2px; }

.versions__current {
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-xs);
  color: var(--success-text);
  font-style: italic;
}


/* Attribution and provenance (§3): worth knowing, never worth reading first. */
.versions__note {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* "They have changed theirs since you copied it" is a notice, not an alarm —
   nothing is wrong, and nothing has happened to this household's plan. */
.versions__note--flag { color: var(--warning-text); }

/* Reporting. Deliberately plain and deliberately last: the rarest thing in the
   card, and never something to click by accident. */
.report {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-faint);
}

.report__reason { min-height: 72px; margin-top: var(--sp-2); }

.report__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

/* Pushed away from Close so the two are not a pair of equals. */
.report__open { margin-right: auto; order: -1; }


/* --- Modal: body and edit form --------------------------------------- */

.modal-body { padding: var(--sp-6) var(--sp-7) var(--sp-7); }
.modal-body--edit { padding: 20px var(--sp-7) var(--sp-7); }

.modal-body__tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }

.modal-body__actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); flex-wrap: wrap; }

.ing-list { display: flex; flex-direction: column; margin-bottom: 20px; }

.ing-list__row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  padding: var(--sp-2) 0;
  /* Dotted, not solid: a recipe card's leader line. Wants the darker token —
     a faint hairline broken into dots reads as nothing at all. */
  border-bottom: 2px dotted var(--border-strong);
  margin-bottom: var(--sp-6);
}

/* The last row's rule underlines the section rather than dividing it. */
.ing-list__row:last-child { border-bottom: 0; margin-bottom: 0; }

.ing-list__qty { width: 74px; flex: none; font-size: var(--fs-sm); color: var(--text-muted); }
.ing-list__name { font-size: var(--fs-md); color: var(--text); }

.edit-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--text);
}

.form-gap { margin-bottom: var(--sp-xl); }

.form-row {
  display: flex;
  gap: var(--sp-5);
  margin-bottom: var(--sp-xl);
  align-items: flex-start;
}

.form-row__grow { flex: 1; min-width: 0; }
.form-row__fixed { width: 78px; flex: none; }
.form-row__fixed--wide { width: 100px; }
.form-row .filters__row { margin-bottom: 0; }

.ing-edit { display: flex; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-2); }
.ing-edit__qty { width: 78px; flex: none; }
.ing-edit__name { flex: 1; min-width: 0; width: auto; }
.ing-edit__cat { width: 118px; flex: none; padding-left: 7px; padding-right: 7px; }
/* Category of a known ingredient: shown, not editable — settings owns it. */
.ing-edit__cat--fixed { font-size: var(--fs-2xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.edit-instructions { height: 84px; line-height: 1.5; }

.edit-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: 20px;
  padding-top: var(--sp-xl);
  border-top: 1px solid var(--border-faint);
}

.edit-foot__right { display: flex; gap: var(--sp-3); }

/* --- Settings -------------------------------------------------------------
   Restored from the unified-settings work (People / Tags / Ingredients /
   Default assignees). The nav's width and direction are the only runtime
   values — the logic decides narrow vs wide, this file owns the rest. */

/* Wraps so the narrow layout drops the panel below the full-width picker
   rather than crushing it to zero width beside it. */
/* Settings stacks a crumb and a tab nav above its list, which the page-level
   --scroll-fit does not know about — the list needs that much less again. */
.settings { display: flex; flex-wrap: wrap; gap: var(--sp-xl); align-items: flex-start; --scroll-fit: calc(100dvh - 340px); }

/* Breadcrumb. The trailing crumb is a native <select>, stripped back to look
   like the rest of the trail — it is the section label and the section picker
   at once, which is what buys back the row the tab grid used to cost. */
.crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }

.crumbs__sep { flex: none; color: var(--text-faint); font-size: var(--fs-2xl); line-height: 1; }

.crumbs__picker {
  /* Without this a <select> is as wide as its longest option ("Default
     assignees"), which strands the caret far from the crumb. Unsupported
     browsers just get the old wider box. */
  field-sizing: content;
  width: auto;
  max-width: 100%;
  border: 0;
  background: transparent;
  padding: 2px var(--sp-1);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--text-muted);
  cursor: pointer;
}

.settings__nav {
  width: 138px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings__tab {
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  border-radius: 9px;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  font-size: var(--fs-md);
  white-space: nowrap;
  text-align: left;
  cursor: pointer;
}

.settings__tab[aria-selected="true"] { background: var(--text); color: var(--text-inverse); }

.settings__panel { flex: 1 1 260px; min-width: 0; }

.settings-list { display: flex; flex-direction: column; gap: var(--sp-1); }

.settings-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border: 1px solid var(--row-bd, var(--border-faint));
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  background: var(--row-bg, var(--surface));
  opacity: var(--row-opacity, 1);
  cursor: pointer;
}

.settings-row__name {
  flex: 1;
  min-width: 0;
  font-weight: var(--fw-heavy);
  font-size: var(--fs-md);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-row__meta { flex: none; font-size: var(--fs-2xs); color: var(--text-muted); white-space: nowrap; }
/* Category picker: the row owns the layout, so it can't take .field's full width. */
select.settings-row__meta { width: 124px; padding: 5px 7px; color: var(--text); }

.hint { margin: var(--sp-4) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.hint--lead { margin: 0 0 var(--sp-4); font-size: var(--fs-sm); }
/* Sits under a block that already carries its own bottom margin, and needs its
   own gap below so the next heading does not sit on it. */
.hint--tight { margin: 0 0 var(--sp-7); }

/* Serves and the source link share the line under the ingredients. Either can be
   absent — a slot's stepper owns the servings, and most recipes have no URL. */
/* Prep time as plain text between ingredients and instructions (was a pill). */
.recipe-prep { margin: var(--sp-5) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.recipe-meta { display: flex; align-items: baseline; gap: var(--sp-5); flex-wrap: wrap; }
.recipe-meta:empty { display: none; }
.recipe-meta__src { color: var(--text-body); text-decoration: underline; text-underline-offset: 2px; }

.add-row__label { flex: none; font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }

/* People tab */

.profile-head__input {
  flex: 1;
  min-width: 0;
  max-width: 260px;
  width: auto;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--text);
  padding: var(--sp-1) 7px;
  border-radius: var(--r-sm);
  cursor: text;
}

.profile-head__input:hover { background: var(--surface-sunken); }

/* Default-assignees tab */

.asg-people { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: var(--sp-xl); }

.asg-person {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-lg);
  padding: 7px 11px 7px var(--sp-3);
  background: var(--surface);
  cursor: grab;
}

.asg-person__name { font-weight: var(--fw-heavy); font-size: var(--fs-md); color: var(--text); white-space: nowrap; }

/* The chip is the people list as well as the drag source, so it carries the
   same chevron-into-detail affordance the people cards used to. */
.asg-person__open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  height: 20px;
  margin-left: -2px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  cursor: pointer;
}

.asg-person__open:hover { background: var(--surface-muted); }

.asg-scroll { overflow-x: auto; }

/* The 520px floor made this grid scroll sideways on every phone, and there was
   nothing on the far side worth the trip — seven drop targets that are already
   only as wide as a three-letter day name. `min()` keeps the comfortable width
   wherever it fits and lets the whole week collapse into view where it does
   not; `minmax(0, 1fr)` stops the day columns from being propped open by their
   own content once they get narrow. */
.asg-grid {
  min-width: min(520px, 100%);
  display: grid;
  grid-template-columns: minmax(56px, 78px) repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.asg-day {
  text-align: center;
  padding: var(--sp-2) 2px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
  color: var(--text-muted);
}

.asg-meal {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-2) var(--sp-1);
  border-radius: var(--r-sm);
  background: var(--asg-tint);
  color: var(--asg-fg);
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}

.asg-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 46px;
  padding: var(--sp-1);
  border: 1px dashed var(--cell-bd);
  border-radius: 9px;
  background: var(--cell-bg);
}

/* Inherited defaults read as an outline, set-here defaults as a solid fill. */
.avatar--ghost { background: transparent; color: var(--avatar-fg); border: 1px dashed var(--avatar-fg); }

.asg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-xl);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--surface-muted);
}

.asg-foot__label { font-size: var(--fs-md); color: var(--text); }

/* --- People roster --------------------------------------------------------
   The People tab is a list you edit, not a palette you drag from (that is the
   Meals grid), so it reads top-to-bottom with its controls on the right. */

.roster { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }

.roster__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: grab;
}

.roster__row:hover { background: var(--surface-warm); }
.roster__name { flex: 1; font-weight: var(--fw-heavy); font-size: var(--fs-md); color: var(--text); }
.roster__row .icon-btn[disabled] { opacity: .3; cursor: default; }

/* --- Meal rules grid ------------------------------------------------------
   The row header carries the household-wide controls; each cell carries the
   same two for one weekday. The per-cell actions stay dim until the cell is
   hovered or focused so the grid still reads as a grid of people. */

/* The grid headers and cells are buttons so they are keyboard-reachable, but
   they keep their own type — a `font: inherit` shorthand here would sit later
   in the cascade than each component's own font-size and silently undo it. */
.asg-day, .asg-meal, .asg-cell {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* The picked scope is what the rule builder below is pointed at. */
.asg-day[aria-pressed="true"],
.asg-meal[aria-pressed="true"] { outline: 2px solid var(--accent, var(--text)); outline-offset: -2px; }
.asg-cell.is-picked { outline: 2px solid var(--text); outline-offset: -2px; }

.asg-meal { flex-direction: column; gap: 2px; border: 0; }
.asg-meal__label { display: block; }
.asg-meal__acts { display: flex; gap: 4px; }
.asg-meal__standing {
  font-size: var(--fs-2xs);
  text-transform: none;
  letter-spacing: 0;
  opacity: .85;
}

.asg-cell { position: relative; flex-wrap: wrap; }

.asg-cell__off {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-muted);
}

.asg-cell__standing {
  width: 100%;
  text-align: center;
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Rule builder ---------------------------------------------------------
   Reads as a sentence, wrapping to as many lines as it needs. The selects sit
   inline with the words rather than in a form grid, so the rule stays readable
   as one statement instead of four labelled fields. */

.rule-builder { margin-top: var(--sp-6); }
.rule-builder__count { flex: none; font-size: var(--fs-2xs); color: var(--text-muted); white-space: nowrap; }

.rule-builder__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--fs-md);
  color: var(--text);
}

.rule-builder__word { color: var(--text-body); }
.rule-builder__select { width: auto; min-width: 0; }
.rule-builder__input { width: auto; min-width: 160px; flex: 1; }
.rule-builder__days { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.rule-builder__acts { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }

/* --- Dietary needs -------------------------------------------------------- */

.diet { margin-bottom: var(--sp-6); }
.diet__veg { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); color: var(--text); margin-bottom: var(--sp-3); }
.diet__list { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.diet__notes { width: 100%; margin-top: var(--sp-3); min-height: 60px; }

/* Advisory only — a warning colour, never a blocked or disabled treatment. */
.diet-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px var(--sp-1);
  border-radius: var(--r-xs);
  background: var(--warning-surface);
  color: var(--warning-text);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

.chip__variant--standing { opacity: .75; font-style: italic; }

/* A meal the household does not plan. Muted and inert — not a drop target. */
.slot--off {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted);
  border-radius: var(--r-sm);
  min-height: 46px;
}

.slot-off__mark { color: var(--text-faint); }

/* A standing meal dropped for one week. Deliberately quieter than a chip and
   louder than an empty slot: it is a decision the household made, and clicking
   it puts the meal back. The solid (not dashed) edge is what separates it at a
   glance from the empty cell's "add something here". */
.slot-skip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  min-height: 96px;
  padding: var(--sp-2);
  border: 1px solid var(--border-faint);
  border-radius: 9px;
  background: var(--surface-muted);
  /* --text-muted, not --text-faint: these are words, and faint is documented
     non-text only. */
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
}

.slot-skip__name {
  font-size: var(--fs-xs);
  text-decoration: line-through;
}

.slot-skip__note {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* The agenda stacks full-width rows rather than filling a grid cell. */
.slot-skip--row {
  flex-direction: row;
  gap: var(--sp-2);
  justify-content: flex-start;
  min-height: 0;
}

/* --- Account -------------------------------------------------------------- */

.acct { display: flex; flex-direction: column; gap: var(--sp-2); }
.acct .btn { align-self: flex-start; }

/* --- First-run setup ------------------------------------------------------
   Full width of the main column, one step at a time. Deliberately roomier than
   Settings: this is the first thing a new household sees. */

.setup { max-width: 640px; margin: 0 auto; }

.setup__step {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-muted);
  margin: 0 0 var(--sp-2);
}

.setup__title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  color: var(--text);
  margin: 0 0 var(--sp-2);
}

.setup__field { width: 100%; margin-top: var(--sp-4); }
.setup__check { display: flex; align-items: flex-start; gap: var(--sp-2); margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--text-body); }

.setup__meals { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }

.setup__meal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.setup__meal[aria-pressed="true"] { background: var(--asg-tint); border-color: var(--asg-fg); }
.setup__meal-name { font-weight: var(--fw-heavy); font-size: var(--fs-md); color: var(--text); }
.setup__meal-state { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); }
.setup__meal[aria-pressed="true"] .setup__meal-state { color: var(--asg-fg); }

.setup__acts { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-6); }
.setup__acts .btn--quiet:last-child { margin-left: auto; }

.stepper--plain { --ctx-color: var(--border); background: var(--surface-sunken); }

.app-footer {
  margin-top: var(--sp-7);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.app-footer__link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.app-footer__link:hover { color: var(--text-body); }


/* ============================================================================
   5. SMALL SCREENS
   Overrides, not a second layout. Everything above still describes the page;
   this section only says what a phone cannot afford. Keyed off `.app--mobile`
   rather than a media query for the same reason as the padding it replaces —
   the logic script already branches on `isMobile`, so one breakpoint decides
   both what renders and how it is spaced. Below 600px, per `breakpoints()`.
   ========================================================================== */

/* --- Full bleed ------------------------------------------------------------
   The page gutter (8px), the card's inset (18px) and its border were spending
   ~27px a side on decoration, on the axis with the least to spare. The card
   goes edge to edge and keeps one 8px gutter of its own, which buys ~38px of
   content width — most of a fourth day in the planner. */
.app--mobile { padding: var(--sp-3) 0 var(--sp-5); }

/* The gutter moves from the page onto the things that still want one. */
.app--mobile .app-header,
.app--mobile .print-title,
.app--mobile .app-footer {
  padding-left: var(--sp-3);
  padding-right: var(--sp-3);
}

/* A card spanning the viewport has no outside to round against: left over, the
   radius and side borders just draw a seam a hair in from the screen edge. */
.app--mobile .layout__main > .card {
  border-left: 0;
  border-right: 0;
  border-radius: 0;
}

.app--mobile .card--pad { padding: var(--sp-4) var(--sp-3) var(--sp-5); }

/* The sheet nests a `.card` inside `.sidebar--sheet`, so its inset was charged
   twice — 14 + 14 = 28px a side before any content. One gutter is enough. */
.app--mobile .sidebar--sheet { padding: var(--sp-3) var(--sp-3) 28px; }
.app--mobile .sidebar--sheet .card--sidebar { padding: var(--sp-3); }

/* --- Filling the viewport --------------------------------------------------
   The planner's rows were a fixed 110px whatever the screen, so a week of
   mostly-empty slots stopped well short of the bottom and left the footer
   stranded over a band of dead background. Handing `.app`'s height down the
   chain — layout, main, card, planner — gives `.planner__grid` something
   definite to fill, and its `auto` rows split the slack between them.

   Deliberately not on tablet: the sidebar is a sheet there too, but a tablet
   has the height to spare and stretched rows would only thin the content out.
   `:only-child` scopes it to the one-week view for the same reason — two weeks
   stacked already fill the screen, and stretching both would push the second
   below the fold. */
.app--mobile .layout { align-items: stretch; }

.app--mobile .layout__main > .card--pad {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app--mobile .planner { flex: 1; min-height: 0; }
/* Day and date share one line, day to the left edge of the column and date to
   the right, which gives a whole line of height back to the meals. */
.app--mobile .day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
}
.app--mobile .day-head__date { font-size: var(--fs-xl); line-height: var(--lh-tight); }

.app--mobile .planner__week:only-child {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app--mobile .planner__week:only-child .planner__grid { flex: 1; }

/* Stretching only helps when there is slack. On a short phone there is not:
   four rows at the desktop 110px floor overshoot a 667px screen and put the
   footer back below the fold, which is the same complaint from the other
   direction. Lowering the floor lets the grid compress to fit there and stretch
   past it everywhere else — the row height follows the screen either way. The
   empty cell drops its own floor because it already fills the slot. */
.app--mobile .slot,
.app--mobile .row-label { min-height: 92px; }
.app--mobile .slot-empty { min-height: 0; }

/* Edge shadow only where the column is reliably doing its job. A phone can
   never fit seven days, so the planner always scrolls and the shadow always
   means something; a desktop mostly fits the week, and there the same shadow is
   just a seam drawn down an empty gutter. */
.app--mobile .row-label { box-shadow: var(--shadow-pinned); }

/* The schedule list had the same dead-space problem seen from the other side —
   a flat 640px cap set at the call site, more than a short phone has. It used
   to be answered here by lowering `--scroll-max`, which never took effect: the
   call site sets that variable inline, and inline beats a stylesheet rule. The
   cap now lives in `.scroll-y`'s `min()` against `--scroll-fit`, which the call
   site cannot outrank; `.app--mobile` only supplies the phone's chrome. */

/* --- Ingredients: the name comes first ------------------------------------
   Three fixed columns (quantity, category, remove) plus a flexible name adds
   up to more than a phone has, and the one that gave way was the name — the
   only part you actually read. Wrapping puts it on its own line and lets the
   fixed columns drop below, where they cost a line but nothing else. The
   settings row does the same with a minimum instead of an order, because the
   checkbox has to stay beside the name. Wrapped rows also need the leader line
   the read-only list uses, or two ingredients read as one four-line block. */
.app--mobile .ing-edit {
  flex-wrap: wrap;
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-6);
  border-bottom: 2px dotted var(--border-strong);
}
.app--mobile .ing-edit__name { flex: 1 0 100%; order: -1; }
.app--mobile .ing-edit:last-of-type { border-bottom: 0; }

.app--mobile .settings-row { flex-wrap: wrap; }
.app--mobile .settings-row__name { min-width: 60%; }

/* --- Tabs: the bottom bar's page ------------------------------------------
   `.app--tabbed` is the phone with its bottom bar up (not while printing or
   during first-run setup). The page keeps the bar's height free at the bottom
   so the last row can always scroll clear of it, and the footer goes: a
   copyright line between the content and the bar is the one thing nobody on a
   phone needs to scroll past. */
.app--tabbed {
  padding-bottom: calc(var(--tabbar-h) + var(--tabbar-inset) + var(--sp-5));
  --scroll-fit: calc(100dvh - 150px - var(--tabbar-h) - var(--tabbar-inset));
}
.app--tabbed .app-footer { display: none; }
.app--tabbed .app-header { margin-bottom: var(--sp-5); }

/* Recipes and Shop: the sidebar laid flat into the page. It stops being a
   fixed-height pane with its own scrollbar and lets the page scroll instead —
   one scroll on a phone, never a box inside a box. The search row pins to the
   top so it is there however far down the list you are. */
.sidebar--page { width: auto; flex: 1; min-width: 0; position: static; }
/* The main column has nothing to show on these two tabs, but as an empty flex
   item it would still take half the row and its gap. */
.layout:has(> .sidebar--page) > .layout__main { display: none; }
.sidebar--page .card--sidebar {
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  padding: var(--sp-4) var(--sp-3) var(--sp-5);
}
.sidebar--page .scroll-y { max-height: none; overflow: visible; }
.sidebar--page .search-row {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-3)) var(--sp-4);
  padding: var(--sp-4) var(--sp-3) var(--sp-3);
  background: var(--surface);
}


/* --- Splash / auth gate --------------------------------------------------
   One overlay does two jobs. It paints before the app boots, so on a warm
   session it is the load screen — logo, hold, fade out over the app — and on a
   cold one the form fades in beneath the logo. Both states are the same
   element; only the classes change, so there is never a flash of a login form
   at somebody who is already logged in. */

.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  padding: var(--sp-6);
  background: radial-gradient(120% 90% at 50% 30%, var(--surface-warm), var(--surface-sunken) 70%);
  font-family: var(--font-body);
  transition: opacity .4s ease;
}

.splash__mark {
  width: 168px;
  max-width: 45vmin;
  height: auto;
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-menu);
}

.splash__name {
  font-family: var(--font-display);
  font-weight: var(--fw-regular);
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: -.01em;
  color: var(--text);
  margin: 0;
}

/* Hidden until /api/me says a login is actually needed. `visibility` rather
   than `display` so the layout below the logo does not jump when it arrives. */
.splash__form {
  width: 280px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(var(--sp-2));
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}

.splash--auth .splash__form {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.splash--done { opacity: 0; pointer-events: none; }

.splash__error {
  color: var(--danger);
  font-size: var(--fs-sm);
  min-height: 1em;
}

.splash__submit { --btn-bg: var(--accent); }

.splash__alt {
  border-color: var(--border);
  color: var(--text-body);
  font-size: var(--fs-sm);
}

@media (prefers-reduced-motion: reduce) {
  .splash, .splash__form { transition-duration: .01ms; }
}
