:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --bg-glow: transparent;
  --surface: #ffffff;
  --surface-2: #F1F1F3;
  --surface-3: #E5E5E9;
  --ink: #111113;
  --ink-2: #4A4A51;
  --ink-3: #6D6D75;
  --ink-4: #8A8A92;
  --accent: #111113;
  --accent-pressed: #2C2C30;
  --accent-ink: #FFFFFF;
  --accent-soft-bg: #F1F1F3;
  --accent-soft-border: #CBCBD1;
  --accent-glow: rgba(0,0,0,0);
  --sheen: rgba(0,0,0,0);
  --focus: var(--accent);
  --focus-ring: #E5E5E9;
  --border: #E4E4E8;
  --border-soft: #E4E4E8;
  --border-strong: #CBCBD1;
  --border-input: #7d7d85;
  --media-stage: #111113;
  --media-reticle: #f5f5f7;
  --success: #1F7A4A;
  --success-ink: #FFFFFF;
  --success-bg: #E8F4EC;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --c-nutrition: var(--ink-2);
  --c-nutrition-soft: var(--surface-2);
  --c-body: var(--ink-2);
  --c-body-soft: var(--surface-2);
  --c-recovery: var(--ink-2);
  --c-recovery-soft: var(--surface-2);
  --signal-up-fg: var(--success);
  --signal-up-bg: var(--success-bg);
  --signal-hold-fg: #8A5A00;
  --signal-hold-bg: #FAF3E3;
  --heat-1: #c5c5ca;
  --heat-2: #85858c;
  --heat-3: var(--accent);
  --heat-count-ink: #111113;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow: none;
  --shadow-lift: 0 2px 10px -4px rgba(17,17,19,.18);
  --shadow-menu: 0 12px 32px rgba(17,17,19,.14);
  --scrim: rgba(17,17,19,.36);
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-sheet: 28px;
  --radius-pill: 999px;
  --tap: 44px;
  --card-pad: 16px;
  --page-gutter: 16px;
  /* S30: the four lengths the workout dock measures for itself. These are
     the values a cold shell uses; app.js republishes them from the real
     bands whenever the keypad, the rest band or the orientation changes. */
  --keypad-dock-height: 330px;
  --rest-dock-height: 56px;
  --workout-headroom: 120px;
  --workout-head-height: 0px;
  /* S31: and the two bands the session bar has to park under and inside. */
  --page-header-height: 60px;
  --session-bar-height: 60px;
  /* S32: the tab bar the session strip docks above. A wrapped row of labels
     plus the home-indicator inset; the cold-shell value is the worst case. */
  --tab-nav-height: 80px;
  /* S43B: the visual viewport an open sheet fits while the iOS keyboard is
     up; app.js republishes both from window.visualViewport. */
  --vv-h: 100dvh;
  --vv-top: 0px;
  --mobile-nav-height: calc(3 * (24px + 1.3rem) + 12px + env(safe-area-inset-bottom));
  --fs-eyebrow: var(--fs-caption);
  --fs-caption: 13px;
  --fs-label: 15px;
  --fs-body: 17px;
  --fs-h3: 20px;
  --fs-h2: 24px;
  --fs-display: 44px;
  --fs-h1: 32px;
  --font-sans: Archivo, system-ui, -apple-system, "Segoe UI", sans-serif;
  --type-meta: var(--fs-label);
  --type-primary: var(--fs-body);
  --type-section: var(--fs-h2);
  --type-page: var(--fs-h1);
  --lh-tight: 1.1;
  --lh-snug: 1.25;
  --lh-body: 1.45;
  --ls-display: -.03em;
  --ls-h1: -.025em;
  --ls-h2: -.02em;
  --ls-h3: -.012em;
  --ls-caption: .005em;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 650;
  --fill: var(--surface-2);
  --text-primary: var(--ink);
  --text-secondary: var(--ink-2);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;
  --ease: cubic-bezier(.22,1,.36,1);
  --ease-in-out: cubic-bezier(.65,0,.35,1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-sheet: 320ms;
  --dur-in: 480ms;
  --dur-fill: 600ms;
  --stagger: 45ms;
  /* ---------- One semantic token set (S16, retuned by the Ledger slice) ----------
     Every surface, ink, accent and status colour in the app is a semantic
     custom property declared exactly once, above, and no component
     references a raw hex. The dark block below remaps these same names to
     the dark values and is the entire dark theme.

     S2's deep-blue light theme used to be declared here and then overridden,
     name for name, by a second monochrome `:root` 1,800 lines further down,
     with a third family (--type-*, --text-*, --fill) introduced alongside it.
     Those three layers are now this one block: a token's value is where its
     name is, and the second family is aliased (--type-section: var(--fs-h2))
     rather than redeclared.

     Colour: "Ink" (design sprint slice 1, owner decision 2026-11-12).
     --accent is the ink itself: the one action colour, the selected state
     and the focus ring, with --accent-ink on it at 18.9:1 light / 18.4:1
     dark. The Ledger's indigo is gone, and the four domain hues are kept as
     *names* only (--c-nutrition, --c-body, --c-recovery and their -soft
     tints resolve to --ink-2 and --surface-2) so a later slice can give a
     hue a defined purpose without renaming every consumer. The only
     chromatic tokens are the status pairs: green (--success) means done or
     met and nothing else, amber (--signal-hold-*) means hold or over goal,
     red (--danger) is destructive or an error. Each is text-grade
     (>=4.5:1 on --surface and on its own soft tint). Every grey above keeps
     a channel spread of at most ten steps. --accent-glow and --sheen are
     retired to transparent (no glow, no sheen) and stay declared only so the
     rules that still name them resolve; --scrim is the veil behind a sheet.
     The training-calendar ramp (--heat-1/2/3) is grey + ink;
     --heat-count-ink measures 10.97:1 on --heat-1 and 5.15:1 on --heat-2, and
     3+ sessions use the --accent/--accent-ink pair.

     Motion: --ease settles without overshoot; nothing springs. --dur-fast is
     press, colour and focus; --dur is disclosure and selection; --dur-sheet
     is a sheet or the keypad arriving; --ease-in-out is for things that move
     and stay on screen. Numbers do not count up: a number is readable in
     the first frame.

     Text colour: --ink-4 is for inactive icons, chevrons and outlines only.
     It measures 3.43:1 on --surface and 3.12:1 on --bg, which clears the
     1.4.11 non-text floor but not the 1.4.3 text floor, so no rule may set
     it as a `color` on text (guarded by
     tests/test_static_theme_contrast.py::test_no_rule_sets_text_colour_to_ink_4).

     Fields: an editable control needs a 3:1 outline against the card it sits
     on *and* against its own fill (WCAG 2.2 1.4.11). --border is 1.2:1 on
     --surface, which is the root cause of the repeated "fields don't look
     editable" findings, so inputs and selects take --border-input instead.
     The Ledger mockups specify #8A8A92 for this outline, but the app fills
     inputs with --surface-3, where #8A8A92 measures only 2.73:1; the app
     therefore keeps the darker #7d7d85, which clears 3:1 on --surface,
     --surface-2, --surface-3 and --bg alike.

     Type: the seven-step scale is in px because the Ledger floor is absolute —
     nothing under 13px, ever. The >=64rem block below remaps the three sizes
     that differ on a desktop workspace, plus the page gutter, and declares no
     colour. One family (--font-sans), four weights (--fw-regular 400,
     --fw-medium 500, --fw-semibold 600, --fw-bold 650). Tracking depends on
     size: body text is 0 with a slightly wider word space (Archivo's word
     space is narrow, so "Log food" and "8k steps" read as one word at
     negative tracking), and headings tighten in steps (--ls-h3 to
     --ls-display). Design sprint slice 2, DESIGN-SPEC §1.2.

     Shape: one surface. A .card is --surface at --radius-lg with no border
     and no shadow; --radius is a button or a segmented track, --radius-sm a
     well, input or key, --radius-sheet the top corners of a sheet and
     --radius-pill a chip or round button. No other radius, except the 3px
     ends of a progress bar (§2.7). --page-gutter is the phone/desktop page
     inset (§1.4).

     --media-stage letterboxes a camera or photo frame rather than being a
     surface, so it stays near-black in both themes. --media-reticle is its
     pair: the scan outline drawn *on* that frame, near-white in both themes
     for the same reason, and the token that retired the one chromatic blue
     left in the sheet (rgba(56,165,255,.9), review N19). Neither is remapped
     in the dark block, because a camera frame is not a surface.

     Why the commentary sits at the foot of the block rather than beside each
     token: several Node DOM harnesses parse this block by splitting on ";"
     and then on ":", so a comment between two declarations silently swallows
     the one after it. Keep notes here, below the last declaration. */
}

/* ---------- Dark parity ----------
   The same semantic property names, dark values only, and only the names
   whose value actually differs. No selector below this point holds a raw hex
   or rgba surface, ink or status colour — every one consumes a token above —
   so this single block is the entire dark theme. Measured pairs: --accent-ink
   18.4:1 on --accent, --border-input 5.84:1 on --surface and 4.10:1 on the
   --surface-3 fill, --heat-count-ink 8.07:1 on --heat-1 and 4.64:1 on
   --heat-2. The same "no comments between declarations" rule applies. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08080a;
    --surface: #141416;
    --surface-2: #1F1F23;
    --surface-3: #2A2A2F;
    --ink: #f5f5f7;
    --ink-2: #C3C3C9;
    --ink-3: #9A9AA2;
    --ink-4: #6E6E76;
    --accent: #f5f5f7;
    --accent-pressed: #D4D4D9;
    --accent-ink: #08080a;
    --accent-soft-bg: #1F1F23;
    --accent-soft-border: #4A4A52;
    --focus-ring: #2A2A2F;
    --border: #26262B;
    --border-soft: #26262B;
    --border-strong: #4A4A52;
    --border-input: #8f8f98;
    --success: #6CC492;
    --success-ink: #08080a;
    --success-bg: #13271B;
    --danger: #F0857B;
    --danger-bg: #341A17;
    --signal-hold-fg: #E2B45F;
    --signal-hold-bg: #2B2211;
    --heat-1: #4a4a51;
    --heat-2: #6e6e76;
    --heat-3: var(--accent);
    --heat-count-ink: #f5f5f7;
    --shadow-lift: 0 2px 10px -4px rgba(0,0,0,.6);
    --shadow-menu: 0 12px 32px rgba(0,0,0,.6);
    --scrim: rgba(0,0,0,.56);
  }
}
/* ---------- Desktop type scale ----------
   The third and last token declaration site in the sheet. It remaps only the
   three type sizes a desktop workspace reads differently (display, body,
   label) and the page gutter (16px phone, 40px desktop, DESIGN-SPEC §1.4),
   and declares no colour and no radius, so the
   "a token's value is where its name is" rule still holds for every colour
   in the two blocks above. Guarded by
   tests/test_static_semantic_tokens.py::test_the_third_root_site_is_type_and_gutter_only. */
@media (min-width: 64rem) {
  :root {
    --fs-label: 14px;
    --fs-body: 16px;
    --fs-display: 56px;
    --page-gutter: 40px;
  }
}

/* ---------- Motion primitives (Ledger) ----------
   CLS-safe by construction: every keyframe below animates transform,
   opacity, colour or SVG stroke-dashoffset only -- never width, height,
   margin, padding, top/left, font-size, border-width, display or
   visibility. Anything that appears to fill is a scaleX on a box that
   already has its final size; anything that counts up paints into a pseudo
   element laid over a transparent copy of the final value, so the box is
   sized by the final value from the first frame.

   Entrances run exactly once, when a panel first becomes visible: the
   renderer adds .is-entering at the same moment it removes
   .is-initial-hydrating and takes it off again on animationend (or after
   1.5s). Re-renders, tab switches and data refreshes therefore insert
   elements with no running animation. The set-check pop is scoped to
   .just-done, which only the owner's tap adds.

   Guarded by tests/test_initial_load_layout_stability_v83.py (static: no
   layout property inside a keyframe, every animation inside a once-only
   selector) and tests/quality/initial_load_layout_shift_check.py (rendered:
   CLS <= 0.01 and getAnimations() empty 1.5s after hydration). */
@property --n { syntax: "<integer>"; inherits: true; initial-value: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fill-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pop { 0% { transform: scale(.72); } 100% { transform: scale(1); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
/* `menu-in` deliberately drops the mockup's scale(.96): a menu item is a
   44px tap target, and getBoundingClientRect reports the *transformed* box,
   so a scaling entrance makes every item measure 42px for 220ms. The
   translate and fade still read as arriving from the top right. */
@keyframes menu-in { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: radial-gradient(120% 90% at 50% -8%, var(--bg-glow), transparent 60%), var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  max-width: 100%;
  /* `clip` rather than `hidden`: `overflow-x: hidden` on <body> makes the body
     a scroll container, and a scroll container that cannot scroll vertically
     silently disables `position: sticky` for everything inside it -- which is
     every sticky bar the Ledger shell introduces. `clip` keeps the same
     horizontal clipping (test_static_mobile_overflow and browser_smoke's
     scrollWidth <= innerWidth checks still hold) without creating one. */
  overflow-x: clip;
}
body.food-capture-open { overflow: hidden; overscroll-behavior: none; }

/* ---------- Layout ---------- */
.shell {
  width: min(760px, calc(100% - 2 * var(--page-gutter)));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right)) 40px max(0px, env(safe-area-inset-left));
}
.app-stack { display: grid; gap: var(--space-4); }

/* ---------- Typography ---------- */
.hero { margin: 6px 0 18px; }
.eyebrow { color: var(--ink-3); font-weight: var(--fw-semibold); letter-spacing: 0; font-size: var(--fs-eyebrow); margin: 0 0 .45rem; }
h1 { font-size: var(--fs-h1); font-weight: var(--fw-bold); line-height: var(--lh-tight); margin: .12em 0; letter-spacing: var(--ls-h1); overflow-wrap: break-word; }
h2 { margin-top: 0; font-size: var(--type-section); font-weight: var(--fw-bold); line-height: 1.15; letter-spacing: var(--ls-h2); overflow-wrap: break-word; }
h3 { margin: .2rem 0 .6rem; font-size: var(--fs-h3); font-weight: var(--fw-bold); letter-spacing: var(--ls-h3); overflow-wrap: break-word; }
p { color: var(--ink-3); margin: .4rem 0; line-height: var(--lh-body); }

/* ---------- Navigation ---------- */
.tab-nav {
  position: sticky; top: 10px; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px;
  padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.tab-button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; color: var(--ink-3); border: 0; border-radius: var(--radius);
  padding: 6px; font-size: var(--fs-caption); font-weight: var(--fw-medium); cursor: pointer;
  min-height: var(--tap);
  transition: color var(--dur-fast) var(--ease);
}
/* §2.8: no backgrounds on a tab, in any state -- the base button's pressed
   and hovered fills would paint a black box behind the icon. */
.tab-button:is(:hover, :active) { background: transparent; }
.tab-icon { width: 24px; height: 24px; display: block; }
/* The one place the type scale is relative rather than absolute: primary
   navigation must honour the owner's browser text-size setting, and the
   floor is still 13px. At a 32px root the labels grow and the bar wraps
   rather than truncating -- the v105 contract. */
.tab-label { max-width: 100%; white-space: nowrap; text-align: center; font-size: max(var(--fs-caption), .8125rem); line-height: 1.2; letter-spacing: var(--ls-caption); }
.tab-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.tab-button.active { background: transparent; color: var(--ink); font-weight: var(--fw-semibold); }
.tab-button.active .tab-icon svg { stroke-width: 2.1; }
.tab-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Cards & forms ---------- */
/* §1.6: the one surface. No border and no shadow in either theme. */
.card { border: 0; background: var(--surface); border-radius: var(--radius-lg); padding: var(--card-pad); box-shadow: none; }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.overview-actions { display: flex; gap: 8px; align-items: center; }
.form { display: grid; gap: 14px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-medium); overflow-wrap: break-word; }
input, textarea {
  width: 100%; border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--ink); padding: 12px 14px;
  font: inherit; font-size: 16px; min-height: var(--tap);
  transition: border-color .15s ease, box-shadow .15s ease;
  /* Form controls do not inherit word-spacing; without this the body's
     .06em "Log food" space stops at every input. */
  word-spacing: inherit;
}
/* Native iOS date/select controls have a wide intrinsic minimum. Let controls
   and their grid items shrink instead of widening the page or review sheet. */
input, textarea, select { min-width: 0; max-width: 100%; }
select { word-spacing: inherit; }
.two-col > *, .review-grid > *, .review-controls > * { min-width: 0; }
textarea { resize: vertical; min-height: 64px; }
input:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 1; }

button {
  border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  font-weight: var(--fw-semibold); padding: 12px 18px; font: inherit; cursor: pointer; min-height: var(--tap);
  /* Buttons do not inherit word-spacing either: "8k steps", "Log food". */
  word-spacing: inherit;
  box-shadow: none;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
button:disabled { opacity: .4; pointer-events: none; }
/* S29: :hover behind the pointer query. iOS latches :hover on whatever was
   last tapped until the owner taps something else, so an unscoped
   `button:hover` painted the *selected* workout template solid
   --accent-pressed while its subtext kept the grey it has on a white card —
   the unreadable indigo row in the 10 Nov device feedback. Hover is a
   pointer state; a phone has no pointer. Nothing changes on a mouse. */
@media (hover: hover) {
  button:hover { background: var(--accent-pressed); }
  button.secondary:hover { background: var(--surface-3); }
}
button:active { transform: scale(.96); transition-duration: 80ms; background: var(--accent-pressed); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border-input); box-shadow: none; }
button.secondary:active { background: var(--surface-3); }
button.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bg); box-shadow: none; }

/* Reviewed body-history deletion (v101). */
.body-delete-review-sheet {
  width: min(100%, 30rem); max-height: min(760px, calc(100dvh - 28px));
  display: flex; flex-direction: column; overflow: hidden;
  color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.body-delete-review-scroll { padding: var(--space-6); overflow: auto; overscroll-behavior: contain; }
.body-delete-review-scroll h2 { margin-top: 0; }
.body-delete-review-fields { display: grid; grid-template-columns: minmax(7rem, auto) minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: var(--space-4) 0; }
.body-delete-review-fields dt { color: var(--ink-2); font-weight: var(--fw-semibold); }
.body-delete-review-fields dd { margin: 0; overflow-wrap: anywhere; }
.body-delete-review-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-4) var(--space-6) max(var(--space-4), env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.body-delete-review-actions button { flex: 1 1 8rem; }
.body-undo-region { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-4) 0; padding: var(--space-4); background: var(--success-bg); border: 1px solid var(--border); border-radius: var(--radius); }
.body-undo-region p { margin: var(--space-1) 0 0; }
/* Reviewed workout-session deletion (v102) reuses the body review sheet. */
/* Exact summary values need the full line on narrow review sheets. */
#nutrition-summary-delete-review-fields { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
#nutrition-summary-delete-review-fields dd { margin: 0 0 var(--space-3); white-space: pre-wrap; }
#nutrition-summary-delete-review-knowledge { padding-left: var(--space-5); overflow-wrap: anywhere; }
.workout-delete-review-sets { display: grid; gap: var(--space-2); margin: 0 0 var(--space-4); padding-left: var(--space-6); overflow-wrap: anywhere; }
@media (max-width: 360px) {
  .body-delete-review-scroll { padding: var(--space-4); }
  .body-delete-review-actions { padding-inline: var(--space-4); }
}
.icon-btn { width: var(--tap); height: var(--tap); padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-row, .mini-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-actions button { padding: 9px 14px; font-size: .85rem; min-height: var(--tap); }
.compact { width: auto; padding-inline: 16px; min-height: var(--tap); }
.primary-action { width: 100%; margin-top: 4px; }
.error, .message.error { color: var(--danger); }
.message.ok { color: var(--success); }
.message { min-height: 1.2em; margin: 6px 0 0; font-size: .92rem; }
.muted { color: var(--ink-3); margin: 0; }
.hidden { display: none !important; }

/* Shell-level status region. A receipt written into a tab panel is invisible
   when the action was launched from another tab, so food adds announce here,
   above the panels and inside no panel. Empty by default, so an idle shell
   spends no layout space on it. */
.shell-status {
  margin: 0; padding: var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink);
  font-size: var(--fs-label); line-height: var(--lh-snug); overflow-wrap: anywhere;
}
.shell-status:empty { display: none; }
.shell-status.error { border-color: var(--danger-bg); }

/* ---------- Overview ---------- */
/* `min(150px, 100%)` rather than a bare 150px floor: Today's one disclosure
   (S24 / B17) leaves this grid laid out even while closed, and a fixed track
   overflowed a 160px-wide phone by 6px. Unchanged above 150px. */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 10px; margin-top: 16px; }
.status-grid article { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px; }
.status-grid article.status-wide { grid-column: 1 / -1; }
.status-grid span { display: block; color: var(--ink-2); font-size: var(--fs-caption); letter-spacing: 0; margin-bottom: 6px; }
.status-grid strong { display: block; font-size: 1.02rem; line-height: var(--lh-snug); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.progression-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.progression-list li { display: grid; gap: 3px; }
.progression-list span { text-transform: none; letter-spacing: 0; margin: 0; font-size: .9rem; }

/* ---------- Today command center ----------
   S3: compact Monitor + Operate surface. One Now card, four operational rows,
   a read-only weekly strip, then collapsed evidence. */
.today-command-center { display: grid; gap: var(--space-3); }
.today-command-center > .row { margin-bottom: 0; }
.today-now {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2);
  padding: var(--space-3); border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius); background: var(--accent-soft-bg); min-width: 0;
}
.today-now-main { display: grid; gap: 3px; min-width: 0; }
.today-now h3 { margin: 0; font-size: 1.12rem; line-height: var(--lh-snug); font-weight: var(--fw-bold); overflow-wrap: anywhere; }
.today-now p { margin: 0; color: var(--ink-2); }
.today-now-cta:empty { display: none; }
/* Fixed-height load placeholder for the one action the plan read fills in
   after Today is revealed: same height as .today-plan-cta, so the reveal
   and the action landing cost no layout shift. */
.today-now-cta-reserve { display: block; min-height: var(--tap); }
.today-now-cta .today-plan-cta { width: 100%; min-height: var(--tap); }
.day-loop-rail {
  display: grid; gap: 0; border: 1px solid var(--border-soft);
  border-radius: var(--radius); background: var(--surface-2); overflow: hidden; min-width: 0;
}
.day-loop-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3);
  align-items: center; min-height: var(--tap); width: 100%; padding: 9px 12px;
  border-radius: 0; background: transparent; color: var(--ink); box-shadow: none;
  border-top: 1px solid var(--border-soft); text-align: left;
}
.day-loop-row:first-child { border-top: 0; }
.day-loop-row:active { transform: none; background: var(--accent-soft-bg); }
.day-loop-copy { display: grid; gap: 1px; min-width: 0; }
.day-loop-label { color: var(--ink-3); font-size: var(--fs-caption); letter-spacing: 0; font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.day-loop-value { font-size: .94rem; line-height: var(--lh-snug); font-weight: var(--fw-bold); overflow-wrap: anywhere; }
.day-loop-note { color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.day-loop-action { color: var(--accent); font-size: .86rem; font-weight: var(--fw-bold); white-space: nowrap; }
.day-loop-row.is-complete .day-loop-value { color: var(--success); }
.readiness-completion {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 8px 10px 8px 12px; border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink-2); min-width: 0;
}
.readiness-completion p { margin: 0; overflow-wrap: anywhere; flex: 1 1 auto; min-width: 0; }
.readiness-completion-dismiss {
  width: var(--tap); min-width: var(--tap); min-height: var(--tap); padding: 0; flex: 0 0 auto;
  border: 0; background: transparent; color: var(--ink-3); box-shadow: none; font-size: 1.25rem;
}
.weekly-today-strip {
  border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface-2);
  padding: 9px 12px; display: grid; gap: var(--space-1); min-width: 0;
}
.weekly-today-strip summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--accent); font-weight: var(--fw-bold); }
.weekly-today-strip p { margin: 0; font-size: .86rem; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.weekly-today-strip .weekly-rec-rationale { color: var(--ink-3); }
.today-plan-secondary { margin: 0; padding: 0; border-left-width: 1px; }
/* Today's goal snapshot error state. The metric-row rules that used to sit
   here went with the markup that built them. */
.progress-fill.is-over { background: var(--border-strong); }
.snapshot-error { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: var(--space-3); display: grid; gap: var(--space-1); }
.snapshot-error { border-color: var(--danger-bg); }
.snapshot-error span { color: var(--danger); font-size: .86rem; }
.snapshot-goals-link { justify-self: start; width: auto; margin-top: var(--space-1); padding: var(--space-2) 14px; min-height: var(--tap); background: transparent; border: 1px solid var(--border); color: var(--accent); font-weight: var(--fw-semibold); font-size: .86rem; border-radius: var(--radius-sm); }

/* ---------- S8 shared tab-level loading/empty/error/retry primitive (issue #41) ----------
   One coherent visual language reused by Nutrition, Workouts, Trends, and
   Settings top-level loads (Today keeps its already-shipped equivalent
   .snapshot-error/.snapshot-goals-link markup above, which
   this mirrors so every tab reads as one system). Empty by default so an
   idle/successful tab spends no layout space on it. */
.tab-state { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: var(--space-3); display: grid; gap: var(--space-2); margin: 0 0 var(--space-3); color: var(--ink-3); font-size: .86rem; overflow-wrap: anywhere; }
.tab-state:empty { display: none; margin: 0; padding: 0; border: 0; }
.tab-state p { margin: 0; color: var(--ink-3); font-size: .86rem; overflow-wrap: anywhere; }
.tab-state-error { border-color: var(--danger-bg); color: var(--danger); }
.tab-state-error p { color: var(--danger); }
.tab-state-retry { justify-self: start; width: auto; padding: var(--space-2) 14px; min-height: var(--tap); background: transparent; border: 1px solid var(--border); color: var(--accent); font-weight: var(--fw-semibold); font-size: .86rem; border-radius: var(--radius-sm); }
.app-hydration-status,
.tab-hydration-status {
  min-height: var(--tap); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); text-align: center;
  color: var(--ink-3); font-size: .9rem; font-weight: var(--fw-semibold);
}
.hydration-retry {
  width: auto; min-height: var(--tap); padding: var(--space-2) 18px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--accent); font: inherit;
}
.app-hydration-status[hidden],
.tab-hydration-status[hidden] { display: none; }
.tab-panel { position: relative; }
.tab-panel > .tab-hydration-status {
  position: absolute; inset: 0 0 auto; z-index: 2;
  box-sizing: border-box; padding: var(--space-2);
  background: var(--surface);
}
#app-card.is-initial-hydrating > :not(.app-hydration-status),
.tab-panel.is-initial-hydrating > :not(.tab-hydration-status) { visibility: hidden; }

/* ---------- S8 global connectivity/recovery banner (issue #41) ----------
   Hidden (zero layout height) when online/healthy; expands only to report a
   real navigator.onLine transition (see index.html CONNECTIVITY_BANNER).
   Same :empty-collapse technique as .tab-state above, deliberately *not*
   max-height/overflow:hidden: a fixed max-height can clip the message at
   larger text sizes, which would defeat Dynamic Type resilience, and
   in some fixed-size collapse techniques an element that's still occupying
   zero rendered height reads as not-currently-visible to some assistive
   tech. Setting text and un-collapsing happen in the same synchronous
   update, so the role="status" content change stays announceable, and an
   empty banner is honestly "nothing to say," not a clipped one. */
.connectivity-banner {
  padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-3);
  border-radius: var(--radius-sm); font-size: var(--fs-label);
  font-weight: var(--fw-semibold); overflow-wrap: anywhere; text-align: center;
}
.connectivity-banner:empty { display: none; margin: 0; padding: 0; border: 0; }
/* Update ready: a new shell is installed but a reload would destroy an open
   dialog, unsaved input, or a running workout. Sits above the modal backdrop
   (z-index 60) and the workout keypad (80) so it stays visible in exactly the
   states that deferred it. */
.update-ready {
  position: fixed; z-index: 90;
  top: calc(var(--space-2) + env(safe-area-inset-top));
  left: max(var(--space-3), env(safe-area-inset-left));
  right: max(var(--space-3), env(safe-area-inset-right));
  display: grid; gap: var(--space-2); padding: var(--space-3);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  border: 1px solid var(--accent-soft-border); box-shadow: var(--shadow-md);
}
.update-ready-title { margin: 0; font-size: var(--fs-label); font-weight: var(--fw-semibold); }
.update-ready-detail { margin: 0; color: var(--ink-2); font-size: var(--fs-caption); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.update-ready-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: var(--space-2); }
.update-ready-actions button { min-height: var(--tap); }
.connectivity-banner-offline { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border-soft); }
.connectivity-banner-online { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bg); }
.tab-state-offline, .snapshot-offline {
  background: var(--surface-2); color: var(--ink-3); border-color: var(--border-soft);
}
.offline-action-blocked {
  opacity: .56;
  cursor: not-allowed;
  filter: saturate(.55);
}
/* Grounded Coach's note (issues #26/#28): one calm synthesized line from stored
   data, distinguished by an accent edge. Hidden entirely when there is nothing
   grounded to say (the .hidden utility carries !important, so the JS toggle wins). */
.today-coach { margin: var(--space-4) 0 0; padding: var(--space-3); background: var(--surface-2); border: 1px solid var(--border-soft); border-left: 3px solid var(--accent); border-radius: var(--radius); display: grid; gap: var(--space-2); }
.today-coach-label { margin: 0; color: var(--ink-3); font-size: var(--fs-caption); letter-spacing: 0; font-weight: var(--fw-semibold); }
.today-coach-body { margin: 0; font-size: var(--fs-body); line-height: var(--lh-snug); font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.today-coach-provenance { margin: 0; color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug); overflow-wrap: anywhere; }
/* Today Plan (issue #63): 0-4 bounded, read-only actions. Each item discloses
   its full contract (freshness/confidence/tradeoff/next feedback) behind a
   44px-floor <details> toggle so the collapsed card stays compact. */
.today-plan { margin: var(--space-4) 0 0; padding: var(--space-3); background: var(--surface-2); border: 1px solid var(--border-soft); border-left: 3px solid var(--accent); border-radius: var(--radius); display: grid; gap: var(--space-2); min-width: 0; max-width: 100%; }
.today-plan.today-plan-secondary { margin: 0; padding: 0; border-left-width: 1px; }
.today-plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); min-width: 0; }
.today-plan-item { background: var(--surface-3); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); display: grid; gap: var(--space-1); min-width: 0; max-width: 100%; }
.today-plan-action { margin: 0; font-size: var(--fs-body); line-height: var(--lh-snug); font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.today-plan-why { margin: 0; color: var(--ink-3); font-size: .86rem; line-height: var(--lh-snug); overflow-wrap: anywhere; }
/* A real, wide 44px CTA — this is a navigating action, not a subtle link. */
.today-plan-cta { width: 100%; min-height: var(--tap); padding: 10px 16px; font-size: .9rem; }
.today-plan-secondary-disclosure > summary {
  min-height: var(--tap); padding: 0 12px; cursor: pointer; display: flex;
  align-items: center; list-style: none; color: var(--accent); font-weight: var(--fw-bold);
}
.today-plan-secondary-disclosure > summary::marker { content: ''; }
.today-plan-secondary-disclosure > summary::-webkit-details-marker { display: none; }
.today-plan-secondary-disclosure > summary::after {
  content: ''; flex: 0 0 auto; width: 8px; height: 8px; margin-left: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s ease;
}
.today-plan-secondary-disclosure[open] > summary::after { transform: rotate(45deg); }
.today-plan-secondary-disclosure > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.today-plan-secondary-body { padding: 0 var(--space-3) var(--space-3); }
.today-plan-details summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; gap: 6px; list-style: none; color: var(--accent); font-weight: var(--fw-semibold); font-size: .84rem; }
/* display:flex on <summary> already suppresses the native marker in most
   engines; hide it explicitly (incl. WebKit's own pseudo) and draw an
   accessible chevron cue that flips with [open] so disclosure state stays
   visible without depending on a browser-default triangle. */
.today-plan-details summary::marker { content: ''; }
.today-plan-details summary::-webkit-details-marker { display: none; }
.today-plan-details summary::after {
  content: ''; flex: 0 0 auto; width: 8px; height: 8px; margin-left: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s ease;
}
.today-plan-details[open] summary::after { transform: rotate(45deg); }
.today-plan-details summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.today-plan-meta { margin: var(--space-1) 0 0; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 4px var(--space-2); font-size: var(--fs-caption); min-width: 0; }
.today-plan-meta dt { color: var(--ink-3); font-weight: var(--fw-semibold); }
.today-plan-meta dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.all-stats-card { margin-top: var(--space-4); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 4px 14px; background: var(--surface-3); }
.all-stats-card > h3 { margin: 0; font-weight: var(--fw-bold); font-size: var(--fs-h3); min-height: var(--tap); display: flex; align-items: center; }
.all-stats-card .status-grid { margin-top: 6px; margin-bottom: 8px; }
.settings-account { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; overflow-wrap: anywhere; }
.settings-account .muted { margin: 0; }

/* ---------- Coaching profile (issue #74) ----------
   A compact single-column disclosure inside Settings: every control keeps the
   44px tap floor and a zero-minimum track, so the long form cannot widen the
   page on a 430px phone. */
.coaching-profile-status { margin: 6px 0 10px; font-size: .88rem; overflow-wrap: anywhere; }
.coaching-profile-card { border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.coaching-profile-card > summary { cursor: pointer; font-weight: var(--fw-semibold); min-height: var(--tap); display: flex; align-items: center; color: var(--accent); }
.coaching-profile-card > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.coaching-profile-form { grid-template-columns: minmax(0, 1fr); margin-top: 10px; }
.coaching-profile-form > * { min-width: 0; max-width: 100%; }
.coaching-profile-form .profile-answered { grid-auto-flow: column; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; min-height: var(--tap); font-size: .86rem; }
.coaching-profile-form .profile-answered input { width: 22px; min-width: 22px; min-height: 22px; margin: 0; }
.coaching-profile-form .profile-abstain { margin: 0; font-size: .84rem; overflow-wrap: anywhere; }
.coaching-profile-form button[disabled], .coaching-profile-form input[disabled], .coaching-profile-form select[disabled], .coaching-profile-form textarea[disabled] { opacity: .55; }

/* ---------- Weekly recommendation status (issues #29 / #50) ----------
   A read-only verdict under the coaching profile. Every track is
   zero-minimum and every sentence wraps, so a long reason cannot widen a
   430px phone. Nothing here is tappable: it states status only. */
.weekly-eligibility-status { margin: 6px 0 10px; font-size: .88rem; overflow-wrap: anywhere; }
.weekly-eligibility { display: grid; gap: var(--space-2); min-width: 0; max-width: 100%; }
.weekly-eligibility > * { min-width: 0; max-width: 100%; }
.weekly-eligibility-lane { border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); display: grid; gap: var(--space-1); min-width: 0; }
.weekly-eligibility-lane-head { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; }
.weekly-eligibility-lane-name { font-weight: var(--fw-semibold); overflow-wrap: anywhere; min-width: 0; }
.weekly-eligibility-verdict { justify-self: end; border-radius: var(--radius-pill); padding: 4px 10px; font-size: var(--fs-caption); font-weight: var(--fw-semibold); white-space: nowrap; }
.weekly-eligibility-verdict.is-possible { background: var(--success-bg); color: var(--success); }
.weekly-eligibility-verdict.is-blocked { background: var(--surface-3); color: var(--ink-2); }
.weekly-eligibility-reasons { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.weekly-eligibility-reasons li { color: var(--ink-2); font-size: .86rem; line-height: var(--lh-snug); overflow-wrap: anywhere; min-width: 0; }
.weekly-eligibility-clear { margin: 0; color: var(--ink-2); font-size: .86rem; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.weekly-eligibility-meta { margin: 0; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 4px var(--space-2); font-size: var(--fs-caption); min-width: 0; }
.weekly-eligibility-meta dt { color: var(--ink-3); font-weight: var(--fw-semibold); }
.weekly-eligibility-meta dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.weekly-eligibility-note { margin: 0; color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug); overflow-wrap: anywhere; }

/* ---------- Weekly review (v59) ---------- */
.weekly-review-status { margin: 6px 0 10px; font-size: .88rem; overflow-wrap: anywhere; }
.weekly-review-view { display: grid; gap: var(--space-2); min-width: 0; max-width: 100%; }
.weekly-review-view[hidden] { display: none; }
.weekly-review-view > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.weekly-review-card { border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); display: grid; gap: var(--space-3); min-width: 0; }
.weekly-review-card h3, .weekly-review-card p { margin: 0; overflow-wrap: anywhere; }
.weekly-review-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); min-width: 0; }
.weekly-review-metric { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: var(--space-2); display: grid; gap: 3px; min-width: 0; }
.weekly-review-metric-label, .weekly-review-metric-detail { color: var(--ink-3); font-size: var(--fs-caption); overflow-wrap: anywhere; }
:is(.weekly-review-sources, .weekly-review-context-sources) { min-width: 0; border-top: 1px solid var(--border-soft); margin-top: 4px; padding-top: 4px; font-size: var(--fs-caption); overflow-wrap: anywhere; }
:is(.weekly-review-sources, .weekly-review-context-sources) summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; text-decoration: underline; text-underline-offset: 2px; }
:is(.weekly-review-sources, .weekly-review-context-sources) summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
:is(.weekly-review-sources, .weekly-review-context-sources) ul { margin: 4px 0 0; padding-inline-start: 1.25rem; }
:is(.weekly-review-sources, .weekly-review-context-sources) li { overflow-wrap: anywhere; }
:is(.weekly-review-sources, .weekly-review-context-sources) p { margin: 4px 0 0; }
.weekly-review-section { border-top: 1px solid var(--border-soft); padding-top: var(--space-3); display: grid; gap: var(--space-2); min-width: 0; }
.weekly-review-disclaimer { color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug); }
.weekly-review-proposal-cta { min-height: var(--tap); width: 100%; min-width: 0; }
@media (max-width: 360px) { .weekly-review-metrics { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Weekly recommendation ---------- */
.weekly-recommendation-view { display: grid; gap: var(--space-2); min-width: 0; max-width: 100%; }
.weekly-recommendation-view > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.weekly-rec-card { border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); display: grid; gap: var(--space-1); min-width: 0; }
.weekly-rec-code { font-weight: var(--fw-semibold); color: var(--ink); overflow-wrap: anywhere; }
.weekly-rec-summary { margin: 0; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.weekly-rec-rationale { margin: 0; color: var(--ink-2); font-size: .86rem; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.weekly-rec-tradeoffs { margin: 0; padding: 0 0 0 var(--space-2); display: grid; gap: 4px; }
.weekly-rec-tradeoffs li { color: var(--ink-2); font-size: .84rem; line-height: var(--lh-snug); overflow-wrap: anywhere; min-width: 0; }
.weekly-rec-confidence { margin: 0; font-size: var(--fs-caption); color: var(--ink-3); overflow-wrap: anywhere; }
.weekly-rec-decision-row { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.weekly-rec-decision-row button { flex: 1 1 auto; min-width: 0; }
.weekly-rec-modification { width: 100%; min-width: 0; box-sizing: border-box; }
.weekly-rec-disclaimer { margin: 0; font-size: var(--fs-caption); color: var(--ink-3); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.weekly-rec-status { margin: 6px 0 10px; font-size: .88rem; overflow-wrap: anywhere; }

/* ---------- Trends overview charts (S6 issue #41; v52 axes/calendar correction) ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.trend-block { min-width: 0; max-width: 100%; }
.trend-block + .trend-block { margin-top: var(--space-4); }
.trend-block h3 { margin: 0 0 8px; font-size: var(--fs-h3); }
.trend-chart { min-width: 0; max-width: 100%; overflow: hidden; display: block; }
.activity-chart { min-width: 0; max-width: 100%; overflow: hidden; }
.trend-svg { width: 100%; height: 150px; max-width: 100%; display: block; }
.trend-line { stroke: var(--accent); stroke-width: 2; fill: none; }
.trend-dot { fill: var(--accent); }
.trend-dot-endpoint { fill: var(--accent); stroke: var(--surface); stroke-width: 1; }
.trend-gridline { stroke: var(--border); stroke-width: 1; }
.trend-tick { stroke: var(--border-strong); stroke-width: 1; }
.trend-axis-label { fill: var(--ink-3); font-size: var(--fs-caption); }
.trend-axis-y { text-anchor: end; dominant-baseline: middle; }
.trend-axis-x { text-anchor: middle; }
.trend-point-label { fill: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-bold); text-anchor: middle; }
.trend-caption { margin: 8px 0 0; color: var(--ink-3); font-size: var(--fs-caption); overflow-wrap: anywhere; }
.trend-empty { margin: 0; color: var(--ink-3); font-size: .95rem; }

/* 12-week training-activity calendar/heatmap (replaces the S6 bars view). */
.calendar-wrap { width: 100%; max-width: 100%; min-width: 0; }
.calendar-months { display: flex; padding-left: 18px; gap: 3px; }
.calendar-month-label { flex: 1 1 0; min-width: 0; font-size: var(--fs-caption); color: var(--ink-3); }
.calendar-body { display: flex; align-items: flex-start; gap: 4px; min-width: 0; }
.calendar-weekdays { display: flex; flex-direction: column; gap: 3px; width: 14px; flex-shrink: 0; }
.calendar-weekday-label { font-size: var(--fs-caption); line-height: 15px; height: 15px; color: var(--ink-3); text-align: center; }
.calendar-grid { display: flex; gap: 3px; flex: 1 1 auto; min-width: 0; }
.calendar-week-col { display: flex; flex-direction: column; gap: 3px; flex: 1 1 0; min-width: 0; max-width: 18px; }
.calendar-cell {
  width: 100%; aspect-ratio: 1 / 1; max-width: 18px; max-height: 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-caption); font-weight: var(--fw-bold); color: var(--ink-3); line-height: 1;
}
.calendar-cell.calendar-level-1 { background: var(--heat-1); border-color: transparent; color: var(--heat-count-ink); }
.calendar-cell.calendar-level-2 { background: var(--heat-2); border-color: transparent; color: var(--heat-count-ink); }
.calendar-cell.calendar-level-3 { background: var(--heat-3); border-color: transparent; color: var(--accent-ink); }
.calendar-cell.calendar-future { background: transparent; border-style: dashed; opacity: .4; }
.calendar-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.calendar-legend-item { display: flex; align-items: center; gap: 3px; font-size: var(--fs-caption); color: var(--ink-3); overflow-wrap: anywhere; }
.calendar-legend-item .calendar-cell { width: 12px; height: 12px; max-width: 12px; max-height: 12px; flex-shrink: 0; }

/* ---------- History ---------- */
.history-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.history-list li { display: grid; gap: 5px; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.history-list li:first-child { border-top: 0; }
.history-list strong { font-weight: var(--fw-semibold); }
.history-list span { color: var(--ink-3); font-size: .9rem; }

/* ---------- Nutrition macro cards ---------- */
.macro-dashboard { display: grid; gap: 10px; margin-top: 16px; }
.macro-card { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px 16px; }
.macro-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.macro-row strong { font-size: 1rem; font-weight: var(--fw-semibold); }
.macro-row span { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .92rem; }
.macro-card.no-target { display: flex; justify-content: space-between; align-items: baseline; }
.macro-card.no-target .macro-row { margin: 0; }
.macro-card.no-target .macro-amount { font-size: 1.05rem; font-weight: var(--fw-bold); color: var(--ink); }
.progress-track { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.quick-copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; margin: 0 0 14px; }
.quick-copy-row p { margin: 0; }
.copy-nutrition-card summary { cursor: pointer; font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.copy-nutrition-card > .muted { margin: 8px 0 14px; }
.copy-nutrition-card .form { margin-bottom: 14px; }
.copy-preview { margin: 12px 0; padding: 13px; border: 1px solid var(--accent-soft-border); border-radius: var(--radius); background: var(--accent-soft-bg); }
.copy-preview-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; color: var(--ink); font-weight: var(--fw-semibold); }
.copy-preview-head span:last-child { text-align: right; }
.copy-preview-list { margin: 8px 0 0; padding-left: 20px; max-height: 190px; overflow-y: auto; }
.copy-preview-list li { margin: 5px 0; overflow-wrap: anywhere; }

/* ---------- Saved meals / templates ---------- */
.saved-meals-card summary { cursor: pointer; font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.saved-meals-card > .muted { margin: 8px 0 14px; }
.saved-meals-card .form { margin-bottom: 14px; }
.saved-meals-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0 8px; }
.inline-check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.inline-check input { width: auto; min-height: 0; }
.saved-meals-list { display: grid; gap: 10px; }
.saved-meal-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px; }
.saved-meal-item.archived { opacity: .62; }
.saved-meal-item > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.saved-meal-item strong { overflow-wrap: anywhere; }
.saved-meal-item span { color: var(--ink-3); font-size: .85rem; overflow-wrap: anywhere; }
.apply-meal-panel { margin-top: 14px; padding: 14px; border: 1px solid var(--accent-soft-border); border-radius: var(--radius); background: var(--accent-soft-bg); }
.apply-meal-head { margin-bottom: 10px; }
.apply-meal-panel .form { margin-bottom: 12px; }

/* ---------- Pantry & shopping (v1: explicit inventory only) ---------- */
.pantry-shopping-card summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.pantry-shopping-counts { font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-pill); padding: 3px 10px; white-space: nowrap; }
.pantry-item-add-details summary, .pantry-preferences-details summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--accent); font-weight: var(--fw-semibold); }
.pantry-item-list { display: grid; gap: 10px; margin: 10px 0 16px; }
.pantry-item-row { min-width: 0; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px; }
.pantry-item-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.pantry-item-row-head strong { overflow-wrap: anywhere; min-width: 0; }
.pantry-item-row-head span { color: var(--ink-3); font-size: .82rem; overflow-wrap: anywhere; }
.pantry-item-notes { margin: 4px 0 0; font-size: .82rem; overflow-wrap: anywhere; }
.pantry-item-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.pantry-item-controls .pantry-adjust-amount { width: 72px; flex: 0 0 auto; min-height: var(--tap); }
.pantry-item-controls button { min-height: var(--tap); padding: 0 12px; flex: 1 1 auto; min-width: 0; }

/* >>> PANTRY_PURCHASE_V75 — reviewed mobile purchase sheet */
.purchase-review-panel {
  background: var(--surface); width: min(100%, 560px); max-width: 100%; max-height: min(88dvh, 760px);
  margin-top: auto; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; overflow: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.purchase-review-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); }
.purchase-review-header h2 { margin: 0; overflow-wrap: anywhere; }
.purchase-review-body, .purchase-options, .purchase-candidates { display: grid; gap: 10px; min-width: 0; }
.purchase-snapshot, .purchase-add-preview, .purchase-candidate { max-width: 100%; min-width: 0; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px; }
.purchase-options { border: 0; padding: 0; margin: 16px 0; }
.purchase-options > label, .purchase-candidate { min-height: var(--tap); display: flex; align-items: center; gap: 10px; }
.purchase-options input[type="radio"] { width: 22px; height: 22px; flex: 0 0 auto; }
.purchase-review-panel button, .purchase-review-panel input { min-height: var(--tap); }
.purchase-review-panel[aria-busy="true"] { cursor: wait; }
/* <<< PANTRY_PURCHASE_V75 */

/* ---------- Recipes (free-form, portion-scaled) ---------- */
.recipes-card summary { cursor: pointer; font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.recipes-card > .muted { margin: 8px 0 14px; }
.recipe-builder { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 14px; }
.recipe-builder .form { margin: 0; }
.recipe-ingredient-search-wrap { display: grid; gap: 6px; font-size: .9rem; color: var(--ink-3); }
.recipe-ingredient-results { max-height: 210px; overflow-y: auto; }
.recipe-ingredient-results:empty { display: none; }
.recipe-ingredient-list { display: grid; gap: 8px; }
.recipe-ingredient-row { display: grid; grid-template-columns: minmax(0, 1fr) 66px 84px 40px; gap: 6px; align-items: center; }
.recipe-ingredient-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.recipe-ingredient-main strong { overflow-wrap: anywhere; font-size: .92rem; }
.recipe-ingredient-main span { font-size: var(--fs-caption); }
.recipe-ingredient-row input, .recipe-ingredient-row select { min-height: 40px; padding: 6px 8px; }
.recipe-ing-remove { min-height: 40px; padding: 0; font-size: 1.2rem; line-height: 1; }
.recipe-builder-totals { display: grid; gap: 4px; }
.recipe-builder-totals:empty { display: none; }
.recipe-builder-actions { display: grid; gap: 8px; }

/* ---------- Recent training timeline ---------- */
/* Flat rows with the standard separator, not cards inside a card. */
.timeline-list { display: grid; gap: 0; margin-top: 16px; }
.timeline-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: none; border: 0; border-radius: 0; padding: 14px 0; }
.timeline-item + .timeline-item { border-top: 1px solid var(--border-soft); }
.timeline-item strong { font-weight: var(--fw-semibold); }
.timeline-item span { display: block; color: var(--ink-3); font-size: .88rem; margin-top: 3px; }

/* ---------- Workout summary ---------- */
.summary-card { border: 0; border-radius: var(--radius); background: var(--accent-soft-bg); padding: 14px; margin-top: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.summary-grid article { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.summary-grid span { display: block; color: var(--ink-3); font-size: var(--fs-caption); letter-spacing: 0; margin-bottom: 4px; }
.summary-grid strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

/* ---------- Strong-style workout card ----------
   Was its own light-surface --w-* island; now consumes the shared semantic
   tokens like every other card, so it follows the app's light/dark theme
   instead of forcing a fixed light surface. */
.workout-card { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--shadow-sm); overflow: hidden; }
.strong-workout-card { max-width: 560px; margin-inline: auto; width: 100%; }
.workout-card p, .workout-card .muted, .workout-card label { color: var(--ink-2); }
.recent-card { background: var(--surface); color: var(--ink); }
.recent-card .muted { color: var(--ink-3); }

.strong-topbar {
  position: sticky; top: 8px; z-index: 35;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  margin: -4px -4px 14px; padding: 8px 8px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.timer-stack { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.top-icon-button { width: 44px; min-height: 44px; padding: 0; background: var(--surface-2); color: var(--ink); border-radius: var(--radius); border: 1px solid var(--border); font-size: 1.1rem; }
.elapsed-wrap { display: flex; flex-direction: column; gap: 1px; text-align: center; }
.elapsed-label { font-size: var(--fs-caption); letter-spacing: 0; color: var(--ink-3); font-weight: var(--fw-bold); }
.elapsed-wrap strong { font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.finish-green { background: var(--success); color: var(--success-ink); border-radius: var(--radius); padding: 12px 22px; }
.finish-green:disabled { opacity: .42; box-shadow: none; cursor: not-allowed; }

.strong-workout-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.strong-workout-head h2 { color: var(--ink); font-size: var(--fs-h2); margin: 0 0 4px; letter-spacing: var(--ls-h2); }
.workout-meta { margin: 2px 0; font-size: .95rem; color: var(--ink-2); }
.workout-card .compact { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }

.workout-unit-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-3) 0; color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-semibold); }
.workout-unit-toggle { display: inline-grid; grid-template-columns: repeat(2, minmax(48px, 1fr)); gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.workout-unit-toggle button { min-width: 48px; min-height: 44px; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); box-shadow: none; }
#workouts-panel .template-editor-card > summary { padding-inline: 16px; }
.workout-unit-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.rest-pill { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 6px 11px; margin: 0; }
.rest-pill span { font-size: var(--fs-caption); letter-spacing: 0; color: var(--ink-2); font-weight: var(--fw-bold); }
.rest-pill strong { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 1rem; }

.template-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; margin: 0; scrollbar-width: none; max-width: 100%; }
.template-strip::-webkit-scrollbar { display: none; }
.template-chip { flex: 0 0 auto; background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 9px 16px; font-weight: var(--fw-semibold); font-size: .9rem; min-height: 40px; width: auto; }
.template-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.workout-start-panel { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; background: var(--surface); display: grid; gap: 10px; }
.workout-start-panel p { margin: 0; }

/* Saved-draft Resume/Discard prompt shown on the clean idle workout screen. */
.workout-resume-prompt { display: grid; gap: 12px; margin: 0 0 12px; padding: 14px; border: 1px solid var(--accent-soft-border); border-radius: var(--radius-lg); background: var(--accent-soft-bg); }
.workout-resume-prompt .resume-copy { display: grid; gap: 4px; }
.workout-resume-prompt h3 { color: var(--accent); margin: 0; font-size: .82rem; font-weight: var(--fw-semibold); letter-spacing: 0; }
.workout-resume-prompt .resume-summary { margin: 0; color: var(--ink); font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.workout-resume-prompt .resume-date { margin: 0; color: var(--ink-2); font-size: .85rem; }
.workout-resume-prompt .button-row button { flex: 1 1 40%; min-height: var(--tap); }
.workout-resume-prompt .button-row .secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }

.exercise-suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.exercise-suggestions::-webkit-scrollbar { display: none; }
.quick-exercise { flex: 0 0 auto; width: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 9px 13px; min-height: 40px; font-size: .86rem; }
.quick-exercise span { color: var(--ink-2); font-size: var(--fs-caption); margin-left: 4px; }
.add-exercises-wide, .cancel-workout-wide {
  width: 100%; border-radius: var(--radius); padding: 12px 14px; min-height: 48px; font-weight: var(--fw-bold);
}
.add-exercises-wide { background: var(--accent-soft-bg); color: var(--accent); border: 1px solid var(--accent-soft-border); }
.cancel-workout-wide { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-bg); margin-top: 2px; }

.strong-exercises { display: grid; gap: 22px; margin-top: 6px; min-width: 0; }
.exercise-block { display: grid; gap: 8px; }
.exercise-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exercise-head h3 { color: var(--accent); font-size: 1.1rem; margin: 0; font-weight: var(--fw-bold); }

.strong-table-head, .strong-set-line { display: grid; grid-template-columns: 44px minmax(72px, 1fr) 1fr 1fr 48px 38px; gap: 8px; align-items: center; }
.strong-table-head { color: var(--ink-2); font-weight: var(--fw-bold); font-size: var(--fs-caption); letter-spacing: 0; padding: 0 2px 2px; }
.strong-set-line { background: transparent; border: 0; padding: 0; }
.set-index-pill, .strong-set-line input, .done-set, .remove-set { border: 0; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-weight: var(--fw-bold); text-align: center; padding: 10px 6px; min-height: var(--tap); font-size: 16px; }
.set-index-pill { color: var(--ink-2); }
.previous-value { color: var(--ink-3); font-weight: var(--fw-semibold); text-align: center; font-size: .9rem; }
.done-set { color: var(--success); padding: 0; font-size: 1.1rem; display: inline-flex; align-items: center; justify-content: center; }
.remove-set { color: var(--danger); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.set-done .done-set { background: var(--success); color: var(--success-ink); }
.set-done input.set-weight, .set-done input.set-reps { background: var(--success-bg); }
.workout-card button.secondary.add-set-wide { width: 100%; background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px; font-weight: var(--fw-bold); }
.workout-card button.secondary.add-set-wide:hover { background: var(--surface-3); }

.template-editor-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--surface); color: var(--ink); margin-top: 2px; }
.template-editor-card summary { font-weight: var(--fw-bold); cursor: pointer; color: var(--ink); min-height: var(--tap); display: flex; align-items: center; }

/* Share the incumbent desktop cue with native phone disclosures. */
#workouts-panel .template-editor-card summary {
  justify-content: space-between;
  gap: 8px;
}
#workouts-panel .template-editor-card summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: var(--fw-regular);
  color: var(--ink-2);
}
#workouts-panel .template-editor-card[open] summary::after { content: '−'; }
.template-editor-card .muted { color: var(--ink-2); }
.template-editor-card textarea { background: var(--surface-2); color: var(--ink); border-color: var(--border); margin-top: 8px; }
.template-editor-card .button-row button { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.workout-card .primary-action { background: var(--accent); color: var(--accent-ink); }
.template-builder { display: grid; gap: 8px; margin: 12px 0; }
.template-empty { background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.template-bubble {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto auto 36px; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; box-shadow: var(--shadow-sm); touch-action: manipulation;
}
/* Native touch scrolling cancels handle drags. Use the accessible arrow controls
   on coarse-pointer devices; keep working mouse drag on fine-pointer desktops. */
@media (pointer: coarse) {
  #workouts-panel .template-bubble .drag-handle { display: none; }
}
@media (pointer: coarse) and (max-width: 430px) {
  #workouts-panel .template-bubble-text { grid-column: 1 / 3; }
}
.template-bubble.dragging { opacity: .55; transform: scale(.985); }
.template-bubble.drag-over { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.drag-handle, .template-remove { width: 36px; height: 36px; min-height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.drag-handle { background: var(--surface-2); color: var(--ink-2); cursor: grab; border-radius: var(--radius-sm); }
.template-edit { width: auto; min-height: 34px; padding: 6px 10px; border-radius: var(--radius-pill); background: var(--accent-soft-bg); color: var(--accent); font-size: var(--fs-caption); }
.template-remove { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-pill); font-size: 1.2rem; line-height: 1; }
.template-bubble-text { min-width: 0; }
.template-bubble-text strong { display: block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-bubble-text span { display: block; color: var(--ink-2); font-size: .82rem; margin-top: 1px; }
.template-set-stepper { display: inline-grid; grid-template-columns: 32px 28px 32px; align-items: center; background: var(--surface-2); border-radius: var(--radius-pill); padding: 3px; }
.template-set-stepper button { width: 32px; min-height: 32px; height: 32px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: none; }
.template-set-stepper span { color: var(--ink); font-weight: var(--fw-bold); text-align: center; font-variant-numeric: tabular-nums; }
.template-reorder-controls { display: inline-grid; grid-template-columns: 30px 30px; gap: 3px; background: var(--surface-2); border-radius: var(--radius-pill); padding: 3px; }
.template-reorder-controls button { width: 30px; height: 30px; min-height: 30px; padding: 0; background: var(--surface); color: var(--ink-2); box-shadow: none; }

/* ---------- Exercise picker modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--scrim);
}
.exercise-picker-sheet {
  width: min(560px, 100%); max-height: min(760px, 88dvh); display: grid; grid-template-rows: auto auto auto auto 1fr;
  background: var(--surface); color: var(--ink); border-radius: var(--radius-sheet); overflow: hidden; box-shadow: var(--shadow-md);
}
.exercise-picker-header { display: grid; grid-template-columns: 44px auto 1fr auto; align-items: center; gap: 4px; padding: 12px 14px 8px; }
.exercise-picker-header h2 { margin: 0; text-align: center; color: var(--ink-2); font-size: 1rem; font-weight: var(--fw-bold); }
.sheet-close, .sheet-link { width: auto; min-height: var(--tap); padding: 6px 10px; background: transparent; color: var(--accent); box-shadow: none; overflow-wrap: anywhere; }
.sheet-close { width: var(--tap); min-width: var(--tap); border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink); font-size: 1.5rem; line-height: 1; }
.sheet-link.muted-action { color: var(--ink-3); }
.exercise-search-wrap { margin: 0 20px 12px; display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 4px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0 10px; color: var(--ink-3); }
.exercise-search-wrap input { background: transparent; border: 0; box-shadow: none; color: var(--ink); padding-inline: 4px; }
.exercise-search-wrap input:focus { box-shadow: none; }
.new-exercise-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 0 20px 12px; }
.new-exercise-form > label, .new-exercise-form > .message { grid-column: 1 / -1; }
.new-exercise-form > label { color: var(--ink-2); font-size: .86rem; font-weight: var(--fw-semibold); }
.new-exercise-form > .message:empty { display: none; }
.new-exercise-form input { background: var(--surface); border-color: var(--border); color: var(--ink); }
.picker-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 78px; gap: 10px; padding: 0 20px 12px; }
.filter-pill { width: 100%; min-height: 40px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-size: .86rem; }
.filter-pill.icon-only { font-size: .82rem; white-space: nowrap; }
#sort-exercises { overflow: hidden; text-overflow: ellipsis; }
.exercise-picker-list { overflow: auto; padding: 0 20px 18px; }
.picker-letter { color: var(--ink-2); font-weight: var(--fw-bold); padding: 12px 6px 6px; border-bottom: 1px solid var(--border); }
.exercise-picker-row { width: 100%; display: grid; grid-template-columns: 54px 1fr 42px; align-items: center; gap: 10px; border-radius: 0; background: var(--surface); color: var(--ink); padding: 10px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.exercise-picker-row.selected { background: var(--accent-soft-bg); }
.exercise-thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: var(--fw-bold); }
.exercise-info { min-width: 0; }
.exercise-info strong, .exercise-info small { display: block; }
.exercise-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
.exercise-info small { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.exercise-row-action { justify-self: end; min-width: 34px; height: 34px; border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft-bg); color: var(--accent); font-weight: var(--fw-bold); }
.picker-empty { display: grid; gap: 10px; justify-items: stretch; text-align: center; padding: 24px 0; }

/* ---------- Strong-style workout keypad ---------- */
.workout-keypad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  display: grid; grid-template-columns: minmax(0, 1fr) 124px; gap: 12px;
  padding: 16px max(18px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-md);
  border-top: 1px solid var(--border);
}
.keypad-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.keypad-actions { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
.workout-keypad button { min-height: 54px; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-size: 1.35rem; box-shadow: none; }
.workout-keypad button:active { background: var(--surface-2); }
.keypad-actions button { background: var(--surface-2); font-size: 1.25rem; }
.keypad-actions .keypad-next { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); font-size: 1.05rem; }
.workout-number:focus { outline: 0; box-shadow: inset 0 0 0 2px var(--focus); }

/* ---------- Cronometer-style nutrition diary ---------- */
.nutrition-date-picker { margin-top: 12px; max-width: 220px; }
.nutrition-diary { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.diary-total { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); }
.diary-total span, .meal-group header span, .food-entry span, .food-entry small { color: var(--ink-3); }
.diary-total strong { font-variant-numeric: tabular-nums; }
.meal-group { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.meal-group header { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-soft); }
.meal-group h3 { margin: 0; }
.food-entry { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border-soft); }
.food-entry:first-of-type { border-top: 0; }
.food-entry strong, .food-entry span, .food-entry small { display: block; }
.food-entry small { margin-top: 2px; font-size: .82rem; }
.manual-nutrition-card { margin-top: 16px; border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.manual-nutrition-card summary { cursor: pointer; font-weight: var(--fw-bold); margin-bottom: 10px; }
select {
  width: 100%; border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--ink); padding: 12px 14px;
  font: inherit; font-size: 16px; min-height: var(--tap);
}

/* ---------- Sheet & modal control contrast ----------
   Sheets now share the app's semantic surface/ink tokens instead of a
   separately-themed light island, so .secondary/.danger/.message/placeholder
   controls stay legible (WCAG AA) automatically in both light and dark. */
.food-sheet .secondary, .exercise-picker-sheet .secondary, .readiness-sheet .secondary {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border);
}
.food-sheet .danger, .exercise-picker-sheet .danger, .readiness-sheet .danger {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger-bg);
}
.food-sheet .message.ok, .exercise-picker-sheet .message.ok, .readiness-sheet .message.ok { color: var(--success); }
.food-sheet .message.error, .exercise-picker-sheet .message.error, .readiness-sheet .message.error { color: var(--danger); }
.food-sheet input::placeholder, .food-sheet textarea::placeholder,
.exercise-picker-sheet input::placeholder,
.readiness-sheet input::placeholder, .readiness-sheet textarea::placeholder { color: var(--ink-2); opacity: 1; }
.food-sheet :focus-visible, .exercise-picker-sheet :focus-visible { outline-color: var(--focus); }
.readiness-sheet :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Start camera is the primary scan action; give it a filled accent that
   meets AA on the sheet surface in both themes. Stop camera keeps the
   legible neutral .secondary treatment above. Both keep the 44px touch
   target (the .compact size would otherwise shrink them to 40). */
#start-scan { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); font-weight: var(--fw-bold); }
.scan-controls .secondary { min-height: var(--tap); }

/* ---------- Workout polish ---------- */
body.keypad-open .strong-workout-form { padding-bottom: 190px; }
.previous-value { border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-3); font-weight: var(--fw-bold); text-align: center; font-size: .9rem; padding: 8px 2px; min-height: 38px; }
.previous-value:not(:empty):active { background: var(--accent-soft-bg); color: var(--accent); }
.rest-pill button { min-height: 30px; width: auto; padding: 3px 7px; border-radius: var(--radius-pill); background: var(--surface); color: var(--ink-2); border: 1px solid var(--border); font-size: var(--fs-caption); box-shadow: none; }
.body-metric-history { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.body-metric-history h3 { margin-bottom: 2px; }
.body-metric-history > p { margin: 0 0 10px; }

/* ---------- Mobile: bottom nav + tighter layout ---------- */
@media (max-width: 680px) {
  #overview-panel :is(button, a, input, select, textarea, summary, [tabindex]) {
    scroll-margin-block: 8px calc(var(--mobile-nav-height) + 48px);
  }

  .shell { width: min(100% - 2 * var(--page-gutter), 760px); padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: calc(var(--mobile-nav-height) + 48px); }
  .hero { margin: 4px 0 12px; }
  .hero p:not(.eyebrow) { display: none; }
  body.signed-in .hero h1 { display: none; }
  body.signed-in .hero .eyebrow { display: none; }
  body.signed-in .hero { margin: 0; }

  /* Five equal cells while they fit, wrapping when they cannot -- which is
     what the owner's enlarged text setting makes happen (v105). A grid of
     five fixed tracks would truncate instead. */
  .tab-nav {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; border-radius: 0;
    border: 0; border-top: 1px solid var(--border);
    padding: 0 max(var(--space-2), env(safe-area-inset-left)) env(safe-area-inset-bottom) max(var(--space-2), env(safe-area-inset-right));
  }
  .tab-button { flex: 1 1 max-content; width: auto; min-width: 0; min-height: 56px; justify-content: center; border-radius: 0; gap: 2px; padding: var(--space-1) 2px; }
  .tab-icon { width: 24px; height: 24px; }
  body.software-keyboard-open .tab-nav { display: none; }

  .two-col, .exercise-adder { grid-template-columns: minmax(0, 1fr); }
  button { width: 100%; }
  .compact, .template-chip, .finish-green, .mini-actions button, .icon-btn, .overview-actions button, .quick-exercise, .done-set, .remove-set { width: auto; }
  .overview-actions .icon-btn, .icon-btn { width: var(--tap); }
  .quick-copy-row { grid-template-columns: 1fr; }
  .quick-copy-row .compact { width: 100%; }
  .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .overview-actions { justify-content: flex-end; }

  .strong-topbar { top: 6px; grid-template-columns: 44px minmax(0, 1fr) auto; margin-inline: -6px; }
  .finish-green { padding-inline: 16px; }
  .rest-pill span { display: none; }
  .strong-table-head, .strong-set-line { grid-template-columns: 34px minmax(44px, 1fr) 1fr 1fr 42px 34px; gap: 5px; }
  .template-bubble { grid-template-columns: 32px minmax(0, 1fr) 68px 42px 104px 32px; gap: 5px; padding: 7px; }
  .drag-handle, .template-remove { width: 32px; height: 32px; min-height: 32px; }
  .template-set-stepper { grid-template-columns: 30px 24px 30px; }
  .template-set-stepper button { width: 30px; height: 30px; min-height: 30px; }
  .exercise-picker-sheet { max-height: 86dvh; border-radius: var(--radius-sheet); }
  .exercise-picker-header { padding-inline: 12px; }
  .exercise-search-wrap, .picker-filters, .new-exercise-form { margin-left: 14px; margin-right: 14px; padding-left: 0; padding-right: 0; }
  .exercise-picker-list { padding-left: 14px; padding-right: 14px; }
  .elapsed-wrap strong { font-size: 1.4rem; }
}

@media (min-width: 390px) and (max-width: 480px) {
  .shell { width: min(100% - 2 * var(--page-gutter), 440px); }
}
/* A 320px screen cannot spend 32px on gutters: the Today rows need their
   150px copy column (browser_smoke). Under 361px the inset is --space-3. */
@media (max-width: 360px) {
  .shell { width: min(100% - 2 * var(--space-3), 760px); }
}

/* ---------- Reduced motion (the one global block) ----------
   The five per-section copies this replaced (#nutrition-panel, #overview-panel
   and the two meal-group summaries) said less than this does and had to be
   kept in sync by hand. The count-up pseudo element is swapped for the real
   value here, so the owner still reads the final number. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .count::after { display: none; }
  .count > b, .is-entering .count > b { color: inherit !important; }
}

/* ---------- Food capture: actions, finder & review sheets ---------- */
.capture-action {
  display: grid; gap: 3px; justify-items: start; text-align: left; padding: 14px;
  min-height: 88px; border-radius: var(--radius); background: var(--accent-soft-bg);
  border: 1px solid var(--accent-soft-border); color: var(--ink); box-shadow: none;
}
.capture-action:active { transform: scale(.99); }
.capture-action-solo { width: 100%; margin: 4px 0 0; }
.capture-icon { width: 26px; height: 26px; color: var(--accent); }
.capture-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.capture-label { font-weight: var(--fw-bold); font-size: var(--fs-body); }
.capture-sub { color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-medium); }

.food-sheet {
  width: min(560px, 100%); max-height: min(820px, 90dvh); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-radius: var(--radius-sheet); overflow: hidden; box-shadow: var(--shadow-md);
}
.food-sheet-header { flex: 0 0 auto; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 6px; padding: 12px 16px 8px; }
.food-sheet-header h2 { margin: 0; text-align: center; color: var(--ink); font-size: 1.05rem; font-weight: var(--fw-bold); }
#food-review-modal #confirm-food-review { display: none; }
.review-commit-context { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 2px 8px; padding: 4px 16px 10px; border-bottom: 1px solid var(--border); color: var(--ink-2); min-width: 0; max-height: min(30dvh, 180px); overflow-y: auto; overflow-wrap: anywhere; }
.review-commit-context strong { flex-basis: 100%; color: var(--ink); }
#personal-food-save-confirmation { flex-basis: 100%; margin: 4px 0 0; }
.review-commit-bar { flex: 0 0 auto; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.review-commit-bar .primary-action { width: 100%; min-height: var(--tap); margin: 0; }
.food-sheet:has(#review-add-button.hidden) .review-commit-bar { display: none; }
.entry-correction-sheet { max-height: calc(100dvh - max(36px, env(safe-area-inset-top)) - max(36px, env(safe-area-inset-bottom))); }
.entry-correction-scroll {
  flex: 1 1 auto; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden;
  padding: 4px 16px 12px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; gap: 12px;
}
.entry-correction-scroll > *, #entry-correction-form, #entry-correction-fields,
#entry-edit-controls, #entry-portion-controls, #entry-replacement-controls { min-width: 0; max-width: 100%; }
#entry-correction-form, #entry-correction-fields, #entry-edit-controls,
#entry-portion-controls, #entry-replacement-controls { display: grid; gap: 12px; }
#entry-correction-fields { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
#entry-correction-fields legend { width: 100%; margin: 0 0 2px; padding: 0; color: var(--ink); font-weight: var(--fw-bold); }
.entry-correction-actions {
  flex: 0 0 auto; display: grid; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface); box-shadow: 0 -8px 24px rgba(0,0,0,.08);
}
.entry-correction-actions .primary-action { margin: 0; }
.sheet-header-spacer { width: 44px; }
.food-sheet label { color: var(--ink-2); }
.food-sheet input, .food-sheet select { background: var(--surface); border-color: var(--border-input); color: var(--ink); }
.food-sheet input:focus, .food-sheet select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.food-sheet .muted { color: var(--ink-2); }

.finder-mode-toggle { flex: 0 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 4px 16px 10px; padding: 5px; background: var(--surface-2); border-radius: var(--radius); }
.mode-tab { min-width: 0; min-height: var(--tap); padding: 8px 4px; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); font-weight: var(--fw-bold); line-height: 1.2; box-shadow: none; }
.mode-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.readiness-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border-soft); border-left: 3px solid var(--accent); border-radius: var(--radius-lg); background: var(--surface-2); }
.readiness-card p { margin: 3px 0 0; overflow-wrap: anywhere; }
/* One quiet line for the exact-date pain answer. Factual weight, not an alert
   colour: the card states the answer and never interprets it. */
.readiness-pain { color: var(--ink-3); font-size: var(--fs-label); }
.readiness-pain[data-pain="present"] { color: var(--ink); font-weight: var(--fw-semibold); }
.readiness-sheet { width: min(100%, 430px); max-width: 430px; max-height: 90dvh; overflow-y: auto; background: var(--surface); color: var(--ink); border-radius: var(--radius-sheet); padding: 16px; }
.readiness-sheet form { grid-template-columns: minmax(0,1fr); }
.readiness-sheet form > * { min-width: 0; max-width: 100%; }
.readiness-sheet input, .readiness-sheet select, .readiness-sheet textarea { background: var(--surface); border-color: var(--border-input); color: var(--ink); }
.readiness-sheet label, .readiness-sheet .readiness-scale legend, .readiness-sheet .modal-head h2 { color: var(--ink); }
.readiness-sheet .modal-head { display: grid; grid-template-columns: minmax(0,1fr) 44px; gap: 8px; align-items: center; }
.readiness-sheet .modal-head h2 { margin: 0; }
#save-readiness { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.readiness-scale { display: grid; grid-template-columns: repeat(5,minmax(44px,1fr)); gap: 6px; margin: 0; padding: 0; border: 0; }
.readiness-scale legend { width: 100%; margin-bottom: 6px; font-weight: var(--fw-bold); }
.readiness-scale legend span { float: right; color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-medium); }
.readiness-scale button { min-width: 44px; min-height: var(--tap); padding: 0; background: var(--surface-2); color: var(--ink); box-shadow: none; }
.readiness-scale button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.finder-mode { flex: 1 1 auto; min-height: 0; padding: 0 16px 18px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.finder-hint { font-size: .82rem; margin: 8px 2px; }
.food-search-wrap { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 4px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0 10px; color: var(--ink-3); }
.food-search-wrap input { background: transparent; border: 0; box-shadow: none; color: var(--ink); padding-inline: 4px; }
.food-search-wrap input:focus { box-shadow: none; }
/* The native `input[type=search]` clear control is the only chromatic accent
   left on the phone: Chromium paints its own × in the UA accent blue (visual
   review p19, designer #7). Replace it with the same glyph drawn from an ink
   token, so the one monochrome palette holds and the affordance survives. */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; cursor: pointer;
  background-image: linear-gradient(var(--ink-3), var(--ink-3)), linear-gradient(var(--ink-3), var(--ink-3));
  background-size: 2px 15px, 15px 2px;
  background-position: center;
  background-repeat: no-repeat;
  transform: rotate(45deg);
}
input[type="search"]::-webkit-search-cancel-button:hover {
  background-image: linear-gradient(var(--ink), var(--ink)), linear-gradient(var(--ink), var(--ink));
}
.food-results { display: grid; gap: 8px; margin-top: 4px; }
.finder-meal-label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin-top: 10px; font-weight: var(--fw-bold); }
.finder-meal-label select { min-height: 44px; }
.food-result-section { display: grid; gap: 8px; }
.food-result-section h3 { margin: 10px 2px 0; font-size: .9rem; color: var(--ink-2); }
.food-result-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 6px; align-items: stretch; }
.food-result { display: grid; gap: 3px; text-align: left; justify-items: start; width: 100%; min-height: var(--tap); padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); color: var(--ink); box-shadow: none; }
.favorite-toggle { min-width: 48px; min-height: 48px; padding: 0; border-radius: var(--radius); background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); color: var(--accent); box-shadow: none; font-size: 1.5rem; }
.food-result:active { background: var(--accent-soft-bg); }
.food-result-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; max-width: 100%; font-size: .98rem; }
.food-result-main strong { min-width: 0; overflow-wrap: anywhere; }
.food-result-sub { color: var(--ink-2); font-size: .82rem; font-weight: var(--fw-medium); }

.scanner-stage { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: var(--media-stage); aspect-ratio: 4 / 3; margin-bottom: 10px; }
#scanner-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-reticle { position: absolute; inset: 18% 12%; border: 2px solid var(--media-reticle); border-radius: var(--radius-sm); box-shadow: 0 0 0 100vmax rgba(0,0,0,.28); }
.scan-controls { display: flex; gap: 8px; justify-content: center; }
.label-photo-picker { display: grid; gap: 8px; min-width: 0; }
.label-photo-picker input { width: 100%; min-width: 0; }
/* The photo pickers inherit the shared input box, but the UA's own button
   inside it stayed grey and system-styled: a bare "Choose File" next to
   "Photo analysis is off." read as a half-built screen (visual review p29).
   Only the button is dressed; the input keeps its 16px floor and 44px box. */
:is(.label-photo-picker, .plate-photo-picker) input[type=file] { padding: 6px 8px; }
:is(.label-photo-picker, .plate-photo-picker) input[type=file]::file-selector-button {
  min-height: 30px; margin-inline-end: 10px; padding: 4px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: .9rem; font-weight: var(--fw-semibold); cursor: pointer;
}
.label-preview-canvas { display: block; width: auto; max-width: 100%; max-height: min(42vh, 420px); margin: 10px auto; border: 1px solid var(--border); border-radius: var(--radius); }
.label-photo-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.label-photo-actions button { min-width: 0; min-height: var(--tap); }
@media (max-width: 360px) {
  .label-photo-actions, .label-transcription-controls { grid-template-columns: minmax(0, 1fr); }
}

/* Plate photo reference (issue #25) — a collapsed one-line disclosure inside
   Search so the four-mode selector above it is untouched. Semantic tokens only,
   so light/dark parity comes from the one theme block. */
.plate-reference { margin: 10px 0 4px; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.plate-reference-summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  min-height: var(--tap); min-width: 0; padding: 6px 12px; cursor: pointer;
  color: var(--accent); font-weight: var(--fw-semibold); font-size: .86rem;
  line-height: var(--lh-snug); list-style: none;
}
.plate-reference-summary::-webkit-details-marker { display: none; }
.plate-reference-badge {
  min-width: 0; padding: 2px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); overflow-wrap: anywhere;
}
.plate-reference-body { display: grid; gap: 8px; min-width: 0; padding: 0 12px 12px; }
.plate-reference-body > * { min-width: 0; max-width: 100%; }
.plate-photo-picker { display: grid; gap: 8px; min-width: 0; }
.plate-photo-picker input { width: 100%; min-width: 0; }
.plate-preview-canvas {
  display: block; width: auto; max-width: 100%; max-height: min(38vh, 360px);
  margin: 4px auto; border: 1px solid var(--border); border-radius: var(--radius);
}
.plate-estimate-note { display: grid; gap: 8px; min-width: 0; }
.plate-estimate-note textarea { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; resize: vertical; }
.plate-photo-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.plate-photo-actions button { min-width: 0; min-height: var(--tap); }
.barcode-manual-form { display: grid; gap: 10px; margin-top: 10px; }
.barcode-manual-form label { color: var(--ink-2); font-weight: var(--fw-semibold); }
#scan-add-custom { display: block; width: 100%; text-align: center; margin-top: 8px; }

.review-body { flex: 1 1 auto; min-height: 0; padding: 4px 16px 18px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; min-width: 0; max-width: 100%; display: grid; grid-auto-rows: max-content; align-content: start; gap: 12px; }
.review-body > * { min-width: 0; max-width: 100%; }
.review-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.review-heading strong { font-size: 1.1rem; }
.source-badge { flex: 0 0 auto; white-space: nowrap; font-size: var(--fs-caption); font-weight: var(--fw-bold); letter-spacing: 0; padding: 3px 8px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink-2); }
.source-badge.source-off { background: var(--success-bg); color: var(--success); }
.source-badge.source-usda { background: var(--surface-3); color: var(--ink-2); }
.source-badge.source-cnf { background: var(--accent-soft-bg); color: var(--accent); }
.source-badge.source-user { background: var(--accent-soft-bg); color: var(--accent); }
.cnf-section { border-top: 1px solid var(--border-soft); padding-top: 8px; min-width: 0; }
.cnf-result-row { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.cnf-result-row .food-result-main, .cnf-result-row .food-result-sub { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.cnf-attribution { color: var(--ink-2); font-size: var(--fs-caption); line-height: 1.45; margin: 8px 2px 2px; overflow-wrap: anywhere; }
.cnf-attribution a { color: var(--accent); }
.cnf-limitation { margin: 2px 0; padding: 10px 12px; border: 1px solid var(--danger-bg); border-radius: var(--radius-sm); background: var(--danger-bg); color: var(--danger); font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.review-cnf-fields { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.review-cnf-fields > * { min-width: 0; max-width: 100%; }
.review-cnf-fields p { margin: 0; overflow-wrap: anywhere; }
.review-cnf-fields select { width: 100%; min-height: var(--tap); }
.usda-fallback { margin-top: 10px; }
.usda-section { border-top: 1px dashed var(--border); padding-top: 8px; }
.usda-attribution { color: var(--ink-2); font-size: var(--fs-caption); margin: 8px 2px 2px; }
.review-custom-fields { display: grid; gap: 10px; }
#personal-food-original { margin: 8px 0; font-size: .875rem; }
#personal-food-original summary { cursor: pointer; min-height: 44px; }
#personal-food-source { max-height: 180px; overflow: auto; overflow-wrap: anywhere; }
#personal-food-source pre { white-space: pre-wrap; font: inherit; }
#personal-food-changes { overflow-wrap: anywhere; max-height: 100px; overflow: auto; }
.review-edit-food { width: 100%; min-height: 44px; }
.review-notes-details > summary { display: none; }
.review-notes-details[open] > #review-notes-field { display: grid; gap: 6px; }
.review-edit-actions { flex: 0 0 auto; display: grid; grid-template-columns: min-content minmax(0, 1fr); gap: 10px; padding: 8px 16px max(8px, env(safe-area-inset-bottom)); background: var(--surface); }
.review-per100 .review-nutrient-value, .review-per100 .review-nutrient-explanation { display: block; overflow-wrap: anywhere; }
.review-per100 .review-nutrient-explanation { margin-top: 4px; }
.review-edit-actions button { min-width: 44px; min-height: 48px; margin: 0; padding: 8px 10px; line-height: 1.2; white-space: normal; overflow-wrap: break-word; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.review-per100 { width: 100%; table-layout: fixed; border-collapse: collapse; }
.review-per100 caption { text-align: left; color: var(--ink-2); font-size: var(--fs-caption); padding-bottom: 6px; }
.review-per100 th, .review-per100 td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.review-per100 td { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.review-per100 th { color: var(--ink-2); font-weight: var(--fw-semibold); }
.review-catalog-details { min-width: 0; border-top: 1px solid var(--border); padding-top: 8px; }
.review-catalog-details summary { color: var(--ink-2); cursor: pointer; font-weight: var(--fw-bold); min-height: 44px; display: flex; align-items: center; }
.review-catalog-details[open] { display: grid; gap: 10px; }
.review-facts-body { display: grid; gap: var(--space-1); min-width: 0; }
.review-facts-body:empty { display: none; }
.review-facts-body .nutrient-status { color: var(--ink-2); font-size: var(--fs-caption); }
.review-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.review-totals { border-radius: var(--radius); background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); padding: 12px; display: grid; gap: 10px; }
.review-totals, .totals-grid, .total-pill { min-width: 0; max-width: 100%; }
.totals-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--ink-2); }
.totals-head strong { color: var(--ink); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.totals-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.total-pill { display: grid; gap: 1px; padding: 6px 4px; border-radius: var(--radius-sm); background: var(--surface); text-align: center; }
.total-pill span { color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-semibold); }
.total-pill strong { font-size: .82rem; font-variant-numeric: tabular-nums; }
#review-add-button { background: var(--accent); color: var(--accent-ink); }
.catalog-add-review #close-food-review { padding: 4px 0; flex: 0 0 var(--tap); }
.catalog-add-review #review-totals p { margin: 0; overflow-wrap: anywhere; color: var(--ink-2); }
.catalog-add-review .review-notes-details { min-width: 0; border-top: 1px solid var(--border); }
.catalog-add-review .review-notes-details > summary { color: var(--ink-2); cursor: pointer; font-weight: var(--fw-bold); min-height: 44px; display: flex; align-items: center; }
.catalog-add-review .review-notes-details[open] { display: grid; gap: 8px; }
.catalog-add-review .review-edit-food { justify-self: start; width: auto; }
.catalog-add-review .review-catalog-details { padding-top: 0; }
.catalog-add-review .review-commit-context { max-height: none; overflow-y: visible; }
.catalog-add-review .review-body { grid-auto-rows: max-content; align-content: start; }
.catalog-add-review .food-sheet-header { display: flex; flex-wrap: wrap; }
.catalog-add-review .food-sheet-header h2 { flex: 1 1 6em; }
.catalog-add-review .sheet-link { flex: 0 0 auto; margin-left: auto; overflow-wrap: normal; }

@media (max-width: 680px) {
  .food-sheet { max-height: 90dvh; border-radius: var(--radius-sheet); }
  .review-controls.two-col { grid-template-columns: minmax(0, 1fr); }
  .totals-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Recommendation follow-through card (issue #29, v58).
   Observation only: it reports logged sessions against the recorded target and
   what the user confirmed. It never styles a verdict about whether the
   recommendation worked. */
.followthrough-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-4);
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.followthrough-heading {
  margin: 0;
  font-size: 1rem;
}

.followthrough-window,
.followthrough-observed,
.followthrough-pending,
.followthrough-inapplicable,
.followthrough-recorded,
.followthrough-recorded-note,
.followthrough-question {
  margin: 0;
}

.followthrough-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.followthrough-choice {
  min-height: 44px;
  flex: 1 1 45%;
  min-width: 0;
}

.followthrough-choice[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.followthrough-note {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
}

.followthrough-submit {
  min-height: 44px;
}

.followthrough-confirm {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.followthrough-confirm[hidden] {
  display: none;
}

.followthrough-confirm-action {
  min-height: 44px;
}

/* ---------- Current split audit (v60) ---------- */
.current-split-audit-status { margin: 6px 0 10px; overflow-wrap: anywhere; }
.current-split-audit-view,
.current-split-card,
.current-split-exercises,
.current-split-progression { min-width: 0; }
.current-split-card { display: grid; gap: var(--space-3); }
.current-split-card > p { margin: 0; overflow-wrap: anywhere; }
.current-split-exercises { display: grid; gap: var(--space-3); }
.current-split-exercise { padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow-wrap: anywhere; }
.current-split-exercise p { margin: var(--space-2) 0 0; }
.current-split-exercise-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); min-width: 0; min-height: 44px; padding-right: 28px; cursor: pointer; }
.current-split-exercise-head::-webkit-details-marker { display: none; }
.current-split-exercise-head::after { content: ''; position: absolute; right: 4px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: translateY(-65%) rotate(45deg); }
.current-split-exercise[open] > .current-split-exercise-head::after { transform: translateY(-35%) rotate(225deg); }
.current-split-exercise-head h3 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.split-chip { flex: 0 0 auto; max-width: 48%; padding: 4px 8px; border-radius: var(--radius-pill); border: 1px solid var(--border); color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-semibold); text-align: center; }
.split-chip-template_only, .split-chip-observed_only { border-color: var(--accent-soft-border); background: var(--accent-soft-bg); color: var(--accent); }
.current-split-progression { display: grid; gap: 4px; margin-top: var(--space-2); }
.split-progression { display: block; overflow-wrap: anywhere; }
.current-split-safety { padding: var(--space-3); border: 1px solid var(--danger); border-radius: var(--radius); background: var(--danger-bg); color: var(--danger); overflow-wrap: anywhere; }
.current-split-safety-unknown { padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); overflow-wrap: anywhere; }
.current-split-limits { border-top: 1px solid var(--border); }
.current-split-limits summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: var(--fw-semibold); }
.current-split-limits ul { margin-bottom: 0; padding-left: 1.25rem; }
@media (max-width: 430px) {
  .current-split-exercise-head { flex-direction: column; }
  .split-chip { max-width: 100%; }
  .current-split-card, .current-split-exercise { max-width: 100%; }
}

/* ---------- 28-day stabilization block (v63) ---------- */
.four-week-proposal-status { margin: 6px 0 10px; overflow-wrap: anywhere; }
.four-week-proposal-view,
.four-week-proposal-card,
.four-week-proposal-weeks { min-width: 0; }
.four-week-proposal-card { display: grid; gap: var(--space-3); }
.four-week-proposal-card > p { margin: 0; overflow-wrap: anywhere; }
.four-week-proposal-boundary { padding: var(--space-3); border: 1px solid var(--accent-soft-border); border-radius: var(--radius); background: var(--accent-soft-bg); color: var(--ink); }
.four-week-proposal-abstained,
.four-week-proposal-unavailable { padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow-wrap: anywhere; }
.four-week-proposal-abstained h3,
.four-week-proposal-unavailable h3 { margin-top: 0; }
.four-week-proposal-weeks { display: grid; gap: var(--space-2); }
.four-week-proposal-week { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow-wrap: anywhere; }
.four-week-proposal-week-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 44px; padding: var(--space-2) 36px var(--space-2) var(--space-3); cursor: pointer; font-weight: var(--fw-semibold); }
.four-week-proposal-week-head::-webkit-details-marker { display: none; }
.four-week-proposal-week-head::after { content: ''; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: translateY(-65%) rotate(45deg); }
.four-week-proposal-week[open] > .four-week-proposal-week-head::after { transform: translateY(-35%) rotate(225deg); }
.four-week-proposal-week-head span { min-width: 0; overflow-wrap: anywhere; }
.four-week-proposal-week-body { padding: 0 var(--space-3) var(--space-3); }
.four-week-proposal-week-body p { margin-top: 0; }
.four-week-proposal-week-body dl { display: grid; gap: var(--space-2); margin: 0; }
.four-week-proposal-week-body dl div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2); }
.four-week-proposal-week-body dt { color: var(--ink-2); }
.four-week-proposal-week-body dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.four-week-proposal-templates,
.four-week-proposal-limits,
.four-week-proposal-templates > div,
.four-week-proposal-limits > div,
.four-week-proposal-templates section,
.four-week-proposal-limits section,
.four-week-proposal-templates h4,
.four-week-proposal-limits p,
.four-week-proposal-templates ul,
.four-week-proposal-limits ul,
.four-week-proposal-templates li,
.four-week-proposal-limits li { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.four-week-proposal-templates,
.four-week-proposal-limits { border-top: 1px solid var(--border); }
.four-week-proposal-templates > summary,
.four-week-proposal-limits > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: var(--fw-semibold); }
.four-week-proposal-templates ul,
.four-week-proposal-limits ul { margin-bottom: 0; padding-left: 1.25rem; }
@media (max-width: 430px) {
  .four-week-proposal-card, .four-week-proposal-week { max-width: 100%; }
  .four-week-proposal-week-head { align-items: flex-start; flex-direction: column; }
  .four-week-proposal-week-body dl div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .four-week-proposal-week-body dd { text-align: left; }
}

/* Confirmed OpenAI vision review (v69). */
.vision-controls,
.vision-confirm,
.vision-estimate { min-width: 0; max-width: 100%; margin-top: var(--space-3); }
.vision-confirm,
.vision-estimate { display: grid; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow-wrap: anywhere; }
.vision-confirm-title,
.vision-confirm p,
.vision-estimate p { margin: 0; }
.vision-confirm-actions button,
.vision-controls button,
.vision-component button { min-height: 44px; }
.vision-components,
.vision-assumptions { min-width: 0; max-width: 100%; margin: 0; padding-left: 1.25rem; }
.vision-component { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); gap: var(--space-2); margin-bottom: var(--space-3); }
.vision-component input,
.vision-component span,
.vision-component button { min-width: 0; max-width: 100%; }
.vision-component span { align-self: center; color: var(--ink-2); overflow-wrap: anywhere; }
@media (max-width: 430px) {
  .vision-component { grid-template-columns: minmax(0, 1fr); }
  .vision-confirm-actions { grid-template-columns: minmax(0, 1fr); }
}

/* Task 7 — B/A hybrid information architecture (v79). */
.quick-actions { display: grid; gap: var(--space-2); min-width: 0; }
.quick-actions-title {
  margin: 0; color: var(--ink-3); font-size: var(--fs-caption);
  font-weight: var(--fw-bold); letter-spacing: 0;
}
.day-loop-row { grid-template-columns: 26px minmax(0, 1fr) auto; }
.day-loop-step {
  display: grid; place-items: center; width: 26px; height: 26px;
  border: 1px solid var(--accent-soft-border); border-radius: var(--radius-pill);
  background: var(--accent-soft-bg); color: var(--accent);
  font-size: var(--fs-caption); font-weight: var(--fw-bold);
}
.day-loop-row.is-complete .day-loop-step {
  border-color: var(--success); background: var(--success-bg); color: var(--success);
}
.nutrition-primary-card { gap: var(--space-3); }
.nutrition-primary-card .capture-action { margin: 0; }
.nutrition-primary-card .nutrition-date-picker { margin-top: 0; }
.weekly-insights-card { gap: var(--space-3); }
.weekly-insights-card > h2,
.weekly-insights-card > p { margin: 0; }
.weekly-insights-card > h2:not(:first-of-type) {
  margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border);
}
.settings-account-card .settings-account { margin-bottom: 0; }
.settings-preferences-card,
.settings-security-card,
.workout-template-management-card { min-width: 0; }
.workout-template-management-card .template-editor-card {
  margin: 0; padding: 0; border: 0; background: transparent;
}
.body-metric-card { order: 99; scroll-margin-top: var(--space-3); }
.template-chip,
.quick-exercise { min-height: var(--tap); }
.rest-pill button { min-width: var(--tap); min-height: var(--tap); }
.previous-value { min-height: var(--tap); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-set,
.remove-set { min-width: var(--tap); }
.drag-handle,
.template-remove { width: var(--tap); height: var(--tap); min-height: var(--tap); }
.template-edit { min-width: var(--tap); min-height: var(--tap); }
.template-reorder-controls { grid-template-columns: var(--tap) var(--tap); }
.template-reorder-controls button { width: var(--tap); height: var(--tap); min-height: var(--tap); }
.template-set-stepper { grid-template-columns: var(--tap) 24px var(--tap); }
.template-set-stepper button { width: var(--tap); height: var(--tap); min-height: var(--tap); }
.filter-pill { min-height: var(--tap); }
.previous-label-compact { display: none; }
#nutrition-panel details > summary { min-height: var(--tap); display: flex; align-items: center; }
@media (max-width: 430px) {
  .day-loop-row { gap: var(--space-2); }
  .day-loop-action { font-size: var(--fs-caption); }
  .strong-table-head,
  .strong-set-line { grid-template-columns: 30px minmax(44px, 1fr) repeat(4, 44px); gap: 2px; }
  .template-bubble {
    grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
    grid-template-areas: "drag text remove" "reorder edit stepper";
    gap: 6px; padding: 8px;
  }
  .drag-handle { grid-area: drag; }
  .template-bubble-text { grid-area: text; }
  .template-remove { grid-area: remove; }
  .template-reorder-controls { grid-area: reorder; justify-self: start; }
  .template-edit { grid-area: edit; justify-self: center; }
  .template-set-stepper { grid-area: stepper; justify-self: end; }
}
.exercise-info strong {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
@media (max-width: 360px) {
  .previous-label-wide { display: none; }
  .previous-label-compact { display: inline; }
}

/* PWA v81 real-iPhone acceptance remediation with Today alignment. */
.day-loop-rail {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  border: 0;
  background: transparent;
  overflow: visible;
}
.day-loop-action-button {
  grid-template-columns: 26px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "step copy" "action action";
  align-items: start;
  align-content: stretch;
  gap: var(--space-2);
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.day-loop-action-button:first-child { border-top: 1px solid var(--accent-soft-border); }
.day-loop-action-button .day-loop-step { grid-area: step; }
.day-loop-action-button .day-loop-copy { grid-area: copy; }
.day-loop-action-button .day-loop-action {
  grid-area: action;
  display: flex;
  align-items: center;
  align-self: end;
  justify-content: center;
  justify-self: stretch;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-pill);
  background: var(--accent-soft-bg);
  color: var(--accent);
  font-size: .9rem;
}
.day-loop-action-button.is-complete .day-loop-action {
  background: var(--success-bg);
  color: var(--success);
}
.nutrition-primary-card .capture-action {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.nutrition-primary-card .capture-icon,
.nutrition-primary-card .capture-sub { color: var(--accent-ink); }
.nutrition-primary-card > p:not(.eyebrow) { margin-bottom: 0; }

#workouts-panel {
  --workout-weight-column: 60px;
  --workout-reps-column: 44px;
}
@media (max-width: 430px) {
  .day-loop-rail { grid-template-columns: minmax(0, 1fr); }
  .day-loop-action-button {
    grid-template-columns: 26px minmax(0, 1fr) auto;
    grid-template-rows: auto;
    grid-template-areas: "step copy action";
    align-items: center;
    min-height: 72px;
    padding: 8px 10px;
  }
  .day-loop-action-button .day-loop-copy { min-width: 0; }
  .day-loop-action-button .day-loop-action {
    align-self: center;
    justify-self: end;
    min-height: var(--tap);
    max-width: 100%;
    padding: 6px 10px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  /* The dated food target is too wide to share a phone row with the totals. */
  .day-loop-action-button[data-loop-row="food"] {
    grid-template-columns: 26px minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas: "step copy" "action action";
  }
  .day-loop-action-button[data-loop-row="food"] .day-loop-action {
    justify-self: stretch;
    text-align: center;
  }
  .strong-table-head,
  .strong-set-line {
    grid-template-columns: 30px minmax(52px, 1fr) var(--workout-weight-column) var(--workout-reps-column) 44px 44px;
    gap: 2px;
  }
  .strong-set-line input.set-weight { min-width: 0; width: 100%; padding-inline: 3px; }
  .strong-set-line input.set-reps { min-width: 0; width: 100%; padding-inline: 3px; }
  .exercise-head { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
  .exercise-head .mini-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-self: stretch;
  }
  .exercise-head .mini-actions button { width: 100%; }
  .workout-resume-prompt .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .workout-resume-prompt .button-row button { width: 100%; }
}
@media (max-width: 360px) {
  #workouts-panel {
    --workout-weight-column: 58px;
    --workout-reps-column: 44px;
  }
  .strong-table-head,
  .strong-set-line { grid-template-columns: 28px minmax(46px, 1fr) var(--workout-weight-column) var(--workout-reps-column) 44px 44px; }
  .previous-value { font-size: .82rem; }
}

.trend-snapshot-grid { display: grid; gap: var(--space-2); }
.trend-snapshot {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  min-width: 0;
}
.trend-snapshot > strong { color: var(--ink); }
.trend-snapshot .trend-caption { margin: 0; color: var(--ink-2); }
.body-entry-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  margin-top: var(--space-3);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: var(--fw-bold);
  text-decoration: none;
}
.body-entry-shortcut:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.trend-disclosure { min-width: 0; }
.trend-disclosure.card { padding: 0; overflow: hidden; }
.trend-disclosure-summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 14px 42px 14px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
}
.trend-disclosure-summary::-webkit-details-marker { display: none; }
.trend-disclosure-summary::after {
  content: '';
  position: absolute;
  right: 18px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-65%) rotate(45deg);
}
.trend-disclosure[open] > .trend-disclosure-summary::after { transform: translateY(-35%) rotate(225deg); }
.trend-disclosure[open] > .trend-disclosure-summary { border-bottom: 1px solid var(--border-soft); }
.trend-disclosure-summary > span { display: grid; gap: 3px; min-width: 0; }
.trend-disclosure-summary strong { font-size: var(--fs-h3); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.trend-disclosure-summary .eyebrow { margin: 0; }
.trend-disclosure-summary .muted,
.trend-disclosure-summary > span > span:last-child {
  margin: 0;
  color: var(--ink-2);
  font-size: .84rem;
  line-height: var(--lh-snug);
  overflow-wrap: anywhere;
}
.trend-disclosure-summary .muted:empty { display: none; }
.trend-disclosure-body { display: grid; gap: var(--space-3); padding: 0 16px 16px; min-width: 0; }
.trend-disclosure-body > p { margin: 0; }
.trend-chart-disclosure { margin-top: var(--space-3); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.trend-chart-details { padding-top: 16px; }
.trend-disclosure-nested { border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface-2); }
.trend-disclosure-nested + .trend-disclosure-nested { margin-top: var(--space-2); }
.trend-disclosure-nested .trend-disclosure-summary { min-height: 64px; }
.trend-disclosure-nested .trend-disclosure-body { padding-top: var(--space-3); background: var(--surface); }
.weekly-insights-card > .muted { margin-bottom: 0; }
.weekly-insights-card .weekly-review-status,
.weekly-insights-card .weekly-eligibility-status,
.weekly-insights-card .weekly-rec-status,
.weekly-insights-card .followthrough-status { margin: 0; }

/* Reliable meal logging: compact secondary metrics, dominant Add food retained. */
#nutrition-dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#nutrition-dashboard > .macro-card { grid-column: auto; min-width: 0; }
.meal-draft-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 16px; }
.meal-draft-bar p { flex: 1; min-width: 0; margin: 0; font-size: .9rem; }
.meal-draft-bar button { width: auto; }
.meal-draft-panel { min-height: 0; min-width: 0; overflow-y: auto; padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
.meal-draft-item { border-bottom: 1px solid var(--border-soft); padding: 12px 0; overflow-wrap: anywhere; }
.meal-draft-item p { margin: 6px 0; color: var(--ink-2); }
.meal-draft-actions { display: grid; gap: 8px; }
.meal-draft-panel input, .meal-draft-panel select { min-width: 0; width: 100%; box-sizing: border-box; }

/* Explicit mode stays readable in narrow cards and with enlarged text. */
.body-form-mode {
  margin: 0;
  font-weight: var(--fw-bold);
  overflow-wrap: anywhere;
}
#body-cancel-edit {
  min-height: 44px;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
#body-cancel-edit[hidden] { display: none; }
#trends-panel { min-width: 0; grid-template-columns: minmax(0, 1fr); }

/* v95 mobile nutrient presentation: compact first, full truth on demand. */
.food-sheet,
.food-sheet *,
.meal-draft-panel,
.meal-draft-panel *,
#meal-draft-items,
#meal-draft-items *,
#meal-draft-totals,
#meal-draft-totals *,
.nutrient-compact,
.nutrient-compact *,
.nutrient-details,
.nutrient-details * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.meal-draft-panel { overflow-x: hidden; overflow-y: auto; }
.meal-draft-panel input,
.meal-draft-panel select,
.meal-draft-panel textarea { width: 100%; min-width: 0; max-width: 100%; }
.food-sheet p,
.food-sheet strong,
.food-sheet small,
.food-entry-content,
.meal-draft-content,
.nutrient-value,
.nutrient-details small { overflow-wrap: anywhere; }

.nutrient-compact { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin-top: 6px; }
.nutrient-compact-item { display: grid; gap: 2px; }
.nutrient-label { color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-semibold); overflow-wrap: normal; word-break: normal; hyphens: none; }
.nutrient-value { color: var(--ink); font-size: .94rem; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.nutrient-status { grid-column: 1 / -1; color: var(--ink-2); font-size: .82rem; }
.day-loop-value > .nutrient-compact { margin-top: 0; }
.nutrient-details { width: 100%; margin-top: var(--space-1); color: var(--ink-2); }
.meal-group > .nutrient-details { padding-inline: var(--space-3); }
.nutrient-details > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-size: .88rem; font-weight: var(--fw-bold); }
.nutrient-details ul,
.review-facts-body ul { display: grid; gap: var(--space-2); margin: 0; padding: var(--space-3); list-style: none; border-radius: var(--radius-sm); background: var(--surface-2); }
.nutrient-details li,
.review-facts-body li { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 2px var(--space-2); }
.nutrient-details li small,
.review-facts-body li small { grid-column: 1 / -1; color: var(--ink-3); line-height: 1.4; }
.nutrient-coverage-note { margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3) 0; border-top: 1px solid var(--border-soft); color: var(--ink-2); font-size: var(--fs-caption); line-height: var(--lh-snug); }
.nutrient-coverage-scope { margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3) 0; border-top: 1px solid var(--border-soft); color: var(--ink-2); font-size: var(--fs-caption); line-height: var(--lh-snug); }
.nutrient-provenance { margin: var(--space-2) var(--space-3) 0; color: var(--ink-2); font-size: var(--fs-caption); overflow-wrap: anywhere; }
.goal-kind { color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-bold); }
.dashboard-knowledge { grid-column: 1 / -1; min-width: 0; }
.daily-summary-source,
.daily-nutrient-coverage,
.nutrition-empty,
.macro-dashboard-empty { grid-column: 1 / -1; margin: 0; }
.daily-summary-source { color: var(--ink-2); font-size: .82rem; font-weight: var(--fw-bold); }
.daily-nutrient-coverage { color: var(--ink-2); font-size: .82rem; }
.nutrition-entry-recovery { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--accent-soft-border); border-radius: var(--radius-sm); background: var(--accent-soft-bg); }
.nutrition-entry-recovery p { margin: 0; color: var(--ink); }
.entry-recovery-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.entry-recovery-action { min-height: 44px; max-width: 100%; overflow-wrap: anywhere; }

/* Premium Nutrition hierarchy: one calm calorie measure, always-visible macros,
   and native, independently nested disclosures. */
#nutrition-dashboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
#nutrition-dashboard .daily-summary-source { color: var(--ink-2); font-size: var(--fs-caption); letter-spacing: .01em; }
.nutrition-calories { display: grid; gap: 5px; min-width: 0; }
.nutrition-calories-label { color: var(--ink); font-size: .88rem; font-weight: var(--fw-bold); }
.nutrition-calories p { margin: 0; color: var(--ink-2); line-height: 1.15; }
.nutrition-calories p strong { color: var(--ink); font-size: clamp(1.9rem, 8vw, 2.45rem); letter-spacing: var(--ls-display); font-variant-numeric: tabular-nums; }
.nutrition-calories p span { font-size: .9rem; margin-inline-start: var(--space-1); }
.nutrition-calories small { color: var(--ink-2); }
.nutrition-calorie-progress { height: 6px; overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-3); }
.nutrition-calorie-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.nutrition-macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.nutrition-macro { display: grid; gap: 2px; min-width: 0; }
#nutrition-panel .nutrition-macro span { color: var(--ink-2); font-size: var(--fs-caption); overflow-wrap: anywhere; }
.nutrition-macro strong { color: var(--ink); font-size: 1.12rem; line-height: 1.15; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.nutrition-protein-target { margin-top: -8px; color: var(--ink-2); font-size: var(--fs-caption); }
.nutrition-day-details { margin-top: 0; border-top: 1px solid var(--border-soft); }
.nutrition-diary { display: grid; gap: 0; overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.nutrition-diary > .meal-group { margin: 0; padding: 0 12px; border: 0; border-radius: 0; background: transparent; }
.nutrition-diary > .meal-group + .meal-group { border-top: 1px solid var(--border-soft); }
#nutrition-panel .meal-group > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  cursor: pointer;
  list-style: none;
}
.meal-group > summary::-webkit-details-marker { display: none; }
.meal-group > summary > span:first-child { display: grid; gap: 4px; min-width: 0; }
.meal-group > summary strong { color: var(--ink); font-size: 1rem; }
.meal-group > summary small { color: var(--ink-2); font-size: var(--fs-caption); line-height: 1.35; overflow-wrap: anywhere; }
.meal-group > summary > span:last-child { color: var(--ink-2); font-size: var(--fs-caption); line-height: 1.35; text-align: right; overflow-wrap: anywhere; }
.meal-group > summary::after { content: '›'; color: var(--ink-2); font-size: 1.35rem; transform: rotate(0); }
.meal-group > summary > span:last-child { grid-column: 2; grid-row: 1; }
.meal-group > summary::after { grid-column: 3; grid-row: 1; justify-self: end; }
.meal-group[open] > summary::after { transform: rotate(90deg); }
/* The meal group's 12px padding supplies the direct disclosure inset; the body
   adds no left inset. The mobile card's separate 14px padding is not this metric. */
.meal-group-body { display: grid; gap: var(--space-2); padding: 0 0 12px; }
.meal-group-body > .nutrient-details { padding-inline: 0; }

@media (prefers-reduced-transparency: reduce) {
  #nutrition-panel .nutrition-diary { background: var(--surface); backdrop-filter: none; }
}

.macro-card.no-target { display: grid; align-items: start; }
.macro-card .nutrient-details { grid-column: 1 / -1; }
.diary-total,
.meal-group header { align-items: start; }
.diary-total > div,
.meal-group header > div { flex: 1; min-width: 0; }
.food-entry,
.meal-draft-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; max-width: 100%; }
.food-entry > .mini-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.meal-draft-item > .mini-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
.food-entry > .mini-actions button,
.meal-draft-item > .mini-actions button { width: 100%; min-width: 0; min-height: 44px; white-space: normal; }
.food-entry > .nutrient-details { margin-top: 0; }
/* S26/B19: one trailing overflow toggle per diary entry; Edit / Duplicate /
   Delete sit inside the menu it reveals and keep every existing button rule. */
.food-entry > .mini-actions:has(> .entry-actions-menu) {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: end; gap: 6px;
}
.entry-actions-toggle { min-width: 44px; letter-spacing: .14em; line-height: 1; }
#nutrition-panel .food-entry > .mini-actions > .entry-actions-toggle { min-width: 44px; padding-inline: 12px; }
.food-entry > .mini-actions > .entry-actions-menu {
  display: grid; gap: 4px; width: max-content; max-width: 100%; padding: 6px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--surface-2);
}
.food-entry > .mini-actions > .entry-actions-menu[hidden] { display: none; }
/* Tabbing into the menu may be what scrolls the row into view, so every action
   keeps a margin of its own at every width, not only under the phone nav. */
#nutrition-diary .mini-actions button { scroll-margin-block: 8px; }
#meal-draft-totals { display: grid; gap: 6px; padding-block: 12px; }

.nutrition-primary-card > p:not(.eyebrow):not(#nutrition-message),
.nutrition-primary-card > h2:first-of-type { display: none; }
.nutrition-primary-card { gap: var(--space-2); }
.nutrition-primary-card .capture-action-solo {
  grid-template-columns: 26px minmax(0, 1fr);
  grid-template-areas: "icon label" "icon copy";
  column-gap: var(--space-3);
  row-gap: 1px;
  align-items: center;
  min-height: var(--tap);
  padding: 8px 12px;
}
.nutrition-primary-card .capture-icon { grid-area: icon; }
.nutrition-primary-card .capture-label { grid-area: label; align-self: end; }
.nutrition-primary-card .capture-sub { grid-area: copy; align-self: start; line-height: var(--lh-snug); overflow-wrap: anywhere; }
.nutrition-primary-card .nutrition-date-picker { gap: var(--space-1); }
.nutrition-diary-card { gap: var(--space-2); }
.nutrition-diary-card > .eyebrow { display: none; }
.meal-group header { padding-block: var(--space-2); }
.food-entry { padding-block: var(--space-2); }

@media (max-width: 430px) {
  #nutrition-dashboard { grid-template-columns: minmax(0, 1fr); }
  .diary-total,
  .meal-group header { display: grid; grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 680px) {
  #nutrition-panel { gap: 8px; padding-bottom: var(--mobile-nav-height); }
  #nutrition-panel .nutrition-primary-card,
  #nutrition-panel .nutrition-diary-card,
  #nutrition-panel .meal-group,
  #nutrition-panel details > summary { scroll-margin-bottom: calc(var(--mobile-nav-height) + var(--space-3)); }
  #nutrition-panel #nutrition-diary .mini-actions button {
    scroll-margin-block: 8px calc(var(--mobile-nav-height) + var(--space-3));
  }
}

/* At 200% zoom on a narrow phone, give the dated food CTA a full row. */
@media (max-width: 280px) {
  .day-loop-action-button {
    grid-template-columns: 26px minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas: "step copy" "action action";
  }
  .day-loop-action-button .day-loop-action {
    justify-self: stretch;
    text-align: center;
  }
}

/* Keep Nutrition content inside its grid tracks with enlarged root text. */
#nutrition-panel,
#nutrition-panel > * {
  min-width: 0;
  max-width: 100%;
}
#nutrition-panel .macro-card {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}
#nutrition-panel .macro-row {
  min-width: 0;
  flex-wrap: wrap;
}
#nutrition-panel .macro-row > *,
#nutrition-panel .macro-card > .macro-amount,
#nutrition-panel .macro-card > .goal-kind,
#nutrition-panel .food-entry-content,
#nutrition-panel .nutrient-details > summary {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
#nutrition-panel .food-entry > .mini-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
}
#nutrition-panel .food-entry > .mini-actions button {
  min-width: 0;
  min-height: 44px;
  white-space: normal;
  overflow-wrap: anywhere;
}
#nutrition-panel .pantry-shopping-card > summary { flex-wrap: wrap; }
#nutrition-panel .pantry-shopping-counts {
  flex: 0 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Shared monochrome shell. Nutrition is the first fully composed surface.
   The token block this slice used to open with lived here; it is now the one
   :root at the top of the sheet. */
@font-face { font-family: Archivo; src: url('./fonts/archivo-var-latin.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
/* Design sprint slice 2 (§1.2): no global negative tracking and no global
   tabular figures. Archivo's word space is narrow, so a slightly wider word
   space keeps "Log food" and "8k steps" two words; tabular figures are set
   only where digits change or line up (timers, set wells, stats). */
body { background: var(--bg); font-family: var(--font-sans); letter-spacing: 0; word-spacing: .06em; }
:is(.workout-number, #workout-elapsed, #rest-time, .timer-stack, .elapsed-wrap, .strong-set-line, .set-index-pill,
  .workout-week-stats, .today-ring-copy, .today-macro, .nutrition-macro, .nutrition-calories, .summary-grid,
  .cut-review-big, .calendar-cell) { font-variant-numeric: tabular-nums; }
::selection { color: var(--accent-ink); background: var(--accent); }
input, textarea { caret-color: var(--ink); }
a { text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.tab-nav, .topbar { background: var(--surface); backdrop-filter: none; box-shadow: none; }
#nutrition-panel { gap: 8px; }
#nutrition-panel .card { border-radius: var(--radius-lg); box-shadow: none; background: var(--surface); padding: var(--card-pad); gap: 6px; }
#nutrition-panel .nutrition-primary-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
#nutrition-panel .nutrition-primary-card > .eyebrow { display: none; }
#nutrition-panel .nutrition-primary-card .nutrition-date-picker { grid-column: 1; grid-row: 1; font-size: var(--fs-caption); }
#nutrition-panel .nutrition-primary-card .nutrition-date-picker input { min-height: 44px; padding: 6px 8px; }
#nutrition-panel .capture-action-solo { grid-column: 2; grid-row: 1; display: flex; gap: 6px; padding: 8px 12px; min-height: 44px; border-radius: var(--radius-pill); }
#nutrition-panel .capture-label { font-size: .9rem; align-self: center; }
#nutrition-panel .capture-sub { display: none; }
#nutrition-panel .capture-icon { width: 18px; height: 18px; }
#nutrition-panel #nutrition-dashboard, #nutrition-panel #nutrition-message { grid-column: 1 / -1; }
#nutrition-dashboard { gap: 8px; }
#nutrition-panel .nutrition-calories p strong { font-size: 1.85rem; font-weight: var(--fw-semibold); }
#nutrition-panel .nutrition-calories-label { font-size: var(--fs-caption); font-weight: var(--fw-medium); }
#nutrition-panel .nutrition-calorie-progress { height: 4px; }
#nutrition-panel .nutrition-macros { gap: 8px; }
#nutrition-panel .nutrition-macro strong { font-weight: var(--fw-semibold); }
#nutrition-panel .nutrition-protein-target { margin-top: 0; }
#nutrition-panel .nutrition-uncertainty { color: var(--ink-2); font-size: var(--fs-caption); margin: 0; }
#nutrition-panel .nutrient-details > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; padding-block: 6px; list-style: none; }
#nutrition-panel .nutrient-details > summary::-webkit-details-marker { display: none; }
#nutrition-panel .nutrient-details > summary::after,
#nutrition-panel .meal-group > summary::after { content: ''; display: block; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); flex: 0 0 8px; margin-left: auto; }
#nutrition-panel .nutrient-details[open] > summary::after,
#nutrition-panel .meal-group[open] > summary::after { transform: rotate(45deg); }
#nutrition-panel .nutrition-diary { margin-top: 0; }
#nutrition-panel .meal-group > summary { padding-block: 8px; min-height: 58px; }
#nutrition-panel .meal-group > summary > span:first-child { gap: 2px; }
#nutrition-panel .meal-group-body { gap: 0; }
#nutrition-panel .food-entry { padding: 8px 0; gap: 4px; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
#nutrition-panel .food-entry-content { grid-column: 1 / -1; }
#nutrition-panel .food-entry-content .nutrient-compact { display: flex; flex-wrap: wrap; gap: 2px 10px; }
#nutrition-panel .food-entry-content .nutrient-compact-item { display: inline-flex; flex-wrap: wrap; gap: 4px; }
#nutrition-panel .food-entry-content .nutrient-label,
#nutrition-panel .food-entry-content .nutrient-value { display: inline; font-size: var(--fs-caption); }
#nutrition-panel .food-entry-content .nutrient-status { flex-basis: 100%; }
#nutrition-panel .food-entry-content > strong { font-weight: var(--fw-semibold); font-size: .9rem; }
#nutrition-panel .food-serving { font-size: var(--fs-caption); }
#nutrition-panel .food-entry .nutrient-compact { margin: 2px 0 0; font-size: var(--fs-caption); }
#nutrition-panel .food-entry > .mini-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; width: auto; }
#nutrition-panel .food-entry > .mini-actions button { width: auto; padding: 6px 8px; font-size: var(--fs-caption); }
#nutrition-panel .food-entry [data-action="edit-nutrition-entry"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#nutrition-panel .food-entry > .nutrient-details { grid-column: 1 / -1; }
#nutrition-panel > .card:has(> details) { padding-block: 0; }
#nutrition-panel > .card > details > summary { min-height: 44px; padding-block: 8px; font-size: .9rem; }
@media (max-width: 63.999rem) {
  #nutrition-panel > .nutrition-workspace > .nutrition-secondary-tools > .card:has(> details) { padding-block: 0; }
  #nutrition-panel > .nutrition-workspace > .nutrition-secondary-tools > .card > details > summary { min-height: 44px; padding-block: 8px; font-size: .9rem; }
}
@media (max-width: 680px) {
  #nutrition-panel .nutrition-primary-card { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
  #nutrition-panel .nutrition-primary-card .nutrition-date-picker { grid-column: auto; grid-row: auto; width: 100%; max-width: none; }
  #nutrition-panel .capture-action-solo { grid-column: auto; grid-row: auto; justify-self: end; }
}
@media (max-width: 360px) {
  #nutrition-panel .capture-action-solo { padding-inline: 8px; }
  #nutrition-panel .nutrition-primary-card { column-gap: 8px; }
}

/* Nutrition desktop workspace. Below 64rem the wrapper has no layout box, so
   the accepted mobile/tablet order and geometry remain the source of truth. */
.nutrition-workspace,
.nutrition-secondary-tools { display: contents; }

@media (min-width: 64rem) {
  /* Share the accepted Nutrition shell without widening other tab contents. */
  .shell:has(> #app-card:not(.hidden)) {
    width: calc(100% - (2 * clamp(24px, 2vw, 48px)));
    max-width: none;
  }
  .shell:has(> #app-card:not(.hidden))
    > .hero {
    width: 100%;
    margin-inline: 0;
    padding-block: 14px 10px;
    border-bottom: 1px solid var(--border-soft);
  }
  .shell:has(> #app-card:not(.hidden))
    > .hero > :not(.eyebrow) {
    display: none;
  }
  #app-card:not(.hidden) > .tab-nav,
  #app-card:not(.hidden) > #app-hydration-status,
  #app-card:not(.hidden) > #connectivity-banner {
    width: 100%;
    margin-inline: 0;
  }
  #app-card:not(.hidden) > .tab-nav {
    position: static;
    display: flex;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    border-radius: 0;
    background: transparent;
  }
  #app-card:not(.hidden) > .tab-nav > button {
    flex: 0 0 auto;
    flex-direction: row;
    width: auto;
    min-width: 0;
    min-height: 40px;
    padding-inline: 14px;
  }
  #app-card:not(.hidden) > .tab-nav .tab-icon {
    display: none;
  }
  #app-card > .tab-panel:not(#overview-panel):not(#nutrition-panel):where(:not(#trends-panel):not(#settings-panel)) {
    width: min(760px, 100%);
    margin-inline: auto;
  }
  #nutrition-panel:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    padding-top: 10px;
  }
  #nutrition-panel > #nutrition-hydration-status {
    grid-column: 1;
  }
  #nutrition-panel > .nutrition-primary-card {
    grid-column: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "title add date"
      "dashboard dashboard dashboard"
      "message message message";
    align-items: end;
    gap: 12px 16px;
    padding: 18px 20px;
  }
  #nutrition-panel .nutrition-primary-card > .eyebrow { display: none; }
  #nutrition-panel #nutrition-selected-heading {
    grid-area: title;
    display: block;
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    border: 0;
    font-size: clamp(1.35rem, 1.5vw, 1.75rem);
  }
  #nutrition-panel .nutrition-primary-card .capture-action-solo {
    grid-area: add;
    grid-column: auto;
    grid-row: auto;
    width: auto;
    max-width: 18rem;
    justify-self: end;
  }
  #nutrition-panel .nutrition-primary-card .nutrition-date-picker {
    grid-area: date;
    grid-column: auto;
    grid-row: auto;
    width: 12rem;
    max-width: 12rem;
    margin: 0;
  }
  #nutrition-panel #nutrition-dashboard {
    grid-area: dashboard;
    grid-template-columns: minmax(15rem, 1.35fr) minmax(18rem, 1fr) minmax(13rem, .8fr);
    align-items: center;
    gap: 10px 22px;
    margin: 4px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
  }
  #nutrition-panel #nutrition-message { grid-area: message; margin: 0; }
  #nutrition-dashboard .nutrition-calories { grid-column: 1; grid-row: 1 / span 2; }
  #nutrition-dashboard .nutrition-calories p strong { font-size: 2.25rem; }
  #nutrition-dashboard .nutrition-macros { grid-column: 2; grid-row: 1; }
  #nutrition-dashboard .nutrition-protein-target { grid-column: 2; grid-row: 2; margin: 0; }
  #nutrition-dashboard .nutrition-uncertainty { grid-column: 3; grid-row: 1; margin: 0; }
  #nutrition-panel #nutrition-dashboard > .dashboard-knowledge {
    grid-column: 1 / -1;
    grid-row: 3;
    min-inline-size: 0;
  }
  #nutrition-dashboard .nutrition-empty { grid-column: 1 / -1; }

  #nutrition-panel > .nutrition-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    min-width: 0;
  }
  #nutrition-panel .nutrition-diary-card {
    min-width: 0;
    padding: 0;
    overflow: hidden;
  }
  #nutrition-panel .nutrition-diary-card > #nutrition-diary-state,
  #nutrition-panel .nutrition-diary-card > #nutrition-entry-recovery { margin: 14px 16px 0; }
  #nutrition-panel .nutrition-diary { margin-top: 0; border-radius: 0; }
  #nutrition-panel .nutrition-secondary-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 12px;
    min-width: 0;
  }
  #nutrition-panel .nutrition-secondary-tools > .card { min-width: 0; }

  #nutrition-panel .food-entry {
    grid-template-columns: minmax(16rem, 1fr) minmax(15rem, .72fr) auto;
    column-gap: 18px;
    align-items: start;
    padding: 12px 0;
  }
  #nutrition-panel .food-entry-content {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / 3;
    align-items: start;
  }
  #nutrition-panel .food-entry-content > strong,
  #nutrition-panel .food-entry-content > .food-serving,
  #nutrition-panel .food-entry-content > small { grid-column: 1; }
  #nutrition-panel .food-entry-content .nutrient-compact {
    grid-column: 2;
    grid-row: 1 / span 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    margin: 0;
  }
  #nutrition-panel .food-entry-content .nutrient-compact-item { display: grid; gap: 2px; }
  #nutrition-panel .food-entry > .mini-actions {
    grid-column: 3;
    display: flex;
    flex-wrap: wrap;
    width: auto;
    gap: 6px;
  }
  #nutrition-panel .food-entry > .mini-actions button { flex: 0 0 auto; width: auto; }
  #nutrition-panel .food-entry > .nutrient-details { grid-column: 1 / -1; }
}

@media (min-width: 80rem) {
  #nutrition-panel > .nutrition-workspace {
    grid-template-columns: minmax(0, 1fr) clamp(18rem, 20vw, 22rem);
    align-items: start;
  }
}

@media (min-width: 64rem) and (max-width: 79.999rem),
       (min-width: 64rem) and (min-resolution: 1.5dppx) {
  #nutrition-panel .food-entry {
    grid-template-columns: minmax(0, 1fr) minmax(13rem, .72fr);
  }
  #nutrition-panel .food-entry-content { grid-column: 1 / -1; }
  #nutrition-panel .food-entry > .mini-actions {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (min-width: 64rem) and (max-width: 70rem) {
  #nutrition-panel > .nutrition-primary-card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title title"
      "add date"
      "dashboard dashboard"
      "message message";
  }
  #nutrition-panel #nutrition-dashboard {
    grid-template-columns: minmax(14rem, 1fr) minmax(18rem, 1fr);
  }
  #nutrition-dashboard .nutrition-uncertainty {
    grid-column: 1 / -1;
    grid-row: 3;
  }
  #nutrition-panel #nutrition-dashboard > .dashboard-knowledge {
    grid-column: 1 / -1;
    grid-row: 4;
  }
}

@media (min-width: 64rem) and (max-height: 34rem) {
  #nutrition-panel > .nutrition-workspace { grid-template-columns: minmax(0, 1fr); }
  #nutrition-panel .nutrition-secondary-tools { grid-column: 1; }
}

@supports not (grid-template-columns: subgrid) {
  @media (min-width: 64rem) {
    #nutrition-panel .food-entry-content { grid-template-columns: minmax(0, 1fr) minmax(15rem, .72fr); }
  }
}

/* Nutrition-only ultrawide legibility tier. The 120rem threshold leaves the
   accepted phone and 1440px desktop geometry untouched; fixed local tokens cap
   the increase instead of scaling with the viewport. */
@media (min-width: 120rem) {
  #app-card:has(> #nutrition-panel:not(.hidden)) {
    --nutrition-wide-meta-type: .875rem;
    --nutrition-wide-body-type: 1rem;
    --nutrition-wide-control-type: 1.0625rem;
    --nutrition-wide-summary-type: 1.1rem;
    --nutrition-wide-control-height: 48px;
    --nutrition-wide-inline-gap: 8px;
  }
  #app-card:not(.hidden) > .tab-nav > button {
    min-height: 44px;
    padding-inline: 16px;
    font-size: .9375rem;
  }
  #nutrition-panel > .nutrition-primary-card {
    gap: 14px 20px;
    padding: 22px 24px;
  }
  #nutrition-panel .nutrition-primary-card .nutrition-date-picker,
  #nutrition-panel .nutrition-calories-label,
  #nutrition-panel .nutrition-uncertainty,
  #nutrition-panel .food-serving,
  #nutrition-panel .food-entry .nutrient-compact,
  #nutrition-panel .food-entry-content .nutrient-label,
  #nutrition-panel .food-entry-content .nutrient-value,
  #nutrition-panel .food-entry > .mini-actions button {
    font-size: var(--nutrition-wide-meta-type);
  }
  #nutrition-panel .nutrition-primary-card .nutrition-date-picker input,
  #nutrition-panel .nutrition-primary-card .capture-action-solo {
    min-height: var(--nutrition-wide-control-height);
    font-size: var(--nutrition-wide-control-type);
  }
  #nutrition-panel .nutrition-primary-card .nutrition-date-picker input { padding: 8px 10px; }
  #nutrition-panel .nutrition-primary-card .capture-action-solo {
    gap: var(--nutrition-wide-inline-gap);
    padding: 10px 16px;
  }
  #nutrition-panel .capture-label,
  #nutrition-panel .food-entry-content > strong { font-size: var(--nutrition-wide-body-type); }
  #nutrition-panel .nutrition-calories p strong { font-size: 2.5rem; }
  #nutrition-panel .nutrition-macro strong { font-size: var(--nutrition-wide-control-type); }
  #nutrition-panel .meal-group > summary {
    min-height: 62px;
    padding-block: 10px;
    font-size: var(--nutrition-wide-control-type);
  }
  #nutrition-panel .nutrient-details > summary {
    min-height: var(--nutrition-wide-control-height);
    padding-block: 8px;
    font-size: .9375rem;
  }
  #nutrition-panel .food-entry {
    column-gap: 22px;
    padding-block: 14px;
  }
  #nutrition-panel .food-entry-content .nutrient-compact {
    gap: var(--nutrition-wide-inline-gap) 16px;
  }
  #nutrition-panel .food-entry-content .nutrient-compact-item { gap: 3px; }
  #nutrition-panel .food-entry > .mini-actions { gap: var(--nutrition-wide-inline-gap); }
  #nutrition-panel .food-entry > .mini-actions button {
    min-height: var(--nutrition-wide-control-height);
    padding: 8px 12px;
  }
  #nutrition-panel .nutrition-secondary-tools { gap: 16px; }
  #nutrition-panel .nutrition-secondary-tools > .card { padding: var(--card-pad); }
  #nutrition-panel .nutrition-secondary-tools > .card > details > summary {
    min-height: var(--nutrition-wide-control-height);
    font-size: var(--nutrition-wide-summary-type);
  }
}

/* Physical iPhone RED: native date bezels exceed card padding even when the
   layout rectangle fits. Keep type=date and its picker; size the author box
   and WebKit value paint explicitly, after all responsive/theme rules. */
#nutrition-date, #body-date {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  box-sizing: border-box;
  inline-size: 100%;
  width: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  margin-inline: 0;
  overflow: hidden;
}
#nutrition-date::-webkit-date-and-time-value,
#body-date::-webkit-date-and-time-value {
  display: block;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  padding: 0;
  text-align: start;
}
#nutrition-date:focus, #body-date:focus {
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}
#nutrition-date:focus-visible, #body-date:focus-visible {
  outline-offset: -2px;
}



/* Today compact monochrome: isolated successor; accepted Nutrition/date untouched. */
#overview-panel { gap: 12px; padding: 14px; border-radius: var(--radius-lg); min-width: 0; }
#overview-panel > .row { align-items: center; }
#overview-panel h2 { margin: 0; font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-h2); }
#overview-panel .today-date { margin: 3px 0 0; color: var(--ink-2); font-size: .82rem; letter-spacing: 0; }
#overview-panel .quick-actions { margin: 0; padding: 0; }
#overview-panel .quick-actions-title { margin: 0 0 6px; font-size: .86rem; font-weight: var(--fw-semibold); text-transform: none; letter-spacing: 0; color: var(--ink-2); }
#overview-panel .day-loop-rail { gap: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
#overview-panel .day-loop-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; grid-template-areas: "copy action"; align-items: center; gap: 8px; min-height: 68px; margin: 0; padding: 10px 0; border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; background: transparent; }
#overview-panel .day-loop-step { display: none; }
#overview-panel .day-loop-label { color: var(--ink-2); font-size: .86rem; font-weight: var(--fw-semibold); text-transform: none; letter-spacing: 0; }
#overview-panel .day-loop-value { font-size: .94rem; font-weight: var(--fw-semibold); }
#overview-panel .day-loop-note { color: var(--ink-2); font-size: var(--fs-caption); }
#overview-panel .day-loop-action { min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink); white-space: normal; overflow-wrap: anywhere; max-width: 11rem; font-size: .82rem; }
#overview-panel .today-food-date { white-space: nowrap; }
#overview-panel #today-log-food .day-loop-action { background: var(--ink); color: var(--surface); border-color: var(--ink); }
#overview-panel #today-log-food { grid-template-columns: minmax(0, 1fr); grid-template-areas: "copy" "action"; }
#overview-panel #today-log-food .day-loop-action { max-width: none; width: 100%; }
#overview-panel .today-now { margin: 0; padding: 10px 12px; gap: 8px; border-color: var(--border-soft); background: var(--surface-2); border-radius: var(--radius-lg); }
#overview-panel .today-now-chip { padding: 0; border: 0; background: transparent; color: var(--ink-2); font-size: var(--fs-caption); }
#overview-panel .today-now h3 { font-size: 1rem; font-weight: var(--fw-semibold); }
#overview-panel #today-now-why { font-size: .82rem; line-height: 1.4; }
#overview-panel .today-details { border-top: 1px solid var(--border-soft); min-width: 0; }
#overview-panel .today-details > summary { min-height: 44px; cursor: pointer; font-size: .86rem; font-weight: var(--fw-semibold); padding: 10px 0; color: var(--ink); }
#overview-panel .all-stats-card { margin-top: 8px; background: transparent; border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; padding: 0; }
#overview-panel #today-set-goals { justify-self: start; margin-top: 8px; white-space: normal; text-align: left; }
#overview-panel .day-loop-row:active { background: var(--surface-2); }
#overview-panel :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (max-width: 360px) {
  #overview-panel .day-loop-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "copy" "action"; }
  #overview-panel .day-loop-action { justify-self: start; max-width: none; }
}

/* Today desktop workspace. Below 64rem the accepted compact layout owns all
   geometry. Keep DOM order: heading, four actions, next action, then review. */
@media (min-width: 64rem) {
  #overview-panel {
    grid-template-columns: minmax(0, 1fr) clamp(18rem, 24vw, 22rem);
    align-items: start;
    gap: var(--space-6);
    padding: 10px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  #overview-panel > .row {
    grid-column: 1 / -1;
    min-width: 0;
  }
  #overview-panel .today-date {
    margin-top: var(--space-2);
    font-size: .875rem;
  }
  #overview-panel > .quick-actions {
    grid-column: 1;
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }
  #overview-panel .quick-actions-title {
    margin: 0;
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-soft);
    color: var(--ink);
    font-size: 1rem;
  }
  #overview-panel .day-loop-rail {
    grid-template-columns: minmax(0, 1fr);
  }
  #overview-panel .day-loop-row,
  #overview-panel #today-log-food {
    grid-template-columns: minmax(0, 1fr) minmax(10rem, 12rem);
    grid-template-areas: "copy action";
    column-gap: var(--space-4);
    min-height: 92px;
    padding-block: var(--space-4);
  }
  #overview-panel .day-loop-copy {
    grid-template-columns: 6rem minmax(0, 1fr);
    gap: var(--space-1) var(--space-4);
    align-items: center;
  }
  #overview-panel .day-loop-label {
    grid-column: 1;
    grid-row: 1 / span 2;
    color: var(--ink);
    font-size: .9375rem;
  }
  #overview-panel .day-loop-value {
    grid-column: 2;
    grid-row: 1;
    font-size: 1rem;
    line-height: 1.4;
  }
  #overview-panel .day-loop-note {
    grid-column: 2;
    grid-row: 2;
    font-size: .875rem;
    line-height: 1.4;
  }
  #overview-panel .day-loop-value > .nutrient-compact {
    max-width: 24rem;
    gap: var(--space-2) var(--space-4);
  }
  #overview-panel .nutrient-label { font-size: .8125rem; }
  #overview-panel .nutrient-value { font-size: 1rem; font-weight: var(--fw-semibold); }
  #overview-panel .day-loop-action,
  #overview-panel #today-log-food .day-loop-action {
    align-self: center;
    justify-self: end;
    min-width: 5rem;
    max-width: 100%;
    padding-inline: var(--space-4);
    font-size: .875rem;
    line-height: 1.4;
    text-align: center;
  }
  #overview-panel #today-set-goals {
    margin-top: var(--space-4);
    font-size: .875rem;
  }
  #overview-panel #today-status-error { margin-top: var(--space-4); }
  #overview-panel > .today-now {
    grid-column: 2;
    padding: var(--space-6);
    gap: var(--space-4);
  }
  #overview-panel .today-now-main { gap: var(--space-3); }
  #overview-panel .today-now-chip { font-size: .8125rem; }
  #overview-panel .today-now h3 {
    font-size: 1.25rem;
    line-height: 1.3;
    letter-spacing: var(--ls-h2);
    text-wrap: pretty;
  }
  #overview-panel #today-now-why {
    max-width: 36ch;
    font-size: .9375rem;
    line-height: 1.5;
  }
  #overview-panel .today-now-cta .today-plan-cta { font-size: .9375rem; }
  #overview-panel > .readiness-completion,
  #overview-panel > .today-details {
    grid-column: 1 / -1;
  }
  #overview-panel > .today-details {
    padding-inline: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }
  #overview-panel .today-details > summary {
    padding-block: var(--space-4);
    font-size: .9375rem;
  }
  #overview-panel .today-details[open] { padding-bottom: var(--space-4); }
  #overview-panel .all-stats-card {
    border: 0;
    border-top: 1px solid var(--border-soft);
    border-radius: 0;
    padding: 0;
    background: transparent;
  }
}
@media (min-width: 64rem) and (hover: hover) {
  #app-card:not(.hidden) > .tab-nav > button:not(.active):hover,
  #overview-panel .day-loop-row:hover,
  #overview-panel .today-details > summary:hover {
    background: var(--surface-2);
  }
  #overview-panel .today-now-cta .today-plan-cta:hover {
    background: var(--accent-pressed);
  }
}

/* Settings personal library; no diary intent. */
.my-food-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.my-food-row > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.my-food-row button { width: auto; flex-shrink: 0; min-width: 44px; }
/* Workouts desktop task workspace. Keep the accepted shell and phone flow. */
@media (min-width: 64rem) {
  /* Outrank the shared narrow secondary-panel rule for Workouts only. */
  #app-card > #workouts-panel.tab-panel:not(#overview-panel):not(#nutrition-panel) {
    width: 100%;
  }
  #workouts-panel:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
  }
  #workouts-panel > .strong-workout-card {
    order: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 20px;
    border-radius: var(--radius-lg);
  }
  #workouts-panel > .recent-card,
  #workouts-panel > .workout-template-management-card {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 20px;
    border-radius: var(--radius-lg);
  }
  #workouts-panel > .workout-template-management-card { order: 1; }
  #workouts-panel > .recent-card { order: 2; }
  #workouts-panel > .recent-card h2,
  #workouts-panel > .workout-template-management-card h2 {
    font-size: 1.125rem;
    line-height: 1.3;
    margin-bottom: 16px;
  }
  #workouts-panel .strong-workout-head { margin-bottom: 12px; }
  #workouts-panel .template-strip { flex-wrap: wrap; overflow: visible; gap: 6px; }
  #workouts-panel .template-chip {
    padding-inline: 14px;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }
  #workouts-panel .workout-unit-row {
    padding-block: 12px;
    margin: 0 0 16px;
    border-bottom: 1px solid var(--border-soft);
  }
  #workouts-panel .workout-start-panel {
    border: 0;
    border-radius: 0;
    padding: 0;
    gap: 20px;
  }
  #workouts-panel .strong-exercises { gap: 28px; }
  #workouts-panel .exercise-block + .exercise-block {
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
  }
  #workouts-panel .exercise-head { flex-wrap: wrap; }
  #workouts-panel .exercise-head h3 {
    flex: 1 1 210px;
    font-size: 1rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  #workouts-panel .exercise-head .mini-actions { gap: 6px; }
  #workouts-panel .exercise-head .mini-actions button { padding-inline: 12px; }
  #workouts-panel .strong-table-head,
  #workouts-panel .strong-set-line {
    grid-template-columns: 32px minmax(64px, 1fr) minmax(60px, .9fr) minmax(52px, .8fr) 44px 44px;
    gap: 6px;
  }
  #workouts-panel .strong-set-line input { min-width: 0; width: 100%; }
  #workouts-panel .exercise-sets { display: grid; gap: 4px; }
  #workouts-panel .previous-value { padding-inline: 0; font-size: .8125rem; }
  #workouts-panel #workout-history .timeline-item {
    flex-wrap: wrap;
    padding: 12px;
    gap: 10px;
  }
  #workouts-panel #workout-history .timeline-item > div { min-width: 0; }
  #workouts-panel #workout-history strong { overflow-wrap: anywhere; }
  #workouts-panel #workout-history .mini-actions { gap: 6px; }
  #workouts-panel #workout-history .mini-actions button { padding-inline: 10px; }
  #workouts-panel .template-editor-card {
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }
  #workouts-panel .template-editor-card .muted { font-size: .875rem; line-height: 1.5; }
  #workouts-panel .template-bubble {
    grid-template-columns: 44px minmax(0, 1fr) auto auto auto 44px;
    grid-template-areas: 'drag text reorder edit stepper remove';
    gap: 10px;
    border-radius: var(--radius);
    padding: 8px;
  }
  #workouts-panel .template-bubble .drag-handle { grid-area: drag; }
  #workouts-panel .template-bubble-text { grid-area: text; }
  #workouts-panel .template-remove { grid-area: remove; }
  #workouts-panel .template-reorder-controls { grid-area: reorder; justify-self: center; }
  #workouts-panel .template-edit { grid-area: edit; padding-inline: 8px; }
  #workouts-panel .template-set-stepper { grid-area: stepper; justify-self: end; }
  #workouts-panel .template-bubble-text strong {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: .9375rem;
    line-height: 1.4;
  }
  #workouts-panel .template-editor-card > .muted { max-width: 70ch; }
  #workouts-panel .template-editor-card .button-row { justify-content: flex-end; }
  #workouts-panel .template-editor-card .button-row > button { width: auto; min-width: 10rem; }
}
@media (min-width: 64rem) and (max-width: 79.999rem) {
  #workouts-panel .template-bubble {
    grid-template-columns: 44px minmax(0, 1fr) auto auto 44px;
    grid-template-areas: 'drag text text text text' '. reorder edit stepper remove';
    gap: 6px 10px;
  }
  #workouts-panel .template-reorder-controls { justify-self: start; }
}

/* ---------- Exploration plots, every width (S21 / B2) ----------
   `#trends-panel #trends-exploration` is displayed inside the Trends coaching
   disclosure at *all* widths, but these plot rules used to sit inside the
   `@media (min-width: 64rem)` block below. On the phone the SVG therefore fell
   back to the replaced-element default (300x150) and the r=22 keyboard/touch
   hit circle `trends-exploration.js` draws per point kept its default black
   fill: a column of 44px discs instead of a chart (visual review p70-p72).
   Geometry and interaction are width-independent, so they live here; only the
   desktop grid that arranges the cards stays in the media query. */
.explore-plot svg { width: 100%; height: 230px; display: block; overflow: visible; }
.explore-plot text { font-size: var(--fs-caption); fill: currentColor; }
.explore-grid { stroke: currentColor; opacity: .12; }
.explore-plot .explore-hit { fill: transparent; stroke: transparent; cursor: pointer; pointer-events: all; }
.explore-plot .explore-marker { fill: currentColor; pointer-events: none; }
.explore-plot .explore-hit:focus { outline: none; }
.explore-plot .explore-hit:focus + .explore-marker, .explore-plot .explore-hit.selected + .explore-marker { stroke: currentColor; stroke-width: 3; fill: var(--surface); }

/* Bounded desktop exploration. Mobile disclosures and forms remain unchanged. */
#trends-exploration { display: none; }
@media (min-width: 64rem) {
  #app-card > #trends-panel, #app-card > #settings-panel {
    width: 100%; margin-inline: 0; padding-top: 10px; min-width: 0;
  }
  #trends-panel:not(.hidden) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; align-items: start; }
  #trends-panel > .trends-overview-card, #trends-exploration { grid-column: 1 / -1; }
  #trends-panel > .trends-overview-card {
    display: grid; grid-template-columns: minmax(0,2fr) minmax(280px,1fr); gap: 0 32px;
    padding: clamp(20px,2vw,36px);
  }
  .trends-overview-card > .eyebrow, .trends-overview-card > h2 { grid-column: 1 / -1; }
  .trends-overview-card > #weight-explorer { grid-column: 1; grid-row: 3 / 7; margin-top: 8px; }
  .trends-overview-card > .trend-snapshot-grid { grid-column: 2; grid-row: 3; margin-top: 12px; align-self: start; }
  .trends-overview-card > .body-entry-shortcut { grid-column: 2; grid-row: 4; justify-self: start; align-self: start; }
  .trends-overview-card > .trend-chart-disclosure { grid-column: 2; grid-row: 5; align-self: start; margin-top: 18px; }
  #weight-explorer .weight-ranges { max-width: 32rem; }
  #trends-exploration { display: block; }
  .exploration-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 24px; margin-top: 24px; }
  .explore-card { min-width: 0; padding-left: 24px; border-left: 1px solid var(--border-soft); }
  .explore-card:nth-child(3n + 1) { padding-left: 0; border-left: 0; }
  .explore-card h3 { margin-top: 0; }
  .explore-card label { display: block; font-size: var(--fs-caption); color: var(--ink-2); margin-bottom: 6px; }
  .explore-card select { width: 100%; min-width: 0; min-height: 44px; }
  .explore-card .muted { min-height: 5em; font-size: .85rem; line-height: 1.5; }
  .explore-plot .weight-date-labels { font-size: var(--fs-caption); }
  .explore-card ol button { min-height: 44px; text-align: left; white-space: normal; width: 100%; }
  .explore-selection { min-height: 3.5em; font-size: .85rem; line-height: 1.5; }
  .explore-card summary { min-height: 44px; padding-block: 12px; cursor: pointer; }
  .explore-card ol { padding-left: 22px; max-height: 18rem; overflow-y: auto; font-size: .85rem; }
  .explore-card li { margin-bottom: 8px; overflow-wrap: anywhere; }
  #settings-panel:not(.hidden) { display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); gap: 18px 24px; align-items: start; }
  #settings-panel > .card { min-width: 0; padding: var(--card-pad); }
  #settings-panel > .settings-account-card { grid-column: 1 / -1; }
  #settings-panel > .my-foods-card { grid-column: 1; grid-row: 2; }
  #settings-panel > .settings-preferences-card { grid-column: 2; grid-row: 2 / 4; }
  #settings-panel > .settings-security-card { grid-column: 1; grid-row: 3; }
  #settings-panel .form { max-width: 56rem; }
  #settings-panel #password-form { max-width: 36rem; }
  #settings-panel p { max-width: 72ch; }
  #settings-panel .settings-account { max-width: none; }
  #settings-panel #my-foods-search-form { grid-template-columns: minmax(0,1fr) auto; align-items: end; }
  #my-foods-search-form > label { grid-column: 1 / -1; }
  #settings-panel #my-foods-search-form button { width: auto; min-width: 7rem; }
}
@media (min-width:64rem) and (max-width:79.99rem) {
  .exploration-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .explore-card { padding: 0; border-left: 0; }
  #explore-training { grid-column: 1 / -1; border-top: 1px solid var(--border-soft); padding-top: 20px; }
  .explore-card .muted { min-height: 6em; }
}

@media (min-width:64rem) { #explore-strength { grid-column: span 2; } #explore-readiness, #explore-strength { border-top: 1px solid var(--border-soft); padding-top: 24px; } }
@media (min-width:64rem) and (max-width:79.99rem) { #explore-strength { grid-column: 1 / -1; } }

/* Previous provenance is a noninteractive full-row description of the snapshot. */
#workouts-panel .previous-value {
  min-width: 0; white-space: normal; overflow: visible; text-overflow: clip;
  overflow-wrap: normal; word-break: normal;
}
#workouts-panel .previous-source {
  grid-column: 1 / -1; min-width: 0; margin: 0; padding: 0;
  color: var(--ink-3); font-size: .9rem; line-height: 1.5;
  font-weight: var(--fw-regular); white-space: normal; overflow-wrap: normal; word-break: normal;
}
@media (max-width: 360px) {
  #workouts-panel .previous-source { font-size: .82rem; }
}
@media (min-width: 64rem) {
  #workouts-panel .previous-source { font-size: .8125rem; }
}

/* Intact enlarged reuse values need their own line on the narrowest phones.
   Keep native button -> load -> reps -> done -> remove focus/visual order. */
@media (max-width: 360px) {
  #workouts-panel .set-row > .previous-value { grid-column: 1 / -1; grid-row: 1; }
  #workouts-panel .set-row > .previous-source { grid-row: 2; }
  #workouts-panel .set-row > .set-index-pill { grid-column: 1; grid-row: 3; }
  #workouts-panel .set-row > .set-weight { grid-column: 3; grid-row: 3; }
  #workouts-panel .set-row > .set-reps { grid-column: 4; grid-row: 3; }
  #workouts-panel .set-row > .done-set { grid-column: 5; grid-row: 3; }
  #workouts-panel .set-row > .remove-set { grid-column: 6; grid-row: 3; }
}

/* Nutrition visual 02: approved overview rhythm; no behavioral state changes. */
#nutrition-panel #nutrition-dashboard { gap: 16px; }
#nutrition-panel .nutrition-calories { gap: 8px; }
#nutrition-panel .nutrition-calories p strong { font-size: 2.75rem; font-weight: var(--fw-semibold); letter-spacing: var(--ls-display); }
#nutrition-panel .nutrition-calories-label,
#nutrition-panel .nutrition-macro > span { font-size: .875rem; color: var(--ink-2); }
#nutrition-panel .nutrition-calories small,
#nutrition-panel .nutrition-protein-target,
#nutrition-panel .nutrition-uncertainty { font-size: .875rem; line-height: 1.5; }
#nutrition-panel .nutrition-macros { gap: 16px; align-items: start; }
#nutrition-panel .nutrition-macro { min-width: 0; gap: 8px; }
#nutrition-panel .nutrition-macro strong { font-size: 1rem; line-height: 1.5; overflow-wrap: normal; word-break: normal; }
#nutrition-panel #nutrition-dashboard > .dashboard-knowledge { height: auto; min-height: 0; max-height: none; overflow: visible; }
#nutrition-panel #nutrition-dashboard > .dashboard-knowledge > summary { position: static; font-size: .875rem; }
@media (min-width: 64rem) {
  #nutrition-panel > .nutrition-primary-card { padding: 24px; gap: 16px; }
  #nutrition-panel #nutrition-dashboard { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 16px; }
  #nutrition-panel #nutrition-dashboard .nutrition-calories { grid-column: 1; grid-row: 1; }
  #nutrition-panel #nutrition-dashboard .nutrition-calories p strong { font-size: 3.25rem; }
  #nutrition-panel #nutrition-dashboard .nutrition-macros { grid-column: 1; grid-row: 2; }
  #nutrition-panel #nutrition-dashboard .nutrition-protein-target { grid-column: 1; grid-row: 3; }
  #nutrition-panel #nutrition-dashboard .nutrition-uncertainty { grid-column: 1; grid-row: 4; }
  #nutrition-panel #nutrition-dashboard > .dashboard-knowledge { grid-column: 1 / -1; grid-row: 5; align-self: start; }
}

/* Nutrition repair 03: intrinsic disclosure footer and compact desktop totals. */
#nutrition-panel #nutrition-message:empty { display: none; }
#nutrition-panel .nutrition-day-details > summary { position: static; font-size: .875rem; }
#nutrition-panel .meal-group > summary small { text-wrap: balance; overflow-wrap: normal; }
@media (min-width: 64rem) {
  #nutrition-panel > .nutrition-primary-card { gap: 12px 20px; }
  #nutrition-panel > .nutrition-primary-card:has(> #nutrition-message:empty) { grid-template-areas: "title add date" "dashboard dashboard dashboard"; }
  #nutrition-panel #nutrition-dashboard { grid-template-columns: minmax(18rem, .8fr) minmax(0, 1.6fr); gap: 12px 32px; }
  #nutrition-panel #nutrition-dashboard .nutrition-calories { grid-column: 1; grid-row: 1 / span 2; }
  #nutrition-panel #nutrition-dashboard .nutrition-macros { grid-column: 2; grid-row: 1; width: 100%; max-width: 48rem; }
  #nutrition-panel #nutrition-dashboard .nutrition-protein-target { grid-column: 2; grid-row: 2; margin: 0; }
  #nutrition-panel #nutrition-dashboard .nutrition-uncertainty { grid-column: 1 / -1; grid-row: auto; margin: 0; }
  #nutrition-panel #nutrition-dashboard > .dashboard-knowledge { grid-column: 1 / -1; grid-row: auto; }
}

/* Nutrition diary refinement: a quiet summary, meal rows, and a secondary library. */
#nutrition-panel:not(.hidden) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 8px 0 24px; }
#nutrition-panel .card { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
#nutrition-panel > .nutrition-primary-card,
#nutrition-panel > .nutrition-primary-card:has(> #nutrition-message:empty) { display: flex; flex-direction: column; align-items: stretch; padding: 0; gap: 20px; }
#nutrition-panel .nutrition-day-header { display: flex; flex-direction: column; gap: 4px; }
#nutrition-panel .nutrition-day-header h2 { margin: 0; font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-h2); }
#nutrition-panel .nutrition-day-navigation { display: flex; align-items: start; gap: 4px; }
#nutrition-panel .nutrition-day-navigation > button { width: 44px; height: 44px; padding: 10px; border: 0; background: transparent; color: var(--ink-2); flex: 0 0 44px; }
#nutrition-panel .nutrition-day-navigation svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
#nutrition-day-picker { min-width: 0; flex: 1; max-width: 260px; }
#nutrition-day-picker > summary { min-height: 44px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2); font-size: .9rem; list-style: none; border-radius: var(--radius); }
#nutrition-day-picker > summary::-webkit-details-marker { display: none; }
#nutrition-day-picker[open] { padding-bottom: 12px; }
#nutrition-panel .nutrition-day-header .nutrition-date-picker { width: 100%; max-width: none; margin: 8px 0; }
#nutrition-panel #nutrition-selected-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; margin: -1px; }
#nutrition-panel #nutrition-dashboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin: 0; padding: 0; border: 0; order: 1; }
#nutrition-panel #nutrition-dashboard > * { grid-area: auto; }
#nutrition-panel #nutrition-dashboard .nutrition-calories,
#nutrition-panel #nutrition-dashboard .nutrition-macros,
#nutrition-panel #nutrition-dashboard .nutrition-uncertainty,
#nutrition-panel #nutrition-dashboard > .dashboard-knowledge { grid-column: 1; grid-row: auto; }
#nutrition-panel .nutrition-calories p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
#nutrition-panel #nutrition-dashboard .nutrition-calories p strong { font-size: clamp(2rem, 7vw, 2.75rem); letter-spacing: var(--ls-display); }
#nutrition-panel .nutrition-macros { gap: 12px; }
#nutrition-panel .nutrition-macro { gap: 4px; }
#nutrition-panel .nutrition-macro small { color: var(--ink-2); font-size: var(--fs-caption); }
#nutrition-panel .nutrition-uncertainty { font-size: var(--fs-caption); }
#nutrition-panel .dashboard-knowledge { border-top: 1px solid var(--border-soft); padding-top: 0; }
#nutrition-panel .capture-action-solo { order: 2; width: 100%; max-width: none; justify-content: center; min-height: 48px; border-radius: var(--radius); padding: 12px 16px; }
#nutrition-panel #nutrition-message { order: 3; }
#nutrition-panel > .nutrition-workspace { display: block; min-width: 0; }
#nutrition-panel .nutrition-diary-card { padding: 0; overflow: visible; }
#nutrition-panel .nutrition-diary-card > .eyebrow { display: none; }
#nutrition-panel .nutrition-diary { border: 0; border-radius: 0; background: transparent; }
#nutrition-panel .nutrition-diary > .meal-group { padding: 0; }
#nutrition-panel .meal-group > summary { min-height: 78px; padding: 14px 0; gap: 12px; }
#nutrition-panel .meal-group > summary small { text-wrap: initial; }
#nutrition-panel .meal-group[open] > summary { border-bottom: 1px solid var(--border-soft); margin-bottom: 8px; }
#nutrition-panel .meal-group > summary::after { transition: transform 160ms ease-out; }
#nutrition-panel .food-entry { grid-template-columns: minmax(0, 1fr); padding: 16px 0; }
#nutrition-panel .food-entry-content { display: block; grid-column: 1; }
#nutrition-panel .food-entry-content > strong,
#nutrition-panel .food-entry-content > .food-serving { display: block; }
#nutrition-panel .food-entry > .mini-actions { grid-column: 1; }
#nutrition-panel .nutrition-secondary-tools { display: block; margin-top: 24px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
#nutrition-panel .nutrition-library-intro { margin: 0 0 16px; font-size: .85rem; }
#nutrition-panel .nutrition-secondary-tools > .card { padding: 0; margin: 0; border-top: 1px solid var(--border-soft); }
#nutrition-panel .nutrition-secondary-tools > .card > details > summary { min-height: 48px; padding: 12px 0; }
#nutrition-panel button, #nutrition-panel summary { min-height: 44px; }
#nutrition-panel :is(button, summary, input, select):focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
#nutrition-panel :is(button, summary):hover { filter: none; }
@media (min-width: 64rem) {
  #nutrition-panel:not(.hidden) { width: 100%; margin: 36px 0; padding-inline: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-6); align-items: start; }
  #nutrition-panel .nutrition-primary-card .capture-action-solo { width: 100%; max-width: none; }
  #nutrition-panel > #nutrition-hydration-status { grid-column: 1 / -1; }
  #nutrition-panel > .nutrition-primary-card { grid-column: 1; }
  #nutrition-panel > .nutrition-workspace { grid-column: 2; padding-top: 4px; }
  #nutrition-panel .nutrition-diary { border-top: 1px solid var(--border-soft); }
  #nutrition-panel .meal-group > summary { min-height: 92px; }
  #nutrition-panel .nutrition-secondary-tools { margin-top: 32px; }
}

/* Photo meal review: shared Nutrition surfaces, compact editable rows. */
#plate-estimate { scroll-margin-top: var(--space-4); }
#plate-estimate h3 { margin-bottom: var(--space-2); }
.plate-estimate-total { font-size: 1.125rem; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.plate-meal-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-3); margin-block: var(--space-4); }
#plate-estimate label { display: grid; gap: var(--space-1); min-width: 0; color: var(--ink-2); font-size: .8125rem; }
#plate-estimate input, #plate-estimate select { width: 100%; min-width: 0; font-size: 1rem; }
#plate-estimate .vision-component { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); border-top: 1px solid var(--border); padding-block: var(--space-3); margin: 0; }
.plate-item-nutrients { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.plate-item-nutrients input { padding-inline: var(--space-2); font-variant-numeric: tabular-nums; }
.plate-item-actions { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.plate-item-actions span { flex: 1; font-size: var(--fs-caption); }
#plate-estimate .plate-item-actions button { width: auto; padding-inline: var(--space-2); font-size: .8125rem; background: transparent; box-shadow: none; }
.plate-estimate-details { border-block: 1px solid var(--border); padding-block: var(--space-3); }
#plate-add { width: 100%; margin-top: var(--space-2); }

/* Once analysed, let review own the finder sheet instead of nesting in its tools. */
.photo-meal-review #finder-mode-tabs,
.photo-meal-review .meal-draft-bar,
.photo-meal-review #finder-search-mode > :not(#plate-reference),
.photo-meal-review #plate-reference > summary,
.photo-meal-review .plate-reference-body > :not(#plate-estimate) { display: none; }
.photo-meal-review #plate-reference,
.photo-meal-review .plate-reference-body,
.photo-meal-review #plate-estimate { border: 0; background: transparent; padding: 0; margin: 0; box-shadow: none; }
.photo-meal-review #plate-estimate { padding-inline: var(--space-1); }
.photo-meal-review .finder-mode { padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); scroll-padding-bottom: var(--space-6); }
.photo-meal-review .vision-estimate-banner { background: transparent; border: 0; padding: 0; font-size: .8125rem; color: var(--ink-2); }
.photo-meal-review .plate-item-actions button { border: 0; text-decoration: underline; text-underline-offset: .2em; }

.plate-meal-footer { display: none; flex: 0 0 auto; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: var(--surface); }
#food-finder-modal:has(#plate-estimate:not(.hidden)) .plate-meal-footer { display: block; }
.plate-meal-footer .message:empty { display: none; }

/* Overhaul S1: shared hierarchy and quiet Workouts groups. */
body.signed-in .hero { display: none; }
.page-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; padding: 14px 4px 6px; }
.page-header h1 { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: var(--type-page); line-height: 1.2; letter-spacing: var(--ls-h1); }
.page-header time, .list-meta { color: var(--text-secondary); font-size: var(--type-meta); line-height: 1.5; }
.page-header time { white-space: nowrap; }
.list-group { background: var(--surface); border-radius: var(--radius-lg); }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 14px 18px; color: var(--text-primary); background: none; border: 0; border-radius: 0; text-align: left; }
.list-row-label { flex: 1; min-width: 0; }
.list-row-label strong { display: block; font-size: var(--type-primary); font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.list-row-label .list-meta { display: block; font-size: 13px; }
.list-row-value { color: var(--text-secondary); font-size: var(--type-meta); white-space: nowrap; }
.list-chevron { color: var(--text-secondary); width: 16px; height: 16px; flex-shrink: 0; }
.list-group > * + * { border-top: 1px solid var(--border-soft); }
.list-row:hover { background: var(--fill); }
.list-row:hover .list-row-label strong { text-decoration: underline; text-underline-offset: 3px; }
.workout-history-detail > summary { list-style: none; cursor: pointer; }
.workout-history-detail > summary::-webkit-details-marker { display: none; }
.workout-history-detail[open] .list-chevron { transform: rotate(90deg); }
.workout-history-detail .mini-actions, .workout-history-detail .workout-detail-copy { padding: 0 18px 16px; }
/* S25 / backlog B8 + B9: one tag spelling for a personal record wherever it
   is claimed (live set, Finish review, history row, Cut Review key lift),
   and the numbers an opened history row used to hide behind Edit. */
.review-exercise-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.record-tag { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: var(--radius-sm); font-size: var(--fs-caption); font-weight: var(--fw-bold); letter-spacing: .02em; color: var(--success); background: var(--success-bg); }
.record-tag::before { content: "\25B4"; line-height: 1; }
.list-row-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.workout-detail-sets { list-style: none; display: grid; gap: var(--space-1); margin: 0; padding: 0 var(--card-pad) var(--space-3); }
.workout-detail-sets li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.workout-detail-exercise { flex: 1 1 auto; min-width: 0; color: var(--ink); font-size: var(--fs-label); overflow-wrap: anywhere; }
.workout-detail-top { color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cardio-list-toggle { width: auto; margin-top: 10px; }
.cardio-list-count { margin: 6px 0 0; }
#workouts-panel { gap: 24px; }
#workouts-panel > .strong-workout-card { padding: 18px; border-radius: var(--radius-lg); gap: 0; }
#workouts-panel .strong-workout-head { margin-bottom: 0; }
#workouts-panel #active-workout-title { font-size: var(--fs-h2); line-height: 1.25; margin: 4px 0; letter-spacing: var(--ls-h2); }
#workouts-panel #workout-template-meta { margin: 0; }
#workouts-panel:not(.workout-is-active) .workout-meta { display: none; }
#workouts-panel.workout-is-active #workout-selection-label,
#workouts-panel.workout-is-active #workout-template-meta { display: none; }
#workouts-panel .template-strip { margin: 16px 0 0; padding: 0; gap: 6px; flex-wrap: wrap; }
#workouts-panel .template-chip { min-height: 44px; font-size: 14px; padding: 10px 13px; border: 0; border-radius: var(--radius-pill); background: var(--fill); color: var(--text-secondary); }
#workouts-panel .template-chip.active { background: var(--accent); color: var(--accent-ink); }
#workouts-panel .workout-start-panel { padding: 0; margin: 16px 0 0; background: none; border: 0; }
#start-workout { min-height: 52px; width: 100%; font-size: 17px; border-radius: var(--radius); }
#workout-message:empty { display: none; }
#workouts-panel > .recent-card, #workouts-panel > .workout-template-management-card { padding: 0; background: none; }
/* Cardio entry (S17) wears the same card chrome as the session card above it. */
#workouts-panel > .cardio-card { padding: 18px; border-radius: var(--radius-lg); }
#workouts-panel > .cardio-card > h2 { margin: 0 0 12px; }
/* Save and Cancel live below the message line rather than inside the field
   grid, so an error is always directly above the button that produced it and
   closing the form cannot hide the confirmation the save wrote. They wear the
   form's own stacked geometry. */
#workouts-panel .cardio-card .cardio-actions { display: grid; gap: 14px; }
#workouts-panel .cardio-card #cardio-list { margin-top: 12px; }
#workouts-panel .cardio-card .timeline-item .list-meta { margin: 4px 0 0; }
#workouts-panel .recent-card h2, .workout-week h2 { margin: 0 4px 10px; }
.workout-week-stats { display: flex; gap: 32px; padding: 16px 18px; }
/* A week the server could not describe leaves no empty card behind (B14). */
.workout-week-stats:empty { display: none; }
.workout-week-stats > * + * { border: 0; }
.workout-week-stats strong { display: block; font-size: 22px; line-height: 1.4; }
.workout-week-stats span { font-size: 13px; color: var(--text-secondary); }
#workout-history > .muted { padding: 18px; }
#workouts-panel .template-editor-card { border: 0; margin: 0; background: var(--surface); border-radius: var(--radius-lg); }
#workouts-panel .template-editor-card > summary { padding-inline: 16px; }
.workout-unit-toggle button[aria-pressed="true"] { text-decoration: underline; text-underline-offset: 4px; }
@media (min-width: 1024px) {
  .shell:has(> #app-card:not(.hidden)):has(#workouts-panel:not(.hidden)) { max-width: 1440px; }
  #workouts-panel:not(.hidden):not(.workout-is-active) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; gap: 24px; }
  #workouts-panel:not(.workout-is-active) > .strong-workout-card { grid-column: 1; grid-row: 1; }
  #workouts-panel:not(.workout-is-active) > .workout-week { grid-column: 1; grid-row: 2; }
  #workouts-panel:not(.workout-is-active) > .cardio-card { grid-column: 1; grid-row: 3; }
  #workouts-panel:not(.workout-is-active) > .workout-template-management-card { grid-column: 1; grid-row: 4; }
  #workouts-panel:not(.workout-is-active) > .recent-card { grid-column: 2; grid-row: 1 / span 4; }
}

/* Overhaul S1b: active session shares S1's quiet groups and rhythm. */
#workouts-panel .previous-source { display: none; }
#workouts-panel.workout-is-active > .strong-workout-card { background: none; padding: 0; }
#workouts-panel.workout-is-active .strong-workout-head { padding: 12px 4px; }
#workouts-panel.workout-is-active .strong-workout-form { gap: 16px; }
#workouts-panel .exercise-block { background: var(--surface); border-radius: var(--radius-lg); padding: var(--card-pad); gap: 8px; }
#workouts-panel .exercise-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
#workouts-panel .exercise-head h3 { flex: 1 1 auto; min-width: 0; color: var(--text-primary); font-size: 18px; font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
#workouts-panel .suggested-next-slot, #workouts-panel .suggested-next { display: contents; }
#workouts-panel .suggested-next-slot:empty { display: none; }
#workouts-panel .suggested-pill { width: auto; min-height: 44px; display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-pill); cursor: pointer; font-size: 14px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; list-style: none; margin-left: auto; }
.suggested-pill::-webkit-details-marker { display: none; }
.signal-up { color: var(--signal-up-fg); background: var(--signal-up-bg); }
.signal-hold { color: var(--signal-hold-fg); background: var(--signal-hold-bg); }
#workouts-panel .suggested-explanation { flex-basis: 100%; margin: 0; color: var(--text-secondary); font-size: var(--type-meta); line-height: 1.5; }
#workouts-panel .exercise-block > .mini-actions { gap: 16px; }
#workouts-panel .exercise-block > .mini-actions button { background: none; border: 0; color: var(--text-secondary); padding: 4px 0; min-width: 44px; min-height: 44px; font-weight: var(--fw-regular); }
#workouts-panel .exercise-sets { display: grid; gap: 8px; }
#workouts-panel .strong-table-head { text-transform: none; letter-spacing: 0; font-weight: var(--fw-regular); color: var(--text-secondary); }
#workouts-panel .strong-set-line { font-variant-numeric: tabular-nums; }
#workouts-panel .strong-set-line input { font-weight: var(--fw-medium); }
#workouts-panel .add-set-wide, #workouts-panel .add-exercises-wide { background: var(--fill); color: var(--text-primary); border: 0; font-weight: var(--fw-medium); min-height: 44px; }
#workouts-panel .cancel-workout-wide { background: none; border: 0; color: var(--danger); font-weight: var(--fw-regular); }
#workouts-panel #finish-workout { width: 100%; min-height: 52px; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); font-size: 17px; }
#workouts-panel .rest-pill { background: none; border: 0; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
#workouts-panel .rest-pill button { min-width: 44px; min-height: 44px; color: var(--text-secondary); background: var(--fill); }
@media (max-width: 700px) {
  #workouts-panel.workout-is-active { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  #workouts-panel .exercise-block { padding: 12px; }
}

#workouts-panel .strong-topbar { position: static; grid-template-columns: auto minmax(0, 1fr); background: none; border: 0; padding: 0 4px; margin: 0 0 12px; backdrop-filter: none; }
#workouts-panel .top-icon-button { width: auto; padding-inline: 8px; background: none; border: 0; color: var(--danger); font-size: 14px; font-weight: var(--fw-regular); }
#workouts-panel .timer-stack { justify-content: flex-end; }
#workouts-panel .elapsed-label, #workouts-panel .rest-pill span { text-transform: none; letter-spacing: 0; font-weight: var(--fw-regular); }
#workouts-panel .exercise-block + .exercise-block { border: 0; }

#workouts-panel:has(#workout-editor-mode.hidden) #save-workout { background: var(--fill); color: var(--text-primary); border: 0; border-radius: var(--radius); font-weight: var(--fw-medium); }
#workouts-panel.workout-is-active #workout-summary { background: var(--surface); border: 0; border-radius: var(--radius-lg); box-shadow: none; }
#workouts-panel.workout-is-active #workout-summary .summary-grid article { background: none; padding: 8px 0; }
#workouts-panel.workout-is-active #workout-summary .summary-grid span { text-transform: none; letter-spacing: 0; color: var(--text-secondary); }

/* Overhaul S2: one recorded series, with quiet history and supporting details. */
#trends-panel { max-width: 1440px; margin-inline: auto; width: 100%; overflow-anchor: none; }
#trends-panel #weight-explorer { display: grid; gap: 16px; margin: 0; min-width: 0; }
.trends-metrics, #trends-panel .weight-ranges { display: flex; flex-wrap: wrap; gap: 8px; }
#trends-panel .trends-metrics button, #trends-panel .weight-ranges button { min-height: 44px; min-width: 44px; width: auto; flex: 1 1 auto; background: none; border: 1px solid var(--border-soft); color: var(--text-secondary); padding: 10px 12px; }
#trends-panel [aria-pressed="true"] { color: var(--text-primary); outline: 2px solid currentColor; outline-offset: -2px; font-weight: var(--fw-semibold); }
#trends-panel h2, #trends-panel h3 { margin: 0; }
#trends-panel .trends-chart { padding: 20px; min-width: 0; }
#trends-panel .trends-chart > * { border: 0; }
#trends-panel #weight-explorer-summary { font-size: 20px; line-height: 1.45; font-weight: var(--fw-medium); margin: 12px 0 20px; }
#trends-panel #weight-explorer-window, #trends-panel #weight-explorer-selection, #trends-panel .weight-date-labels { color: var(--text-secondary); }
#trends-panel #weight-explorer-selection { font-size: 14px; line-height: 1.5; margin-bottom: 0; min-height: 80px; }
#weight-explorer-selection button { margin: 8px 8px 0 0; min-height: 44px; }
#trends-panel #weight-explorer-plot .weight-measured-line { stroke-width: 2; opacity: 1; }
#trends-panel .weight-grid { opacity: .12; }
#trends-panel .trends-history { min-width: 0; align-self: start; overflow: hidden; }
.trends-history h3 { padding: 20px 18px 10px; }
#trends-panel #weight-explorer-list { list-style: none; padding: 0; margin: 0; max-height: 440px; overflow-y: auto; }
#trends-panel #weight-explorer-list li { border-top: 1px solid var(--border-soft); }
#trends-panel #weight-explorer-list button { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; width: 100%; margin: 0; background: none; border: 0; border-radius: 0; color: var(--text-primary); font-weight: var(--fw-regular); }
#trends-panel #weight-explorer-list span { color: var(--text-secondary); }
#trends-panel #body-entry-shortcut { border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; margin: 0; background: none; color: var(--text-primary); text-decoration: none; }
#trends-panel [hidden] { display: none !important; }
#trends-panel .coaching-details { min-width: 0; }
#trends-panel .coaching-details > summary { cursor: pointer; }
#trends-panel .coaching-details > :not(summary) { margin: 0; padding: 16px; border-top: 1px solid var(--border-soft); }
#trends-panel .coaching-details :is(.card,.explore-card,.trend-snapshot,.trend-block,.timeline-item,.history-card) { background: none; box-shadow: none; border-radius: 0; }
#trends-panel .coaching-details .card { border: 0; border-top: 1px solid var(--border-soft); }
#trends-panel .coaching-details :is(.trend-snapshot,.trend-chart-disclosure) { border: 0; border-radius: 0; box-shadow: none; }
#trends-panel .coaching-details :is(article,.current-split-card,.weekly-review-card,.four-week-proposal-card) { background: none; box-shadow: none; border-radius: 0; }
#trends-panel #weight-explorer-list .list-chevron { width: 16px; height: 16px; min-height: 0; }
#trends-panel #weight-explorer-list strong { margin-left: auto; }
#trends-panel #weight-explorer-summary { color: var(--text-primary); }
#trends-panel .coaching-details :is(.trend-disclosure-body,.exploration-grid) { padding-inline: 0; }
#trends-panel #trends-exploration { display: block; }
#trends-panel .exploration-grid { display: grid; grid-template-columns: minmax(0,1fr); }
#trends-panel .explore-card { border: 0; border-top: 1px solid var(--border-soft); min-width: 0; }
#trends-panel .eyebrow { display: none; }
#trends-panel :is(.muted,.trend-caption,.trend-disclosure-summary span span) { color: var(--text-secondary); }
#trends-panel .body-metric-card { background: var(--surface); border-radius: var(--radius-lg); }
#trends-panel :is(button,summary,a) { overflow-wrap: anywhere; }
#trends-panel .body-undo-region { background: var(--surface); }
@media (min-width: 1024px) {
  #trends-panel:not(.hidden) { display: flex; flex-direction: column; }
  #trends-panel #weight-explorer { grid-template-columns: minmax(0,2fr) minmax(0,1fr); width: 100%; }
  #trends-panel .trends-metrics, #trends-panel .weight-ranges, #weight-explorer-heading { grid-column: 1 / -1; }
  #trends-panel .trends-metrics, #trends-panel .weight-ranges { max-width: 480px; }
  #trends-panel .trends-chart { grid-column: 1; }
  #trends-panel .trends-history { grid-column: 2; }
  #trends-panel .coaching-details { width: 100%; }
  #trends-panel .exploration-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 240px) {
  #trends-panel .trends-chart, #trends-panel .coaching-details > :not(summary) { padding: 8px; }
  #trends-panel .list-row { padding-inline: 8px; }
  .page-header time { white-space: normal; }
}

/* Overhaul S3: focused Settings children and the shared quiet list language. */
#settings-panel:not(.hidden) { overflow-anchor: none; align-items: stretch; display: flex; flex-direction: column; gap: 20px; max-width: 1440px; width: 100%; margin-inline: auto; }
#settings-panel .settings-groups { width: 100%; display: grid; gap: var(--space-5); min-width: 0; }
#settings-panel .settings-group { min-width: 0; }
#settings-panel .settings-group h2 { margin: 0 4px 10px; }
#settings-panel .settings-row { width: 100%; border: 0; border-radius: 0; text-align: left; font-weight: var(--fw-regular); color: var(--text-primary); background: none; min-height: 56px; padding: var(--space-3) var(--card-pad); }
#settings-panel .list-group { overflow: hidden; }
#settings-panel .list-group > * + * { border-top: 1px solid var(--border-soft); }
#settings-panel .list-row-value { white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; margin-left: auto; text-align: right; }
#settings-panel .list-row-label { flex: 1; }
#settings-panel :is(.muted,.list-meta,.coaching-profile-status) { color: var(--text-secondary); }
#settings-panel .coaching-profile-status { display: block; margin: 4px 0 0; font-size: 13px; font-weight: var(--fw-regular); line-height: 1.5; }
#settings-panel .settings-unit-home { padding: var(--space-2) var(--card-pad); }
#settings-panel .workout-unit-row { margin: 0; padding: 0; flex-wrap: wrap; gap: 8px; }
#settings-panel .workout-unit-row > span { color: var(--text-primary); font-size: var(--type-primary); font-weight: var(--fw-semibold); }
#settings-panel .settings-child { min-width: 0; }
#settings-panel .settings-child-head { display: grid; grid-template-columns: var(--tap) minmax(0,1fr) var(--tap); align-items: center; gap: var(--space-2); min-height: 56px; margin: 0 0 var(--space-3); }
#settings-panel .settings-child-head h2 { grid-column: 2; margin: 0; text-align: center; font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1.3; letter-spacing: 0; color: var(--ink); }
#settings-panel .settings-back { grid-column: 1; grid-row: 1; display: grid; place-items: center; width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink-2); box-shadow: none; text-decoration: none; }
#settings-panel .settings-child-content { padding: var(--card-pad); }
#settings-panel .settings-child-content > * { border: 0; }
#settings-panel .settings-child-content > p:first-child { margin-top: 0; color: var(--text-secondary); }
#settings-panel .coaching-profile-card { padding: 0; margin: 0; background: none; border: 0; border-radius: 0; }
#settings-panel :is(input,select,textarea) { background: transparent; color: var(--text-primary); min-width: 0; max-width: 100%; }
#settings-panel :is(button,label,p,span,h2) { overflow-wrap: anywhere; }
#settings-panel .my-food-row { background: none; }
#settings-panel #my-foods-status:empty, #settings-panel .message:empty, #settings-panel .tab-state:empty { display: none; }
#settings-panel .hidden { display: none !important; }
@media (min-width: 1024px) {
  .shell:has(> #app-card:not(.hidden)):has(#settings-panel:not(.hidden)) { max-width: 1440px; }
  #settings-panel .settings-groups { grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
  #settings-panel .settings-child { width: 100%; max-width: 960px; margin-inline: auto; }
}
@media (max-width: 240px) {
  #settings-panel .settings-row { flex-wrap: wrap; padding: 12px 8px; gap: 8px; }
  #settings-panel .settings-child-head { grid-template-columns: var(--tap) minmax(0,1fr); }
  #settings-panel .settings-row .list-row-label { flex-basis: calc(100% - 24px); }
  #settings-panel .settings-row .list-row-value { margin-left: 0; text-align: left; }
  #settings-panel .settings-child-content, #settings-panel .settings-unit-home { padding: 8px; }
}


/* Overhaul S4: Today shares the quiet header, groups and activity rows. */
#overview-panel:not(.hidden) { display: flex; flex-direction: column; align-items: stretch; gap: 20px; width: 100%; max-width: 1440px; margin-inline: auto; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
#overview-panel .today-intro { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
#overview-panel .today-intro > div:first-child { flex: 1; min-width: 0; }
#overview-panel .today-status-sentence { margin: 0; padding: 0 4px; color: var(--text-secondary); font-size: var(--type-meta); line-height: 1.5; }
#overview-panel #today-date[hidden] { display: none; }
#overview-panel #open-settings { background: none; border: 0; color: var(--text-secondary); }
#overview-panel > .quick-actions { display: grid; grid-template-columns: minmax(0,1fr); gap: 20px; padding: 0; background: none; border: 0; border-radius: 0; }
#overview-panel #today-now { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding: 20px; border: 0; border-radius: var(--radius-lg); background: var(--surface); }
#overview-panel .today-now-main { display: flex; flex-direction: column; gap: 8px; }
#overview-panel #today-now-action { margin: 0; font-size: var(--fs-h2); line-height: var(--lh-snug); }
#overview-panel #today-now-why, #overview-panel #today-now-freshness { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; max-width: none; }
#overview-panel #today-now-cta { width: 100%; }
#overview-panel #today-now-cta .today-plan-cta { width: 100%; min-height: 44px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius); white-space: normal; }
#overview-panel #day-loop-rail { display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; background: var(--surface); border: 0; border-radius: var(--radius-lg); overflow: hidden; }
#overview-panel .day-loop-row, #overview-panel #today-log-food { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 14px 18px; margin: 0; border: 0; border-radius: 0; background: none; text-align: left; font-weight: var(--fw-regular); color: var(--text-primary); box-shadow: none; }
#overview-panel .day-loop-row + .day-loop-row { border-top: 1px solid var(--border-soft); }
#overview-panel .day-loop-copy { display: block; flex: 1; min-width: 0; }
#overview-panel .day-loop-label { display: block; color: var(--text-primary); font-size: var(--type-primary); font-weight: var(--fw-semibold); }
#overview-panel :is(.day-loop-value,.day-loop-note,.day-loop-row.is-complete .day-loop-value) { display: block; color: var(--text-secondary); font-size: 13px; font-weight: var(--fw-regular); line-height: 1.5; }
#overview-panel .day-loop-action, #overview-panel #today-log-food .day-loop-action { display: block; flex: 0 1 auto; width: auto; min-width: 0; max-width: 100%; min-height: 0; margin: 0 0 0 auto; padding: 0; background: none; border: 0; border-radius: 0; color: var(--text-secondary); font-size: var(--type-meta); line-height: 1.5; white-space: normal; text-align: right; }
#overview-panel .list-chevron { width: 16px; height: 16px; min-height: 0; }
#overview-panel #today-set-goals { margin: 0; padding: 14px 18px; text-align: left; background: none; color: var(--text-secondary); border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; }
#overview-panel #today-details { margin: 0; padding: 0; background: var(--surface); border: 0; border-radius: var(--radius-lg); }
#overview-panel #today-details > summary { padding: 14px 18px; min-height: 60px; list-style: none; color: var(--text-primary); }
#overview-panel #today-details > summary::after { display: none; }
#overview-panel #today-details > summary::-webkit-details-marker { display: none; }
#overview-panel #today-details[open] > summary .list-chevron { transform: rotate(90deg); }
#overview-panel #today-details > :not(summary) { margin: 0; padding: 16px 18px; border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; background: none; box-shadow: none; }
#overview-panel #today-details :is(.today-plan-item,.today-plan-details,.stat,.metric,.weekly-rec-rationale) { background: none; border-radius: 0; box-shadow: none; }
#overview-panel #today-details :is(p,dt,dd,summary,.muted) { color: var(--text-secondary); }
#overview-panel #today-details button { background: none; color: var(--text-primary); }
#overview-panel :is(button,summary,p,span,strong,h3) { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#overview-panel .hidden { display: none !important; }
@media (min-width: 1024px) {
  .shell:has(> #app-card:not(.hidden)):has(#overview-panel:not(.hidden)) { max-width: 1440px; }
  #overview-panel > .quick-actions { grid-template-columns: minmax(0,1fr) minmax(0,2fr); align-items: start; }
  #overview-panel #today-details { width: calc((100% - 20px) * 2 / 3); margin-left: auto; }
}
@media (max-width: 240px) {
  #overview-panel .day-loop-row, #overview-panel #today-log-food { flex-wrap: wrap; padding: 12px 8px; gap: 8px; }
  #overview-panel .day-loop-copy { flex-basis: 100%; }
  #overview-panel .day-loop-action, #overview-panel #today-log-food .day-loop-action { margin-left: 0; text-align: left; }
  #overview-panel #today-now, #overview-panel #today-details > :not(summary) { padding: 12px 8px; }
}

#overview-panel #status-summary article { background: none; border: 0; border-radius: 0; }

/* Overhaul S5: Nutrition foundation alignment; preserve diary composition. */
#nutrition-panel > .nutrition-primary-card,
#nutrition-panel > .nutrition-primary-card:has(> #nutrition-message:empty),
#nutrition-panel .nutrition-diary-card { background: var(--surface); border-radius: var(--radius-lg); padding: 18px; }
#nutrition-panel .nutrition-day-header h2[hidden] { display: none; }
#nutrition-panel .nutrient-details ul { background: none; border-radius: 0; padding-inline: 0; }
#nutrition-panel .meal-group > summary strong,
#nutrition-panel .food-entry-content > strong { font-size: var(--type-primary); font-weight: var(--fw-semibold); }
#nutrition-panel :is(.food-serving,.food-entry small,.food-entry span,.nutrient-details li small) { color: var(--text-secondary); }
#nutrition-panel .meal-group > summary small,
#nutrition-panel .food-serving { font-size: 13px; line-height: 1.5; }
#nutrition-panel .food-entry > .mini-actions button { background: none; color: var(--text-primary); border-color: var(--border-soft); }
#nutrition-panel .food-entry > .mini-actions:has(> .entry-actions-menu) {
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: end; gap: 6px;
}
#nutrition-panel .food-entry .entry-actions-menu { background: var(--surface-2); }
/* The menu's one grid column is as wide as its widest label and never wider
   than the row, so the actions stay equal width at 200% zoom on a 320 px phone
   instead of being pushed off the side by a fixed minimum. */
#nutrition-panel .food-entry .entry-actions-menu button { width: 100%; }
#overview-panel .day-loop-row .day-loop-label { text-decoration: none; }
@media (min-width: 1024px) {
  .shell:has(> #app-card:not(.hidden)):has(#nutrition-panel:not(.hidden)) { max-width: 1440px; }
}
@media (max-width: 240px) {
  #nutrition-panel > .nutrition-primary-card,
  #nutrition-panel > .nutrition-primary-card:has(> #nutrition-message:empty),
  #nutrition-panel .nutrition-diary-card { padding: 8px; }
}

/* Overhaul S6: one sheet shell, two surfaces, existing form and recovery owners. */
.s6-sheet { padding: 24px; align-items: center; justify-content: center; }
.s6-sheet > :first-child {
  width: min(560px, 100%); max-width: 560px; min-width: 0;
  max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  overflow: hidden; border: 0; border-radius: var(--radius-sheet); background: var(--bg);
  color: var(--text-primary); box-shadow: var(--shadow-md);
}
.s6-sheet *, .s6-form * { min-width: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.s6-sheet :is(.food-sheet-header,.modal-head,.purchase-review-header) {
  flex: 0 0 auto; display: grid; grid-template-columns: 44px minmax(0,1fr) 44px;
  gap: 8px; padding: 12px 16px; margin: 0; border: 0; background: var(--bg);
}
.s6-sheet :is(.food-sheet-header,.modal-head,.purchase-review-header) h2 { grid-column: 2; grid-row: 1; margin: 0; text-align: center; font-size: 18px; font-weight: var(--fw-semibold); color: var(--text-primary); }
.s6-sheet :is(.sheet-close,#close-readiness) { grid-column: 1; grid-row: 1; width: 44px; padding: 0; }
.s6-sheet :is(.review-body,.entry-correction-scroll,.finder-mode,.meal-draft-panel,.purchase-review-body,#readiness-form) {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); scroll-padding-block: 16px 96px;
}
.s6-sheet :is(.review-commit-bar,.entry-correction-actions,.review-edit-actions,.plate-meal-footer) {
  flex: 0 0 auto; margin: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border: 0; box-shadow: none;
}
.s6-sheet :is(button,summary), .s6-form button { min-height: 44px; white-space: normal; }
.s6-sheet button { background: transparent; color: var(--text-primary); border-color: var(--border-soft); box-shadow: none; }
.s6-sheet :is(.primary-action,#meal-draft-submit,#finder-manual-start,#barcode-manual-form button[type=submit],#label-review-manually,#plate-add,#label-analyse,#plate-analyse),
.s6-form #body-save { background: var(--text-primary); color: var(--bg); border: 0; border-radius: var(--radius); }
.s6-sheet :is(.sheet-link,.secondary,.mode-tab,.sheet-close) { background: transparent; color: var(--text-primary); }
.s6-sheet :is(.muted,.finder-hint,.source-badge,.total-pill span,.food-result-meta,.food-result-source,small),
.s6-form .muted { color: var(--text-secondary); }
.s6-sheet :is(.source-badge,.total-pill,.nutrition-coverage,.nutrient-details ul,.review-facts-body ul) { background: none; border: 0; border-radius: 0; }
.s6-sheet :is(.review-grid,.review-controls,.two-col), .s6-form { grid-template-columns: minmax(0,1fr); gap: 0; }
.s6-sheet label:not(:has(input[type=radio])) , .s6-form > label {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.2fr); align-items: center; gap: 12px;
  padding: 10px 14px; margin: 0; min-height: 56px; background: var(--surface);
  border: 0; border-bottom: 1px solid var(--border-soft); color: var(--text-secondary); font-size: 14px;
}
.s6-sheet :is(input,select,textarea), .s6-form :is(input,select,textarea) {
  min-width: 0; width: 100%; min-height: 44px; font-size: 16px; line-height: 1.4;
  padding: 8px 0; border: 0; border-radius: 0; background: transparent; color: var(--text-primary);
  font-variant-numeric: tabular-nums; box-shadow: none;
}
.s6-sheet input::placeholder, .s6-sheet textarea::placeholder, .s6-form textarea::placeholder { color: var(--text-secondary); opacity: 1; }
.s6-sheet :is(.review-controls,.review-grid,.review-custom-fields,.review-cnf-fields,.food-results,#meal-draft-items,.purchase-options,.readiness-scale),
.s6-form { border: 0; border-radius: var(--radius-lg); background: var(--surface); }
.s6-sheet :is(.review-controls,.review-grid) { overflow: hidden; }
.s6-sheet :is(.review-custom-fields,.review-cnf-fields) :is(.review-grid,.review-controls) { border-radius: 0; }
.s6-sheet :is(.review-totals,#meal-draft-totals,.purchase-snapshot) { padding: 14px; background: var(--surface); border: 0; border-radius: var(--radius-lg); }
.s6-sheet .totals-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.s6-sheet .total-pill { padding: 4px 0; text-align: left; }
.s6-sheet .total-pill span { font-size: 13px; }
.s6-sheet .total-pill strong { font-size: 16px; }
.s6-sheet .review-commit-context { border: 0; padding: 0 16px 12px; color: var(--text-secondary); }
.s6-sheet .review-heading { padding: 0; }
.s6-sheet .review-heading { color: var(--text-secondary); }
.s6-sheet .review-body { gap: 16px; }
.s6-sheet details > summary { padding-block: 10px; color: var(--text-secondary); cursor: pointer; }
.s6-sheet :is(.review-notes-details,.review-catalog-details,.s6-source) { border: 0; background: transparent; }
.s6-sheet :is(.food-result,.meal-draft-item) { padding: 14px; margin: 0; border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; background: transparent; box-shadow: none; }
.s6-sheet .meal-draft-item { grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 8px; }
.s6-sheet .meal-draft-item > .mini-actions { display: flex; flex-direction: column; width: auto; gap: 0; }
.s6-sheet .meal-draft-item .mini-actions button { padding: 8px; }
.s6-sheet .meal-draft-item p { font-size: 13px; color: var(--text-secondary); }
.s6-sheet .s6-item-options > summary { text-align: center; }
.s6-sheet .meal-draft-actions { padding-bottom: env(safe-area-inset-bottom); }
.s6-sheet:has(#meal-draft-panel:not(.hidden)) .meal-draft-bar { display: none; }
.s6-sheet .finder-mode-toggle { gap: 0; background: var(--surface); border-radius: var(--radius); margin: 0 16px 12px; padding: 4px; }
.s6-sheet .finder-mode-toggle button { border: 0; border-radius: var(--radius-sm); font-size: 13px; }
.s6-sheet .finder-mode-toggle .active { text-decoration: underline; text-underline-offset: 6px; }
.s6-sheet :is(.plate-reference,.plate-reference-body,.vision-estimate,.vision-confirm,.privacy-notice,.label-photo-picker,.plate-photo-picker) { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.s6-sheet :is(.vision-components > li,.vision-component) { background: var(--surface); border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; }
.s6-sheet .vision-components label { background: transparent; }
.s6-sheet #entry-correction-help { margin: 0; color: var(--text-secondary); }
.s6-sheet #entry-correction-fields { gap: 16px; }
.s6-sheet #entry-correction-fields legend { padding-block: 8px; font-size: 20px; }
.s6-sheet :is(#entry-edit-controls,#entry-portion-controls,#entry-replacement-controls) { gap: 0; }
.s6-sheet #entry-portion-help { color: var(--text-secondary); font-size: 14px; }
.s6-sheet #entry-correction-preview:not(:empty) { background: var(--surface); border-radius: var(--radius-lg); padding: 14px; }
.s6-sheet #entry-correction-preview p { margin: 4px 0; }
.s6-sheet .readiness-scale { padding: 12px; margin: 0; }
.s6-sheet .readiness-scale legend { color: var(--text-primary); }
.s6-sheet .readiness-scale button[aria-pressed=true] { background: var(--bg); color: var(--text-primary); border-color: var(--text-primary); }
.s6-sheet #readiness-form { gap: 12px; }
#body-metric-entry { background: var(--bg); border: 0; box-shadow: none; }
.s6-form { overflow: hidden; padding: 0; }
.s6-form > p { padding: 14px; margin: 0; }
.s6-form > button { margin: 12px; width: calc(100% - 24px); }
.s6-form > label:last-of-type { border-bottom: 0; }
@media (max-width: 600px) {
  .s6-sheet { padding: 0; align-items: flex-end; }
  .s6-sheet > :first-child { width: 100%; max-height: calc(100dvh - max(16px, env(safe-area-inset-top))); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
}
@media (max-width: 300px) {
  .s6-sheet :is(.food-sheet-header,.modal-head,.purchase-review-header) { padding-inline: 8px; grid-template-columns: 44px minmax(0,1fr); }
  .s6-sheet label:not(:has(input[type=radio])), .s6-form > label { grid-template-columns: minmax(0,1fr); gap: 0; padding: 8px; }
  .s6-sheet .totals-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .s6-sheet .finder-mode-toggle { flex-wrap: wrap; }
  .s6-sheet .meal-draft-item { grid-template-columns: minmax(0,1fr); }
  .s6-sheet .meal-draft-item > .mini-actions { flex-direction: row; flex-wrap: wrap; }
}

/* Multi-food review: compact rows with one reserved commit area. */
.s6-sheet .s6-meal-footer { display: none; }
.s6-sheet:has(#meal-draft-panel:not(.hidden)) .s6-meal-footer { display: block; flex: 0 0 auto; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.s6-sheet .s6-meal-footer #meal-draft-totals { margin: 0; padding: 0; background: none; border-radius: 0; }
.s6-sheet .s6-meal-footer #meal-draft-message { font-size: 13px; margin: 4px 0; }
.s6-sheet .s6-meal-footer .meal-draft-actions { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0; }
.s6-sheet #meal-draft-submit { order: -1; flex: 1 0 100%; }
.s6-sheet .s6-meal-footer .secondary { flex: 1; padding: 4px; font-size: 13px; border: 0; }
.s6-sheet #meal-draft-panel { padding-top: 0; }
.s6-sheet #meal-draft-panel > .muted { font-size: 13px; }
.s6-sheet #meal-draft-panel > .form { margin-bottom: 16px; border-radius: var(--radius-lg); overflow: hidden; }
.s6-sheet .meal-draft-item .nutrient-compact { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.s6-sheet .meal-draft-item .nutrient-compact-item { display: inline-flex; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.s6-sheet .meal-draft-item .nutrient-value { font-size: inherit; }
.s6-sheet .meal-draft-item .nutrient-details { margin: 0; padding: 0; }
.s6-sheet .meal-draft-item .nutrient-details > summary { font-size: 13px; font-weight: var(--fw-regular); }
.s6-sheet .meal-draft-item > .mini-actions button { border: 0; }
.s6-sheet .s6-meal-footer .nutrient-compact { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.s6-sheet .s6-meal-footer .nutrient-compact-item { display: inline-flex; gap: 4px; }
.s6-sheet .s6-meal-footer .nutrient-details > summary { font-size: 13px; font-weight: var(--fw-regular); }
.s6-sheet .s6-meal-footer .nutrient-status { font-size: 13px; }
.s6-sheet .s6-meal-footer #meal-draft-totals { max-height: 22dvh; overflow: auto; }
.s6-sheet .review-heading #review-food-name { font-size: 16px; }

.s6-sheet .s6-entry-summary { display: grid; gap: 6px; margin-top: 8px; font-size: 14px; font-weight: var(--fw-regular); color: var(--text-secondary); }
.s6-sheet .s6-entry-summary .nutrient-compact { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.s6-sheet .s6-entry-summary .nutrient-compact-item { display: inline-flex; gap: 4px; }
.s6-sheet label:has(> #entry-method) { grid-template-columns: minmax(0,1fr); gap: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
#trends-panel #body-metric-entry { background: var(--bg); }
#trends-panel #body-metric-entry > .trend-disclosure-body { padding-inline: 0; }
#trends-panel #body-metric-entry .body-metric-history { padding: 16px; background: var(--surface); border: 0; border-radius: var(--radius-lg); }
#trends-panel #body-metric-entry .body-metric-history details { background: none; border: 0; border-radius: 0; }
.s6-sheet .meal-draft-bar:has(#meal-draft-count:empty) { display: none; }
.s6-sheet .food-search-wrap { grid-template-columns: 24px minmax(0,1fr) !important; }

.s6-sheet :is(.sheet-close,#close-readiness) { font-size: 24px; line-height: 1; }

/* S6 owner review: compact content, friendly native dates and quiet alternatives. */
.s6-sheet #start-scan { background: transparent; color: var(--text-primary); border-color: var(--border-soft); }
.s6-sheet .meal-draft-item { position: relative; display: block; }
.s6-sheet .meal-draft-content { padding-right: 54px; }
.s6-sheet .meal-draft-content p { margin: 4px 0 0; line-height: 1.5; }
.s6-sheet .meal-draft-content .s6-macros { white-space: nowrap; font-size: var(--fs-caption); }
.s6-sheet .s6-item-options > summary { position: absolute; right: 14px; top: 12px; list-style: none; font-size: 13px; }
.s6-sheet .s6-item-options > summary::-webkit-details-marker { display: none; }
.s6-sheet .s6-item-options > div { padding-top: 12px; }
.s6-sheet .s6-meal-footer #meal-draft-totals { font-size: 14px; line-height: 1.5; }
.s6-sheet .s6-meal-footer .meal-draft-actions { gap: 0; }
.s6-sheet .s6-meal-footer .secondary { border-radius: 0; }
.s6-sheet .s6-meal-footer .secondary + .secondary { border-left: 1px solid var(--border-soft); }
.s6-sheet .s6-meal-details > summary { font-size: 13px; }
.s6-sheet .s6-meal-details p { color: var(--text-secondary); font-size: 13px; }
.s6-date-value { position: relative; display: flex; align-items: center; min-height: 44px; color: var(--text-primary); font-size: 16px; }
.s6-sheet .s6-date-value input[type=date], .s6-form .s6-date-value input[type=date] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.s6-date-value:focus-within { outline: 2px solid var(--text-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
#body-form-mode:empty, #body-message:empty,
#cardio-form-mode:empty, #cardio-message:empty { display: none; }
#sleep-form-mode:empty, #sleep-message:empty, #sleep-duration:empty { display: none; }
#body-form { min-height: 0; padding-bottom: 0; }
#body-form > [hidden] { display: none; }
@media (max-width: 300px) {
  .s6-sheet .meal-draft-content { padding-right: 0; }
  .s6-sheet .meal-draft-content .s6-macros { white-space: normal; }
  .s6-sheet .s6-item-options > summary { position: static; text-align: left; }
}

.s6-sheet .message:empty { display: none; }

/* Consent is the active decision; keep alternative actions quiet. */
.s6-sheet:has(#label-confirm:not(.hidden)) #label-review-manually,
.s6-sheet:has(#plate-confirm:not(.hidden)) #plate-add { background: transparent; color: var(--text-primary); }

/* Overhaul S6b: rounded fields, explicit selection, and a stable capture sheet. */
.s6-sheet :is(input,select,textarea), .s6-form :is(input,select,textarea) {
  border-radius: var(--radius-sm); border: 0; padding-inline: 8px;
}
.s6-sheet label:not(:has(input[type=radio])) { border-radius: var(--radius-lg); }
.s6-sheet .sheet-field-group { border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.s6-sheet :is(.sheet-field-group,.review-controls,.review-grid) > label:not(:has(input[type=radio])) {
  border-radius: 0;
}
.s6-sheet :is(.sheet-field-group,.review-controls,.review-grid) > label:last-child { border-bottom: 0; }
.sheet-unit { display: flex; align-items: center; gap: 8px; }
.sheet-unit input { flex: 1; }
.s6-sheet .readiness-scale { display: block; padding: 0; margin-top: 8px; background: transparent; }
.s6-sheet .readiness-scale legend {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 12px; padding: 0; margin: 0 0 8px; line-height: 1.5;
}
.s6-sheet .readiness-scale legend span { float: none; margin-left: auto; color: var(--text-secondary); }
.readiness-values { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 4px; padding: 8px; border-radius: var(--radius-lg); background: var(--surface); }
.s6-sheet .readiness-scale button { min-width: 0; background: var(--surface); border: 0; border-radius: var(--radius-pill); }
.s6-sheet .readiness-scale button[aria-pressed=true],
.s6-sheet .finder-mode-toggle .active {
  background: var(--text-primary); color: var(--surface); font-weight: var(--fw-bold);
  text-decoration: none; border: 0;
}
#food-finder-modal > .food-sheet { height: min(810px, calc(100dvh - 48px)); }
#food-finder-modal .finder-mode-toggle {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); flex: 0 0 auto; gap: 4px;
  border-radius: var(--radius);
}
#food-finder-modal .finder-mode-toggle button { padding: 8px 4px; border-radius: var(--radius-sm); }
#food-finder-modal .finder-mode { flex: 1 1 0; }
#food-finder-modal .finder-mode > * { margin-block: 0 16px; }
#food-finder-modal .finder-hint { font-size: 14px; line-height: 1.5; }
.s6-sheet .food-search-wrap svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.s6-sheet .food-search-wrap { border-radius: 0; }
.s6-sheet .food-result-row { gap: 0; align-items: center; border-bottom: 1px solid var(--border-soft); padding-right: 8px; }
.s6-sheet .food-result-row .food-result { border: 0; }
.s6-sheet .favorite-toggle { border: 0; background: transparent; width: 44px; min-height: 44px; padding: 8px; }
.s6-sheet .food-result-section h3 { padding: 12px 14px 0; font-size: 14px; color: var(--text-secondary); }
.s6-sheet .food-result-section > p.muted { margin: 0; padding: 0 14px 14px; font-size: 14px; line-height: 1.45; }
.s6-sheet #review-source-badge { text-transform: none; letter-spacing: normal; font-size: 14px; font-weight: var(--fw-regular); padding: 0; }
.s6-sheet #review-edit-food { border: 0; border-radius: 0; text-align: left; padding: 8px 0; color: var(--text-secondary); align-self: stretch; }
.photo-choices { display: flex; gap: 8px; }
.s6-sheet .photo-choice { flex: 1; border-radius: var(--radius); }
.s6-sheet .photo-choice[aria-pressed=true] { font-weight: var(--fw-bold); border-color: var(--text-primary); }
#finder-label-mode #plate-reference > summary { display: none; }
#finder-label-mode #plate-reference:not([open]) { display: none; }
#finder-label-mode:has(#plate-reference[open]) .label-content { display: none; }
.label-content > * { margin-block: 0 16px; }
.photo-meal-review #finder-label-mode > :not(#plate-reference) { display: none; }
.photo-meal-review #finder-label-mode { padding-bottom: 16px; }
@media (max-width:600px) {
  #food-finder-modal > .food-sheet { height: 90dvh; }
}
@media (max-width:300px) {
  #food-finder-modal .finder-mode-toggle { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .readiness-values { grid-template-columns: repeat(auto-fit,minmax(32px,1fr)); }
  .photo-choices { flex-wrap: wrap; }
}

/* Grid's automatic minimum must not collapse the clipped field group. */
#readiness-sheet > .readiness-sheet { padding: 0; }
#readiness-sheet #readiness-form { display: block; }
#readiness-form > :not(.hidden):not(input[type=hidden]) { margin-block: 0 20px; }
#readiness-sheet .readiness-scale { background: transparent; border-radius: 0; }
#readiness-sheet .readiness-scale legend { margin-bottom: 8px; }
#readiness-sheet .sheet-field-group { margin-top: 20px; }
#food-finder-modal :is(#label-preview-canvas,#plate-preview-canvas)[hidden] { display: none; }
#food-finder-modal input[type=file]::file-selector-button { border-radius: var(--radius-sm); border: 0; background: var(--bg); color: var(--text-primary); padding: 8px; }
#food-finder-modal :is(.label-photo-picker,.plate-photo-picker) { grid-template-columns: minmax(0,1fr); gap: 4px; }
.s6-sheet .food-result-row:last-child { border-bottom: 0; }

/* Selection must be immediately legible, including during theme changes. */
#readiness-sheet .readiness-scale button,
#food-finder-modal .mode-tab { transition: none; }

#food-finder-modal .label-content > * { margin-block: 0 16px; }
#food-finder-modal .photo-choice[aria-pressed=true] { background: var(--surface); border: 0; }
#food-finder-modal .label-photo-actions button:disabled { background: transparent; color: var(--text-secondary); }

/* Editor field rows use the same clipped group as finder and readiness. */
.s6-sheet .two-col { border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.s6-sheet .two-col > label:not(:has(input[type=radio])) { border-radius: 0; }
.s6-sheet .two-col > label:last-child { border-bottom: 0; }
.s6-sheet .sheet-field-group > .two-col { border-radius: 0; }
.s6-sheet :is(.review-custom-fields,.review-cnf-fields) { overflow: hidden; }

/* Photo review: full-width fields and comfortable phone editing. */
#plate-estimate-components { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 16px; }
#plate-estimate .vision-component { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
#plate-estimate .plate-item-nutrients { gap: 8px; }
#plate-estimate .plate-item-nutrients label { white-space: nowrap; }
#plate-estimate input, #plate-estimate select { min-height: 44px; }
#plate-estimate .plate-item-nutrients input { padding-inline: 4px; appearance: textfield; }
#plate-estimate .plate-item-nutrients input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.plate-estimate-details { font-size: .8125rem; color: var(--ink-2); }
.plate-estimate-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.plate-estimate-note { margin-bottom: 12px; }
#finder-label-mode .privacy-notice:empty, #finder-label-mode p:has(> [id$="analysis-headline"]:empty) { display: none; }
#label-discard, #plate-discard { background: transparent; box-shadow: none; text-decoration: underline; }
@media (max-width: 600px) {
  #plate-estimate .plate-meal-fields { grid-template-columns: minmax(0, 1fr); }
}

.s6-sheet:has(#label-analysis-controls:not(.hidden)) #label-review-manually { background: transparent; box-shadow: none; color: var(--ink); }

#plate-estimate label { grid-template-columns: minmax(0, 1fr); padding: 0; border: 0; background: transparent; }
#plate-estimate .plate-meal-fields input, #plate-estimate .plate-meal-fields select { padding-inline: 10px; background: var(--surface); }
.s6-sheet .plate-estimate-note { grid-template-columns: minmax(0, 1fr); }

/* Mockup A: a quiet desktop sidebar and truthful Today nutrition. */
.sidebar-brand { display: none; }
#overview-panel :is(.today-nutrition-card,.today-meals-card) {
  min-width: 0; padding: 24px; border-radius: var(--radius-lg); background: var(--surface);
}
#overview-panel :is(.today-nutrition-card,.today-meals-card) h2,
#overview-panel .today-next-heading { margin: 0 0 20px; font-size: 16px; font-weight: var(--fw-semibold); letter-spacing: 0; }
#overview-panel .today-next-heading { margin-bottom: 0; }
.today-nutrition-layout { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 28px; align-items: center; }
.today-energy { min-width: 0; text-align: center; }
.today-ring-copy { position: absolute; inset: 26px 18px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.today-ring-copy strong { font-size: 32px; line-height: 1.15; letter-spacing: var(--ls-display); font-weight: var(--fw-bold); }
.today-ring-copy strong.ring-incomplete { font-size: 14px; line-height: 1.4; letter-spacing: 0; }
.today-ring-copy > span { font-size: var(--fs-caption); color: var(--text-secondary); }
#overview-panel .today-remaining { font-size: 13px; margin: 10px 0 0; color: var(--text-secondary); }
.today-macro-bars { display: grid; gap: 22px; min-width: 0; }
.today-macro > div:first-child { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 13px; color: var(--text-secondary); }
.today-macro strong { font-weight: var(--fw-semibold); color: var(--text-primary); }
.today-macro-track { height: 5px; background: var(--surface-2); border-radius: 3px; margin-top: 9px; overflow: hidden; }
.today-macro-track > span { display: block; height: 100%; background: var(--text-primary); border-radius: inherit; }
.today-macro small { display: block; margin-top: 6px; font-size: var(--fs-caption); line-height: 1.4; color: var(--text-secondary); }
#overview-panel .today-nutrition-coverage { padding-top: 16px; margin: 20px 0 0; border-top: 1px solid var(--border-soft); font-size: var(--fs-caption); color: var(--text-secondary); }
.today-recent-meals ul { list-style: none; margin: 0; padding: 0; }
.today-recent-meals li { display: flex; align-items: center; gap: 12px; padding: 16px 0; }
.today-recent-meals li + li { border-top: 1px solid var(--border-soft); }
.today-recent-meals li:first-child { padding-top: 0; }
.today-recent-meals li:last-child { padding-bottom: 0; }
.today-meal-initial { display: grid; place-items: center; width: 36px; height: 40px; flex: 0 0 36px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; color: var(--text-secondary); }
.today-recent-meals li > div { flex: 1; min-width: 0; }
.today-recent-meals strong { display: block; font-size: 14px; font-weight: var(--fw-semibold); }
.today-recent-meals li > div > span { display: block; font-size: var(--fs-caption); color: var(--text-secondary); margin-top: 4px; }
.today-meal-energy { max-width: 100px; font-size: var(--fs-caption); text-align: right; color: var(--text-secondary); }
.today-recent-meals > p { margin: 0; }
@media (min-width: 1024px) {
  .shell:has(> #app-card:not(.hidden)) {
    width: auto; max-width: none; margin: 0 0 0 232px; padding: 28px var(--page-gutter) var(--space-8);
  }
  .shell:has(> #app-card:not(.hidden)) > .hero { display: none; }
  #app-card:not(.hidden) > .tab-nav {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 232px; height: 100dvh;
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 2px; margin: 0; padding: 28px var(--space-4) var(--space-5); background: var(--bg);
    border: 0; border-right: 1px solid var(--border); border-radius: 0;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  /* §2.9: a flat wordmark, no gradient badge. The "H" span stays in the
     markup and is simply not drawn. */
  .sidebar-brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-3) 22px; font-size: var(--fs-body); font-weight: var(--fw-bold); letter-spacing: var(--ls-h2); }
  .sidebar-brand > span { display: none; }
  #app-card:not(.hidden) > .tab-nav > button { flex: 0 0 auto; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: var(--space-3); width: 100%; min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--ink-2); background: transparent; }
  #app-card:not(.hidden) > .tab-nav > button:hover { background: var(--surface-2); color: var(--ink); }
  #app-card:not(.hidden) > .tab-nav > button.active { color: var(--ink); background: var(--surface-3); font-weight: var(--fw-semibold); }
  #app-card:not(.hidden) > .tab-nav > button:last-child { margin-top: auto; }
  #app-card:not(.hidden) > .tab-nav .tab-icon { display: flex; width: 20px; height: 20px; transform: none; }
  #app-card .page-header { position: static; padding: 10px 0 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  #app-card .page-header h1 { font-size: var(--type-page); font-weight: var(--fw-bold); }
  #overview-panel > .quick-actions { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); grid-template-areas: "nutrition next" "meals activities"; gap: 20px; align-items: stretch; }
  .today-nutrition-card { grid-area: nutrition; }
  #overview-panel #today-now { grid-area: next; padding: 24px; }
  #overview-panel #today-now-cta { margin-top: auto; }
  .today-meals-card { grid-area: meals; }
  #overview-panel #day-loop-rail { grid-area: activities; }
  #overview-panel #today-details { width: 100%; margin: 0; }
}
@media (min-width:1024px) and (max-width:1250px) {
  .shell:has(> #app-card:not(.hidden)) { padding-inline: var(--space-6); margin-left: 208px; }
  #app-card:not(.hidden) > .tab-nav { width: 208px; }
  .today-nutrition-layout { grid-template-columns: minmax(0,1fr); gap: 20px; }
}
@media (max-width: 600px) {
  #overview-panel :is(.today-nutrition-card,.today-meals-card) { padding: 20px; }
  .today-nutrition-layout { grid-template-columns: minmax(0,1fr); gap: 24px; }
  .today-macro-bars { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
  .today-macro > div:first-child { display: grid; gap: 6px; font-size: var(--fs-caption); }
  #overview-panel .today-nutrition-card h2 { margin-bottom: 12px; }
  #overview-panel .today-nutrition-coverage { margin-top: 18px; }
}
@media (max-width: 240px) {
  #overview-panel :is(.today-nutrition-card,.today-meals-card) { padding: 12px 8px; }
  .today-recent-meals li { flex-wrap: wrap; }
  .today-meal-energy { max-width: 100%; }
  .today-macro-bars { grid-template-columns: minmax(0,1fr); }
}

/* Lifter slice 1: a compact session, bounded set entry, persistent rest. */
#workouts-panel.workout-is-active > .strong-workout-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; overflow: visible;
}
#workouts-panel.workout-is-active .strong-workout-head { grid-column: 1; grid-row: 1; padding: 0 4px; align-self: center; }
#workouts-panel.workout-is-active .workout-meta,
#workouts-panel.workout-is-active #template-strip { display: none; }
#workouts-panel .strong-topbar { grid-column: 2; grid-row: 1; margin: 0; align-self: center; }
#workouts-panel .elapsed-wrap { display: flex; flex-direction: row; align-items: baseline; gap: 8px; }
#workouts-panel .elapsed-label { font-size: 13px; }
#workouts-panel .workout-options { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; background: none; }
#workouts-panel .workout-options > summary { min-height: 44px; display: flex; align-items: center; width: fit-content; padding: 0 8px; cursor: pointer; font-size: 14px; color: var(--text-secondary); }
#workouts-panel .workout-options > summary::after { content: "+"; margin-left: 12px; }
#workouts-panel .workout-options[open] > summary::after { content: "−"; }
#workouts-panel .workout-options > p { margin: 8px; max-width: 55ch; }
#workouts-panel .workout-rpe-preference { display: flex; align-items: center; min-height: 44px; gap: 10px; padding: 0 8px; }
#workouts-panel .workout-rpe-preference input { width: 24px; height: 24px; min-height: 0; accent-color: var(--accent); }
#workouts-panel .workout-unit-row { margin: 0 8px 8px; }
#workouts-panel .strong-workout-form { grid-column: 1 / -1; min-width: 0; }
#workouts-panel .workout-session-main { display: grid; gap: 16px; min-width: 0; }
#workouts-panel .workout-session-rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
#workouts-panel .workout-session-rail > h3 { margin: 0; font-size: 18px; }
#workouts-panel .workout-session-rail #workout-summary { padding: 0; margin: 0; background: none; }
#workouts-panel .workout-session-rail #workout-summary p { margin-block: 8px; }
#workouts-panel #workout-message, #workouts-panel #post-workout-review,
#workouts-panel #workout-save-retry, #workouts-panel #workout-tab-state { grid-column: 1 / -1; }
#workouts-panel #workout-tab-state:empty { display: none; }
#workouts-panel .workout-template-help { font-size: 13px; margin: -4px 0 0; }
#workouts-panel .cancel-workout-wide { color: var(--text-secondary); border-top: 1px solid var(--border); border-radius: 0; margin-top: 8px; min-height: 44px; }
#workouts-panel .rest-pill { gap: 4px; padding: 4px 8px; border: 1px solid var(--border); background: var(--surface); justify-content: space-between; }
#workouts-panel .rest-pill span { display: inline; font-size: 13px; }
#workouts-panel .rest-pill strong { min-width: 4ch; text-align: center; }
#workouts-panel .rest-pill button { padding-inline: 6px; font-size: 13px; }
/* The undo offer sits under Add set, below the whole list, so it never
   interrupts the rows the lifter is reading down. Quiet by design: a muted
   line, not a box competing with the sets above it. */
#workouts-panel .set-undo-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin-top: 6px; padding: 0 4px; color: var(--text-secondary); font-size: 14px; }
#workouts-panel .set-undo-row button { width: auto; min-height: 44px; padding-inline: 14px; }
/* Rest is over. The pill states it instead of leaving a vibration — which iOS
   does not deliver from a web app — as the only cue that the set is due. */
#workouts-panel .rest-pill.rest-ready { background: var(--accent); border-color: var(--accent); }
#workouts-panel .rest-pill.rest-ready span, #workouts-panel .rest-pill.rest-ready strong { color: var(--accent-ink); }
#workouts-panel .rest-pill.rest-ready button { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }
#workouts-panel .previous-value { white-space: normal; line-height: 1.35; }
#workouts-panel .set-effort { grid-column: 2 / -1; border: 0; padding: 0; margin: 0; background: none; }
#workouts-panel .set-effort summary { min-height: 44px; padding: 10px 8px; width: fit-content; font-size: 14px; cursor: pointer; }
#workouts-panel .rpe-picker { display: flex; flex-wrap: wrap; gap: 4px; }
#workouts-panel .rpe-picker button { min-width: 44px; min-height: 44px; width: auto; padding: 8px; background: var(--fill); color: var(--text-primary); }
#workouts-panel .rpe-picker button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#workouts-panel .set-pr { grid-column: 2 / -1; justify-self: start; padding: 4px 8px; border-radius: var(--radius-sm); font-size: 13px; font-weight: var(--fw-semibold); color: var(--success); background: var(--success-bg); }
#workouts-panel .done-set { color: var(--ink-3); background: var(--surface-2); border: 1px solid transparent; }
#workouts-panel .remove-set { color: var(--text-primary); }
/* Ink: a completed set is green -- green means done, and nothing else on the
   screen is green. The fields go quiet rather than green. */
#workouts-panel .set-done .done-set { background: var(--success); color: var(--success-ink); border-color: var(--success); box-shadow: none; }
#workouts-panel .set-done input.set-weight, #workouts-panel .set-done input.set-reps { background: var(--surface-2); border-color: transparent; color: var(--ink-2); }
#workouts-panel .signal-up { background: var(--signal-up-bg); color: var(--signal-up-fg); }
#workouts-panel .signal-hold { background: var(--signal-hold-bg); color: var(--signal-hold-fg); }
@media (max-width: 1023px) {
  #workouts-panel:not(.hidden) .rest-pill { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 16px); z-index: 81; }
  /* viewport-fit=cover with a translucent status bar: a bare 8px puts the pill
     under the Dynamic Island on a 15 Pro Max. Clear the inset first. */
  body.keypad-open #workouts-panel .rest-pill { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 8px); }
  #workouts-panel.workout-is-active { padding-bottom: 148px; }
}
@media (min-width: 1024px) {
  #workouts-panel.workout-is-active .strong-workout-form { display: grid; grid-template-columns: minmax(0, 720px) minmax(260px, 300px); align-items: start; gap: 24px; justify-content: center; }
  #workouts-panel .workout-session-rail { position: sticky; top: 16px; padding: 20px; background: var(--surface); border-radius: var(--radius-lg); }
  #workouts-panel .workout-session-rail .rest-pill { flex-wrap: wrap; padding: 4px; }
  #workouts-panel .workout-session-rail #save-workout { order: 1; }
  #workouts-panel .workout-session-rail .cancel-workout-wide { order: 2; }
  #workouts-panel #workout-date-review { grid-column: 1 / -1; }
  #workouts-panel .strong-table-head, #workouts-panel .strong-set-line { grid-template-columns: 36px minmax(110px, 1fr) minmax(70px, 100px) minmax(60px, 90px) 44px 44px; gap: 8px; }
}

body:has(#workouts-panel.workout-is-active:not(.hidden)) { overflow-x: clip; }
#workouts-panel .message { color: var(--text-secondary); }
/* A refused save is not a quiet note. The panel's secondary ink above would
   otherwise win on specificity and print a 422 in the same grey as the hints
   beside it. */
#workouts-panel .message.error { color: var(--danger); }

/* Fast food logging: existing monochrome sheet, explicit portion and destination. */
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 8px; }
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions::after { display: none; }
#nutrition-diary .empty-meal-title { flex-basis: 100%; padding: 4px 0; }
#nutrition-diary .meal-add { font-weight: var(--fw-semibold); }
#nutrition-diary .meal-add, #nutrition-diary .meal-repeat { flex: 1 1 100%; }
#nutrition-diary .meal-repeat { text-align: left; white-space: normal; }
#nutrition-diary [data-add-meal], #nutrition-diary [data-repeat-meal] { min-width: 44px; min-height: 44px; }
#food-review-modal.catalog-add-review #review-food-name { display: none; }
#food-review-modal #review-quantity { border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--bg); padding: 10px 12px; min-height: 44px; width: 100%; }
#food-review-modal #review-commit-action button { white-space: normal; min-height: 48px; }
#food-review-modal .manual-entry-help { margin: 0 0 12px; }
#food-review-modal:has(#label-transcription-options:not(.hidden)) .manual-entry-help { display: none; }

#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions) { grid-template-columns: minmax(0, 1fr) auto auto 16px; gap: 8px; padding-inline-end: 4px; }
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions)::after { grid-column: 4; justify-self: center; margin: 0; }
#nutrition-panel #nutrition-diary .meal-group > summary > [data-add-meal]:not(.meal-add) { grid-column: 3; grid-row: 1; width: auto; min-width: 56px; padding-inline: 12px; }
#food-review-modal.catalog-add-review .review-heading { display: none; }
#food-review-modal:has(#review-custom-fields:not(.hidden)):not(:has(#label-transcription-options:not(.hidden))) .review-heading { display: none; }
#food-review-modal .manual-entry-help { font-size: 14px; padding: 12px 14px 0; }

#nutrition-panel #copy-message { color: var(--text-secondary); }

/* S8b: shared status meaning across the daily summary and Today. */
.is-goal-met { --goal-color: var(--success); }
.is-over { --goal-color: var(--signal-hold-fg); }
:is(#nutrition-panel, #overview-panel) :is(.is-goal-met, .is-over) .goal-status { color: var(--goal-color); }
:is(.is-goal-met, .is-over) :is(.nutrition-calorie-progress, .today-macro-track) > span { background: var(--goal-color); }
.nutrition-macro .nutrition-calorie-progress { width: 100%; margin-top: 8px; }
#nutrition-panel .nutrition-macro .goal-status { display: block; margin-top: 6px; line-height: 1.4; }
#nutrition-diary [data-add-meal], #nutrition-diary [data-repeat-meal],
#food-finder-modal [data-finder-saved-meals] { border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text-primary); }
#nutrition-diary .meal-add, #nutrition-diary .meal-repeat { text-align: center; }
@media (min-width: 1024px) {
  #nutrition-diary .meal-add, #nutrition-diary .meal-repeat { flex: 1 1 0; }
}

/* S9: first-use actions and compact, content-sized Today groups. */
#overview-panel > .quick-actions { align-items: start; }
#overview-panel #today-now-cta { margin-top: 0; }
#overview-panel .today-setup-hint { margin: 0 0 12px; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.today-setup { display: grid; gap: 8px; }
#overview-panel .today-setup-step,
#overview-panel #today-set-goals {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 48px; width: 100%; margin: 0; padding: 12px;
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: transparent; color: var(--text-primary); text-align: left; font-size: 14px;
}
#overview-panel .today-setup-step.primary-action,
#overview-panel #today-set-goals.primary-action { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#overview-panel .today-step-done { display: inline-flex; align-items: center; gap: 4px; color: var(--success); font-size: var(--fs-caption); }
.today-step-done svg { width: 18px; height: 18px; }
#overview-panel .day-loop-note:empty { display: none; }
#overview-panel #open-readiness.is-complete .day-loop-label { color: var(--success); }
@media (max-width: 1023px) {
  #overview-panel > .quick-actions { gap: 12px; }
  #overview-panel :is(.day-loop-row,#today-log-food) { padding: 10px 14px; min-height: 64px; gap: 8px; }
  #overview-panel .day-loop-action { font-size: 13px; }
}
@media (min-width: 241px) and (max-width: 600px) {
  #overview-panel .today-nutrition-card { padding: 16px; }
  .today-nutrition-layout { gap: 14px; }
  .today-ring-copy { inset: 18px 8px; }
  .today-ring-copy strong { font-size: 26px; }
  .today-macro-bars { gap: 12px; }
  #overview-panel .today-remaining { margin-top: 4px; }
}

#overview-panel #today-food-status .nutrient-compact { display: flex; flex-wrap: wrap; gap: 2px 12px; }
#overview-panel #today-food-status .nutrient-compact-item { display: inline-flex; align-items: baseline; gap: 4px; }
#overview-panel #today-food-status .nutrient-label { font-size: var(--fs-caption); font-weight: var(--fw-regular); }
#overview-panel #today-food-status .nutrient-value { font-size: 13px; font-weight: var(--fw-regular); }

/* Owner fixes 28 Oct: exercise search icon size, add-to-list beside the primary add. */
.exercise-search-wrap svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.exercise-search-wrap { min-height: 44px; }
#food-review-modal .review-commit-bar:has(#review-queue-button:not(.hidden)) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 8px; }
#food-review-modal .review-commit-bar #review-queue-button { width: 100%; margin: 0; min-height: 44px; border-radius: var(--radius); background: transparent; border: 1px solid var(--border-strong, var(--border)); color: var(--ink); }
#food-review-modal .review-commit-bar > :not(button) { grid-column: 1 / -1; }

/* Owner tidy 29 Oct: buttons are rounded rectangles; icon-only buttons stay circular. */
.icon-btn, #nutrition-previous-day, #nutrition-next-day { border-radius: var(--radius-pill); }
#label-discard, #plate-discard { text-decoration: none; border: 1px solid var(--border-strong, var(--border)); }
#finder-label-mode #label-review-manually { border: 1px solid var(--border-strong, var(--border)); }
#finder-search-mode #usda-fallback:not(.hidden) { margin: 0 0 12px; }
#body-metric-entry { scroll-margin-top: 12px; }

/* Weekly Cut Review: one surface, three readable columns, native disclosures. */
.cut-review { scroll-margin-top: 24px; width: 100%; min-width: 0; }
.cut-review .weekly-review-card { padding: 0; border: 0; background: transparent; }
.cut-review .cut-review-headline { color: var(--ink); font-size: clamp(1.75rem, 4.4vw, 2.6rem); line-height: var(--lh-tight); letter-spacing: var(--ls-h1); max-width: 30ch; margin: 14px 0 16px; font-weight: var(--fw-bold); }
.cut-review-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.cut-review-grid section { min-width: 0; border-top: 1px solid var(--border); padding-top: 16px; }
.cut-review-grid h3 { margin: 0 0 14px; }
.cut-review-grid p { margin: 8px 0; }
.cut-review-value { font-size: 1.15rem; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.cut-review :is(.is-goal-met, .is-over) .goal-status { color: var(--goal-color); }
.cut-review summary { cursor: pointer; min-height: 44px; padding: 12px 0; }
.cut-review summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.cut-explainer { margin-top: 12px; font-size: .875rem; }
.cut-explainer p { max-width: 65ch; color: var(--ink-2); }
.cut-review-details { margin-top: 24px; border-top: 1px solid var(--border); }
.cut-review-details > summary { font-weight: var(--fw-bold); }
.today-review-row { width: 100%; border-radius: var(--radius); min-height: 56px; text-align: left; }
.today-review-row > span:first-child { display: grid; gap: 4px; }
.today-review-row[hidden] { display: none; }
@media (max-width: 700px) { .cut-review-grid { grid-template-columns: 1fr; gap: 16px; } }

#weekly-review-status:empty { display: none; }
.cut-review .cut-review-summary > .muted { margin: 8px 0 12px; }
.cut-review .cut-review-value { color: var(--ink); }
.today-review-row { display: flex; justify-content: space-between; gap: 16px; background: var(--surface); }
@media (max-width: 700px) {
  .cut-review .cut-review-headline { font-size: 1.75rem; margin: 8px 0 14px; }
  .cut-review-grid { gap: 10px; }
  .cut-review-grid section { padding-top: 10px; }
  .cut-review-grid h3 { margin-bottom: 8px; }
  .cut-explainer { margin-top: 4px; }
  .cut-review-details { margin-top: 12px; }
}

/* One quiet line when no body weight goal is answered: the sentence, then a
   secondary control sized to its own words rather than the phone's full width. */
.cut-review-goal-unset { display: grid; justify-items: start; gap: 12px; margin: 0 0 20px; max-width: 65ch; }
.cut-review-goal-cta { display: inline-flex; align-items: center; width: auto; min-height: var(--tap); border-radius: var(--radius); padding: 10px 18px; }

/* Key lifts stay compact within the existing Cut Review training column. */
.cut-review-lifts { list-style: none; padding: 0; margin: 12px 0; }
.cut-review-lifts li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.cut-review-lifts li > div { min-width: 0; }
.cut-review-lifts strong { display: block; overflow-wrap: anywhere; }
.cut-review-lifts .muted { display: block; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.cut-review-lifts .goal-status { flex: 0 0 auto; font-size: 0.8125rem; }
.cut-review-lift-record { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; color: var(--text-secondary); font-size: 0.8125rem; }

/* ---------- Visual weekly review (S12b) ----------
   One big number per column, then the shape behind it. Monochrome ink plus the
   existing muted success / amber hold tokens, each always carrying a text
   label; nothing here is red and nothing is a score. Charts are inline SVG
   drawn from payload numbers — no chart library and no new request. */
.cut-review-big { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }
.cut-review-big > strong { font-size: clamp(2.1rem, 6.8vw, 3.1rem); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--ls-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cut-review :is(.cut-review-big.is-goal-met, .cut-review-big.is-over) > strong { color: var(--goal-color); }
/* The pace unit never leaves its number behind on a phone line break. */
.cut-review-big-unit { color: var(--ink-3); font-size: .9rem; font-weight: var(--fw-semibold); white-space: nowrap; }
.cut-review .cut-review-big + .cut-review-value { color: var(--ink-3); font-size: .9rem; font-weight: var(--fw-medium); margin: 0 0 10px; }
/* The week's cardio minutes are a second small fact under the workout count,
   not a competing headline, so they read like the comparison line above them. */
.cut-review .cut-review-cardio { color: var(--ink-3); font-size: .9rem; font-weight: var(--fw-medium); margin: 0 0 10px; }
/* The week's sleep reads as the same kind of small fact as the cardio line
   above it, so it takes the same treatment rather than a new one (S18). */
.cut-review .cut-review-sleep { color: var(--ink-3); font-size: .9rem; font-weight: var(--fw-medium); margin: 0 0 10px; }

/* The one action slot. S13 replaces its contents with the real suggestion; the
   box, its spacing and its 44px control are already the shipped shape. */
.cut-review-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 22px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); max-width: 65ch; }
.cut-review-action-text { font-size: .95rem; font-weight: var(--fw-semibold); min-width: 0; overflow-wrap: anywhere; }
.cut-review-action-cta { display: inline-flex; align-items: center; width: auto; min-height: var(--tap); border-radius: var(--radius); padding: 10px 18px; }

/* Pace rail: the goal band on its own axis, with this week's pace marked. */
.cut-review-rail { display: block; width: 100%; height: auto; max-width: 420px; margin: 2px 0 4px; }
.cut-review-rail-track { fill: var(--ink); fill-opacity: .08; }
.cut-review-rail-band { fill: var(--ink); fill-opacity: .15; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.cut-review-rail-zero { stroke: var(--ink-3); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cut-review-rail-mark { fill: var(--ink); }
.cut-review-rail:is(.is-goal-met, .is-over) .cut-review-rail-mark { fill: var(--goal-color); }
.cut-review-rail-key { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: 0 0 12px; }

/* Weight chart: the reviewed week as a column, the trailing mean as the heavy
   line, every weigh-in as a dot. The goal band lives on the pace rail only. */
.cut-review-chart { display: block; width: 100%; height: auto; margin: 10px 0 6px; overflow: visible; }
.cut-review-chart-week { fill: var(--ink); opacity: .055; }
.cut-review-chart-trend { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.cut-review-chart-dot { fill: var(--ink-3); }
.cut-review-chart-key { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: 0 0 4px; }

/* Seven day marks instead of a sentence. Rounded squares, not pills. */
.cut-review-days { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 4px 0 10px; }
.cut-review-days li { display: grid; justify-items: center; gap: 3px; }
.cut-review-day-mark { display: block; width: 18px; height: 18px; border-radius: var(--radius-sm); border: 2px solid var(--border-strong); background: transparent; }
.cut-review-days .is-goal-met .cut-review-day-mark { background: var(--success); border-color: var(--success); }
.cut-review-days .is-over .cut-review-day-mark { background: var(--signal-hold-bg); border-color: var(--signal-hold-fg); }
.cut-review-days .is-logged .cut-review-day-mark { background: var(--ink-3); border-color: var(--ink-3); }
.cut-review-days .is-unlogged .cut-review-day-mark { border-style: dashed; }
.cut-review-day-name { color: var(--ink-3); font-size: var(--fs-caption); line-height: 1; }

.cut-review-strength { margin: 0 0 4px; font-size: .9rem; }
.cut-review-spark { flex: 0 0 auto; width: 70px; height: 21px; }
.cut-review-spark-line { fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.cut-review-spark-head { fill: var(--ink); }
.cut-review-lifts :is(.is-goal-met, .is-over) .cut-review-spark-line { stroke: var(--goal-color); }
.cut-review-lifts :is(.is-goal-met, .is-over) .cut-review-spark-head { fill: var(--goal-color); }

/* The only motion: each chart draws itself in once per render. */
@keyframes cut-review-draw { from { stroke-dashoffset: 420; } to { stroke-dashoffset: 0; } }
@keyframes cut-review-draw-spark { from { stroke-dashoffset: 160; } to { stroke-dashoffset: 0; } }
@keyframes cut-review-appear { from { opacity: 0; } to { opacity: 1; } }
.is-entering .cut-review-chart-trend { stroke-dasharray: 420; animation: cut-review-draw 820ms var(--ease) forwards; }
.is-entering .cut-review-chart-dot { animation: cut-review-appear 420ms var(--ease) 480ms forwards; }
.is-entering .cut-review-spark-line { stroke-dasharray: 160; animation: cut-review-draw-spark 620ms var(--ease) forwards; }
/* The two property resets the global reduced-motion block cannot make: an
   un-animated dash pattern would paint a dashed trend line, and the dot's
   entrance opacity is now its default rather than a keyframe start. */
@media (prefers-reduced-motion: reduce) {
  .cut-review-chart-trend, .cut-review-spark-line,
  .is-entering .cut-review-chart-trend, .is-entering .cut-review-spark-line { stroke-dasharray: none; }
}
@media (max-width: 700px) {
  .cut-review-action { margin-bottom: 16px; }
  .cut-review-big > strong { font-size: 2.3rem; }
}
/* ---------- end visual weekly review (S12b) ---------- */

/* ---------- Weekly coaching suggestion (S13) ----------
   The action slot, filled. One headline, one line of detail, two 44px controls
   and one status line. Monochrome ink plus the existing muted success / amber
   hold tokens, each always carrying a text label; nothing here is red, nothing
   is a pill, and nothing animates. */
/* One column that is always the full width of the card, never the width of
   whatever happens to be in it. Without the explicit track this grid sizes
   itself to its widest row's max-content, so a card that gains a line — the
   optional note arriving a moment after the card is painted — would widen and
   reflow the two decision controls under the owner's thumb. */
.cut-review-suggestion { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.cut-review-suggestion-copy { min-width: 0; display: grid; gap: 4px; }
.cut-review-suggestion .cut-review-action-text { color: var(--goal-color); font-size: 1.05rem; }
.cut-review-suggestion-detail { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: 0; overflow-wrap: anywhere; }
/* One quiet extra line, always labelled as written by Claude. Readable at
   --fs-label like the detail above it (never a tiny caption), and the label
   carries its own weight rather than a colour, so it reads the same in light
   and dark and needs no token of its own. */
.cut-review-suggestion-note { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: 2px 0 0; overflow-wrap: anywhere; }
.cut-review-suggestion-note-label { font-weight: var(--fw-semibold); white-space: nowrap; }
.cut-review-suggestion-note-text { font-weight: var(--fw-regular); }
.cut-review-suggestion-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.cut-review-suggestion-decide { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 7.5rem; min-height: var(--tap); border-radius: var(--radius); padding: 10px 18px; }
.cut-review-suggestion-decide[disabled] { opacity: .55; }
.cut-review-suggestion-decided { color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: var(--lh-snug); margin: 0; overflow-wrap: anywhere; }
.cut-review-suggestion-status:empty { display: none; }
.cut-review-suggestion-status { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: 0; overflow-wrap: anywhere; }

/* Last week's recorded decision beside this week's observed pace. Inside the
   suggestion card it is one of the card's own rows, so the card's grid gap
   spaces it and it carries no margin of its own. */
.cut-review-last-decision { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: -12px 0 22px; overflow-wrap: anywhere; }
.cut-review-suggestion .cut-review-last-decision { margin: 0; }
/* The owner's destination, under the pace it is measured from. */
.cut-review-goal-weight { color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug); margin: 0 0 10px; }
/* The Settings hint for the optional own target. */
.profile-hint { font-size: var(--fs-label); line-height: var(--lh-snug); margin: -4px 0 4px; }
@media (max-width: 700px) {
  .cut-review-last-decision { margin-bottom: 16px; }
  .cut-review-suggestion-decide { flex: 1 1 8rem; }
}
/* ---------- end weekly coaching suggestion (S13) ---------- */

/* ---------- daily checklist (S19) ---------- */
/* One compact card on Today, wearing the card and row chrome the panel already
   uses. Monochrome throughout: the only state a row shows is its own tick, and
   that is drawn with the existing ink and surface tokens, never a new colour. */
.checklist-card { display: grid; gap: 10px; }
.checklist-head { align-items: baseline; gap: 12px; }
.checklist-head h2 { margin: 0; }
#checklist-items .list-meta { margin: 0; padding: 14px 18px; }
.checklist-row { width: 100%; min-height: var(--tap); }
.checklist-mark { flex-shrink: 0; width: 22px; height: 22px; border: 2px solid var(--border-strong); border-radius: var(--radius-sm); }
.checklist-row[aria-pressed="true"] .checklist-mark { background: var(--success); border-color: var(--success); }
/* The tick itself: two borders rotated into a check, in the success pair's
   ink, the same green-and-ink as a done set's tick in both themes. */
.checklist-row[aria-pressed="true"] .checklist-mark::after {
  content: ""; display: block; width: 6px; height: 11px; margin: 2px auto 0;
  border-right: 2px solid var(--success-ink); border-bottom: 2px solid var(--success-ink);
  transform: rotate(45deg);
}
/* A ticked row is not a visited link. The filled mark is the whole of the
   state, so the label keeps the panel's own ink and gains no underline from
   the shared row hover (visual review p04/p09, designer note 11). */
.checklist-row[aria-pressed="true"] .list-row-label strong { color: var(--text-primary); }
.checklist-row:hover .list-row-label strong, .checklist-row:focus-visible .list-row-label strong { text-decoration: none; }
#checklist-message:empty, #checklist-editor-message:empty, #checklist-form-mode:empty { display: none; }
/* The way into the editor is the panel's own quiet link control, so Today
   keeps exactly one filled button: the next action. */
.checklist-card #checklist-settings { margin-top: 0; }
/* The Settings editor reuses the timeline row, with the actions below the name
   on a phone so four 44px controls never crowd one line. */
.checklist-editor-row { flex-wrap: wrap; }
/* The first item cannot go up and the last cannot go down: the control says so
   rather than silently doing nothing, in the panel's own disabled treatment. */
.checklist-editor-row button[disabled] { opacity: .45; }
.checklist-editor-row strong { flex: 1 1 100%; overflow-wrap: anywhere; }
.checklist-archived { margin-top: 12px; }
.checklist-archived summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }
.checklist-archived summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Today's own entry sheets (S18B, owner review of the S18 shots) ----------

   Two things the 430x932 contact sheet showed. The Log sleep sheet was a panel
   parked in the lower third of the phone, and the Note value ran off the end of
   its single-line field ("Woke up once, late dinne"). Both are fixed here, for
   Today's own sheets only: nothing in this block names `.s6-sheet`, so the food,
   check-in and review sheets keep the shape they already ship.

   On a phone the sheet *is* the screen: full dynamic viewport height below the
   top safe area, its own scrolling body, and a footer that holds Save clear of
   the home indicator however long the form gets. On anything wider the centred
   dialog `.s6-sheet` already draws is left alone. */
.today-sheet > .readiness-sheet { padding: 0; }
.today-sheet .today-sheet-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; gap: 0; }
.today-sheet .today-sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 16px 16px; scroll-padding-block: 16px;
}
.today-sheet .today-sheet-body > :not(.hidden) { margin-block: 0 12px; }
.today-sheet .today-sheet-body > :last-child { margin-bottom: 0; }
/* Save never scrolls away, and never sits under the home indicator. */
.today-sheet .today-sheet-actions {
  flex: 0 0 auto; display: grid; gap: 8px; margin: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--border-soft);
}
.today-sheet .today-sheet-actions > .message { margin: 0; }
/* A sentence is not a number: the note takes the whole row and grows down the
   sheet (app.js sets the height from its own content), so what the owner typed
   wraps instead of scrolling sideways out of a 195px column. */
/* Three classes, because the row shape it is overriding is
   `.s6-sheet label:not(:has(input[type=radio]))` and that is not a plain
   two-class selector. */
.today-sheet .today-sheet-body .sheet-note-field { grid-template-columns: minmax(0,1fr); align-items: start; gap: 2px; padding-block: 10px; }
.today-sheet .today-sheet-body .sheet-note-field textarea {
  min-height: 44px; resize: none; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere; text-overflow: clip;
}
@media (max-width: 600px) {
  .today-sheet > .readiness-sheet {
    height: calc(100dvh - env(safe-area-inset-top));
    max-height: calc(100dvh - env(safe-area-inset-top));
    border-radius: 0;
  }
}
/* ---------- end Today's own entry sheets (S18B) ---------- */


/* ============================================================================
   Ledger shell and shared primitives (owner-approved 2026-11-09)
   ----------------------------------------------------------------------------
   A quiet ruled ledger, now in colour: one accent for every action, four
   domain hues that say what a number is about, one tinted hero card per
   screen, and progress that fills once on first paint and never again on a
   data refresh. Values live in the token blocks at the top of this sheet;
   nothing below holds a raw hex.

   Motion contract: transform / opacity / colour / box-shadow / SVG
   stroke-dashoffset only. Every entrance, fill, count-up and draw is scoped
   under .is-entering (added by hydrateTabPanel at the moment
   .is-initial-hydrating leaves, removed on animationend or after 1500ms), so
   the initial-load CLS budget of 0.01 holds and a later render inserts
   elements with no running animation.
   ========================================================================= */

/* Page header: the phone's sticky top bar, 28px title + 15px date sub.
   Opaque page colour, no glass (§1.6): content never ghosts through it. */
.page-header {
  position: sticky; top: 0; z-index: 25;
  padding: var(--space-3) var(--space-1) var(--space-2);
  background: var(--bg);
}
.page-header h1 { font-size: var(--type-page); font-weight: var(--fw-bold); letter-spacing: var(--ls-h1); line-height: var(--lh-tight); }
.page-header time { color: var(--ink-3); font-size: var(--fs-label); }

/* Entrances. --i numbers each panel's direct children so cards arrive top-down. */
.tab-panel.is-entering > :nth-child(1) { --i: 0; }
.tab-panel.is-entering > :nth-child(2) { --i: 1; }
.tab-panel.is-entering > :nth-child(3) { --i: 2; }
.tab-panel.is-entering > :nth-child(4) { --i: 3; }
.tab-panel.is-entering > :nth-child(5) { --i: 4; }
.tab-panel.is-entering > :nth-child(n+6) { --i: 5; }
/* `.strong-workout-card` is excluded on purpose: it contains the rest band,
   which is `position: fixed`, and an ancestor with a live `transform` becomes
   that band's containing block -- so the band would ride the entrance down
   the page instead of staying on screen. A card that holds a fixed
   descendant cannot be animated. */
.tab-panel.is-entering > .card:not(.strong-workout-card),
.tab-panel.is-entering > .ledger-col > .card,
.tab-panel.is-entering.card,
#app-card.is-entering > .page-header {
  animation: rise var(--dur-in) var(--ease) both;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}
.tab-panel.is-entering > .ledger-col:nth-child(2) > .card { --i: 2; }

/* Hero: the one tinted card per screen. --hero / --hero-soft are set per
   card. The modifier is `ledger-hero`, not `hero`: `.hero` is already the
   signed-out landing section and `body.signed-in .hero { display: none }`
   would hide every tinted card the moment the owner signs in -- which is
   exactly what it did to the Trends chart before this rename. */
.card.ledger-hero {
  --hero: var(--accent); --hero-soft: var(--accent-soft-bg);
  position: relative; overflow: hidden;
  border-color: color-mix(in srgb, var(--hero) 22%, var(--border));
  background:
    radial-gradient(120% 90% at 0% 0%, var(--hero-soft) 0%, transparent 62%),
    radial-gradient(80% 60% at 100% 100%, color-mix(in srgb, var(--hero-soft) 70%, transparent) 0%, transparent 60%),
    var(--surface);
}
.card.ledger-hero > .ledger-eyebrow { color: var(--hero); }
.card.ledger-hero.is-nutrition { --hero: var(--c-nutrition); --hero-soft: var(--c-nutrition-soft); }
.card.ledger-hero.is-body { --hero: var(--c-body); --hero-soft: var(--c-body-soft); }
.card.ledger-hero.is-recovery { --hero: var(--c-recovery); --hero-soft: var(--c-recovery-soft); }

.ledger-eyebrow { color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.35; letter-spacing: 0; margin: 0; }

/* A flush card hosts a ruled list; its header keeps the padding. */
.card.ledger-flush { padding: 0; overflow: hidden; }
.card.ledger-flush > .ledger-card-head { padding: var(--card-pad) var(--card-pad) 0; }
.ledger-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.ledger-card-head h2, .ledger-card-head h3 { margin: 0; font-size: var(--fs-label); font-weight: var(--fw-semibold); color: var(--ink-2); letter-spacing: 0; line-height: 1.35; }
.ledger-card-head .ledger-meta { color: var(--ink-3); font-size: var(--fs-label); }
/* Design sprint slice 2 (§2.1, §1.2 rule 2-3): a card's heading is a group
   header -- sentence case, --fs-label/600/--ink-2 -- and it is the same on
   every tab. The ID prefix outranks the per-panel `h2` size rules
   (#overview-panel h2 and friends) that used to make the same level a
   different size on each screen. */
#app-card :is(.ledger-card-head :is(h2, h3), .ledger-eyebrow),
#settings-panel .settings-group > h2,
#trends-panel .trends-history h3,
#workouts-panel .workout-session-rail > h3 {
  font-size: var(--fs-label); font-weight: var(--fw-semibold); color: var(--ink-2);
  letter-spacing: 0; line-height: 1.35; text-transform: none;
}
/* §2.1: the header's text action sits at the right edge. The phone-wide
   `button { width: 100% }` used to stretch it across the header, so "Diary"
   and "Add" read as part of the title. */
.ledger-card-head > .ledger-link { width: auto; margin-inline-start: auto; }

/* Rows. 56px, title + sub on the left, value / verb / chevron on the right. */
.ledger-list { display: grid; }
.ledger-list > * + * { border-top: 1px solid var(--border-soft); }
.ledger-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-3) var(--card-pad); width: 100%; text-align: left;
  color: var(--ink); background: none; border: 0; border-radius: 0; box-shadow: none; font-weight: var(--fw-regular);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.ledger-row.lead { grid-template-columns: auto minmax(0, 1fr) auto; }
.ledger-row:is(a, button):active { background: var(--surface-2); transform: none; }
.ledger-row .ledger-title { display: block; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: var(--lh-snug); }
.ledger-row .ledger-sub { display: block; color: var(--ink-3); font-size: var(--fs-label); margin-top: 2px; }
.ledger-trail { display: flex; align-items: center; gap: var(--space-2); color: var(--ink-2); font-size: var(--fs-label); white-space: nowrap; }
.ledger-trail .ledger-value { color: var(--ink); font-weight: var(--fw-semibold); font-size: var(--fs-body); }
.ledger-trail .ledger-action { color: var(--accent); font-weight: var(--fw-semibold); }
.ledger-chev { width: 18px; height: 18px; color: var(--ink-4); stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; transition: transform var(--dur) var(--ease), color var(--dur) var(--ease); }

/* 36px domain icon tile: soft tint behind a 20px stroke icon in the strong hue. */
.ico { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); flex: none; }
.ico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico.nutri { background: var(--c-nutrition-soft); color: var(--c-nutrition); }
.ico.train { background: var(--accent-soft-bg); color: var(--accent); }
.ico.weight { background: var(--c-body-soft); color: var(--c-body); }
.ico.recov { background: var(--c-recovery-soft); color: var(--c-recovery); }
.ico.ok { background: var(--success-bg); color: var(--success); }

/* Formerly the count-up. Ink retires it: a number is readable in the first
   frame, so the real value (<b>) paints at once and nothing is laid over it.
   The span stays because app.js still wraps the calorie total in it. */
.count { position: relative; display: inline-block; --to: 0; --n: var(--to); }
.count > b { font: inherit; }

/* Bars. 6px track, fill in the card's domain hue; the fill scales from 0 and
   its box already has its final width, so filling is never a layout change. */
.ledger-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.ledger-bar > span { display: block; height: 100%; background: var(--fill, var(--accent)); border-radius: inherit; transform-origin: left; }
.is-entering .ledger-bar > span { animation: fill-x var(--dur-fill) var(--ease) both; animation-delay: calc(var(--i, 0) * var(--stagger) + 200ms); }
.ledger-bar.dashed { background: repeating-linear-gradient(90deg, var(--surface-3) 0 6px, transparent 6px 10px); }

/* Tag. 22px, 13px, grey by default; the success variant carries a glyph too,
   because colour is never the only signal. */
.ledger-tag { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: var(--radius-sm); font-size: var(--fs-caption); font-weight: var(--fw-bold); letter-spacing: .02em; color: var(--ink-2); background: var(--surface-2); }
.ledger-tag.ok { color: var(--success); background: var(--success-bg); }
.ledger-tag.outline { background: none; box-shadow: inset 0 0 0 1px var(--border-strong); }

/* Text and quiet actions. */
.ledger-link { color: var(--accent); font-weight: var(--fw-semibold); font-size: var(--fs-label); background: none; border: 0; box-shadow: none; min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 var(--space-2); border-radius: var(--radius); }
.ledger-link:hover, .ledger-link:active { background: var(--accent-soft-bg); color: var(--accent); }
.ledger-link.is-danger { color: var(--danger); }
.ledger-link.is-danger:hover, .ledger-link.is-danger:active { background: var(--danger-bg); }
/* A class that sets `display` outranks the UA's `[hidden] { display: none }`,
   so every Ledger primitive that does has to honour the attribute itself. */
.ledger-link[hidden], .ledger-row[hidden], .ledger-list[hidden] { display: none; }

/* Desktop hover lift. Pointer devices only; the phone has no hover state and
   the title keeps its colour, so the lift is never the only cue. */
@media (hover: hover) and (min-width: 64rem) {
  .ledger-row:is(a, button):hover { background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--shadow-lift); position: relative; z-index: 1; }
  .ledger-row:is(a, button):hover .ledger-chev { transform: translateX(2px); color: var(--ink-2); }
}

/* ============================================================================
   Ledger — Today (slice 2)
   ----------------------------------------------------------------------------
   Today is six sibling cards, not one card holding four: Up next (the hero),
   Nutrition, Log, Recent meals, Checklist and More. The decision comes first
   because the 2026-08-03 review asked for exactly that, and the DOM order is
   the phone's reading order, so nothing is reordered by CSS alone.
   ========================================================================= */
#overview-panel {
  display: grid; gap: var(--space-4);
  padding: 0; border: 0; border-radius: 0; background: transparent;
}
#overview-panel > .row.today-intro { align-items: center; padding: 0 var(--space-1); }
#overview-panel .today-status-sentence { margin: 0; color: var(--ink-2); font-size: var(--fs-label); }
#overview-panel .today-date { margin: 2px 0 0; color: var(--ink-3); font-size: var(--fs-caption); }
#overview-panel > .quick-actions { display: grid; gap: var(--space-4); min-width: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }

/* Up next — the hero. Eyebrow, 20px decision, one sentence, one accent
   button, and the provenance line as a quiet text link beneath it. */
#overview-panel #today-now {
  display: grid; gap: var(--space-3);
  margin: 0; padding: var(--card-pad); border-radius: var(--radius-lg);
}
#overview-panel #today-now > .today-next-heading { margin: 0; }
#overview-panel .today-now-main { display: grid; gap: var(--space-1); min-width: 0; }
#overview-panel .today-now h3 { margin: 0; font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-h2); line-height: var(--lh-snug); color: var(--ink); }
#overview-panel #today-now-why { margin: 0; font-size: var(--fs-label); line-height: var(--lh-body); color: var(--ink-2); }
#overview-panel #today-now-cta { margin: 0; }
#overview-panel .today-now-freshness { margin: 0; font-size: var(--fs-label); color: var(--accent); font-weight: var(--fw-semibold); }
#overview-panel .today-now-chip { padding: 0; border: 0; background: transparent; color: var(--ink-3); font-size: var(--fs-caption); }

/* Nutrition — one 44px number with its unit, then three 6px bars. */
#overview-panel .today-nutrition-card { padding: var(--card-pad); border-radius: var(--radius-lg); }
#overview-panel .today-nutrition-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
#overview-panel .today-energy { text-align: left; min-width: 0; }
/* `justify-content: start` is load-bearing: the ring's old rule centred this
   block, and a grid whose single column is centred puts the day's number in
   the middle of the card rather than on the ledger's left edge. */
#overview-panel .today-ring-copy { position: static; inset: auto; display: grid; justify-items: start; justify-content: start; align-content: start; gap: 0; margin: 0; }
#overview-panel .today-ring-copy strong { font-size: var(--fs-display); line-height: 1; letter-spacing: var(--ls-display); font-weight: var(--fw-bold); color: var(--ink); }
#overview-panel .today-ring-copy strong.ring-incomplete { font-size: var(--fs-h2); line-height: var(--lh-snug); letter-spacing: var(--ls-h2); }
/* The direct child only: the count-up's own <span class="count"> lives
   inside <strong> and must keep the display size. */
#overview-panel .today-ring-copy > span { font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--ink-3); line-height: var(--lh-snug); }
#overview-panel .today-remaining { margin: 2px 0 0; font-size: var(--fs-label); color: var(--ink-3); line-height: var(--lh-snug); }
#overview-panel .today-macro-bars { --fill: var(--ink); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); min-width: 0; }
#overview-panel .today-macro > div:first-child { display: grid; gap: 2px; font-size: var(--fs-caption); color: var(--ink-3); }
#overview-panel .today-macro strong { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--ink); }
#overview-panel .today-macro-track { height: 6px; margin-top: var(--space-2); border-radius: 3px; }
#overview-panel .today-macro small { display: block; margin-top: var(--space-1); font-size: var(--fs-caption); line-height: var(--lh-snug); color: var(--ink-3); }
#overview-panel .today-nutrition-coverage {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-2);
  min-height: var(--tap);
  margin: var(--space-3) 0 0; padding-top: var(--space-2); border-top: 1px solid var(--border-soft);
  font-size: var(--fs-caption); line-height: var(--lh-snug); color: var(--ink-3);
}
#overview-panel .today-nutrition-coverage > .ledger-link { min-height: var(--tap); white-space: nowrap; }

/* Log — a flush list card of 56px rows, each led by its domain tile. */
#overview-panel #day-loop-rail { display: grid; gap: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
#overview-panel #day-loop-rail > .ledger-card-head { padding: var(--card-pad) var(--card-pad) var(--space-2); margin: 0; }
#overview-panel .day-loop-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: none; align-items: center; column-gap: var(--space-3); row-gap: 0;
  min-height: 56px; margin: 0; padding: var(--space-3) var(--card-pad);
  border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; background: transparent;
}
#overview-panel .day-loop-row > .ico { grid-area: auto; grid-column: 1; }
#overview-panel .day-loop-row > .day-loop-copy { grid-area: auto; grid-column: 2; }
#overview-panel .day-loop-row > .day-loop-action { grid-area: auto; grid-column: 3; }
#overview-panel .day-loop-row > .list-chevron { grid-area: auto; grid-column: 4; }
#overview-panel .day-loop-copy { display: grid; gap: 2px; min-width: 0; }
#overview-panel .day-loop-label { color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-medium); text-transform: none; letter-spacing: 0; }
#overview-panel .day-loop-value { color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular); }
#overview-panel .day-loop-note { color: var(--ink-3); font-size: var(--fs-caption); }
#overview-panel .day-loop-action {
  justify-self: end; min-height: var(--tap); max-width: 11rem;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--accent); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#overview-panel #today-log-food { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: none; }
#overview-panel #today-log-food .day-loop-action { max-width: 11rem; width: auto; }
#overview-panel .day-loop-row.is-complete .day-loop-value { color: var(--success); font-weight: var(--fw-semibold); }
#overview-panel .list-chevron { width: 18px; height: 18px; color: var(--ink-4); }

/* Recent meals — rows with a --c-nutrition avatar. */
#overview-panel .today-meals-card { padding: 0; border-radius: var(--radius-lg); }
#overview-panel .today-meals-card > .ledger-card-head { padding: var(--card-pad) var(--card-pad) var(--space-2); margin: 0; }
#overview-panel .today-recent-meals li { padding: var(--space-3) var(--card-pad); min-height: 56px; border-top: 1px solid var(--border-soft); }
#overview-panel .today-recent-meals li + li { border-top: 1px solid var(--border-soft); }
#overview-panel .today-recent-meals > p { padding: 0 var(--card-pad) var(--card-pad); }
#overview-panel .today-meal-initial { height: 36px; width: 36px; flex: 0 0 36px; border-radius: var(--radius-sm); background: var(--c-nutrition-soft); color: var(--c-nutrition); font-size: var(--fs-label); font-weight: var(--fw-semibold); }
#overview-panel .today-recent-meals strong { font-size: var(--fs-body); font-weight: var(--fw-medium); }
#overview-panel .today-recent-meals li > div > span { font-size: var(--fs-label); color: var(--ink-3); }
#overview-panel .today-meal-energy { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--ink); }

/* Checklist — one quiet row while the list is empty. */
#overview-panel #checklist-card { padding: var(--card-pad); border-radius: var(--radius-lg); }
#overview-panel #checklist-card .checklist-head { margin: 0 0 var(--space-3); }
#overview-panel #checklist-card.is-empty { padding: 0; }
#overview-panel #checklist-card.is-empty > #checklist-items { display: none; }
#overview-panel #checklist-card.is-empty > #checklist-message:empty { display: none; }
#overview-panel #checklist-card.is-empty > .checklist-head {
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 2px;
  min-height: 56px; margin: 0; padding: var(--space-3) var(--card-pad) var(--space-3);
}
#overview-panel #checklist-card.is-empty #checklist-heading { font-size: var(--fs-body); font-weight: var(--fw-medium); }
#overview-panel #checklist-card.is-empty #checklist-progress { margin: 0; color: var(--ink-3); font-size: var(--fs-label); }
#overview-panel #checklist-card.is-empty > #checklist-settings {
  width: 100%; justify-content: space-between; margin: 0;
  padding: var(--space-3) var(--card-pad); border-top: 1px solid var(--border-soft);
}

/* More — the two quiet rows the owner needs one tap away. */
#overview-panel .today-more-card { padding: 0; border-radius: var(--radius-lg); }
#overview-panel .today-more-card > #today-details { border-top: 0; }
#overview-panel .today-details > summary { min-height: 56px; padding: var(--space-3) var(--card-pad); font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); }
#overview-panel .today-details[open] > summary { border-bottom: 1px solid var(--border-soft); }
#overview-panel .today-review-row { min-height: 56px; padding: var(--space-3) var(--card-pad); border-top: 1px solid var(--border-soft); border-radius: 0; background: transparent; box-shadow: none; color: var(--ink); font-weight: var(--fw-regular); }
#overview-panel .today-review-row strong { font-size: var(--fs-body); font-weight: var(--fw-medium); }
#overview-panel .today-review-row .muted { display: block; font-size: var(--fs-label); color: var(--ink-3); }
#overview-panel .today-review-row > span:last-child { color: var(--accent); font-weight: var(--fw-semibold); }
#overview-panel .all-stats-card { margin: 0; padding: var(--space-3) var(--card-pad) var(--card-pad); border-top: 1px solid var(--border-soft); border-radius: 0; background: transparent; }

/* The one accent button on the screen. */
#overview-panel #today-now-cta .today-plan-cta { width: 100%; min-height: var(--tap); border-radius: var(--radius); font-size: var(--fs-body); font-weight: var(--fw-semibold); }

@media (max-width: 420px) {
  #overview-panel .today-macro-bars { gap: var(--space-3); }
}

/* Today desktop workspace: two columns, 7fr / 5fr. Up next top-left, Log
   top-right; the DOM order is still the phone's reading order, so the areas
   below are the only thing that differs. */
@media (min-width: 64rem) {
  #overview-panel { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); padding: 0; }
  #overview-panel > .row.today-intro { grid-column: 1; }
  #overview-panel > .quick-actions {
    display: grid; gap: var(--space-5);
    grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr);
    grid-template-areas: "next log" "nutrition checklist" "meals more";
    align-items: start;
    padding: 0; border: 0; background: transparent;
  }
  #overview-panel #today-now { grid-area: next; padding: var(--space-6); }
  #overview-panel .today-nutrition-card { grid-area: nutrition; padding: var(--space-6); }
  #overview-panel #day-loop-rail { grid-area: log; }
  #overview-panel .today-meals-card { grid-area: meals; }
  #overview-panel #checklist-card { grid-area: checklist; }
  #overview-panel .today-more-card { grid-area: more; }
  #overview-panel .today-nutrition-layout { grid-template-columns: minmax(0, 1fr); }
  #overview-panel #day-loop-rail > .ledger-card-head,
  #overview-panel .today-meals-card > .ledger-card-head { padding: var(--space-6) var(--space-6) var(--space-2); }
  #overview-panel .day-loop-row,
  #overview-panel #today-log-food {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: none;
    min-height: 56px; padding: var(--space-3) var(--space-6);
  }
  #overview-panel .day-loop-copy { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  #overview-panel .day-loop-label { grid-column: auto; grid-row: auto; font-size: var(--fs-body); }
  #overview-panel .day-loop-value { grid-column: auto; grid-row: auto; font-size: var(--fs-label); }
  #overview-panel .day-loop-note { grid-column: auto; grid-row: auto; font-size: var(--fs-caption); }
  #overview-panel .today-recent-meals li { padding: var(--space-3) var(--space-6); }
  #overview-panel #checklist-card.is-empty > .checklist-head { padding-inline: var(--space-6); }
  #overview-panel #checklist-card.is-empty > #checklist-settings { padding-inline: var(--space-6); }
  #overview-panel :is(.today-details > summary, .today-review-row) { padding-inline: var(--space-6); }
  #overview-panel .today-command-center, #overview-panel { max-width: 1200px; }
}
@media (hover: hover) and (min-width: 64rem) {
  #overview-panel :is(.day-loop-row, .today-review-row, .today-details > summary):hover {
    background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--shadow-lift);
  }
  #overview-panel :is(.day-loop-row, .today-review-row):hover .list-chevron { transform: translateX(2px); color: var(--ink-2); }
}

/* First run. The setup card is Today's tallest block, and on a 390x844 phone
   the Log rail has to stay reachable behind it without scrolling, so this
   state drops the decorations it cannot afford: there is no diary to open
   yet, the hint is caption-sized, and the three steps sit at the 44px tap
   floor rather than 48px. Nothing here is below a floor. */
#overview-panel .today-nutrition-card:has(.today-setup) { padding: var(--space-3); }
#overview-panel .today-nutrition-card:has(.today-setup) .ledger-card-head { margin-bottom: var(--space-2); }
#overview-panel .today-nutrition-card:has(.today-setup) .ledger-card-head .ledger-link { display: none; }
#overview-panel .today-setup-hint { margin: 0 0 var(--space-1); font-size: var(--fs-caption); line-height: var(--lh-snug); }
#overview-panel .today-setup { gap: 0; }
#overview-panel :is(.today-setup-step, #today-set-goals) {
  min-height: var(--tap); padding: var(--space-2) var(--space-1); font-size: var(--fs-label);
  border: 0; border-radius: 0; background: transparent;
}
#overview-panel .today-setup > .today-setup-step + .today-setup-step { border-top: 1px solid var(--border-soft); }
#overview-panel .today-setup-step.primary-action { padding-inline: var(--space-3); border-radius: var(--radius); }
#overview-panel #today-now { gap: var(--space-2); }
#overview-panel #day-loop-rail > .ledger-card-head { padding: var(--space-2) var(--card-pad); }
@media (max-width: 1023px) { #overview-panel { gap: var(--space-3); } }
@media (min-width: 64rem) {
  #overview-panel #today-now { gap: var(--space-3); }
  #overview-panel #day-loop-rail > .ledger-card-head { padding: var(--space-6) var(--space-6) var(--space-2); }
}

/* Short phones (a 390x844 iPhone, not the 430x932 reference) tighten Today's
   card padding by one step so the Log rail still clears the tab bar without a
   scroll on first open. Card padding is the only thing that moves: every tap
   target stays 44px and no text moves off the 13px floor. */
@media (max-width: 1023px) and (max-height: 900px) {
  #overview-panel :is(#today-now, .today-nutrition-card) { padding: var(--space-3); }
}

/* Narrow phones. The Log row's verb is the app's long form ("Start workout",
   not the mockup's "Start"), so below the 430px reference it drops to label
   size and wraps rather than squeezing the row's title column: browser_smoke
   holds that column at >=150px from 320px up. Under 360px the 36px domain
   tile goes too -- there is not room for both it and a readable title. */
@media (max-width: 1023px) {
  #overview-panel .day-loop-action {
    max-width: 6.5rem; white-space: normal; text-align: right;
    font-size: var(--fs-label); line-height: var(--lh-snug);
  }
}
@media (max-width: 359.98px) {
  #overview-panel .day-loop-row > .ico { display: none; }
  #overview-panel .day-loop-row, #overview-panel #today-log-food { column-gap: var(--space-2); }
  #overview-panel .day-loop-action { max-width: 4.5rem; }
}

/* 240px and under (the smoke lane's smallest viewport): the verb can no
   longer sit beside the title, so it takes its own line under it. */
@media (max-width: 240px) {
  #overview-panel .day-loop-row,
  #overview-panel #today-log-food { grid-template-columns: minmax(0, 1fr) auto; }
  #overview-panel .day-loop-row > .day-loop-copy { grid-column: 1; grid-row: 1; }
  #overview-panel .day-loop-row > .list-chevron { grid-column: 2; grid-row: 1; }
  #overview-panel .day-loop-row > .day-loop-action {
    grid-column: 1 / -1; grid-row: 2; justify-self: start; max-width: none; text-align: left;
  }
}

/* ============================================================================
   Ledger — Workout logging, phone (slice 3)
   ----------------------------------------------------------------------------
   One sticky glass session bar with the elapsed time, the set count and the
   one action that ends the session; the rest band as this screen's hero
   directly under it; and a set row that is a number, a ghost of last time,
   two fields and a check. Every id, aria-* and data-* hook is unchanged; the
   `.finish-green` and `.template-chip.active` rule texts stay in the sheet
   because tests/test_static_theme_contrast.py pins them verbatim, even though
   nothing applies those classes any more.
   ========================================================================= */
#workouts-panel .strong-topbar {
  position: sticky; top: 0; z-index: 25;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: var(--space-2); margin: 0; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border-soft);
}
#workouts-panel .strong-topbar.hidden { display: none; }
#workouts-panel .strong-topbar #cancel-workout-top {
  width: auto; min-width: 0; min-height: var(--tap); padding: 0 var(--space-2);
  border: 0; background: none; box-shadow: none;
  color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-medium);
}
#workouts-panel .strong-topbar .timer-stack { display: grid; justify-items: center; gap: 0; min-width: 0; }
#workouts-panel .strong-topbar .elapsed-wrap { display: flex; align-items: baseline; gap: var(--space-2); }
#workouts-panel .strong-topbar .elapsed-label { color: var(--ink-3); font-size: var(--fs-caption); }
#workouts-panel .strong-topbar #workout-elapsed { font-size: var(--fs-body); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
#workouts-panel .strong-topbar .session-progress { color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug); }
#workouts-panel .strong-topbar .session-progress:empty { display: none; }
#workouts-panel .strong-topbar-actions { display: flex; align-items: center; gap: var(--space-1); }
/* The design draws this as a 36px "small" pill; the app's touch floor is
   44px and browser_smoke enforces it, so the pill keeps the floor. */
#workouts-panel #finish-workout.session-finish-pill {
  width: auto; min-height: var(--tap); padding: 0 var(--space-4); border: 0;
  border-radius: var(--radius-pill); background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-label); font-weight: var(--fw-semibold); white-space: nowrap;
  box-shadow: inset 0 1px 0 var(--sheen), 0 6px 16px -8px var(--accent-glow);
}
#workouts-panel .session-options-toggle {
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  border: 0; border-radius: var(--radius); background: none; box-shadow: none;
  color: var(--ink-2); font-size: var(--fs-h3); line-height: 1;
}
#workouts-panel .session-options-toggle:active { background: var(--surface-2); }

/* The rest band: this screen's hero on the phone. `.card.rest` keeps the
   sticky position at a higher specificity than `.card.ledger-hero`'s relative. */
/* The band keeps the geometry the phone loop already proves -- fixed, above
   the keypad, moved to the top inset while the keypad is open -- because that
   is what keeps it on screen in both states. What changes is what it looks
   like: the screen's one hero, an accent countdown line across its top, the
   time in accent at section size, and three 44px chips. */
#workouts-panel .rest-pill.card.rest {
  --p: 0;
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center; gap: var(--space-2);
  left: var(--space-2); right: var(--space-2); width: auto; max-width: none; transform: none;
  margin: 0; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius); overflow: hidden;
}
#workouts-panel .rest-pill.card.rest::before {
  content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 3px;
  background: var(--accent); box-shadow: 0 0 12px 1px var(--accent-glow);
  transform: scaleX(var(--p)); transform-origin: left;
  transition: transform 1s linear;
}
#workouts-panel .rest-pill #rest-label { color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: 0; }
#workouts-panel .rest-pill #rest-time { color: var(--accent); font-size: var(--fs-h3); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; text-align: center; }
#workouts-panel .rest-pill button {
  width: auto; min-width: var(--tap); min-height: var(--tap); padding: 0 var(--space-2);
  border: 1px solid var(--ink-4); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink-2); box-shadow: none;
  font-size: var(--fs-caption); font-weight: var(--fw-semibold);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
#workouts-panel .rest-pill button:active { transform: scale(.94); transition-duration: 80ms; background: var(--surface-2); }

/* Set rows. 36px number, the ghost of last time, 76px weight (4px of
   horizontal padding so "142.5" is never clipped), 60px reps, 44px check. */
@media (max-width: 1023px) {
  #workouts-panel .strong-table-head,
  #workouts-panel .strong-set-line {
    grid-template-columns: 36px minmax(0, 1fr) 76px 60px 44px;
    gap: var(--space-2); align-items: center; min-height: 52px; padding: var(--space-1) 0;
  }
  #workouts-panel .strong-set-line.is-editing-sets-row { grid-template-columns: 36px minmax(0, 1fr) 76px 60px 44px 36px; }
  #workouts-panel .exercise-block.is-editing-sets .strong-set-line,
  #workouts-panel .exercise-block.is-editing-sets .strong-table-head {
    grid-template-columns: 36px minmax(0, 1fr) 76px 60px 44px 36px;
  }
  #workouts-panel .set-index-pill {
    width: 32px; height: 32px; display: grid; place-items: center; justify-self: center;
    border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink-2);
    font-size: var(--fs-label); font-weight: var(--fw-semibold);
  }
  #workouts-panel .previous-value {
    justify-self: start; text-align: left; padding: 0 var(--space-1); min-height: var(--tap);
    color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-medium);
  }
  #workouts-panel :is(.set-weight, .set-reps) {
    min-height: var(--tap); padding: 0 4px; text-align: center;
    border: 1px solid var(--border-input); border-radius: var(--radius);
    background: var(--surface); color: var(--ink);
    font-size: var(--fs-body); font-weight: var(--fw-semibold);
  }
  #workouts-panel .done-set {
    width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap);
    display: grid; place-items: center; padding: 0;
    border: 1px solid var(--ink-4); border-radius: var(--radius);
    background: var(--surface); color: var(--ink-3); box-shadow: none;
  }
}
/* The per-set minus is behind the exercise's "Edit sets" toggle at every
   width: five tappable things on one row was the finding, and the desktop
   set grid is the same five columns as the phone's. */
#workouts-panel .remove-set { display: none; }
#workouts-panel .exercise-block.is-editing-sets .remove-set { display: grid; place-items: center; width: var(--tap); min-width: var(--tap); min-height: var(--tap); }
#workouts-panel .done-set svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#workouts-panel .set-done .set-index-pill { background: var(--success); color: var(--success-ink); box-shadow: none; }
/* The pop is on the glyph, not on the 44px button: a transform changes what
   getBoundingClientRect reports, and the tap-target floor is measured from
   that box (browser_smoke saw 34px mid-animation). The check still pops. */
#workouts-panel .set-done.just-done .done-set svg { animation: pop 360ms var(--ease) both; }
#workouts-panel .set-done.just-done .done-set svg path { stroke-dasharray: 1; animation: draw 320ms var(--ease) both; }
#workouts-panel .set-pr { color: var(--success); font-size: var(--fs-caption); font-weight: var(--fw-semibold); }
#workouts-panel .set-pr:not(.hidden)::before { content: "★"; margin-right: 4px; }
#workouts-panel .add-set-wide {
  width: 100%; min-height: var(--tap); border: 0; background: none; box-shadow: none;
  color: var(--accent); font-size: var(--fs-body); font-weight: var(--fw-semibold); text-align: left;
}
#workouts-panel .exercise-head h3 { font-size: var(--fs-h3); font-weight: var(--fw-bold); letter-spacing: var(--ls-h3); }

/* Keypad. One 4-column grid: digits 3x4, then minus, plus and an accent Next
   spanning the last two rows. The two wrappers become `display: contents` so
   the twelve digits and the three actions share one grid. */
#workouts-panel .workout-keypad, .workout-keypad {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 88px; gap: var(--space-2);
}
.workout-keypad.hidden { display: none; }
.workout-keypad .keypad-grid, .workout-keypad .keypad-actions { display: contents; }
.workout-keypad button {
  min-height: 50px; border-radius: var(--radius); font-size: 22px; font-weight: var(--fw-semibold);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.workout-keypad button:active { transform: scale(.95); transition-duration: 80ms; }
.workout-keypad .keypad-actions > [data-key="minus"] { grid-column: 4; grid-row: 1; }
.workout-keypad .keypad-actions > [data-key="plus"] { grid-column: 4; grid-row: 2; }
.workout-keypad .keypad-actions > .keypad-next {
  grid-column: 4; grid-row: 3 / span 2; font-size: var(--fs-body);
  box-shadow: inset 0 1px 0 var(--sheen), 0 6px 16px -8px var(--accent-glow);
}

/* The session rail keeps its place in the form -- Save current workout is the
   form's submit, and Cancel/Save as template sit beside it -- but only one
   action on this screen is the accent one, and it is Finish & save in the
   sticky bar above. These three become quiet: a surface-2 fill, a hairline
   secondary and a muted text button, in that order. */
#workouts-panel .workout-session-rail > h3 { margin: 0; }
#workouts-panel #save-workout {
  background: var(--surface-2); color: var(--ink); box-shadow: none;
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
/* A historical edit hides Finish & save, which makes Save changes the one
   action on the screen -- so it takes the accent, exactly as Start does. */
#workouts-panel:has(#finish-workout.hidden) #save-workout {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 var(--sheen), 0 6px 16px -8px var(--accent-glow);
}
#workouts-panel #save-workout-template { border: 1px solid var(--border-input); background: var(--surface); color: var(--ink); box-shadow: none; }
#workouts-panel .cancel-workout-wide {
  border: 0; background: none; box-shadow: none;
  color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-medium);
}
#workouts-panel .cancel-workout-wide:active { background: var(--surface-2); }
@media (min-width: 64rem) {
  #workouts-panel .strong-topbar { padding-block: var(--space-1); }
  #workouts-panel .rest-pill.card.rest {
    position: fixed; left: auto; right: var(--space-6); bottom: var(--space-6);
    top: auto; width: min(360px, 32vw); z-index: 81;
  }
}

/* ============================================================================
   Ledger — Plates per side (slice 4)
   ----------------------------------------------------------------------------
   Pure arithmetic on the focused weight field, docked above the keypad so
   showing it costs no layout shift (the dock is already fixed). It renders
   only while a weight field has focus and Plates has been tapped once this
   session; the heaviest plate in the set is the accent chip.
   ========================================================================= */
.workout-keypad .plates-strip {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: var(--space-1) var(--space-2); max-height: 72px;
  margin: 0 0 var(--space-1); padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-soft);
  animation: sheet-in var(--dur-sheet) var(--ease);
}
.workout-keypad .plates-strip[hidden] { display: none; }
.plates-head { display: flex; align-items: baseline; gap: var(--space-2); margin: 0; min-width: 0; }
.plates-label { color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: 0; }
#plates-target { color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.plates-chips { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); min-width: 0; }
.plate-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 var(--space-2); border-radius: var(--radius-pill);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border);
  color: var(--ink-2); font-size: var(--fs-caption); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums;
}
.plate-chip.is-heavy { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.plate-note { color: var(--ink-3); font-size: var(--fs-caption); }
.plates-short { grid-column: 1; margin: 0; color: var(--ink-3); font-size: var(--fs-caption); }
.plates-short:empty { display: none; }
#plates-bar {
  grid-column: 2; grid-row: 1 / span 3; align-self: center;
  width: auto; min-width: 0; min-height: var(--tap); padding: 0 var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-2); box-shadow: none;
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); white-space: nowrap;
}
#workouts-panel .plates-toggle {
  width: auto; min-height: var(--tap); border: 0; background: none; box-shadow: none;
  color: var(--accent); font-size: var(--fs-label); font-weight: var(--fw-semibold);
}
#workouts-panel .plates-toggle:active { background: var(--accent-soft-bg); }

/* The session stack above the exercises: one sticky bar, the title block and
   the options summary. test_browser_lifter_workouts holds the first exercise
   block's top at <=205px so the lifter sees a set row without scrolling, and
   the 44px Finish pill in the bar costs eight of those pixels back. Taking
   them out of the list's own leading margin keeps every target at its floor. */
#workouts-panel .strong-exercises { margin-top: 0; }
#workouts-panel .strong-workout-head { margin-bottom: 0; padding-bottom: 0; }
#workouts-panel .workout-session-main { gap: var(--space-3); }

/* ============================================================================
   Ledger — Workout logging, desktop (slice 5)
   ----------------------------------------------------------------------------
   A workspace, not a widened phone: the exercises take the left column and
   the session rail is a fixed 360px on the right, holding the Rest card (the
   desktop hero, with a 112px ring), the session's own numbers, and the three
   actions stacked. The keypad is a touch affordance and has no place here.
   Phone CSS from slices 3 and 4 is untouched.
   ========================================================================= */
.rest-pill .rest-ring { display: none; }
@media (min-width: 64rem) {
  /* Out of the 760px reading-column cap: this screen is two columns. The
     shell's own 1440px cap and --page-gutter still own the outer frame, so the
     panel shares the page header's axis exactly (asserted in
     test_browser_nutrition_desktop_composition). */
  #app-card > #workouts-panel { width: 100%; max-width: none; margin-inline: 0; }
  #workouts-panel.workout-is-active .strong-workout-form {
    display: grid; grid-template-columns: minmax(640px, 720px) 360px;
    align-items: start; gap: var(--space-6); justify-content: start;
  }
  /* `position: sticky` always creates a stacking context, so the Rest card's
     own z-index is scoped inside this rail -- and the rail, at z-index auto,
     paints below the cards that follow it in the DOM. Without a z-index here
     the "This week" card covers the rest timer's controls. */
  #workouts-panel .workout-session-rail {
    position: sticky; top: var(--space-4); z-index: 50; display: grid; gap: var(--space-4);
    align-content: start; padding: 0; background: none; border-radius: 0;
  }
  #workouts-panel .workout-session-rail > h3 { padding: 0 var(--space-1); }
  #workouts-panel .workout-session-rail #workout-summary {
    padding: var(--space-4); margin: 0; border: 0;
    border-radius: var(--radius-lg); background: var(--surface);
  }
  #workouts-panel .workout-session-rail .summary-grid { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); }
  #workouts-panel .workout-session-rail .summary-grid article {
    display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
    padding: 0; border: 0; border-radius: 0; background: none;
  }
  #workouts-panel .workout-session-rail .summary-grid span { color: var(--ink-3); font-size: var(--fs-label); }
  #workouts-panel .workout-session-rail .summary-grid strong { font-size: var(--fs-body); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }

  /* The Rest card: the desktop hero. The ring is the countdown -- an accent
     stroke with a drop-shadow glow whose stroke-dashoffset is driven by the
     same --p the phone's line scales, so it never touches layout. */
  /* The Rest card stays pinned bottom-right of the workspace rather than
     riding the rail. `position: sticky` can only travel the difference
     between its container's height and its own, and in a long session the
     rail runs out of travel well before the last exercise -- which is
     exactly when a lifter is resting. The rail's 360px track is unchanged
     and still sits to the right of the exercises. */
  #workouts-panel .rest-pill.card.rest {
    position: fixed; left: auto; right: var(--space-6); bottom: var(--space-6); top: auto;
    width: min(360px, 32vw); max-width: none; z-index: 81;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: "ring ring ring" "label label label" "minus plus skip";
    justify-items: center; gap: var(--space-2);
    padding: var(--space-5); border-radius: var(--radius-lg);
  }
  #workouts-panel .rest-pill.card.rest::before { display: none; }
  #workouts-panel .rest-pill .rest-ring { display: block; grid-area: ring; width: 112px; height: 112px; transform: rotate(-90deg); }
  #workouts-panel .rest-pill .rest-ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
  #workouts-panel .rest-pill .rest-ring-track { stroke: var(--surface-3); }
  #workouts-panel .rest-pill .rest-ring-value {
    stroke: var(--accent); stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--p));
    filter: drop-shadow(0 0 6px var(--accent-glow));
    transition: stroke-dashoffset 1s linear;
  }
  #workouts-panel .rest-pill #rest-label { grid-area: label; }
  #workouts-panel .rest-pill #rest-minus { grid-area: minus; }
  #workouts-panel .rest-pill #rest-time { grid-area: ring; place-self: center; font-size: var(--fs-h3); }
  #workouts-panel .rest-pill #rest-plus { grid-area: plus; }
  #workouts-panel .rest-pill #rest-skip { grid-area: skip; width: 100%; }
  #workouts-panel .rest-pill button { width: 100%; }

  /* Set rows: 48px number, the ghost, a 128px weight field, 96px reps, the
     44px check. The per-set minus is behind "Edit sets" here too. */
  #workouts-panel .strong-table-head,
  #workouts-panel .strong-set-line { grid-template-columns: 48px minmax(0, 1fr) 128px 96px 44px; gap: var(--space-2); }
  #workouts-panel .exercise-block.is-editing-sets .strong-table-head,
  #workouts-panel .exercise-block.is-editing-sets .strong-set-line { grid-template-columns: 48px minmax(0, 1fr) 128px 96px 44px 44px; }
  #workouts-panel .set-index-pill {
    width: 40px; height: 40px; display: grid; place-items: center; justify-self: center;
    border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink-2);
    font-size: var(--fs-label); font-weight: var(--fw-semibold);
  }
  #workouts-panel .set-done .set-index-pill { background: var(--success); color: var(--success-ink); }
  #workouts-panel :is(.set-weight, .set-reps) {
    min-height: var(--tap); padding: 0 var(--space-2); text-align: center;
    border: 1px solid var(--border-input); border-radius: var(--radius);
    background: var(--surface); color: var(--ink);
    font-size: var(--fs-body); font-weight: var(--fw-semibold);
  }
  #workouts-panel .previous-value { justify-self: start; text-align: left; min-height: var(--tap); padding-inline: var(--space-1); font-size: var(--fs-label); color: var(--ink-3); }
  #workouts-panel .exercise-head h3 { flex: 1 1 210px; font-size: var(--fs-h3); line-height: var(--lh-snug); }

  /* The keypad is a touch affordance. */
  .workout-keypad { display: none !important; }

  /* Rows lift on a pointer device, as everywhere else in the Ledger. */
  #workouts-panel .workout-session-rail #save-workout { order: 1; }
  #workouts-panel .workout-session-rail .cancel-workout-wide { order: 2; }
}

/* ============================================================================
   Ledger — Workouts tab (slice 6)
   ----------------------------------------------------------------------------
   "This week" is this screen's hero: the count, then a Mon-Sun strip of the
   days that were trained. Templates and cardio are rows, history rows open
   in place with a 3px accent spine, and Delete... is only reachable from
   inside the row it belongs to. The `.template-chip.active` rule text stays
   in the sheet because tests/test_static_theme_contrast.py pins it, even
   though nothing applies that class any more.
   ========================================================================= */
#workouts-panel .workout-week.card.ledger-hero { display: grid; gap: var(--space-3); padding: var(--card-pad); border-radius: var(--radius-lg); }
#workouts-panel .workout-week .ledger-card-head { margin: 0; }
#workouts-panel .workout-week-stats {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-6);
  background: none; border: 0; border-radius: 0; padding: 0;
}
#workouts-panel .workout-week-stats > div { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
#workouts-panel .workout-week-stats strong { font-size: var(--fs-h1); font-weight: var(--fw-bold); letter-spacing: var(--ls-h1); line-height: 1; }
#workouts-panel .workout-week-stats span { color: var(--ink-3); font-size: var(--fs-label); }
#workouts-panel .week-days { display: flex; gap: var(--space-2); align-items: center; }
#workouts-panel .week-day { display: grid; justify-items: center; gap: var(--space-1); }
#workouts-panel .week-day-letter { color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-semibold); }
#workouts-panel .week-day-mark { width: 14px; height: 14px; border-radius: var(--radius-sm); background: var(--surface-3); }
#workouts-panel .week-day.is-trained .week-day-mark { background: var(--accent); box-shadow: 0 0 10px -2px var(--accent-glow); }
#workouts-panel .week-day.is-today .week-day-mark { box-shadow: inset 0 0 0 1.5px var(--accent); }
#workouts-panel .week-day.is-trained.is-today .week-day-mark { box-shadow: inset 0 0 0 1.5px var(--surface), 0 0 10px -2px var(--accent-glow); }
.is-entering #workouts-panel .week-day-mark,
#workouts-panel .is-entering .week-day-mark { animation: pop 360ms var(--ease) both; }

/* Templates as rows. */
#workouts-panel #template-strip { display: grid; gap: 0; }
#workouts-panel #template-strip > .template-row + .template-row { border-top: 1px solid var(--border-soft); }
#workouts-panel .template-row { padding-inline: 0; }
#workouts-panel #start-workout {
  width: 100%; min-height: var(--tap); border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
  box-shadow: inset 0 1px 0 var(--sheen), 0 6px 16px -8px var(--accent-glow);
}

/* History rows. 56px, a PR tag that says PR and carries a glyph, and an
   expanded row with a 3px accent spine, surface-2 and a body that fades in. */
#workouts-panel .workout-history-detail > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-3) var(--card-pad); list-style: none; cursor: pointer;
}
#workouts-panel .workout-history-detail > summary::-webkit-details-marker { display: none; }
#workouts-panel .workout-history-detail .list-row-title strong { font-size: var(--fs-body); font-weight: var(--fw-medium); }
#workouts-panel .workout-history-detail .list-meta { color: var(--ink-3); font-size: var(--fs-label); }
#workouts-panel .workout-history-detail .list-row-value { color: var(--ink-2); font-size: var(--fs-label); white-space: nowrap; }
#workouts-panel .workout-history-detail .list-chevron { transition: transform var(--dur) var(--ease); }
#workouts-panel .workout-history-detail[open] > summary .list-chevron { transform: rotate(90deg); }
#workouts-panel .workout-history-detail[open] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
#workouts-panel .workout-history-detail.just-opened > :not(summary) { animation: fade var(--dur-sheet) var(--ease) 200ms both; }
#workouts-panel .workout-detail-sets li { display: flex; align-items: baseline; gap: var(--space-2); padding: var(--space-2) 0; }
#workouts-panel .workout-history-detail .mini-actions { padding: 0 var(--card-pad) var(--space-3); }
#workouts-panel .workout-history-detail .ledger-link.is-danger { min-height: var(--tap); }

/* Cardio as rows. */
#workouts-panel #cardio-list.timeline-list { display: grid; gap: 0; }
#workouts-panel #cardio-list > * + * { border-top: 1px solid var(--border-soft); }
#workouts-panel #cardio-card .ledger-card-head { margin-bottom: var(--space-2); }

/* Desktop: three columns — start and this week, then history, then cardio and
   template management. */
@media (min-width: 64rem) {
  #workouts-panel:not(.workout-is-active) {
    display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px;
    align-items: start; gap: var(--space-5);
  }
  #workouts-panel:not(.workout-is-active) > .strong-workout-card { grid-column: 1; grid-row: 1; }
  #workouts-panel:not(.workout-is-active) > .workout-week { grid-column: 1; grid-row: 2; }
  #workouts-panel:not(.workout-is-active) > .recent-card { grid-column: 2; grid-row: 1 / span 3; }
  #workouts-panel:not(.workout-is-active) > #cardio-card { grid-column: 3; grid-row: 1; }
  #workouts-panel:not(.workout-is-active) > .workout-template-management-card { grid-column: 3; grid-row: 2; }
  #workouts-panel:not(.workout-is-active) > #workout-tab-state { grid-column: 1 / -1; }
  #workouts-panel:not(.workout-is-active) > #workout-undo-region { grid-column: 1 / -1; }
  #workouts-panel .workout-history-detail > summary { padding-inline: var(--space-5); }
  #workouts-panel .workout-history-detail :is(.workout-detail-sets, .mini-actions) { padding-inline: var(--space-5); }
}
@media (hover: hover) and (min-width: 64rem) {
  #workouts-panel :is(.template-row, .workout-history-detail > summary):hover { background: var(--surface-2); }
  #workouts-panel .template-row:hover .ledger-chev { transform: translateX(2px); color: var(--ink-2); }
}

/* ============================================================================
   Ledger — Nutrition (slice 7)
   ----------------------------------------------------------------------------
   The day summary is this screen's hero in the nutrition hue: one 44px kcal
   number that counts up once, three --c-nutrition bars that fill from zero,
   and the day's coverage as one footnote that opens the one day-level
   disclosure. The diary is a flush card of 56px rows, and the library's
   sections are rows. Food finder, review sheet, barcode/label/photo capture,
   recipes, pantry logic, reuse/copy and the `data-disclosure-key`
   persistence are untouched.
   ========================================================================= */
#nutrition-panel .nutrition-primary-card.card.ledger-hero { border-radius: var(--radius-lg); }
#nutrition-panel .nutrition-day-header { align-items: center; }
#nutrition-panel .nutrition-day-navigation {
  display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
  align-items: center; gap: var(--space-2); min-height: var(--tap);
}
#nutrition-panel :is(#nutrition-previous-day, #nutrition-next-day) {
  width: var(--tap); min-width: var(--tap); min-height: var(--tap); padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--border-input); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-2); box-shadow: none;
}
#nutrition-panel :is(#nutrition-previous-day, #nutrition-next-day)[disabled] { opacity: .4; }
#nutrition-panel #nutrition-day-picker > summary {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--tap); border-radius: var(--radius);
  font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--ink);
  transition: transform var(--dur) var(--ease);
}
#nutrition-panel #nutrition-day-picker > summary:active { transform: scale(.98); transition-duration: 80ms; }
#nutrition-panel .nutrition-calories-label { color: var(--ink); font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: 0; }
#nutrition-panel .nutrition-calories p strong { font-size: var(--fs-display); line-height: var(--lh-tight); letter-spacing: var(--ls-display); font-weight: var(--fw-bold); color: var(--ink); }
#nutrition-panel .nutrition-calories p > span { color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-medium); }
#nutrition-panel .nutrition-calories .goal-status { display: block; margin-top: var(--space-1); font-size: var(--fs-label); }
/* The calorie bar is ink (§2.7); without this it took the global --fill
   (--surface-2) and looked empty on its --surface-3 track. */
#nutrition-panel .nutrition-calories { --fill: var(--ink); }
#nutrition-panel .nutrition-macros { --fill: var(--c-nutrition); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
#nutrition-panel .nutrition-macro > span { color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-semibold); letter-spacing: .02em; }
/* The macro value keeps the accepted 16px rather than taking --fs-body's
   17px: at 320px the three macro columns are ~73px, and the longest word in
   a provenance line ("completeness") only fits with `overflow-wrap: normal`
   at 16px. mobile_nutrient_disclosure_browser_check holds both -- three
   macros on one row, and no word broken mid-stem. */
#nutrition-panel .nutrition-macro strong { font-weight: var(--fw-semibold); }
#nutrition-panel .nutrition-macro small { color: var(--ink-3); font-size: var(--fs-caption); }
#nutrition-panel .nutrition-calorie-progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
#nutrition-panel .nutrition-uncertainty { color: var(--ink-3); font-size: var(--fs-caption); }
#nutrition-panel .nutrition-day-details > summary { min-height: var(--tap); display: flex; align-items: center; font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--ink-3); }
#nutrition-panel .daily-nutrient-coverage, #nutrition-panel .daily-summary-source { color: var(--ink-3); font-size: var(--fs-caption); }

/* The diary: one flush card of 56px rows. */
#nutrition-panel .nutrition-diary-card { padding: 0; overflow: hidden; border-radius: var(--radius-lg); }
#nutrition-panel .nutrition-diary-card > .eyebrow { padding: var(--card-pad) var(--card-pad) 0; margin: 0; }
#nutrition-panel .meal-group > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-3) var(--card-pad); list-style: none; cursor: pointer;
}
#nutrition-panel .meal-group > summary::-webkit-details-marker { display: none; }
#nutrition-panel .meal-group > summary strong { font-size: var(--fs-body); font-weight: var(--fw-medium); }
#nutrition-panel .meal-group > summary small { display: block; color: var(--ink-3); font-size: var(--fs-label); margin-top: 2px; }
#nutrition-panel .meal-group > summary > span:nth-child(2) { color: var(--ink-3); font-size: var(--fs-label); white-space: nowrap; }
#nutrition-panel .meal-group > summary:not(.empty-meal-actions) [data-add-meal] {
  width: auto; min-height: var(--tap); padding: 0 var(--space-2);
  border: 0; background: none; box-shadow: none;
  color: var(--accent); font-size: var(--fs-label); font-weight: var(--fw-semibold); white-space: nowrap;
}
#nutrition-panel .meal-group > summary:not(.empty-meal-actions) [data-add-meal]::before { content: "+"; margin-right: 4px; }
#nutrition-panel .meal-group + .meal-group { border-top: 1px solid var(--border-soft); }
#nutrition-panel .food-entry { min-height: 56px; padding: var(--space-3) var(--card-pad); border-top: 1px solid var(--border-soft); }
#nutrition-panel .food-entry-content > strong { font-size: var(--fs-body); font-weight: var(--fw-medium); }
#nutrition-panel .food-serving, #nutrition-panel .food-entry .nutrient-compact { color: var(--ink-3); font-size: var(--fs-label); }
#nutrition-panel .food-entry .nutrient-value { color: var(--ink-2); font-size: var(--fs-label); }
#nutrition-panel .food-entry small { color: var(--ink-3); font-size: var(--fs-caption); }
#nutrition-panel .entry-actions-toggle {
  width: var(--tap); min-width: var(--tap); min-height: var(--tap); padding: 0;
  border: 0; border-radius: var(--radius); background: none; box-shadow: none;
  color: var(--ink-2); font-size: var(--fs-h3); line-height: 1;
}
#nutrition-panel .entry-actions-toggle[aria-expanded="true"] { background: var(--surface-2); }
#nutrition-panel .entry-actions-menu {
  min-width: 180px; padding: var(--space-1); border-radius: var(--radius);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border), var(--shadow-menu);
  /* Opacity only. A 44px menu item is a tap target, and
     getBoundingClientRect reports the transformed box, so any translate or
     scale in this entrance makes the three items measure short for 220ms --
     which mobile_nutrient_disclosure_browser_check catches, intermittently,
     exactly as a real thumb would. */
  transform-origin: top right; animation: fade 220ms var(--ease) both;
}
#nutrition-panel .entry-actions-menu button {
  width: 100%; min-height: var(--tap); justify-content: flex-start; text-align: left;
  border: 0; border-radius: var(--radius-sm); background: none; box-shadow: none;
  color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-medium);
}
#nutrition-panel .entry-actions-menu button:hover { background: var(--surface-2); }
#nutrition-panel .entry-actions-menu button.danger { color: var(--danger); background: none; border: 0; }
#nutrition-panel .entry-actions-menu button.danger:hover { background: var(--danger-bg); }
#nutrition-panel .empty-meal-actions .empty-meal-title { color: var(--ink-3); font-weight: var(--fw-medium); }

/* The library: one row per section. */
#nutrition-panel .nutrition-library-intro { color: var(--ink-3); font-size: var(--fs-label); }
#nutrition-panel .nutrition-secondary-tools > .card { border-radius: var(--radius-lg); }
#nutrition-panel .nutrition-secondary-tools > .card > details > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 56px; font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); cursor: pointer;
}

#nutrition-panel .nutrition-macro { min-width: 0; }

/* ============================================================================
   Ledger — Trends (slice 8)
   ----------------------------------------------------------------------------
   The chart card is this screen's hero in the body-weight hue, the two
   groups of range/metric buttons become segmented controls, the weigh-ins
   become rows, and the Weekly Review's numbers come down from 2.6rem to the
   28px title stop. weekly_review.py and every coaching payload, the
   exploration selectors, the undo flows and the `data-trends-disclosure`
   persistence are untouched.
   ========================================================================= */
#trends-panel .trends-chart.card.ledger-hero { border-radius: var(--radius-lg); padding: var(--card-pad); }
#trends-panel #weight-explorer-window { color: var(--ink-3); font-size: var(--fs-caption); }
#trends-panel #weight-explorer-selection { color: var(--ink-3); font-size: var(--fs-label); }

/* Segmented controls: a surface-2 track with a 3px inset; the selected
   segment is a surface chip with accent text, a 35%-accent ring and 600
   weight, so the selection is never colour alone. */
#trends-panel :is(.trends-metrics, .weight-ranges),
#settings-panel .workout-unit-toggle {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  padding: 3px; border-radius: var(--radius); background: var(--surface-2);
}
/* The design draws a segmented control at 36px; the app's touch floor is
   44px and test_browser_weight_explorer enforces it, so the segments keep
   the floor. */
#trends-panel :is(.trends-metrics, .weight-ranges) button,
#settings-panel .workout-unit-toggle button {
  width: auto; min-width: 0; min-height: var(--tap); padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-sm); background: none; box-shadow: none;
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-medium);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#trends-panel :is(.trends-metrics, .weight-ranges) button:active,
#settings-panel .workout-unit-toggle button:active { transform: scale(.97); transition-duration: 80ms; }
#trends-panel :is(.trends-metrics, .weight-ranges) button[aria-pressed="true"],
#settings-panel .workout-unit-toggle button[aria-pressed="true"] {
  background: var(--surface); color: var(--accent); font-weight: var(--fw-semibold);
  box-shadow: 0 0 0 1px var(--accent-soft-border);
}

/* Weigh-ins as rows, with "Log weight" as the accent row at the end. */
#trends-panel .trends-history { border-radius: var(--radius-lg); }
#trends-panel .trends-history h3 { margin: 0 0 var(--space-2); }
#trends-panel #weight-explorer-list { padding-left: 0; list-style: none; }
#trends-panel #weight-explorer-list > li + li { border-top: 1px solid var(--border-soft); }
#trends-panel #weight-explorer-list button {
  min-height: 56px; margin: 0; padding: var(--space-3) 0; width: 100%;
  border: 0; border-radius: 0; background: none; box-shadow: none;
  color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-regular); text-align: left;
}
#trends-panel #body-entry-shortcut {
  display: flex; align-items: center; min-height: 56px; padding: var(--space-3) 0;
  border-top: 1px solid var(--border-soft);
  color: var(--accent); font-size: var(--fs-body); font-weight: var(--fw-semibold); text-decoration: none;
}

/* Weekly Review: the 2.6rem headline and the 3.1rem numbers come down to the
   title stop, and the days-logged dots take the nutrition hue. */
#trends-panel .cut-review-big > strong { font-size: var(--fs-h1); font-weight: var(--fw-bold); letter-spacing: var(--ls-h1); }
#trends-panel .cut-review-big-unit { font-size: var(--fs-label); color: var(--ink-3); }
#trends-panel .cut-review h2 { font-size: var(--fs-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-h2); }
#trends-panel .cut-review-dot { background: var(--surface-3); }
#trends-panel .cut-review-dot.is-on { background: var(--c-nutrition); }
#trends-panel .is-entering .cut-review-dot.is-on { animation: pop 360ms var(--ease) both; }

/* More: the four disclosures become rows. */
#trends-panel .coaching-details > summary,
#trends-panel .trends-disclosure > summary {
  min-height: 56px; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); cursor: pointer;
}

/* Desktop: the chart and the review left, the weigh-ins and More right. */
@media (min-width: 64rem) {
  #trends-panel .trends-chart.card.ledger-hero { padding: var(--space-5); }
  #trends-panel #weight-explorer-plot svg { min-height: 360px; }
}

/* ============================================================================
   S29 — Cohesion & readability pass (owner device feedback, 10 Nov 2026)
   ----------------------------------------------------------------------------
   Presentation only. Nothing below changes a hook: every id, class, role,
   aria-* and data-* attribute the shell writes is untouched, and no rule here
   shows or hides a control the app did not already show or hide.

   The owner read v142 on a 15 Pro Max and reported one thing in five ways:
   the screens are built from four or five different box styles, so nothing
   reads as one system. This block is the single place that answers that --
   one field style in the tracker, one disclosure row in Nutrition's library,
   one card style on Workouts, one spacing scale from the --space-* tokens
   already declared at the top of this sheet, and no element whose right edge
   is outside the viewport.

   It is appended rather than merged into the sections above because those
   sections are each pinned, verbatim in several cases, by
   tests/test_static_*.py; the S29 rules are additive overrides at the same
   or higher specificity and leave every pinned rule text where it is.
   ========================================================================= */

/* ---------- 1. Nothing crosses the right edge -----------------------------
   iOS lays out `input[type=date]` from its own intrinsic width and ignores
   the grid track it is in, so From date / To date in Copy a past day and
   Saved meals ran off the screen (feedback shot 1). The four properties
   below are what pins it to its column on iOS; `display: block` stops the
   inline baseline box from adding a descender row under it. */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"] {
  display: block; width: 100%; max-width: 100%; min-width: 0;
  box-sizing: border-box; -webkit-appearance: none; appearance: none;
  min-height: var(--tap);
}
/* The native picker glyph is the control's only affordance once the
   appearance is reset, so it keeps its own ink rather than the UA default. */
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .7; cursor: pointer; }
/* An empty date field on iOS paints nothing at all -- a grey box with no
   text, which is what the owner photographed. The format hint beside the
   label is always visible and never lies about the value, and it is
   aria-hidden so the field's accessible name stays the label alone. */
.field-format { color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-medium); }

/* A `details.timeline-item` is a disclosure, not a row of flex items: the
   `display: flex` it inherited laid its summary, its note and its Edit /
   Delete pair side by side on one line, which pushed both buttons past the
   right edge on every width (cardio on Workouts, body history on Trends). */
details.timeline-item { display: block; }
details.timeline-item > summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); min-height: var(--tap); cursor: pointer; list-style: none;
}
details.timeline-item > summary::-webkit-details-marker { display: none; }
details.timeline-item > summary > :first-child { min-width: 0; overflow-wrap: anywhere; }
details.timeline-item > summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-right: 2px;
  border-right: 2px solid var(--ink-4); border-bottom: 2px solid var(--ink-4);
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease);
}
details.timeline-item[open] > summary::after { transform: rotate(45deg); }
details.timeline-item > .mini-actions { margin-top: var(--space-2); }
details.timeline-item > .mini-actions button { flex: 0 1 auto; }

/* Desktop template editor: six 44px-floor controls on one 415px row inside a
   360px rail. The phone's own two-row grid already solves this at <=430px;
   the rail is the same width problem, so it gets the same two rows. */
#workouts-panel .template-bubble { max-width: 100%; min-width: 0; }
#workouts-panel .template-bubble-text { min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 64rem) {
  #workouts-panel .template-bubble {
    grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
    grid-template-areas: "drag text remove" "reorder edit stepper";
    gap: var(--space-2) 6px;
  }
  #workouts-panel .template-bubble > .drag-handle { grid-area: drag; }
  #workouts-panel .template-bubble > .template-bubble-text { grid-area: text; }
  #workouts-panel .template-bubble > .template-remove { grid-area: remove; }
  #workouts-panel .template-bubble > .template-reorder-controls { grid-area: reorder; justify-self: start; }
  #workouts-panel .template-bubble > .template-edit { grid-area: edit; justify-self: center; }
  #workouts-panel .template-bubble > .template-set-stepper { grid-area: stepper; justify-self: end; }
}

/* ---------- 2. Workouts: the template selector ----------------------------
   The row says the template's name, what is in it and whether it is the one
   that will start. Selection is a surface-2 fill, a 3px accent spine and a
   tick beside the word "Selected" -- never a saturated fill under grey text,
   and never colour alone. */
#workouts-panel #template-strip > .template-row {
  padding-block: var(--space-3); padding-inline: var(--space-2);
  border-radius: var(--radius); background: none; color: var(--ink);
}
#workouts-panel #template-strip > .template-row .ledger-title { color: var(--ink); font-weight: var(--fw-semibold); }
/* Two lines of preview, then an ellipsis: a seven-exercise template used to
   push the row to 113px and the rows below it off the first screen. */
#workouts-panel #template-strip > .template-row .ledger-sub {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; color: var(--ink-3);
}
#workouts-panel #template-strip > .template-row[aria-pressed="true"] {
  background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent);
}
#workouts-panel #template-strip > .template-row[aria-pressed="true"] .ledger-sub { color: var(--ink-2); }
#workouts-panel #template-strip > .template-row[aria-pressed="true"] .ledger-action::before { content: "\2713\00a0"; }
/* Latched :hover on a phone, and a mouse hover on a desktop, both land here
   rather than on the accent fill the base button rule paints. */
#workouts-panel #template-strip > .template-row:hover,
#workouts-panel #template-strip > .template-row:active { background: var(--surface-2); color: var(--ink); }
/* The card already names the selected template and says what is in it; the
   row below repeated the word "Selected" directly under it. */
#workouts-panel:not(.workout-is-active) #workout-selection-label { display: none; }
#workouts-panel:not(.workout-is-active) #active-workout-title { font-size: var(--fs-h2); font-weight: var(--fw-bold); margin: 0 0 var(--space-1); }
#workouts-panel:not(.workout-is-active) .strong-workout-head { margin-bottom: var(--space-2); }
#workouts-panel .template-strip { margin-top: var(--space-3); }

/* ---------- 3. Workouts: the session bar and the titles -------------------
   Two sticky layers both parked at top: 0 -- the page header and the session
   bar -- so scrolling slid "Workout 0:28 / Finish & save" straight over
   "Workouts" (feedback shot 2). The header wins the stack and the bar sticks
   below it. `position: sticky` is out of flow, so the first set row does not
   move and the <=205px first-block budget is unchanged. */
.page-header { z-index: 30; }
@media (max-width: 1023px) {
  #workouts-panel .strong-topbar { top: 60px; }
}
/* The title block, the options summary and the exercise cards share one
   left inset, so "Session options" no longer floats at its own margin. */
#workouts-panel.workout-is-active .strong-workout-head { padding-inline: var(--space-3); }
#workouts-panel .workout-options > summary { padding-inline: var(--space-3); gap: var(--space-2); justify-content: flex-start; }
#workouts-panel .workout-options > summary::after { margin-left: var(--space-2); }

/* ---------- 4. Workouts: one field style in the tracker -------------------
   The owner counted four boxes on one set row: a grey circle, a white
   shadowed pill with a violet underline, an outlined number field and an
   outlined check. "Previous" is a reading, not a field, so it is plain muted
   text; the two numbers and the check share one height, one radius and one
   border. */
#workouts-panel .previous-value {
  background: none; border: 0; box-shadow: none; border-radius: var(--radius);
  color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-medium);
  text-align: left; padding: 0 var(--space-1);
}
#workouts-panel .previous-value:hover { background: none; }
#workouts-panel .previous-value:active { background: var(--surface-2); color: var(--ink-2); }
#workouts-panel :is(.set-weight, .set-reps, .done-set) {
  min-height: var(--tap); height: var(--tap);
  border: 1px solid var(--border-input); border-radius: var(--radius);
  background: var(--surface); box-shadow: none;
}
#workouts-panel .done-set { color: var(--ink-3); }
#workouts-panel .set-done .done-set { background: var(--success); border-color: var(--success); color: var(--success-ink); }
#workouts-panel .set-index-pill {
  box-shadow: none; background: var(--surface-2); color: var(--ink-2);
  font-size: var(--fs-label); font-weight: var(--fw-semibold);
}
/* The header row is the set row's own grid, one scale quieter, sitting
   directly on the first row instead of two spacing steps above it. */
#workouts-panel .strong-table-head {
  min-height: 0; padding: 0 0 var(--space-1);
  color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-medium);
}
#workouts-panel .strong-table-head > * { text-align: center; }
/* The head carries six cells and the row five columns unless "Edit sets" is
   on, so the sixth -- always empty -- opened a second grid row and made the
   header eight pixels taller in one state than the other. The 52px floor it
   used to carry hid that; without the floor it has to go. */
#workouts-panel .strong-table-head > span:empty { display: none; }
#workouts-panel .strong-table-head > :first-child,
#workouts-panel .strong-table-head > :nth-child(2) { text-align: left; }
#workouts-panel .exercise-sets { gap: var(--space-2); }

/* ---------- 5. Workouts: the title line and its last-time chip ------------
   A two-column grid, so the chip keeps the title's line and a long name
   wraps beside it instead of pushing it onto a row of its own (feedback
   shot 3: "ISO-Lateral High Row (Plate Loaded)" left 40px of dead space).
   `align-items: center` is what keeps the chip's centre on the title's
   centre whether the title runs to one line or three. */
#workouts-panel .exercise-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; column-gap: var(--space-3); row-gap: var(--space-2);
}
#workouts-panel .exercise-head h3 { min-width: 0; margin: 0; }
#workouts-panel .suggested-pill { margin-left: 0; justify-self: end; }
/* `display: contents` on the <details> hoists its paragraph into the head's
   grid, which also costs it the closed state the UA would have given it: the
   explanation was laid out at zero width and spilled 720px of text past the
   right edge of every screen. It is a full-width row when open and absent
   when closed, which is what the pill's aria-expanded already promises. */
#workouts-panel .suggested-next:not([open]) > .suggested-explanation { display: none; }
#workouts-panel .suggested-explanation { grid-column: 1 / -1; width: 100%; min-width: 0; }
/* Monochrome-consistent: a repeat of last time is neutral, and --success
   stays reserved for a confirmed record. */
#workouts-panel .suggested-pill.signal-hold { background: var(--surface-2); color: var(--ink-2); }

/* ---------- 6. Workouts: the exercise action row --------------------------
   Four bare words with uneven gaps and no tap affordance become four quiet
   44px chips on one scale. "Edit" and "Edit sets" were the same word twice:
   the one that renames the exercise now says so. Same handlers, same ids. */
#workouts-panel .exercise-block > .mini-actions { gap: var(--space-2); }
#workouts-panel .exercise-block > .mini-actions button {
  flex: 0 1 auto; width: auto; min-width: 0; min-height: var(--tap);
  padding: 0 var(--space-3); border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-medium);
  box-shadow: none; white-space: nowrap;
}
#workouts-panel .exercise-block > .mini-actions button:active { background: var(--surface-2); }
#workouts-panel .exercise-block > .mini-actions .plates-toggle { color: var(--accent); border-color: var(--accent-soft-border); }
#workouts-panel .exercise-block > .mini-actions .edit-sets[aria-pressed="true"] {
  background: var(--surface-2); border-color: var(--border-input); color: var(--ink);
}

/* ---------- 7. Workouts: one card style -----------------------------------
   This Week was a tinted hero, Cardio a white card holding grey filled rows,
   and Recent was not a card at all. All three are the sheet's one card now:
   --surface, --radius-lg, --card-pad, with ruled rows inside -- and, since
   design sprint slice 2, no outline (§1.6). */
#workouts-panel > :is(.recent-card, .workout-template-management-card) {
  border-radius: var(--radius-lg);
  background: var(--surface); padding: var(--card-pad);
}
#workouts-panel > .cardio-card { padding: var(--card-pad); border-radius: var(--radius-lg); }
#workouts-panel .workout-week.card.ledger-hero {
  background: var(--surface);
  padding: var(--card-pad); border-radius: var(--radius-lg);
}
#workouts-panel .workout-week-stats { gap: var(--space-6); padding: 0; }
#workouts-panel #cardio-list > details.timeline-item {
  background: none; border: 0; border-radius: 0; padding: var(--space-3) 0;
}
#workouts-panel #cardio-list > details.timeline-item + details.timeline-item { border-top: 1px solid var(--border-soft); }
#workouts-panel #workout-history > .timeline-item,
#workouts-panel #workout-history > .workout-history-detail { background: none; }
#workouts-panel .recent-card h2, #workouts-panel .workout-week h2 { margin-inline: 0; }

/* ---------- 8. One spacing scale ------------------------------------------
   The four panels used 6/8/10/12/14/16/18/24/32 between sections. They use
   the --space-* steps already declared at the top of this sheet, and card
   padding is --card-pad everywhere. */
#workouts-panel { gap: var(--space-4); }
#workouts-panel > .strong-workout-card { padding: var(--card-pad); }
#overview-panel, #nutrition-panel, #trends-panel { gap: var(--space-4); }
#workouts-panel .exercise-block { padding: var(--card-pad); gap: var(--space-2);
  border-radius: var(--radius-lg); }
#workouts-panel .strong-exercises { display: grid; gap: var(--space-3); }
#nutrition-panel .nutrition-secondary-tools { margin-top: var(--space-6); }
#trends-panel .cut-review-lifts { margin-block: var(--space-3); }
@media (max-width: 700px) {
  #workouts-panel .exercise-block { padding: var(--card-pad); }
}

/* ---------- 9. Nutrition: one disclosure row ------------------------------
   Each library section was a 44px transparent strip carrying a 16px radius
   and a single top border, which draws two stray curves and no box -- the
   "rows render as slivers with clipped partial borders" of the feedback.
   They are one card apiece now, 56px of row, and the open body sits inside
   the same card rather than bleeding onto the page background. */
#nutrition-panel .nutrition-secondary-tools {
  display: grid; gap: var(--space-3);
  margin-top: var(--space-6); padding-top: 0; border-top: 0;
}
#nutrition-panel .nutrition-library-intro { margin: 0 0 var(--space-1); }
#nutrition-panel .nutrition-secondary-tools > .card {
  border: 0; border-radius: var(--radius-lg);
  background: var(--surface); padding: 0 var(--card-pad); margin: 0;
}
#nutrition-panel .nutrition-secondary-tools > .card > details > summary {
  min-height: 56px; padding-block: var(--space-3);
  font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink);
}
#nutrition-panel .nutrition-secondary-tools > .card > details[open] > summary {
  border-bottom: 1px solid var(--border-soft); margin-bottom: var(--space-3);
}
#nutrition-panel .nutrition-secondary-tools > .card > details > :last-child { margin-bottom: var(--card-pad); }
#nutrition-panel .nutrition-secondary-tools > .card > details > .form { gap: var(--space-3); }
/* The row's trailing count is the row's meta, not a chip on a chip: a
   painted pill inside a painted card is the "card in a card" the nutrition
   foundation audit forbids, and it reads quieter as plain text anyway. */
#nutrition-panel .pantry-shopping-counts {
  flex: none; background: none; padding: 0; border-radius: 0;
  color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-medium); white-space: nowrap;
}

/* ---------- 10. Trends ----------------------------------------------------
   The chart card carried 70px of empty card under the caption, because the
   plot's own minimum height was taller than the plot it drew. */
#trends-panel #weight-explorer-plot svg { min-height: 0; }
#trends-panel #weight-explorer { margin-top: var(--space-4); }
#trends-panel #weight-explorer-selection { margin-bottom: 0; }
#trends-panel .weight-date-labels { margin-top: var(--space-1); }
/* The weekly review's own sparkline gets room, and every shaded region it
   draws is named in the key under it. */
#trends-panel .cut-review-chart { margin: var(--space-3) 0 var(--space-2); }
/* The key lift rows: name and numbers left, one fixed sparkline column, one
   fixed verdict column -- so three rows of different name lengths line their
   sparklines and their "New"/"Holding" up with each other. */
#trends-panel .cut-review-lifts li {
  display: grid; grid-template-columns: minmax(0, 1fr) 70px 72px;
  align-items: center; gap: var(--space-3); padding: var(--space-3) 0;
}
#trends-panel .cut-review-lifts .cut-review-spark { justify-self: center; }
#trends-panel .cut-review-lifts .goal-status { justify-self: end; text-align: right; white-space: nowrap; }
/* A number with no status meaning is not a status colour. The week's average
   intake was painted in the "over" amber whenever it sat above the calorie
   goal, with nothing on screen saying why -- and on a lean gain, above the
   goal is not a warning. The line below it already names the goal, so the
   average is ink and the state stays on the element for anything reading it. */
#trends-panel .cut-review .cut-review-calorie-average .goal-status { color: var(--ink); }

/* ---------- 11. Desktop (1440) keeps what it had --------------------------
   Every rule above is either width-neutral or already inside a phone query;
   these three restore the desktop columns the new grids would otherwise
   narrow. */
@media (min-width: 64rem) {
  #workouts-panel .exercise-head { column-gap: var(--space-4); }
  #trends-panel .cut-review-lifts li { grid-template-columns: minmax(0, 1fr) 90px 92px; }
  #nutrition-panel .nutrition-secondary-tools { gap: var(--space-4); }
}
#trends-panel .cut-review-chart-legend { margin: 0 0 var(--space-2); color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug); }

/* ---------- 12. S29 second pass (from the owner contact sheet) ------------ */
/* "Enter daily totals" was the one library section still wearing its own
   surface-2 box inside the card that already is one. */
#nutrition-panel .nutrition-secondary-tools > .card > details.manual-nutrition-card {
  margin: 0; padding: 0; border: 0; border-radius: 0; background: none;
}
#nutrition-panel .nutrition-secondary-tools > .card > details.manual-nutrition-card > summary {
  margin-bottom: 0; font-weight: var(--fw-medium);
}
/* The action chips are one row on one scale: Plates is the accent *word*,
   not a second border colour. */
#workouts-panel .exercise-block > .mini-actions .plates-toggle { border-color: var(--border-strong); }
/* The set-number column is centred, so its header sits over the pill rather
   than beside it. */
#workouts-panel .strong-table-head > :first-child { text-align: center; }

/* ============================================================================
   S30 — The Plates chip and the keypad dock (owner device feedback on v143)
   ----------------------------------------------------------------------------
   "The plates button does not work sometimes, and when it's open everything
   gets cramped." Both halves are one geometry bug and one event bug; this
   section is the geometry. Every id, role, aria-* and data-* hook above is
   untouched — these rules only place what is already there.
   ========================================================================= */

/* ---------- 1. The strip is the dock's first row, not an eighth one -------
   `.plates-strip` had a definite column (1 / -1) and no row, so grid
   auto-placement had to walk it past the four rows the −/+/Next column
   already occupies: three empty cells beside the actions, the strip under
   them, and the twelve digits spilling into a fourth column below that. That
   is the half-screen keypad in the owner's shot. Pinning the strip to row 1
   and moving the actions down one row *only while it is open* costs one row
   instead of four, and the digits stay a 3x4 block. */
.workout-keypad .plates-strip { grid-row: 1; }
.workout-keypad:has(.plates-strip:not([hidden])) .keypad-actions > [data-key="minus"] { grid-row: 2; }
.workout-keypad:has(.plates-strip:not([hidden])) .keypad-actions > [data-key="plus"] { grid-row: 3; }
.workout-keypad:has(.plates-strip:not([hidden])) .keypad-actions > .keypad-next { grid-row: 4 / span 2; }

/* ---------- 2. One line, not a three-row block ----------------------------
   The 72px cap of slice 4 is tightened, not loosened: label, total, chips,
   shortfall and the bar button share a single 44px row, which is the tap
   floor and therefore the smallest honest height this row can have. */
.workout-keypad .plates-strip {
  display: flex; flex-wrap: nowrap; align-items: center;
  gap: var(--space-2); min-height: var(--tap); max-height: 56px;
  margin: 0 0 var(--space-1); padding: 0 0 var(--space-1);
  overflow: hidden;
}
.workout-keypad .plates-strip .plates-head { flex: 0 0 auto; gap: var(--space-1); }
.workout-keypad .plates-strip .plates-chips {
  flex: 0 1 auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.workout-keypad .plates-strip .plates-chips::-webkit-scrollbar { display: none; }
.workout-keypad .plates-strip .plates-short { flex: 0 0 auto; white-space: nowrap; }
.workout-keypad .plates-strip .plate-note { white-space: nowrap; }
.workout-keypad .plates-strip #plates-bar { flex: 0 0 auto; margin-left: auto; }
/* No bar, no bar button and no "per side": a cable stack has neither. The
   note carries the whole message on its own. */
.workout-keypad .plates-strip[data-verdict="no-bar"] :is(.plates-head, #plates-bar) { display: none; }

/* ---------- 3. The form reserves the dock it actually has -----------------
   190px was a guess made when the dock was four rows; the dock publishes its
   measured height now, and the fallback is the five-row worst case so a
   build with JS still loading never reserves too little. */
body.keypad-open .strong-workout-form { padding-bottom: calc(var(--keypad-dock-height, 330px) + var(--space-6)); }

@media (max-width: 1023px) {
  /* ---------- 4. The bands stack, they do not pile up ---------------------
     With the keypad open the rest band is parked at the top inset, where the
     session bar's own 60px shelf put the two of them 10px into each other at
     375px. The bar parks under the band instead of behind it. */
  body.keypad-open:has(#workouts-panel .rest-pill:not(.hidden)) #workouts-panel .strong-topbar {
    top: calc(env(safe-area-inset-top, 0px) + var(--rest-dock-height, 56px) + var(--space-3));
  }

  /* ---------- 5. The exercise title had a shelf; S31 took it away ---------
     This slice made the worked exercise's title and chip row sticky under the
     bands so "Triceps Pressd…" could not slide under the session bar. On the
     owner's device that produced the next report instead — "the exercise
     controls of the exercise I'm in also stay and then scroll away" — with
     the chip row coming to rest half on top of set 1. A sticky header cannot
     both stick and never overlap the rows that scroll under it, so it does
     not stick: see S31 §3 below for what keeps the title readable instead.
     `.is-entering-set` is still published by app.js from `activeWorkoutInput`
     — it is the app's own answer to "which exercise" and nothing here moves
     a box, so entering a set still cannot move a set row. */
}
/* Layout-neutral and unconditional: an equal negative margin and padding
   leaves the title exactly where it was and only lets the shelf's fill reach
   the card's own edge. Applying it with the class instead would resize the
   head mid-session, which is the one thing a set row may never feel. */
#workouts-panel.workout-is-active .exercise-block > .exercise-head {
  margin-inline: calc(var(--card-pad) * -1); padding-inline: var(--card-pad);
}

/* ---------- 6. The chip is only where it can do something -----------------
   The strip lives inside the keypad, and the keypad is `display: none` on a
   pointer device — so on a desktop the chip was a control with nothing
   behind it. It is a touch affordance, like the dock it opens. */
@media (min-width: 64rem) {
  #workouts-panel .exercise-block > .mini-actions .plates-toggle { display: none; }
}

/* ============================================================================
   S31 — The keypad-open screen: scrolling, and a plates row that fits
   ----------------------------------------------------------------------------
   Owner, mid-workout on v144: "Due to the 2.5 lb increments, it doesn't always
   fit on the screen and cuts off, e.g. bar plus 5 and 1.3. As I scroll with
   the keypad open a black area appears at the bottom, and as I scroll the
   Finish workout disappears at a certain point. The exercise controls of the
   exercise I'm in also stay and then scroll away. Only with the keypad open."

   Four geometry faults, none of them arithmetic. Presentation only: every id,
   role, aria-* and data-* hook above is untouched; these rules only place
   what is already there.
   ========================================================================= */

/* ---------- 1. The dock's reserve belongs at the end of the page ----------
   `body.keypad-open .strong-workout-form` reserved the dock's measured height
   at the end of the *form* -- which is the middle of the Workouts tab, with
   the status message, This week, Cardio, Recent and Manage templates all
   below it. That is the black band between the header and the content in the
   owner's last shot: a whole dock's worth of empty page, nowhere near the
   dock. The reserve moves to the end of the panel, which is the only place
   the dock actually covers anything. */
body.keypad-open .strong-workout-form { padding-bottom: 0; }
/* The 148px an active session already reserves at the foot of the tab stays:
   it clears the fixed rest band, and it is also what lets the status line
   scroll clear of the parked session bar at the end of the page. */
body.keypad-open #workouts-panel.workout-is-active {
  padding-bottom: calc(var(--keypad-dock-height, 330px) + var(--space-6));
}

@media (max-width: 1023px) {
  /* ---------- 2. The session bar parks under the header, and lands on its
     own pad ----------------------------------------------------------------
     `top: 60px` was a guess at the header's height; with viewport-fit=cover
     and a translucent status bar the header is taller than that, so the bar
     tucked under "Workouts". It parks under the *measured* header now. And
     because a sticky box is clamped by the card that holds it, the bar was
     being pushed down onto `#workout-message` in the card's last 60px -- the
     half-hidden "Finish & save" sitting on "Workout started. Draft sa…". The
     card ends with a landing pad the bar's own height, so that clamp falls on
     padding and never on a line of text. */
  #workouts-panel .strong-topbar { top: calc(var(--page-header-height, 60px) + var(--space-1)); }
  /* The clamp is the bar's grid area, which ends at the card's *content* box
     -- padding on the card moves the clamp up rather than down, so the pad
     goes on the last row instead. The status line keeps its text where it was
     and gains a bar's height of empty room under it to be landed on. */
  #workouts-panel.workout-is-active #workout-message {
    padding-bottom: calc(var(--session-bar-height, 60px) + var(--space-3));
  }
  /* A blurred 86% surface let whatever was underneath read straight through
     the bar -- the ghosted card title and message in two of the owner's
     shots. Session chrome that covers content has to actually cover it, and
     the header the bar finally slides away behind has to cover the bar, so
     the exit is an occlusion and not a half-painted pill. */
  #workouts-panel.workout-is-active .strong-topbar {
    background: var(--surface);
    -webkit-backdrop-filter: none; backdrop-filter: none;
    /* It floats over the rows it passes; a hairline under it is not enough to
       say so once it is opaque. */
    box-shadow: var(--shadow-lift), 0 0 0 1px var(--border-soft);
  }
  body:has(#workouts-panel.workout-is-active:not(.hidden)) #app-card > .page-header {
    background: var(--bg);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }

  /* ---------- 3. The exercise shelf is retired -----------------------------
     S30 gave the worked exercise's title and chip row a two-level sticky
     shelf so the title could not slide under the session bar. On the owner's
     device it did exactly what he then reported: "the exercise controls of
     the exercise I'm in also stay and then scroll away", and the chip row
     came to rest on top of set 1, half covering it. The brief offers
     sticky-within-its-own-card or not sticky at all, and asks for the one
     that tests clean: a sticky header cannot both stick and never overlap the
     rows that scroll under it, so it does not stick. The title stays readable
     because the session bar is opaque and parks under the header, and because
     opening the keypad parks the row in the band between the bands and the
     dock. `.is-entering-set` is still published -- it is the app's own answer
     to "which exercise" and costs nothing. The rules themselves are deleted
     in place, in S30 section 5 above, rather than overridden here: nothing
     pins their text, and a sticky rule cancelled from a later section is a
     trap for whoever reads the S30 block next. */
}

/* ---------- 4. The plates row fits, in two lines --------------------------
   One 44px row could not hold a label, a total, up to six chips, a shortfall
   line and the bar button: `.plates-chips` was a 41px window onto 60px of
   chips, so "35" was followed by half a "5" and the lifter could not read his
   own load. The strip is a grid again -- head and shortfall on the first
   line, chips across the second, the bar button spanning both at the right --
   and nothing is clipped, scrolled or hidden. Two text lines beside a 44px
   button still cost the dock a single row (<= 72px, the slice-4 cap), and
   tests/test_browser_keypad_scroll_s31.py measures that across every total
   from 45 to 405 lb in 2.5 steps and the kg equivalents. */
.workout-keypad .plates-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: var(--space-2); row-gap: 2px;
  max-height: none; overflow: visible;
}
.workout-keypad .plates-strip .plates-head { grid-column: 1; grid-row: 1; flex-wrap: nowrap; }
.workout-keypad .plates-strip .plates-short {
  grid-column: 2; grid-row: 1; justify-self: end; text-align: right;
}
.workout-keypad .plates-strip .plates-chips {
  grid-column: 1 / 3; grid-row: 2; flex-wrap: wrap; overflow: visible;
}
.workout-keypad .plates-strip #plates-bar {
  grid-column: 3; grid-row: 1 / span 2; margin-left: 0;
}
/* A verdict with no per-side reading has no first line to sit under. */
.workout-keypad .plates-strip[data-verdict="no-bar"] .plates-chips { grid-column: 1 / -1; grid-row: 1; }
/* The chips give up their side padding before they give up a chip: six of
   them plus a shortfall line is an ordinary 2.5 lb total, and the 28px box
   and 28px minimum width that the readability floor pins are untouched. */
.workout-keypad .plates-strip .plate-chip { padding: 0 var(--space-1); }

/* ---------- 5. The session title keeps its letters -----------------------
   The card's first row is "Workout" in column 1 and the session bar in an
   `auto` column 2; at 375px the bar's own width left the title 97px for 115px
   of word, so "Workout" was painted under "Workout 0:34". The timer is a
   number the lifter reads mid-set and the word in front of it is decoration,
   so the decoration goes first. Narrowing the bar is the whole fix: letting
   the title wrap instead would add a second line to the card's first row, and
   the first exercise block has a 205px budget at 390px that a second line
   spends. */
@media (max-width: 400px) {
  #workouts-panel.workout-is-active .strong-topbar .elapsed-label { display: none; }
}
/* The bar's own column is `auto`, so it takes its whole max-content and the
   title gets whatever is left: at 375px that was 97px for 117px of "Workout".
   Capping the bar instead would overflow it -- with Cancel hidden, Finish &
   save sits in the bar's `minmax(0, 1fr)` track and a capped bar simply
   pushes the pill off the screen. So the bar is made to *want* less: the
   label in front of the timer and the two words that restate the progress
   numbers (app.js: "0/21 sets", not "0 of 21 sets done") are what it gives up
   first. Both text lines then ellipsize rather than grow, and the title does
   the same instead of wrapping -- a second line in the card's first row would
   spend the 205px budget the first exercise block has at 390px. */
@media (max-width: 1023px) {
  #workouts-panel.workout-is-active .strong-topbar .session-progress {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #workouts-panel.workout-is-active #active-workout-title {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}

/* ============================================================================
   S32 — Finish & save is reachable at every scroll position, and Plates is
   only on the lifts that have plates
   ----------------------------------------------------------------------------
   Owner on v145: the session bar still leaves the screen with the card that
   holds it, so on a long session Finish & save is somewhere up the page; and
   "Plates" is offered on cables, machines and dumbbells, where plate maths
   describes an object that is not on the floor.

   The bar does not become a better sticky box -- S31 proved both ways out of
   the card cost a pinned budget. A sticky box is clamped by its own card, and
   taking it out of that card's grid and back into the flow spends the <=205px
   the first exercise block has at 390px. So it stops being a box in the flow
   at all: on the phone it is a strip docked to the bottom of the screen,
   directly above the tab bar, and above the keypad dock while a set is being
   typed. Its height is reserved once, at the end of the panel -- never in the
   middle of it, and never as something the keypad's arrival changes, so no
   set row moves when the dock opens (pinned to 0.5px).

   Presentation only: every id, role, aria-* and data-* hook is untouched, and
   the strip is still the same `.strong-topbar` the idle state hides.
   ========================================================================= */

@media (max-width: 1023px) {
  /* ---------- 1. The strip is docked, not sticky -------------------------
     `position: sticky` can only travel inside the box that holds it, and the
     box that holds this one is a card the lifter scrolls past. Fixed to the
     bottom edge it has no travel to run out of. The tab bar's height is
     measured and published rather than guessed: it is a wrapped row of
     labels plus the home-indicator inset, and at the owner's text size a
     guessed 80px would park the strip on top of it. */
  #workouts-panel.workout-is-active .strong-topbar {
    position: fixed; z-index: 59;
    top: auto; left: 0; right: 0;
    bottom: var(--tab-nav-height, 80px);
    grid-column: 1; grid-row: 1;
    margin: 0; border-radius: 0;
    padding: var(--space-2) max(var(--space-3), env(safe-area-inset-right))
             var(--space-2) max(var(--space-3), env(safe-area-inset-left));
    border-top: 1px solid var(--border);
    box-shadow: none;
  }
  /* Below the exercise picker's backdrop (60) on purpose: a sheet that covers
     the screen covers this too, exactly as it covers the page under it. */

  /* The timer reads from the left edge and the one accent action sits at the
     right, which is where a thumb is. The three-track template is unchanged:
     Cancel is `hidden` in this state, so the timer takes the `auto` track and
     the actions take the `minmax(0, 1fr)` one. */
  #workouts-panel.workout-is-active .strong-topbar .timer-stack { justify-items: start; }
  #workouts-panel.workout-is-active .strong-topbar-actions { justify-content: flex-end; }

  /* With a set open the tab bar is behind the dock, so the strip rides on the
     dock instead -- one band above the other, never two bands deep. */
  body.keypad-open #workouts-panel.workout-is-active .strong-topbar {
    bottom: var(--keypad-dock-height, 330px);
  }
  /* S30 §4 gave the bar a top anchor under the rest band, and that selector
     carries two ids: it outranked the rule above and left the strip with
     *both* a top and a bottom. An over-constrained fixed box with the card's
     `align-self: center` on it comes to rest halfway between the two, which
     is a session strip floating in the middle of a set list. A docked strip
     has no top anchor; the rest band stacks on it in section 3 instead. */
  body.keypad-open:has(#workouts-panel .rest-pill:not(.hidden))
    #workouts-panel.workout-is-active .strong-topbar {
    top: auto; bottom: var(--keypad-dock-height, 330px); align-self: auto;
  }

  /* The card's second column held the bar; with the bar out of the flow the
     head has the card to itself rather than an empty track and a gap. */
  #workouts-panel.workout-is-active > .strong-workout-card { grid-template-columns: minmax(0, 1fr); }

  /* ---------- 2. One reserve, at the end of the panel --------------------
     The strip's height is reserved where the strip actually covers something:
     past the end of the content, so the last set row and Add exercise can be
     scrolled clear of it. It is *not* reserved inside the form, which is the
     middle of this tab (S31 §1, the owner's black band), and the keypad-open
     reserve differs from the closed one only by the dock's own height -- the
     strip costs the same either way, so opening a keypad still moves nothing
     above it.

     The shell's own foot is handed over for the duration: it reserves
     `--mobile-nav-height + 48px`, which is 194px for a 54px tab bar, and that
     is the field of black the owner scrolls into at the end of a long
     session. Two reserves for one tab bar is one too many, so while a session
     is running the panel's measured one is the only one. */
  body:has(#workouts-panel.workout-is-active:not(.hidden)) .shell { padding-bottom: 0; }
  #workouts-panel.workout-is-active {
    padding-bottom: calc(var(--tab-nav-height, 80px) + var(--session-bar-height, 60px) + var(--space-3));
  }
  body.keypad-open #workouts-panel.workout-is-active {
    padding-bottom: calc(var(--keypad-dock-height, 330px) + var(--session-bar-height, 60px) + var(--space-3));
  }

  /* ---------- 3. The rest band stacks on the strip -----------------------
     The rest band was pinned 80px up from the bottom edge, which is now the
     strip's own band. It takes the next shelf up. While the keypad is open it
     is at the top inset (S30 §4) and this does not apply. */
  body:not(.keypad-open) #workouts-panel.workout-is-active:not(.hidden) .rest-pill {
    bottom: calc(var(--tab-nav-height, 80px) + var(--session-bar-height, 60px) + var(--space-2));
  }

  /* ---------- 4. The landing pad is retired ------------------------------
     S31 §2 gave `#workout-message` a bar's height of empty room so the sticky
     bar's clamp fell on padding instead of on "Workout started. Draft sa...".
     A docked strip has no clamp and never reaches that row, so the pad is
     now only a band of empty page in the middle of the tab -- the very thing
     S31 §1 took out. It goes with the clamp that needed it. */
  #workouts-panel.workout-is-active #workout-message { padding-bottom: 0; }

  /* ---------- 5. P2: it arrives, it does not appear ----------------------
     One 16px rise, on the transition into an active session and only when the
     Workouts tab is already on screen -- a session restored from a draft
     during hydration paints in place, with no animation on first paint. The
     keyframe moves a transform and an opacity and nothing else, so it cannot
     shift a row, and the sheet-wide `prefers-reduced-motion` rule turns it
     off entirely. */
  #workouts-panel.workout-is-active .strong-topbar.is-arriving {
    animation: sheet-in var(--dur-sheet) var(--ease);
  }
}

/* ============================================================================
   S35 — Design 3/5: the set table (DESIGN-SPEC §3.3, §3.4, §2.3, §2.5, §2.6)
   ----------------------------------------------------------------------------
   One exercise group: a 44px header row (name, target chip, ⋯), a set table
   whose header and rows share one grid so "kg" and "Reps" sit over their
   wells, and a quiet Add set. Plates, Edit sets, Rename and Remove live in
   the ⋯ menu (same buttons, same handlers). A ticked set is a line of text
   with a green tick; only the sets still to do have fields. `#sets` in every
   selector is what lets this block win over the layered workout rules above
   without !important. Nothing here is sticky or fixed (S31).
   ========================================================================= */
#workouts-panel #sets .exercise-block {
  --set-cols: 28px minmax(0, 1fr) 84px 64px 44px;
  gap: 0; padding: var(--space-3) var(--card-pad) var(--space-2);
}
#workouts-panel #sets .exercise-block.is-editing-sets { --set-cols: 28px minmax(0, 1fr) 72px 56px 44px 44px; }
/* At 375 the spec's 84/64 wells leave "Previous" 59px and "77.5 kg × 7"
   broke onto two lines; narrower wells keep it on one. */
@media (max-width: 400px) {
  #workouts-panel #sets .exercise-block { --set-cols: 24px minmax(0, 1fr) 72px 56px 44px; }
  #workouts-panel #sets .exercise-block.is-editing-sets { --set-cols: 24px minmax(0, 1fr) 64px 48px 44px 44px; }
}
/* Under 361px (and at Safari's 125-150% page zoom) "Previous" has a row of
   its own above the fields, so its column may shrink to nothing, and the
   wells give way before the page scrolls sideways. */
@media (max-width: 360px) {
  #workouts-panel #sets .exercise-block { --set-gap: var(--space-1); --set-cols: 24px minmax(0, 1fr) minmax(44px, 64px) minmax(40px, 52px) 44px; }
  #workouts-panel #sets .exercise-block.is-editing-sets { --set-cols: 24px minmax(0, 1fr) minmax(40px, 56px) minmax(36px, 48px) 44px 44px; }
}
@media (min-width: 64rem) {
  #workouts-panel #sets .exercise-block { --set-cols: 28px minmax(0, 1fr) 120px 96px 44px; }
  #workouts-panel #sets .exercise-block.is-editing-sets { --set-cols: 28px minmax(0, 1fr) 120px 96px 44px 44px; }
}

/* The header row: name, then the chip, then ⋯ hard against the right edge. */
#workouts-panel #sets .exercise-block > .exercise-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center;
  column-gap: var(--space-2); row-gap: var(--space-1); min-height: var(--tap);
}
/* The chip's slot and <details> are `display: contents`, so their parts are
   grid items too: every item is placed, or ⋯ wraps under the name. */
#workouts-panel #sets .exercise-head h3 { grid-column: 1; grid-row: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
#workouts-panel #sets .exercise-head .suggested-pill { grid-column: 2; grid-row: 1; }
#workouts-panel #sets .exercise-head > .exercise-menu-toggle { grid-column: 3; grid-row: 1; }
#workouts-panel #sets .exercise-head .suggested-explanation { grid-column: 1 / -1; grid-row: 2; }
/* Narrow (and page-zoomed) phones: the name keeps the width, the chip takes
   the line under it, ⋯ stays top right. */
@media (max-width: 360px) {
  #workouts-panel #sets .exercise-block > .exercise-head { grid-template-columns: minmax(0, 1fr) auto; }
  #workouts-panel #sets .exercise-head > .exercise-menu-toggle { grid-column: 2; }
  #workouts-panel #sets .exercise-head .suggested-pill { grid-column: 1; grid-row: 2; justify-self: start; }
  #workouts-panel #sets .exercise-head .suggested-explanation { grid-row: 3; }
}
#workouts-panel #sets .exercise-menu-toggle {
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap);
  margin-right: calc(var(--space-2) * -1); padding: 0;
  display: grid; place-items: center; justify-self: end;
  border: 0; border-radius: var(--radius-pill); background: none; box-shadow: none; color: var(--ink-2);
}
#workouts-panel #sets .exercise-menu-toggle svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
#workouts-panel #sets .exercise-menu-toggle:active,
#workouts-panel #sets .exercise-menu-toggle[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }

/* The target chip (§2.6): 28px to the eye, still a 44px target. The 8px
   transparent border is part of the hit box; the fill stops inside it. */
#workouts-panel #sets .suggested-pill {
  min-height: var(--tap); height: var(--tap); padding: 0 var(--space-2);
  border: 8px solid transparent; border-inline-width: 0; background-clip: padding-box;
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-pill); font-size: var(--fs-caption); font-weight: var(--fw-semibold);
  white-space: nowrap; justify-self: end; margin: 0;
}
#workouts-panel #sets .suggested-pill svg {
  width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
}

/* The ⋯ menu: in the flow under the header (S31: nothing in a card is
   pinned), right-aligned, one plain row per action, Remove last in danger. */
#workouts-panel #sets .exercise-block > .exercise-menu {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; justify-self: end;
  width: min(15rem, 100%); margin: 0 0 var(--space-2); padding: 0; overflow: hidden;
  background: var(--surface-2); border-radius: var(--radius);
}
#workouts-panel #sets .exercise-block > .exercise-menu[hidden] { display: none; }
#workouts-panel #sets .exercise-block > .exercise-menu.mini-actions button {
  width: 100%; min-width: 0; min-height: var(--tap); padding: 0 var(--space-4);
  border: 0; border-radius: 0; background: none; box-shadow: none;
  color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-medium);
  text-align: left; justify-content: flex-start; white-space: normal;
}
#workouts-panel #sets .exercise-block > .exercise-menu.mini-actions button:not(:last-child) { border-bottom: 1px solid var(--border-soft); }
#workouts-panel #sets .exercise-block > .exercise-menu.mini-actions button:active { background: var(--surface-3); }
#workouts-panel #sets .exercise-block > .exercise-menu.mini-actions .edit-sets[aria-pressed="true"] { background: var(--surface-3); font-weight: var(--fw-semibold); }
#workouts-panel #sets .exercise-block > .exercise-menu.mini-actions .remove-exercise { color: var(--danger); background: var(--danger-bg); }

/* The table: one grid for the header and every row. */
#workouts-panel #sets .strong-table-head,
#workouts-panel #sets .strong-set-line {
  grid-template-columns: var(--set-cols); column-gap: var(--set-gap, var(--space-2)); row-gap: 0; align-items: center;
}
#workouts-panel #sets .strong-table-head {
  min-height: 28px; padding: 0; color: var(--ink-3);
  font-size: var(--fs-caption); font-weight: var(--fw-regular);
}
#workouts-panel #sets .strong-table-head > :first-child { text-align: center; }
#workouts-panel #sets .strong-table-head > :nth-child(2) { text-align: left; }
#workouts-panel #sets .strong-table-head > :nth-child(n+3) { text-align: center; }
#workouts-panel #sets .exercise-sets { gap: 0; }
#workouts-panel #sets .strong-set-line { min-height: 52px; padding: var(--space-1) 0; }

/* Set number: plain text, no circle; ink once the set is done. */
#workouts-panel #sets .set-index-pill {
  width: auto; height: auto; min-height: 0; padding: 0; justify-self: center;
  border: 0; border-radius: 0; background: none; box-shadow: none;
  color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-medium);
}
#workouts-panel #sets .set-done .set-index-pill { background: none; color: var(--ink); }

/* Previous: a reading, not a field. One line; it is still the button that
   copies last time into the row. */
#workouts-panel #sets .previous-value {
  justify-self: stretch; min-width: 0; min-height: var(--tap); padding: 0;
  border: 0; background: none; box-shadow: none; text-align: left;
  color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 400px) { #workouts-panel #sets .previous-value { font-size: var(--fs-caption); } }
/* Under 361px "Previous" has a row of its own (above) and may wrap there. */
@media (max-width: 360px) { #workouts-panel #sets .previous-value { white-space: normal; overflow: visible; } }

/* Wells (§2.5): the scoped exception to the --border-input rule -- the
   column header, the position and the focus ring identify the field. */
#workouts-panel #sets .strong-set-line :is(input.set-weight, input.set-reps) {
  width: 100%; min-width: 0; height: var(--tap); min-height: var(--tap); padding: 0 var(--space-1);
  border: 0; border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: none;
  color: var(--ink); text-align: center;
  font-size: var(--fs-h3); font-weight: var(--fw-semibold); letter-spacing: var(--ls-h3);
  transition: background-color var(--dur) var(--ease);
}
#workouts-panel #sets .strong-set-line :is(input.set-weight, input.set-reps):focus {
  outline: 0; background: var(--surface); box-shadow: 0 0 0 2px var(--ink);
}
/* Done: the wells settle into plain ink numerals. Unticking restores them. */
#workouts-panel #sets .set-done :is(input.set-weight, input.set-reps) { background: none; color: var(--ink); }

/* The tick (§2.3): a 32px mark inside a 44px target. The 6px transparent
   border is the rest of the target; the ring is an inset line on the mark. */
#workouts-panel #sets .done-set {
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  display: grid; place-items: center; justify-self: center;
  border: 6px solid transparent; border-radius: var(--radius-pill); background-clip: padding-box;
  background-color: transparent; box-shadow: inset 0 0 0 1.75px var(--ink-4); color: var(--ink-3);
}
#workouts-panel #sets .done-set svg { width: 16px; height: 16px; stroke: var(--ink-4); stroke-width: 2.25; }
#workouts-panel #sets .set-done .done-set svg { stroke: currentColor; }
#workouts-panel #sets .set-done .done-set {
  background: var(--success); background-clip: padding-box; color: var(--success-ink);
  border-color: transparent; box-shadow: none;
}

/* Add set (§3.3): a text button with a plus, left under the table. */
#workouts-panel #sets .add-set-wide {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start;
  width: auto; min-height: var(--tap); padding: 0 var(--space-1);
  border: 0; border-radius: var(--radius-sm); background: none; box-shadow: none;
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); text-align: left;
}
#workouts-panel #sets .add-set-wide svg {
  width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}

/* ============================================================================
   S36 — Design 4/5: session header, one dock, keypad (DESIGN-SPEC §3.3, §3.4)
   ----------------------------------------------------------------------------
   The session header is one row: the session name, "24:18 elapsed · 2 of 12
   sets" under it, and ⋯ (Session options) at the right; the page title and
   date step aside while a session runs. The rest band is no longer a box of
   its own floating over the sets: it lives inside `.strong-topbar`, which
   lives at the top of the session rail. On the phone that strip is S32's
   dock (fixed above the tab bar, or above the keypad); on the desktop it is
   the rail's first group, so it can no longer sit on "Save as template".
   The dock keeps S32's geometry and reserve untouched; only what is inside it
   changes. The older rules that pinned the rest band to the screen (S30 §4,
   S32 §3, slice 4's fixed band, the desktop corner card) are inert here
   because the band is `position: static` inside the dock, not because they
   were loosened. `#workout-session-sheet` in the selectors is what outranks
   them without !important.
   ========================================================================= */

/* ---------- 1. Session header ------------------------------------------- */
body:has(#workouts-panel.workout-is-active:not(.hidden)) #app-card > .page-header { display: none; }
#workouts-panel.workout-is-active > .strong-workout-card { position: relative; grid-template-columns: minmax(0, 1fr); }
#workouts-panel.workout-is-active .strong-workout-head {
  min-height: var(--tap); padding: 0 calc(var(--tap) + var(--space-1)) 0 var(--space-1);
}
#workouts-panel.workout-is-active .strong-workout-head #active-workout-title {
  margin: 0; font-size: var(--fs-h2); font-weight: var(--fw-bold);
  letter-spacing: var(--ls-h2); line-height: var(--lh-snug);
}
#workouts-panel .session-meta {
  margin: 2px 0 0; color: var(--ink-3); font-size: var(--fs-caption); line-height: var(--lh-snug);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#workouts-panel .session-meta #workout-elapsed { font-weight: var(--fw-regular); color: inherit; font-size: inherit; }
/* ⋯ is the Session options summary, pinned to the header row's right edge;
   opening it lays the options out under the header as before. */
#workouts-panel.workout-is-active .workout-options { grid-column: 1; margin: 0; }
#workouts-panel.workout-is-active .workout-options > summary {
  position: absolute; top: 2px; right: 0;
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap);
  display: grid; place-items: center; padding: 0; margin: 0;
  border-radius: var(--radius-pill); color: var(--ink-2); list-style: none;
}
#workouts-panel.workout-is-active .workout-options > summary::-webkit-details-marker { display: none; }
#workouts-panel.workout-is-active .workout-options > summary::after { content: none; }
#workouts-panel.workout-is-active .workout-options[open] > summary,
#workouts-panel.workout-is-active .workout-options > summary:active { background: var(--surface-2); color: var(--ink); }
#workouts-panel .workout-options > summary svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }

/* ---------- 2. One dock: rest and Finish in the same bar ---------------- */
#workouts-panel #workout-session-sheet .strong-topbar {
  grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-3); align-items: center;
  background: var(--surface); box-shadow: none;
}
#workouts-panel #workout-session-sheet .strong-topbar > :is(.timer-stack, .rest-pill) { grid-column: 1; grid-row: 1; min-width: 0; }
#workouts-panel #workout-session-sheet .strong-topbar > .strong-topbar-actions { grid-column: 2; grid-row: 1; }
#workouts-panel #workout-session-sheet .strong-topbar:has(> .rest-pill:not(.hidden)) > .timer-stack { display: none; }
#workouts-panel #workout-session-sheet .strong-topbar .timer-stack { justify-items: start; justify-content: start; }
#workouts-panel #workout-session-sheet .strong-topbar .session-progress {
  color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-snug);
}
/* The rest band, inside the dock: "Rest" over the time, −30, +30, Skip. No
   box, no border (S34 review item 4), no fill. */
#workouts-panel #workout-session-sheet .rest-pill.card.rest {
  position: static; inset: auto; transform: none; z-index: auto;
  width: auto; min-width: 0; max-width: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: auto var(--tap) var(--tap) auto; grid-template-rows: auto auto;
  grid-template-areas: "label minus plus skip" "time minus plus skip";
  align-items: center; justify-content: start; justify-items: start; column-gap: var(--space-2); row-gap: 0;
  border: 0; border-radius: 0; background: none; box-shadow: none; overflow: visible;
}
#workouts-panel #workout-session-sheet .rest-pill .rest-ring { display: none; }
#workouts-panel #workout-session-sheet .rest-pill #rest-label {
  grid-area: label; align-self: end; display: block;
  color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-regular); line-height: var(--lh-snug);
}
#workouts-panel #workout-session-sheet .rest-pill #rest-time {
  grid-area: time; align-self: start; place-self: start; min-width: 4ch; text-align: left;
  color: var(--ink); font-size: var(--fs-h2); font-weight: var(--fw-bold); line-height: var(--lh-tight);
}
#workouts-panel #workout-session-sheet .rest-pill :is(#rest-minus, #rest-plus) {
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  border: 0; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink);
  font-size: var(--fs-label); font-weight: var(--fw-semibold); box-shadow: none;
}
#workouts-panel #workout-session-sheet .rest-pill #rest-minus { grid-area: minus; }
#workouts-panel #workout-session-sheet .rest-pill #rest-plus { grid-area: plus; }
#workouts-panel #workout-session-sheet .rest-pill #rest-skip {
  grid-area: skip; width: auto; min-width: var(--tap); min-height: var(--tap); padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2);
  font-size: var(--fs-label); font-weight: var(--fw-semibold); box-shadow: none;
}
#workouts-panel #workout-session-sheet .rest-pill :is(#rest-minus, #rest-plus, #rest-skip):active { background: var(--surface-3); }
/* The countdown: a 2px ink line along the dock's top edge, shrinking with the
   time left. `--p` is remaining/total, set by updateRestDisplay as before. */
#workouts-panel #workout-session-sheet .rest-pill.card.rest::before {
  content: ""; display: block; position: absolute; left: 0; top: -1px; width: 100%; height: 2px;
  background: var(--ink); box-shadow: none;
  transform: scaleX(var(--p)); transform-origin: left; transition: transform 1s linear;
}
/* Rest done reads in words ("Rest done", "Go", "Clear"), not as a black slab
   in the middle of the dock: Finish is the bar's one filled control. */
#workouts-panel #workout-session-sheet .rest-pill.rest-ready { background: none; }
#workouts-panel #workout-session-sheet .rest-pill.rest-ready #rest-time { color: var(--ink); }
#workouts-panel #workout-session-sheet .rest-pill.rest-ready #rest-label { color: var(--ink-3); }
#workouts-panel #workout-session-sheet .rest-pill.rest-ready :is(#rest-minus, #rest-plus) { background: var(--surface-2); color: var(--ink); }
#workouts-panel #workout-session-sheet .rest-pill.rest-ready #rest-skip { background: none; color: var(--ink-2); }
/* Finish: the primary button, 44px in a bar (§2.4), not a glowing pill. */
#workouts-panel #workout-session-sheet #finish-workout.session-finish-pill {
  width: auto; min-height: var(--tap); height: var(--tap); padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-body); font-weight: var(--fw-semibold); box-shadow: none; white-space: nowrap;
}

@media (max-width: 1023px) {
  /* The dock is 64px whether or not a rest is running, so its reserve (S32)
     never changes when a set is ticked. */
  #workouts-panel.workout-is-active #workout-session-sheet .strong-topbar {
    min-height: 64px; padding-block: var(--space-2);
    padding-inline: max(var(--space-4), env(safe-area-inset-left)) max(var(--space-4), env(safe-area-inset-right));
  }
  /* With the page header gone nothing covers the status bar while a session
     scrolls; viewport-fit=cover would put set rows under the clock. This
     band is 0px wherever there is no inset (every desktop and Chromium). */
  body:has(#workouts-panel.workout-is-active:not(.hidden)) #app-card::before {
    content: ""; position: fixed; z-index: 58; top: 0; left: 0; right: 0;
    height: env(safe-area-inset-top, 0px); background: var(--bg); pointer-events: none;
  }
}

/* ---------- 3. Keypad, attached under the dock -------------------------- */
@media (max-width: 1023px) {
  #workout-keypad.workout-keypad {
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.12fr);
    grid-template-rows: repeat(4, 54px); gap: calc(var(--space-1) * 1.5);
    padding: var(--space-1) max(var(--space-3), env(safe-area-inset-right))
             calc(var(--space-1) * 1.5 + env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left));
    background: var(--surface); border-top: 0; box-shadow: none;
  }
  #workout-keypad.workout-keypad:has(.plates-strip:not([hidden])) { grid-template-rows: auto repeat(4, 54px); }
  /* Keys only: the plates strip's "20 kg bar" button keeps its own style. */
  #workout-keypad.workout-keypad :is(.keypad-grid, .keypad-actions) > button {
    min-height: 54px; height: 54px; padding: 0; border: 0; border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--ink); box-shadow: none;
    font-size: var(--fs-h2); font-weight: var(--fw-medium); line-height: 1;
  }
  #workout-keypad.workout-keypad .keypad-actions > :is([data-key="minus"], [data-key="plus"]) {
    background: var(--surface-3); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
  }
  #workout-keypad.workout-keypad .keypad-actions > .keypad-next {
    height: auto; background: var(--accent); color: var(--accent-ink);
    font-size: var(--fs-body); font-weight: var(--fw-semibold); box-shadow: none;
  }
  #workout-keypad.workout-keypad :is(.keypad-grid, .keypad-actions) > button:active { background: var(--surface-3); }
  #workout-keypad.workout-keypad .keypad-actions > .keypad-next:active { background: var(--accent); }
  #workout-keypad.workout-keypad [data-key="backspace"] svg {
    width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
  }
  /* The plates strip is the first row of the same surface, between the dock
     and the keys. */
  #workout-keypad.workout-keypad .plates-strip { margin: 0; }
}

/* ---------- 4. Desktop: rest and Finish are the rail's first group ------ */
@media (min-width: 64rem) {
  #workouts-panel #workout-session-sheet .strong-topbar {
    position: relative; top: auto; z-index: auto; grid-column: auto; grid-row: auto;
    grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-3);
    margin: 0; padding: var(--space-4); border-radius: var(--radius-lg); overflow: hidden;
  }
  #workouts-panel #workout-session-sheet .strong-topbar.hidden { display: none; }
  #workouts-panel #workout-session-sheet .rest-pill.card.rest { width: auto; border-radius: 0; }
  /* Inset to the group's padding so the line never sits as a flat lid on the
     rounded corners. */
  #workouts-panel #workout-session-sheet .rest-pill.card.rest::before {
    top: var(--space-2); left: var(--space-4); width: calc(100% - 2 * var(--space-4));
  }
  #workouts-panel #workout-session-sheet .rest-pill button { width: auto; }
  /* Resting, the rest controls take the whole first line and Finish the
     second, full width; idle, the set count sits beside Finish. */
  #workouts-panel #workout-session-sheet .strong-topbar:has(> .rest-pill:not(.hidden)) > .strong-topbar-actions { grid-column: 1 / -1; grid-row: 2; }
  #workouts-panel #workout-session-sheet .strong-topbar:has(> .rest-pill:not(.hidden)) > .rest-pill { grid-column: 1 / -1; }
  #workouts-panel #workout-session-sheet .strong-topbar:has(> .rest-pill:not(.hidden)) #finish-workout { width: 100%; }
}

/* ---------- 5. S36 fix pass ---------------------------------------------- */
/* The focused well shows the ring only: no inverted selection box, during
   typing or after the keypad closes. `color` is the ink token, not
   `inherit`: highlight pseudos inherit from the parent's ::selection, whose
   accent-ink would turn the number white on the well. */
#workouts-panel #sets .workout-number::selection { background: transparent; color: var(--ink); }
/* Edit sets: a "Done" text button left of ⋯ while editing is the way out. */
#workouts-panel #sets .exercise-head > .exercise-edit-done { display: none; }
#workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head { grid-template-columns: minmax(0, 1fr) auto auto auto; }
#workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head > .exercise-edit-done {
  grid-column: 3; grid-row: 1; display: inline-flex; align-items: center; justify-self: end;
  width: auto; min-width: var(--tap); min-height: var(--tap); height: var(--tap); padding: 0 var(--space-2);
  border: 0; border-radius: var(--radius-sm); background: none; box-shadow: none;
  color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold); white-space: nowrap;
}
#workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head > .exercise-edit-done:active { background: var(--surface-2); }
#workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head > .exercise-menu-toggle { grid-column: 4; }
@media (max-width: 360px) {
  #workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head { grid-template-columns: minmax(0, 1fr) auto auto; }
  #workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head > .exercise-edit-done { grid-column: 2; }
  #workouts-panel #sets .exercise-block.is-editing-sets > .exercise-head > .exercise-menu-toggle { grid-column: 3; }
}
#workouts-panel #sets .remove-set svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}

/* =========================================================================
   S37 Design 5/5: Today (spec §3.1, §3.2, §2.1–§2.7, §1.3, §4).
   Group headers sit outside their surface; each group's surface is its
   .today-group-body. Phone order is hero, Nutrition, Log, Checklist, Meals
   today, last group (the two .today-col wrappers are display: contents and
   `order` sets the sequence); desktop is the two columns, 7fr / 5fr, both
   starting on the line under the title. One block, ID-weighted, last in the
   sheet so it outranks the older Today layers without !important.
   ========================================================================= */
#overview-panel > .row.today-intro {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
#overview-panel #today-now > .today-next-heading.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
#overview-panel #open-settings[hidden], #overview-panel #today-now-freshness[hidden] { display: none; }
#overview-panel > .quick-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
#overview-panel .today-col { display: contents; }
#overview-panel #today-now { order: 1; }
#overview-panel .today-nutrition-card { order: 2; }
#overview-panel #day-loop-rail { order: 3; }
#overview-panel #checklist-card { order: 4; }
#overview-panel .today-meals-card { order: 5; }
#overview-panel .today-more-card { order: 6; }

/* Group: header outside, surface below (§2.1). */
#overview-panel :is(.today-nutrition-card, .today-meals-card, #day-loop-rail, #checklist-card) {
  display: block; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none;
  background: transparent; overflow: visible;
}
#overview-panel :is(.today-nutrition-card, .today-meals-card, #day-loop-rail, #checklist-card) > .ledger-card-head {
  display: flex; align-items: baseline; justify-content: flex-start; gap: var(--space-2);
  min-height: 28px; margin: 0; padding: 0 var(--space-1) var(--space-2);
}
#overview-panel :is(.today-nutrition-card, .today-meals-card, #day-loop-rail, #checklist-card) > .ledger-card-head > :is(.ledger-link, .ledger-meta:last-child) { margin-inline-start: auto; }
#overview-panel :is(.today-nutrition-card, .today-meals-card, #day-loop-rail, #checklist-card) > .ledger-card-head > * {
  margin: 0; padding: 0; min-height: 0; line-height: 1.35;
}
/* Header text actions ("Diary", "Edit") keep a 44px target that overhangs
   the 28px header row instead of growing it. */
#overview-panel :is(.today-nutrition-card, .today-meals-card, #day-loop-rail, #checklist-card) > .ledger-card-head > .ledger-link {
  display: inline-flex; align-items: center; justify-content: flex-end;
  min-width: 44px; min-height: 44px; margin-block: -8px; padding: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold);
}
#overview-panel .today-group-body {
  min-width: 0; margin: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface);
  overflow: hidden; box-shadow: none;
}

/* Hero: heading, one line, the screen's one filled button. */
#overview-panel #today-now {
  display: grid; gap: var(--space-4); margin: 0; padding: var(--space-5);
  border: 0; border-radius: var(--radius-lg); background: var(--surface); box-shadow: none;
}
#overview-panel #today-now .today-now-main { display: grid; gap: var(--space-1); min-width: 0; }
#overview-panel #today-now #today-now-action { font-size: var(--fs-h2); line-height: 1.15; letter-spacing: var(--ls-h2); font-weight: var(--fw-bold); color: var(--ink); }
#overview-panel #today-now #today-now-why { font-size: var(--fs-label); line-height: 1.35; color: var(--ink-2); max-width: none; }
#overview-panel #today-now #today-now-freshness { margin: 0; color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-regular); }
#overview-panel #today-now-cta .today-plan-cta { min-height: 52px; border-radius: var(--radius); font-size: var(--fs-body); font-weight: var(--fw-semibold); }
#overview-panel #today-now-cta .today-now-cta-reserve { min-height: 52px; }

/* Nutrition: total, one bar, macros, Log food. */
#overview-panel .today-nutrition-card > .today-group-body { display: grid; gap: var(--space-4); padding: var(--space-5); }
#overview-panel .today-nutrition-visual { min-width: 0; }
#overview-panel .today-nutrition-visual > .list-meta { margin: 0; }
:is(#overview-panel, #nutrition-panel) .today-nutrition-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
:is(#overview-panel, #nutrition-panel) .today-energy { --fill: var(--ink); display: grid; gap: var(--space-3); min-width: 0; text-align: left; }
:is(#overview-panel, #nutrition-panel) .today-ring-copy { position: static; display: flex; flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: flex-start; column-gap: var(--space-2); row-gap: 0; margin: 0; }
:is(#overview-panel, #nutrition-panel) .today-ring-copy > strong { font-size: var(--fs-display); line-height: 1; letter-spacing: var(--ls-display); font-weight: var(--fw-bold); color: var(--ink); }
:is(#overview-panel, #nutrition-panel) .today-ring-copy > strong.ring-incomplete { font-size: var(--fs-h2); line-height: 1.15; letter-spacing: var(--ls-h2); }
:is(#overview-panel, #nutrition-panel) .today-ring-copy > .today-kcal-target { font-size: var(--fs-label); font-weight: var(--fw-regular); color: var(--ink-3); white-space: nowrap; }
:is(#overview-panel, #nutrition-panel) .today-ring-copy > .today-remaining { margin: 0 0 0 auto; font-size: var(--fs-label); font-weight: var(--fw-semibold); color: var(--ink); white-space: nowrap; }
:is(#overview-panel, #nutrition-panel) .today-energy:is(.is-goal-met, .is-over) .today-ring-copy > .today-remaining { color: var(--goal-color); }
:is(#overview-panel, #nutrition-panel) .today-macro-track { height: 4px; margin: var(--space-2) 0 0; border-radius: var(--radius-pill); background: var(--surface-3); }
:is(#overview-panel, #nutrition-panel) .today-energy > .today-calorie-track { height: 6px; margin: 0; border-radius: var(--radius-pill); }
:is(#overview-panel, #nutrition-panel) .today-macro-bars { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
:is(#overview-panel, #nutrition-panel) .today-macro { display: block; min-width: 0; }
:is(#overview-panel, #nutrition-panel) .today-macro > .today-macro-label { display: block; font-size: var(--fs-caption); line-height: 1.3; color: var(--ink-3); }
:is(#overview-panel, #nutrition-panel) .today-macro > .today-macro-value { display: block; margin-top: 2px; white-space: normal; font-size: var(--fs-h3); line-height: 1.25; letter-spacing: var(--ls-h3); }
:is(#overview-panel, #nutrition-panel) .today-macro-value > strong { font-size: inherit; font-weight: var(--fw-bold); color: var(--ink); }
/* An incomplete or unverified macro prints its sentence; it wraps in the label size instead of overflowing. */
:is(#overview-panel, #nutrition-panel) .today-macro > .today-macro-value.is-incomplete { white-space: normal; overflow-wrap: anywhere; font-size: var(--fs-label); letter-spacing: 0; line-height: 1.35; }
:is(#overview-panel, #nutrition-panel) .today-macro > .today-macro-value.is-incomplete > strong { white-space: normal; font-weight: var(--fw-semibold); }
:is(#overview-panel, #nutrition-panel) .today-macro-value > .unit { margin-left: .18em; font-size: var(--fs-label); font-weight: var(--fw-regular); letter-spacing: 0; color: var(--ink-2); }
:is(#overview-panel, #nutrition-panel) .today-macro-value > :is(strong, .unit) { white-space: nowrap; }
:is(#overview-panel, #nutrition-panel) .today-macro-value > .today-macro-target { display: inline-block; white-space: nowrap; margin-left: 0; font-size: var(--fs-caption); font-weight: var(--fw-regular); letter-spacing: 0; color: var(--ink-3); }
#overview-panel .today-nutrition-card .today-nutrition-coverage { margin: var(--space-3) 0 0; padding-top: var(--space-2); border-top: 1px solid var(--border-soft); }
#overview-panel .today-nutrition-card #today-log-food {
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-height: 48px; margin: 0;
  padding: var(--space-1) var(--space-5); border: 0; border-radius: var(--radius); box-shadow: none;
  background: var(--surface-2); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
/* The Food row's status copy stays in the button for its description and
   the read model; anchored to the button's corner so its 1px box never sits
   outside the page. */
#overview-panel .today-nutrition-card #today-log-food { position: relative; }
#overview-panel .today-nutrition-card #today-log-food > .sr-only { top: 0; left: 0; display: block; }
#overview-panel .today-nutrition-card #today-log-food .day-loop-action {
  display: inline; width: auto; margin: 0; max-width: none; min-height: 0; padding: 0; border: 0; background: transparent;
  color: inherit; font-size: inherit; font-weight: var(--fw-semibold);
}
#overview-panel .today-nutrition-card #today-log-food:active { transform: scale(.97); background: var(--surface-3); }

/* Log: a status mark leads, the value or a verb sits at the right (§2.2, §2.3). */
#overview-panel #day-loop-rail { display: grid; grid-template-columns: minmax(0, 1fr); counter-reset: today-log-done today-log-total; }
/* "2 of 4 today": CSS counters over the rows' own is-complete state, so the
   count can never disagree with the marks and needs no JS. A counter prints
   only after its increments, so this is the rail's ::after, placed in the
   header's grid cell. */
#overview-panel #day-loop-rail > .ledger-card-head { grid-row: 1; grid-column: 1; }
#overview-panel #day-loop-rail::after {
  content: counter(today-log-done) " of " counter(today-log-total) " today";
  grid-row: 1; grid-column: 1; justify-self: end; align-self: start;
  padding: 0 var(--space-1); line-height: 1.35; color: var(--ink-3); font-size: var(--fs-label);
}
#overview-panel #day-loop-rail .today-log-rows { display: grid; }
#overview-panel #day-loop-rail .day-loop-row {
  counter-increment: today-log-total;
  position: relative; display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto 14px; grid-template-rows: auto auto auto; grid-template-areas: none;
  align-items: center; column-gap: var(--space-3); row-gap: 0;
  width: 100%; min-height: 60px; margin: 0; padding: 10px var(--space-4);
  border: 0; border-radius: 0; background: transparent; box-shadow: none; text-align: left; color: var(--ink);
}
#overview-panel #day-loop-rail .day-loop-row.is-complete { counter-increment: today-log-total today-log-done; }
#overview-panel #day-loop-rail .day-loop-row + .day-loop-row { border-top: 0; }
#overview-panel #day-loop-rail .day-loop-row + .day-loop-row::before {
  content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--border);
}
#overview-panel #day-loop-rail .day-loop-row:active { transform: none; background: var(--surface-2); }
#overview-panel #day-loop-rail .day-loop-copy { display: contents; }
#overview-panel #day-loop-rail .day-loop-row > .today-mark { grid-column: 1; grid-row: 1 / span 3; }
#overview-panel #day-loop-rail .day-loop-label { grid-column: 2; grid-row: 1; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.3; color: var(--ink); }
#overview-panel #day-loop-rail :is(.day-loop-value, .day-loop-note) {
  grid-column: 2; min-width: 0; margin-top: 1px;
  font-size: var(--fs-label); font-weight: var(--fw-regular); line-height: 1.35; color: var(--ink-3);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
#overview-panel #day-loop-rail .day-loop-value { grid-row: 2; }
#overview-panel #day-loop-rail .day-loop-note { grid-row: 3; }
#overview-panel #day-loop-rail .day-loop-row > .day-loop-action {
  grid-column: 3; grid-row: 1 / span 3; justify-self: end;
  display: block; width: auto; max-width: 9rem; min-height: 0; margin: 0; padding: 0;
  border: 0; border-radius: 0; background: transparent;
  color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold); white-space: nowrap; text-align: right;
}
#overview-panel #day-loop-rail .day-loop-row > .list-chevron { grid-column: 4; grid-row: 1 / span 3; width: 20px; height: 20px; margin-right: -6px; color: var(--ink-4); }
/* Done: the value moves to the right and the verb steps aside; the detail
   line (weight change, sleep times, 7-day count) is the second line. The
   check-in's value is its answers, so it keeps them as the second line and
   its "Edit" verb. */
#overview-panel #day-loop-rail .day-loop-row.is-complete:not([data-loop-row="checkin"]) > .day-loop-copy > .day-loop-value {
  grid-column: 3; grid-row: 1 / span 3; justify-self: end; margin: 0;
  font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--ink); text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}
#overview-panel #day-loop-rail .day-loop-row.is-complete:not([data-loop-row="checkin"]) > .day-loop-copy > .day-loop-note { grid-row: 2; }
#overview-panel #day-loop-rail .day-loop-row.is-complete:not([data-loop-row="checkin"]) > .day-loop-action { display: none; }
#overview-panel #day-loop-rail #open-readiness.is-complete .day-loop-label { color: var(--ink); }
/* The status mark: a ring, or a filled green circle with a check. */
#overview-panel .today-mark {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none; padding: 0;
  border: 1.75px solid var(--ink-4); border-radius: var(--radius-pill); background: transparent;
}
#overview-panel .today-mark > svg { width: 14px; height: 14px; fill: none; stroke: var(--success-ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
#overview-panel .is-complete > .today-mark { border-color: var(--success); background: var(--success); }
#overview-panel .is-complete > .today-mark > svg { visibility: visible; }
#overview-panel #day-loop-rail > :is(#today-status-error, .snapshot-error) { margin: var(--space-2) var(--space-1) 0; }

/* Checklist: count beside the title, Edit at the right, marks as §2.3. */
#overview-panel #checklist-card > .checklist-head > #checklist-progress { margin: 0; color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular); }
#overview-panel #checklist-card > .checklist-head > #checklist-settings { margin-inline-start: auto; width: auto; }
#overview-panel #checklist-card > #checklist-items { display: grid; gap: 0; padding: 0; }
#overview-panel #checklist-card.is-empty > #checklist-items { display: grid; }
#overview-panel #checklist-card.is-empty > .checklist-head { display: flex; min-height: 28px; padding: 0 var(--space-1) var(--space-2); }
#overview-panel #checklist-card.is-empty #checklist-heading { font-size: var(--fs-label); font-weight: var(--fw-semibold); }
#overview-panel #checklist-items .checklist-row {
  position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; column-gap: var(--space-3);
  width: 100%; min-height: 56px; margin: 0; padding: 10px var(--space-4);
  border: 0; border-radius: 0; background: transparent; box-shadow: none; text-align: left;
}
#overview-panel #checklist-items .checklist-row + .checklist-row { border-top: 0; }
#overview-panel #checklist-items .checklist-row + .checklist-row::before {
  content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--border);
}
#overview-panel #checklist-items .checklist-row:active { transform: none; background: var(--surface-2); }
#overview-panel #checklist-items .checklist-mark {
  display: grid; place-items: center; width: 24px; height: 24px; border: 1.75px solid var(--ink-4); border-radius: var(--radius-pill); background: transparent;
}
#overview-panel #checklist-items .checklist-row[aria-pressed="true"] .checklist-mark { border-color: var(--success); background: var(--success); }
#overview-panel #checklist-items .checklist-row[aria-pressed="true"] .checklist-mark::after { width: 5px; height: 10px; margin: 0 0 2px; }
#overview-panel #checklist-items .checklist-row .list-row-label strong { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); }
#overview-panel #checklist-items .checklist-row[aria-pressed="true"] .list-row-label strong { color: var(--ink-3); }
#overview-panel #checklist-items > .list-meta { margin: 0; padding: var(--space-4); }
#overview-panel #checklist-card > #checklist-message:not(:empty) { margin: var(--space-2) var(--space-1) 0; }

/* Meals today: food as the title, meal as the second line, kcal as the value. */
#overview-panel .today-meals-card .today-recent-meals ul { margin: 0; padding: 0; list-style: none; }
#overview-panel .today-meals-card .today-recent-meals li {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-3);
  min-height: 60px; margin: 0; padding: 10px var(--space-4); border: 0;
}
#overview-panel .today-meals-card .today-recent-meals li + li { border-top: 0; }
#overview-panel .today-meals-card .today-recent-meals li + li::before {
  content: ""; position: absolute; top: 0; left: var(--space-4); right: 0; height: 1px; background: var(--border);
}
#overview-panel .today-meals-card .today-recent-meals li > div { min-width: 0; }
#overview-panel .today-meals-card .today-recent-meals li > div > strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.3; color: var(--ink); }
#overview-panel .today-meals-card .today-recent-meals li > div > span { display: block; margin-top: 1px; font-size: var(--fs-label); line-height: 1.35; color: var(--ink-3); }
#overview-panel .today-meals-card .today-meal-energy { max-width: none; font-size: var(--fs-body); font-weight: var(--fw-regular); color: var(--ink-2); text-align: right; white-space: nowrap; }
#overview-panel .today-meals-card .today-meal-energy > .today-meal-kcal { font-weight: var(--fw-semibold); color: var(--ink); }
#overview-panel #today-log-food > #today-food-draft { display: block; max-width: 100%; margin: 2px 0 0; font-size: var(--fs-caption); font-weight: var(--fw-regular); line-height: 1.3; color: var(--ink-3); overflow-wrap: anywhere; }
#overview-panel #today-log-food > #today-food-draft:empty { display: none; }
:is(#overview-panel, #nutrition-panel) .today-macro > .macro-note { display: block; margin-top: 2px; font-size: var(--fs-caption); line-height: 1.3; color: var(--ink-3); }
:is(#overview-panel, #nutrition-panel) .today-macro > .goal-status { display: block; margin-top: var(--space-1); font-size: var(--fs-caption); font-weight: var(--fw-semibold); line-height: 1.3; }
#overview-panel .today-meals-card .today-recent-meals > p { margin: 0; padding: var(--space-4); }
#overview-panel :is(.today-meals-card, .today-nutrition-card) .unit, #nutrition-panel .today-nutrition-layout .unit { margin-left: .18em; font-weight: var(--fw-regular); color: var(--ink-2); }

/* Last group: two plain rows. */
#overview-panel .today-more-card {
  display: flex; flex-direction: column; padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: none; overflow: hidden;
}
#overview-panel .today-more-card > #today-weekly-review {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 14px; align-items: center; column-gap: var(--space-3);
  width: 100%; min-height: 60px; margin: 0; padding: 10px var(--space-4);
  border: 0; border-radius: 0; background: transparent; box-shadow: none; text-align: left; color: var(--ink);
}
#overview-panel .today-more-card > #today-weekly-review[hidden] { display: none; }
#overview-panel .today-more-card > #today-weekly-review strong { display: block; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.3; }
#overview-panel .today-more-card > #today-weekly-review .muted { display: block; margin-top: 1px; font-size: var(--fs-label); line-height: 1.35; color: var(--ink-3); }
#overview-panel .today-more-card > #today-weekly-review:not([hidden]) + #today-details > summary { position: relative; }
#overview-panel .today-more-card > #today-weekly-review:not([hidden]) + #today-details > summary::before {
  content: ""; position: absolute; top: 0; left: var(--space-4); right: 0; height: 1px; background: var(--border);
}
#overview-panel .today-more-card > #today-details { border: 0; }
#overview-panel .today-more-card > #today-details > summary {
  display: grid; grid-template-columns: minmax(0, 1fr) 14px; align-items: center; column-gap: var(--space-3);
  min-height: 56px; padding: 10px var(--space-4); font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink);
}
#overview-panel .today-more-card .list-chevron { width: 20px; height: 20px; margin-right: -6px; color: var(--ink-4); }

/* Narrow phones and large text: the value or verb drops under the row's
   copy so the title keeps its width. */
@media (max-width: 340px) {
  #overview-panel #day-loop-rail .day-loop-row > :is(.today-mark, .list-chevron) { grid-row: 1 / span 4; }
  #overview-panel #day-loop-rail .day-loop-row > .day-loop-action,
  #overview-panel #day-loop-rail .day-loop-row.is-complete:not([data-loop-row="checkin"]) > .day-loop-copy > .day-loop-value {
    grid-column: 2; grid-row: 4; justify-self: start; margin-top: var(--space-1); text-align: left;
  }
}
@media (min-width: 64rem) {
  #overview-panel > .quick-actions {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-template-areas: none;
    column-gap: var(--space-6); row-gap: 0; align-items: start;
  }
  #overview-panel .today-col { display: grid; gap: var(--space-6); align-content: start; min-width: 0; }
  #overview-panel #today-now, #overview-panel .today-nutrition-card, #overview-panel #day-loop-rail,
  #overview-panel .today-meals-card, #overview-panel #checklist-card, #overview-panel .today-more-card { grid-area: auto; order: 0; }
  #overview-panel #today-now { grid-template-columns: minmax(0, 1fr) 220px; align-items: center; column-gap: var(--space-6); row-gap: var(--space-2); padding: var(--space-6); }
  #overview-panel #today-now > .today-now-main { grid-column: 1; grid-row: 1; }
  #overview-panel #today-now > #today-now-cta { grid-column: 2; grid-row: 1; }
  #overview-panel #today-now > #today-now-freshness { grid-column: 1; grid-row: 2; }
  #overview-panel .today-nutrition-card > .today-group-body { padding: var(--space-6); row-gap: var(--space-5); }
  :is(#overview-panel, #nutrition-panel) .today-nutrition-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); column-gap: var(--space-7); align-items: end; }
  #overview-panel .today-nutrition-card #today-log-food { width: auto; min-width: 220px; justify-self: start; }
  #overview-panel .today-meals-card .today-recent-meals li,
  #overview-panel #day-loop-rail .day-loop-row, #overview-panel #checklist-items .checklist-row { min-height: 56px; padding-inline: var(--space-4); }
}

/* =========================================================================
   S38 (gym feedback, 2026-11-14): the exercise ⋯ menu and the target chip's
   explanation float over the card instead of pushing the set table down;
   the diary's meal-total row sits on the item rows' insets; the dock shows
   the elapsed time beside the set count.
   ========================================================================= */
/* 1-2. Popovers. Absolute in the exercise block, so they scroll with the
   card and are never pinned (S31); app.js placeExercisePopover sets left/top
   under the button, or above it (.opens-up) when the dock would cover them. */
#workouts-panel #sets .exercise-block { position: relative; }
#workouts-panel #sets .exercise-block > .exercise-menu,
#workouts-panel #sets .exercise-head .suggested-next[open] > .suggested-explanation {
  position: absolute; z-index: 10; margin: 0;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-menu);
}
#workouts-panel #sets .exercise-block > .exercise-menu { width: min(15rem, calc(100vw - 16px)); }
#workouts-panel #sets .exercise-head .suggested-next[open] > .suggested-explanation {
  width: min(18rem, calc(100vw - 16px)); padding: var(--space-3) var(--space-4);
  color: var(--ink-2); font-size: var(--fs-label); line-height: var(--lh-body);
}
#workouts-panel #sets .exercise-head .suggested-explanation > span { display: block; margin-top: var(--space-1); color: var(--ink-3); font-size: var(--fs-caption); }
#workouts-panel #sets .exercise-head .suggested-explanation:focus:not(:focus-visible) { outline: none; }

/* 3. The diary on the phone. The meal-total "… nutrient details" row takes
   the item rows' --card-pad insets, so its chevron is in their column. */
@media (max-width: 63.999rem) {
  #nutrition-panel .meal-group-body > .nutrient-details {
    padding-inline: var(--card-pad); border-top: 1px solid var(--border-soft);
  }
  /* "…" moves up beside the food's name: the name, serving, numbers and
     details row read as one block. The name and serving keep clear of it. */
  #nutrition-panel .food-entry { grid-template-columns: minmax(0, 1fr) var(--tap); column-gap: var(--space-2); row-gap: var(--space-1); }
  #nutrition-panel .food-entry-content { grid-column: 1 / -1; grid-row: 1; }
  #nutrition-panel .food-entry-content > :is(strong, .food-serving) { padding-right: calc(var(--tap) + var(--space-1)); }
  #nutrition-panel .food-entry > .mini-actions {
    grid-column: 2; grid-row: 1; align-self: start; justify-self: end; margin-top: calc(var(--space-3) * -1);
  }
  /* S48: Edit / Duplicate / Delete open as a popover over the rows (S48
     block at the end), so "…" keeps its box and nothing under it moves. */
  #nutrition-panel .food-entry > .nutrient-details { grid-column: 1 / -1; }
}

/* 4. The dock: "4:36 · 0 of 21 sets" beside Finish, tabular so it does not
   jitter. The time is the header's tick (updateElapsed), aria-hidden here. */
#workouts-panel #workout-session-sheet .strong-topbar .timer-stack {
  display: flex; align-items: baseline; gap: var(--space-1); flex-wrap: nowrap; min-width: 0;
}
#workouts-panel #workout-session-sheet .strong-topbar:has(> .rest-pill:not(.hidden)) > .timer-stack { display: none; }
#workouts-panel #workout-session-sheet .strong-topbar .session-elapsed {
  flex: none; color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold);
  line-height: var(--lh-snug); font-variant-numeric: tabular-nums;
}
#workouts-panel #workout-session-sheet .strong-topbar .session-elapsed::after {
  content: "·"; margin-left: var(--space-1); color: var(--ink-3); font-weight: var(--fw-regular);
}
#workouts-panel #workout-session-sheet .strong-topbar .timer-stack:has(> .session-progress:empty) > .session-elapsed::after { content: none; }
#workouts-panel #workout-session-sheet .strong-topbar .session-progress {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* =========================================================================
   S39 Design: Nutrition (spec §3.5, §2.1, §2.2, §2.4, §2.7, §2.12, §1.3).
   Day header row, then three groups: the day's summary (the one Today shows,
   nutritionSummaryMarkup), Meals as one list group of rows, Library as one
   list group of plain rows. Phone first; at >=64rem the Today grid, 7fr / 5fr:
   summary and meals on the left, Library on the right, both under the title.
   One block, ID-weighted, last in the sheet, so it outranks the older
   Nutrition layers without !important.
   ========================================================================= */
#nutrition-panel:not(.hidden) { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; }
#nutrition-panel > .nutrition-workspace { display: contents; }
#nutrition-panel .nutrition-group-title {
  display: block; margin: 0; padding: 0 var(--space-1) var(--space-2); min-height: 28px;
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.35;
  letter-spacing: 0; text-transform: none;
}

/* Day header: the date between two 44px icon buttons, one line, outside the group. */
#nutrition-panel > section.nutrition-primary-card.card,
#nutrition-panel > section.nutrition-primary-card.card:has(> #nutrition-message:empty) {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: none; gap: var(--space-2);
  margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible;
}
#nutrition-panel > .nutrition-primary-card > .nutrition-day-header { display: block; margin: 0; padding: 0; grid-area: auto; }
#nutrition-panel .nutrition-day-header .nutrition-day-navigation {
  display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); align-items: center; gap: var(--space-1);
  width: 100%; min-height: var(--tap);
}
#nutrition-panel .nutrition-day-navigation > :is(#nutrition-previous-day, #nutrition-next-day) {
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  display: grid; place-items: center; border: 0; border-radius: var(--radius-pill); background: transparent; box-shadow: none; color: var(--ink-2);
}
#nutrition-panel .nutrition-day-navigation > :is(#nutrition-previous-day, #nutrition-next-day) svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#nutrition-panel .nutrition-day-navigation > :is(#nutrition-previous-day, #nutrition-next-day):active { transform: scale(.97); background: var(--surface-2); }
#nutrition-panel .nutrition-day-navigation > #nutrition-day-picker { min-width: 0; }
#nutrition-panel .nutrition-day-navigation > #nutrition-day-picker > summary {
  justify-content: center; min-height: var(--tap); padding: 0 var(--space-2); border: 0; background: transparent;
  font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#nutrition-panel .nutrition-day-navigation > #nutrition-day-picker > summary::after { display: none; }

/* Summary group: the shared summary, the incompleteness line when a macro is
   not fully known, Daily details, then the screen's one primary button. */
#nutrition-panel .nutrition-summary-body {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0;
  padding: var(--space-5); border-radius: var(--radius-lg); background: var(--surface);
}
#nutrition-panel .nutrition-summary-body > #nutrition-message:empty { display: none; }
#nutrition-panel .nutrition-summary-body > #nutrition-message { margin: 0; }
#nutrition-panel #nutrition-dashboard {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-area: auto; gap: var(--space-4);
  margin: 0; padding: 0; border: 0; min-width: 0;
}
#nutrition-panel #nutrition-dashboard > * { grid-column: 1 / -1; grid-row: auto; margin: 0; }
#nutrition-panel #nutrition-dashboard > .dashboard-knowledge { grid-column: 1 / -1; grid-row: auto; padding: 0; border: 0; }
#nutrition-panel .today-macro-bars { --fill: var(--ink); }
/* The display number's line box holds its glyphs (Archivo's ascent is taller than 1em). */
#nutrition-panel .today-ring-copy > strong { line-height: 1.1; }
#nutrition-panel #nutrition-dashboard .nutrition-day-details > summary { min-height: var(--tap); font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--ink-2); }
#nutrition-panel #nutrition-dashboard > .nutrition-uncertainty { color: var(--ink-3); font-size: var(--fs-label); line-height: 1.35; }
#nutrition-panel #nutrition-dashboard > .nutrition-empty { color: var(--ink-2); font-size: var(--fs-body); line-height: 1.35; }
#nutrition-panel #nutrition-dashboard > .nutrition-empty > strong { font-weight: var(--fw-medium); color: var(--ink); }
#nutrition-panel .nutrition-summary-body > #open-food-search.capture-action-solo {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2); grid-area: auto;
  width: 100%; max-width: none; min-height: 52px; margin: 0; padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius); box-shadow: none; background: var(--accent); color: var(--accent-ink);
  font-size: var(--nutrition-wide-control-type, var(--fs-body)); font-weight: var(--fw-semibold);
}
#nutrition-panel .nutrition-summary-body > #open-food-search .capture-icon { display: grid; place-items: center; width: auto; height: auto; margin: 0; padding: 0; background: none; color: inherit; }
#nutrition-panel .nutrition-summary-body > #open-food-search .capture-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#nutrition-panel .nutrition-summary-body > #open-food-search:active { transform: scale(.97); }

/* Meals: one list group. Each meal is a row (§2.2): name, then the food
   count and macros; kcal as the value; a 44px "+" icon button; the chevron. */
#nutrition-panel .nutrition-diary-card {
  display: block; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible;
}
#nutrition-panel .nutrition-diary-card > .eyebrow.nutrition-group-title { display: block; padding: 0 var(--space-1) var(--space-2); }
#nutrition-panel .nutrition-diary-card > :is(#nutrition-diary-state, #nutrition-entry-recovery):not(:empty):not(.hidden) { margin: 0 0 var(--space-2); }
#nutrition-panel .nutrition-diary-card > #nutrition-diary {
  display: block; margin: 0; padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); overflow: hidden;
}
#nutrition-panel .nutrition-diary-card > #nutrition-diary:empty { display: none; }
#nutrition-panel #nutrition-diary .meal-group { position: relative; margin: 0; border: 0; border-radius: 0; background: transparent; }
#nutrition-panel #nutrition-diary .meal-group + .meal-group { border-top: 0; }
#nutrition-panel #nutrition-diary .meal-group + .meal-group::before {
  content: ""; position: absolute; top: 0; left: var(--space-4); right: 0; height: 1px; background: var(--border); z-index: 1;
}
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions) {
  display: grid; grid-template-columns: minmax(0, 1fr) auto var(--tap) 14px; align-items: center; column-gap: var(--space-2); row-gap: 0;
  min-height: 60px; margin: 0; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
}
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions):active { background: var(--surface-2); }
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions) > span:first-child { grid-column: 1; min-width: 0; }
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions) > span:first-child > strong {
  display: block; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.3; color: var(--ink);
}
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions) > span:first-child > small {
  display: block; margin-top: 1px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: var(--fs-label); line-height: 1.35; color: var(--ink-3);
}
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-energy {
  grid-column: 2; justify-self: end; max-width: 9rem; text-align: right;
  font-size: var(--fs-body); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums lining-nums;
}
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-energy > strong { font-size: inherit; font-weight: var(--fw-semibold); color: var(--ink); }
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-energy > .unit { margin-left: .18em; font-weight: var(--fw-regular); color: var(--ink-2); }
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-energy > strong:not(.num) { font-size: var(--fs-label); white-space: normal; }
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-add-icon[data-add-meal],
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions > .meal-add > svg { color: var(--ink-2); }
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-add-icon[data-add-meal] {
  grid-column: 3; grid-row: 1; display: grid; place-items: center;
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); margin: 0; padding: 0;
  border: 0; border-radius: var(--radius-pill); background: transparent; box-shadow: none;
}
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-add-icon[data-add-meal]::before { content: none; display: none; }
#nutrition-panel #nutrition-diary .meal-group > summary > .meal-add-icon[data-add-meal]:active { transform: scale(.97); background: var(--surface-2); }
#nutrition-panel #nutrition-diary .meal-group > summary :is(.meal-add-icon, .meal-add) > svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round;
}
#nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions)::after { grid-column: 4; justify-self: end; margin: 0; }

/* An empty meal is one quiet row: "Add dinner" and a "+" in the same column. */
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions { display: block; position: relative; margin: 0; padding: 0; }
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions > .empty-meal-title {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions > .meal-add {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--tap) 14px; align-items: center; column-gap: var(--space-2);
  width: 100%; min-height: 56px; margin: 0; padding: 6px var(--space-3) 6px var(--space-4);
  border: 0; border-radius: 0; box-shadow: none; background: transparent; text-align: left;
  color: var(--ink-2); font-size: var(--fs-body); font-weight: var(--fw-medium);
}
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions > .meal-add > svg { grid-column: 2; justify-self: center; }
#nutrition-panel #nutrition-diary .meal-group > summary.empty-meal-actions > .meal-add:active { transform: none; background: var(--surface-2); }

/* Library: one list group of plain rows; the section bodies open in place. */
#nutrition-panel .nutrition-secondary-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 0; padding: 0; border: 0; }
#nutrition-panel .nutrition-secondary-tools > h2.nutrition-group-title { position: static; width: auto; height: auto; clip: auto; overflow: visible; white-space: normal; }
#nutrition-panel .nutrition-secondary-tools > .card {
  position: relative; margin: 0; padding: 0 var(--space-4); border: 0; border-radius: 0; box-shadow: none; background: var(--surface);
}
#nutrition-panel .nutrition-secondary-tools > h2 + .card { border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }
#nutrition-panel .nutrition-secondary-tools > .card:last-child { border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }
#nutrition-panel .nutrition-secondary-tools > .card + .card::before {
  content: ""; position: absolute; top: 0; left: var(--space-4); right: 0; height: 1px; background: var(--border);
}
#nutrition-panel > .nutrition-workspace > .nutrition-secondary-tools > .card > details > summary {
  min-height: 56px; padding-block: 10px; font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink);
}
#nutrition-panel .nutrition-secondary-tools > .card > details > summary:active { background: transparent; }
#nutrition-panel .nutrition-secondary-tools .pantry-shopping-counts {
  margin-inline-start: auto; color: var(--ink-2); font-size: var(--fs-body); font-weight: var(--fw-regular); font-variant-numeric: tabular-nums;
}

/* Repeat yesterday, inside the Add food sheet beside Saved meals. */
#food-finder-modal .finder-repeat-yesterday { display: grid; gap: var(--space-2); }
#food-finder-modal .finder-repeat-yesterday[hidden], #food-finder-modal .finder-repeat-yesterday:empty { display: none; }
#food-finder-modal .finder-repeat-yesterday > .meal-repeat { width: 100%; min-height: var(--tap); white-space: normal; }

@media (min-width: 64rem) {
  #nutrition-panel:not(.hidden) {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); grid-auto-flow: row dense;
    column-gap: var(--space-6); row-gap: var(--space-6); margin: 0; padding-inline: 0;
  }
  #nutrition-panel > #nutrition-hydration-status { grid-column: 1 / -1; }
  #nutrition-panel > .nutrition-primary-card { grid-column: 1; }
  #nutrition-panel .nutrition-diary-card { grid-column: 1; min-width: 0; }
  #nutrition-panel .nutrition-secondary-tools { grid-column: 2; grid-row: span 2; min-width: 0; }
  #nutrition-panel .nutrition-summary-body { padding: var(--space-6); row-gap: var(--space-5); }
  #nutrition-panel .nutrition-summary-body > #open-food-search.capture-action-solo { width: auto; min-width: 220px; justify-self: start; }
  #nutrition-panel .nutrition-day-header .nutrition-day-navigation { justify-content: start; grid-template-columns: var(--tap) auto var(--tap); }
  #nutrition-panel #nutrition-diary .meal-group > summary:not(.empty-meal-actions) { min-height: 60px; }
}

/* ============================================================================
   S40 — Trends and charts (design spec §3.5 Trends, §1.8 Charts, §2.5, §2.12)
   ----------------------------------------------------------------------------
   Presentation only: the same reads, periods, handlers and calculations.
   Every chart is one ink series with hairlines and right-side labels; the
   period and metric selectors are §2.5 segmented controls; the review verdict
   is the h2 stop and its explanations are 44px rows with a chevron.
   ========================================================================= */
/* Segmented: a --surface-3 track with a 3px inset; the selected segment is a
   raised --surface chip in ink at 600 with the "selected outline" token, so
   the selection is never colour alone. */
#trends-panel :is(.trends-metrics, .weight-ranges),
#settings-panel .workout-unit-toggle {
  gap: 0; padding: 3px; border-radius: var(--radius); background: var(--surface-3);
}
#trends-panel :is(.trends-metrics, .weight-ranges) button,
#settings-panel .workout-unit-toggle button {
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums lining-nums; outline: 0;
}
#trends-panel :is(.trends-metrics, .weight-ranges) button[aria-pressed="true"],
#settings-panel .workout-unit-toggle button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: var(--fw-semibold); box-shadow: none;
  outline: 1px solid var(--accent-soft-border); outline-offset: -1px;
}
#trends-panel :is(.trends-metrics, .weight-ranges) button:focus-visible,
#settings-panel .workout-unit-toggle button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The chart group: period control, then the value and one sentence, then the
   window, then the plot. */
#trends-panel .trends-chart > .weight-ranges { margin: 0 0 var(--space-4); }
#trends-panel .trends-chart-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-4);
}
#trends-panel .trends-chart-value {
  margin: 0; color: var(--ink); font-size: var(--fs-h2); font-weight: var(--fw-bold); line-height: 1.15;
  letter-spacing: var(--ls-h2); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap;
}
#trends-panel .trends-chart-value .unit {
  margin-left: .18em; color: var(--ink-2); font-size: var(--fs-body); font-weight: var(--fw-regular); letter-spacing: 0;
}
#trends-panel .trends-chart-value:empty { display: none; }
#trends-panel #weight-explorer-summary {
  margin: 0; color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular); line-height: var(--lh-snug);
}
#trends-panel #weight-explorer-window { margin: var(--space-1) 0 0; color: var(--ink-3); font-size: var(--fs-caption); font-variant-numeric: tabular-nums lining-nums; }
#trends-panel #weight-explorer-plot { margin-top: var(--space-3); }
#trends-panel #weight-explorer-plot svg { height: 200px; min-height: 0; }
#trends-panel #weight-explorer-plot .weight-grid { stroke: var(--border); opacity: 1; }
#trends-panel #weight-explorer-plot .weight-measured-line { stroke: var(--ink); stroke-width: 1.75px; opacity: 1; }
#trends-panel .weight-date-labels { margin-top: var(--space-2); color: var(--ink-3); }
#trends-panel #weight-explorer-plot .weight-date-labels .is-latest { color: var(--ink); }
#trends-panel #weight-explorer-selection { min-height: 0; margin: var(--space-3) 0 0; color: var(--ink-3); font-size: var(--fs-label); }
#trends-panel #weight-explorer-selection:empty { display: none; }

/* §2.12, Trends only. Loading: skeleton bars in --surface-2 where the value,
   the sentence and the plot will be; the status text stays for a screen
   reader but is not painted. Empty: the one line, and "Log weight" below is
   its action. Error: the one line and Retry. */
#trends-panel #weight-explorer[data-state="loading"] .trends-chart-value { display: block; }
#trends-panel #weight-explorer[data-state="loading"] .trends-chart-value::before {
  content: ""; display: block; width: 6.5rem; height: 1.15em; border-radius: var(--radius-sm); background: var(--surface-2);
}
#trends-panel #weight-explorer[data-state="loading"] #weight-explorer-summary {
  color: transparent; border-radius: var(--radius-sm); background: var(--surface-2);
}
#trends-panel #weight-explorer[data-state="loading"] #weight-explorer-plot {
  height: calc(200px + 1.5rem); border-radius: var(--radius-sm); background: var(--surface-2);
}
#trends-panel #weight-explorer:is([data-state="empty"], [data-state="error"], [data-state="unavailable"]) #weight-explorer-summary {
  color: var(--ink-2); font-size: var(--fs-body);
}
#trends-panel #weight-explorer:is([data-state="empty"], [data-state="error"]) .trends-history h3 { display: none; }
#trends-panel #weight-explorer-retry { width: auto; min-height: var(--tap); margin-top: var(--space-3); }
#trends-panel #weight-explorer-retry:not([hidden]) { display: inline-flex; align-items: center; }

/* One surface (§1.6): the chart group drops the old hue haze. Weigh-in rows
   take the row inset (§2.2) instead of running flush to the group edge. */
#trends-panel .trends-chart.card.ledger-hero { background: var(--surface); border: 0; }
#trends-panel #weight-explorer-list button { padding-inline: var(--space-4); }
#trends-panel .trends-history h3 { padding-inline: var(--space-4); }

/* Weekly review: the card title is a group header, the verdict is the h2
   stop with the one plain sentence under it. */
#trends-panel .cut-review #cut-review-heading {
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); letter-spacing: 0; line-height: var(--lh-snug);
}
#trends-panel .cut-review .cut-review-summary > .muted { margin: var(--space-1) 0 0; font-size: var(--fs-caption); color: var(--ink-3); }
#trends-panel .cut-review .cut-review-headline {
  max-width: none; margin: var(--space-3) 0 var(--space-2); color: var(--ink);
  font-size: var(--fs-h2); font-weight: var(--fw-bold); line-height: 1.15; letter-spacing: var(--ls-h2);
}
/* "How this is worked out": a row with a chevron drawn in CSS (no text
   glyph, no data URI). Same native disclosure, same content. 48px rather
   than 44: the panel's entrance transform can measure a 44px box at
   43.9999px while it settles. */
#trends-panel .cut-review .cut-explainer { margin-top: var(--space-2); font-size: var(--fs-label); }
#trends-panel .cut-review :is(.cut-explainer, .cut-review-details) > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 48px; padding: 0; list-style: none; border-top: 1px solid var(--border);
  color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-medium);
}
#trends-panel .cut-review :is(.cut-explainer, .cut-review-details) > summary::-webkit-details-marker { display: none; }
#trends-panel .cut-review :is(.cut-explainer, .cut-review-details) > summary::after {
  content: ""; flex: 0 0 8px; width: 8px; height: 8px; margin-right: var(--space-1);
  border-right: 1.75px solid var(--ink-4); border-bottom: 1.75px solid var(--ink-4);
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease);
}
#trends-panel .cut-review :is(.cut-explainer, .cut-review-details)[open] > summary::after { transform: rotate(45deg); }
#trends-panel .cut-review .cut-explainer > p { margin: 0 0 var(--space-3); color: var(--ink-2); line-height: 1.4; }
#trends-panel .cut-review .cut-review-details > summary { font-size: var(--fs-body); border-top: 0; }

/* The review's weight chart (§1.8): stretched viewBox for the lines, HTML for
   every label and the latest-point dot. */
#trends-panel .cut-review-plot {
  --cut-y-gutter: 2.75rem;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--cut-y-gutter); height: 200px; margin: var(--space-4) 0 0;
}
#trends-panel .cut-review-plot-area { position: relative; min-width: 0; height: 100%; }
#trends-panel .cut-review-plot .cut-review-chart { display: block; width: 100%; height: 100%; margin: 0; overflow: visible; }
#trends-panel .cut-review-chart-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
#trends-panel .cut-review-chart-week { fill: var(--surface-2); opacity: 1; }
#trends-panel .cut-review-chart-trend { fill: none; stroke: var(--ink-3); stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#trends-panel .cut-review-chart-line { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#trends-panel .cut-review-chart-dot { fill: var(--ink-4); }
#trends-panel .cut-review-chart-latest {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: var(--radius-pill);
  background: var(--ink); box-shadow: 0 0 0 2px var(--surface); pointer-events: none;
}
#trends-panel .cut-review-chart-week-label {
  position: absolute; bottom: calc(5% + var(--space-2)); margin-right: var(--space-2); white-space: nowrap;
  color: var(--ink-3); font-size: var(--fs-caption); line-height: 1;
}
#trends-panel .cut-review-chart-y { position: relative; height: 100%; }
#trends-panel .cut-review-chart-y > span {
  position: absolute; left: var(--space-2); transform: translateY(-50%);
  color: var(--ink-3); font-size: var(--fs-caption); line-height: 1; font-variant-numeric: tabular-nums lining-nums;
}
#trends-panel .cut-review-chart-x {
  display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between;
  margin: var(--space-2) 0 var(--space-2); padding-right: 2.75rem;
  color: var(--ink-3); font-size: var(--fs-caption); line-height: 1.3; font-variant-numeric: tabular-nums lining-nums;
}
#trends-panel .cut-review-chart-x .is-latest { color: var(--ink); font-weight: var(--fw-semibold); }

/* Adherence dots: 10px. Goal met = --success with a check; logged = ink;
   no food = a 1.5px --ink-4 ring. Each still carries its own words. */
#trends-panel .cut-review-days { gap: var(--space-3); margin: var(--space-2) 0 var(--space-3); }
#trends-panel .cut-review-days li { gap: var(--space-1); }
#trends-panel .cut-review-days .cut-review-day-mark {
  display: grid; place-items: center; width: 10px; height: 10px; border: 0; border-radius: var(--radius-pill); background: var(--ink);
}
#trends-panel .cut-review-days .is-goal-met .cut-review-day-mark { background: var(--success); }
#trends-panel .cut-review-days .is-unlogged .cut-review-day-mark { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-4); }
#trends-panel .cut-review-day-mark svg {
  display: block; width: 10px; height: 10px; fill: none; stroke: var(--success-ink); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Sparklines in the lift list: 56 x 20, --ink-3, 1.5px, no dots, no fill;
   the status word beside them carries the meaning. */
#trends-panel .cut-review-spark { width: 56px; height: 20px; }
#trends-panel .cut-review-lifts .cut-review-spark-line,
#trends-panel .cut-review-lifts :is(.is-goal-met, .is-over) .cut-review-spark-line { stroke: var(--ink-3); stroke-width: 1.5; }
#trends-panel .cut-review-lifts li { grid-template-columns: minmax(0, 1fr) 56px 72px; }

/* The review's buttons ("Approve", "Not now", "Set your goal", "Open
   goals"): 48px, so a subpixel layout can never measure them under the 44px
   floor (the S37 run's 43.99997px flake at 1440; 43.99998px here at 390). */
#trends-panel :is(.cut-review-suggestion-decide, .cut-review-goal-cta, .cut-review-action-cta) { min-height: 48px; }

/* The exploration charts: hairlines, labels on the right in --ink-3, ink
   marks. */
#trends-panel .explore-plot svg { height: 200px; }
#trends-panel .explore-plot .explore-grid { stroke: var(--border); opacity: 1; }
#trends-panel .explore-plot text { fill: var(--ink-3); font-variant-numeric: tabular-nums lining-nums; }
#trends-panel .explore-plot .explore-marker { fill: var(--ink); }

@media (min-width: 64rem) {
  #trends-panel #weight-explorer-plot svg { height: 280px; }
  #trends-panel #weight-explorer[data-state="loading"] #weight-explorer-plot { height: calc(280px + 1.5rem); }
  #trends-panel .explore-plot svg { height: 280px; }
  /* Today's grid: 7fr / 5fr, both columns starting on one line. The heading
     and the metric control share the first row, the chart and the weigh-ins
     the second. */
  #trends-panel #weight-explorer {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: var(--space-6); row-gap: var(--space-4); align-items: start;
  }
  #trends-panel #weight-explorer-heading { grid-column: 1; grid-row: 1; align-self: center; }
  #trends-panel #weight-explorer > .trends-metrics { grid-column: 2; grid-row: 1; max-width: none; }
  #trends-panel #weight-explorer .weight-ranges { max-width: none; }
  #trends-panel #weight-explorer > .trends-chart { grid-column: 1; grid-row: 2; }
  #trends-panel #weight-explorer > .trends-history { grid-column: 2; grid-row: 2; }
  #trends-panel .cut-review-lifts li { grid-template-columns: minmax(0, 1fr) 56px 92px; }
}

/* ============================================================================
   S43 — Sheets, part 1 (spec §2.10, §2.5, §2.2, §2.11, §2.12)
   ----------------------------------------------------------------------------
   One sheet shell for every `.s6-sheet`: the --surface panel over --scrim,
   --radius-sheet corners (top only on the phone), no shadow, a 56px header
   with the title centred and a 44px close icon on the left, and a footer
   pinned to the bottom edge with the safe area inside it. Check-in, sleep,
   weight, Duplicate and Review purchase take the shell only; their bodies are
   part 2. Add food and Review food are rebuilt on it: a segmented mode
   switch, form fields with the label above, list rows, and a footer whose
   primary is last and widest. No markup step, id or handler changed.
   ========================================================================= */
.modal-backdrop.s6-sheet { background: var(--scrim); }
.modal-backdrop.s6-sheet > :first-child { background: var(--surface); box-shadow: none; }
.modal-backdrop.s6-sheet :is(.food-sheet-header, .modal-head, .purchase-review-header) {
  min-height: 56px; padding: 6px var(--space-2); align-items: center; gap: var(--space-2); background: var(--surface);
}
/* Ids: Today's sheets sit inside #overview-panel, whose `h2` rule is an id rule. */
:is(#readiness-sheet, #sleep-sheet, #weight-sheet, #food-finder-modal, #food-review-modal, #entry-correction-modal, #repeat-review-modal, #purchase-review-sheet).s6-sheet :is(.food-sheet-header, .modal-head, .purchase-review-header) h2 {
  font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1.3; letter-spacing: 0; color: var(--ink);
}
.modal-backdrop.s6-sheet :is(.sheet-close, .modal-head .icon-btn) {
  grid-column: 1; grid-row: 1; display: grid; place-items: center;
  width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink-2); box-shadow: none;
}
.modal-backdrop.s6-sheet .sheet-icon,
#settings-panel .settings-back .sheet-icon,
#food-review-modal #review-edit-food .sheet-icon {
  width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
/* The footer is part of the shell: --surface, a hairline above, --space-4
   padding with the home indicator inside it. */
.modal-backdrop.s6-sheet :is(.review-commit-bar, .entry-correction-actions, .review-edit-actions, .plate-meal-footer),
.modal-backdrop.s6-sheet:has(#meal-draft-panel:not(.hidden)) .s6-meal-footer,
.modal-backdrop.s6-sheet.today-sheet .today-sheet-actions {
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: none;
}
/* Check-in's scale buttons were --surface pills on a --surface track; on the
   --surface shell they are fill (spec §1.6: things you press), so the five
   values stay visible. Selection is unchanged. */
.modal-backdrop.s6-sheet .readiness-scale button[aria-pressed=false] { background: var(--surface-2); }
@media (max-width: 600px) {
  /* Round top corners on Today's full-height sheets too; the height is theirs. */
  .modal-backdrop.s6-sheet.today-sheet > .readiness-sheet { border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
}

/* ---- Add food: segmented mode switch (spec §2.5, specimen bottom right) ---- */
#food-finder-modal .finder-mode-toggle {
  gap: 0; padding: 3px; margin: var(--space-1) var(--space-4) var(--space-3);
  background: var(--surface-3); border: 0; border-radius: var(--radius);
}
#food-finder-modal .finder-mode-toggle .mode-tab {
  min-height: var(--tap); padding: 0 var(--space-1); border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-medium); text-decoration: none;
}
#food-finder-modal .finder-mode-toggle .mode-tab.active {
  background: var(--surface); color: var(--ink); font-weight: var(--fw-semibold);
  box-shadow: 0 0 0 1px var(--accent-soft-border);
}

/* ---- Form fields (spec §2.5): label above, a 48px box, 1px --border-input ---- */
#food-finder-modal :is(.sheet-field-group, .barcode-manual-form, #meal-draft-panel .form),
#food-review-modal :is(.review-controls, .review-grid) {
  display: grid; gap: var(--space-4); padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible;
}
#food-review-modal :is(.review-controls.two-col, .review-grid),
#food-finder-modal #meal-draft-panel .form.two-col { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
#food-review-modal :is(.review-custom-fields, .review-cnf-fields) {
  display: grid; gap: var(--space-4); padding: 0; border-radius: 0; background: transparent; overflow: visible;
}
#food-finder-modal :is(.sheet-field-group, .barcode-manual-form, #meal-draft-panel .form) > label:not(.food-search-wrap),
#food-review-modal :is(.review-controls, .review-grid, .review-custom-fields, .review-cnf-fields, .review-notes-details) > label {
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--space-2);
  min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-regular); line-height: 1.35;
}
#food-finder-modal :is(.sheet-field-group, .barcode-manual-form, #meal-draft-panel .form) > label:not(.food-search-wrap) > :is(input, select, .s6-date-value),
#food-review-modal :is(.review-controls, .review-grid, .review-custom-fields, .review-cnf-fields) > label > :is(input, select, .s6-date-value),
#food-review-modal #review-quantity {
  box-sizing: border-box; width: 100%; height: 48px; min-height: 48px; padding: 0 var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); font-size: var(--fs-body); line-height: 1.3; box-shadow: none;
}
#food-review-modal .review-notes-details > label > textarea {
  box-sizing: border-box; width: 100%; min-height: 88px; padding: var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); font-size: var(--fs-body); line-height: 1.4;
}
:is(#food-finder-modal, #food-review-modal) :is(input:not([type=file]), select, textarea):focus,
:is(#food-finder-modal, #food-review-modal) .s6-date-value:focus-within {
  border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus-ring); outline: none;
}
:is(#food-finder-modal, #food-review-modal) .s6-date-value { display: flex; align-items: center; }
/* Search: the same 48px box with a 20px search icon inside it. */
#food-finder-modal .sheet-field-group > .food-search-wrap {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) !important; align-items: center; gap: var(--space-2);
  min-height: 48px; padding: 0 var(--space-1) 0 var(--space-3); margin: 0;
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-3); overflow: hidden;
}
#food-finder-modal .food-search-wrap:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus-ring); }
#food-finder-modal .food-search-wrap svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
#food-finder-modal .food-search-wrap input {
  height: 46px; min-height: 46px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--ink); font-size: var(--fs-body);
}
#food-finder-modal .food-search-wrap input:focus { box-shadow: none; }
#food-finder-modal .finder-hint { margin-inline: 4px; color: var(--ink-3); font-size: var(--fs-label); }

/* ---- List groups and rows (spec §2.1, §2.2) ----
   On the --surface sheet a list group has no box: its header sits above it
   and rows run edge to edge, split by hairlines from the text edge. */
#food-finder-modal :is(.food-results, .finder-shortcuts) {
  width: auto; max-width: none; margin-inline: calc(-1 * var(--space-4)); padding: 0; border: 0; border-radius: 0; background: transparent;
}
#food-finder-modal .food-results:empty { display: none; }
#food-finder-modal .food-result-section { margin: 0 0 var(--space-4); padding: 0; }
#food-finder-modal .food-result-section h3 {
  margin: 0; padding: 0 calc(var(--space-4) + 4px) var(--space-2);
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.35;
}
#food-finder-modal .food-result-section > p:not(.food-results-loading),
#food-finder-modal .food-result-section > .usda-attribution { margin: 0; padding: var(--space-2) var(--space-4); color: var(--ink-3); font-size: var(--fs-label); }
#food-finder-modal .food-result-row {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0;
  padding: 0 var(--space-2) 0 0; margin: 0; border: 0; background: transparent;
}
#food-finder-modal .food-result-row + .food-result-row::before,
#food-finder-modal .finder-shortcuts > * + * > .meal-repeat:first-child::before,
#food-finder-modal .finder-repeat-yesterday > .meal-repeat + .meal-repeat::before {
  content: ""; position: absolute; top: 0; left: var(--space-4); right: 0; height: 1px; background: var(--border);
}
#food-finder-modal .food-result-row > .food-result {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title value" "sub value";
  align-items: center; column-gap: var(--space-3); row-gap: 1px;
  width: 100%; min-height: 60px; padding: 10px 0 10px var(--space-4); margin: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--ink); text-align: left;
}
#food-finder-modal .food-result-row:last-child > .food-result:only-child { padding-right: var(--space-2); }
#food-finder-modal .food-result:active { background: var(--surface-2); }
#food-finder-modal .food-result-main { grid-area: title; min-width: 0; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.3; }
#food-finder-modal .food-result-main strong { font-weight: var(--fw-medium); }
#food-finder-modal .food-result-sub {
  grid-area: sub; display: block; min-width: 0; color: var(--ink-3); font-size: var(--fs-label); line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal;
}
#food-finder-modal .food-result-sub:empty { display: none; }
#food-finder-modal .food-result-value {
  grid-area: value; display: block; text-align: right; white-space: nowrap; overflow-wrap: normal;
  font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1.3; color: var(--ink);
}
#food-finder-modal .food-result-value .num,
#food-review-modal #review-totals .num { font-variant-numeric: tabular-nums lining-nums; }
#food-finder-modal .food-result-value .unit,
#food-review-modal #review-totals .unit { font-weight: var(--fw-regular); color: var(--ink-2); }
#food-finder-modal .food-result-value small { display: block; color: var(--ink-3); font-size: var(--fs-caption); font-weight: var(--fw-regular); }
#food-finder-modal .food-result .source-badge { padding: 0; margin-left: var(--space-1); background: none; border: 0; color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular); text-transform: none; letter-spacing: 0; }
/* The favourite star: a 44px icon button, outline when off, filled when on. */
#food-finder-modal .favorite-toggle {
  display: grid; place-items: center; width: var(--tap); min-width: var(--tap); height: var(--tap); min-height: var(--tap);
  padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink-3); box-shadow: none;
}
#food-finder-modal .favorite-toggle[aria-pressed=true] { color: var(--ink); }
#food-finder-modal .favorite-toggle[aria-pressed=true] .sheet-icon { fill: currentColor; }
/* Saved meals and Repeat yesterday: two plain rows in one list group. */
#food-finder-modal .finder-shortcuts { display: grid; }
#food-finder-modal .finder-shortcuts :is([data-finder-saved-meals], .meal-repeat) {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  width: 100%; min-height: 56px; padding: 0 var(--space-5) 0 var(--space-4); margin: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-medium); text-align: left;
}
#food-finder-modal .finder-shortcuts :is([data-finder-saved-meals], .meal-repeat)::after {
  content: ""; flex: 0 0 auto; width: 7px; height: 7px; margin-right: 2px;
  border-top: 1.75px solid var(--ink-4); border-right: 1.75px solid var(--ink-4); transform: rotate(45deg);
}
#food-finder-modal .finder-shortcuts :is([data-finder-saved-meals], .meal-repeat):active { background: var(--surface-2); }
#food-finder-modal .finder-repeat-yesterday { display: grid; gap: 0; }

/* ---- Empty and loading (spec §2.12): the two food sheets and, from S44, the exercise picker ---- */
#food-finder-modal .food-results-empty,
#exercise-picker-modal .picker-empty {
  display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-6) var(--space-4); text-align: center;
}
#food-finder-modal .food-results-empty p,
#exercise-picker-modal .picker-empty p { margin: 0; color: var(--ink-2); font-size: var(--fs-body); }
#food-finder-modal .food-results-empty button,
#exercise-picker-modal .picker-empty button {
  width: auto; min-height: var(--tap); padding: 0 var(--space-5); border: 0; border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
:is(#food-finder-modal, #exercise-picker-modal) .food-results-loading { display: grid; gap: 0; margin: 0; padding: 0; }
:is(#food-finder-modal, #exercise-picker-modal) .skeleton-row { position: relative; display: block; height: 60px; }
:is(#food-finder-modal, #exercise-picker-modal) .skeleton-row::before,
:is(#food-finder-modal, #exercise-picker-modal) .skeleton-row::after {
  content: ""; position: absolute; left: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2);
}
:is(#food-finder-modal, #exercise-picker-modal) .skeleton-row::before { top: 13px; width: 55%; height: 16px; }
:is(#food-finder-modal, #exercise-picker-modal) .skeleton-row::after { top: 36px; width: 32%; height: 12px; }

/* ---- Buttons in the two food sheets (spec §2.4) ---- */
#food-finder-modal :is(#barcode-manual-form button[type=submit], #plate-add, #meal-draft-submit),
#food-review-modal :is(#review-add-button, #review-save-edit) {
  min-height: 52px; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#food-finder-modal #usda-search-btn {
  min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#food-finder-modal #start-scan, #food-finder-modal #stop-scan,
#food-review-modal :is(#review-cancel-edit, #review-refresh-catalog) {
  min-height: var(--tap); border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
/* Review food footer: "Add to list" is the outline secondary, the Add button
   is last and takes the rest of the row. */
#food-review-modal .review-commit-bar:has(#review-queue-button:not(.hidden)) {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2);
}
#food-review-modal .review-commit-bar #review-queue-button {
  width: auto; min-height: 52px; padding: 0 var(--space-5); margin: 0; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#food-review-modal .review-commit-bar #review-add-button { width: 100%; margin: 0; }
#food-review-modal .review-edit-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2); }
#food-review-modal .review-edit-actions:is(.hidden) { display: none; }
#food-review-modal .review-edit-actions button { margin: 0; }
@media (max-width: 300px) {
  #food-review-modal :is(.review-commit-bar:has(#review-queue-button:not(.hidden)), .review-edit-actions) { grid-template-columns: minmax(0, 1fr); }
  #food-review-modal .review-commit-bar #review-queue-button { width: 100%; }
}

/* ---- Review food body ---- */
#food-review-modal .review-commit-context { padding: 0 var(--space-4) var(--space-3); color: var(--ink-3); font-size: var(--fs-label); }
#food-review-modal .review-commit-context strong { color: var(--ink); font-size: var(--fs-h3); font-weight: var(--fw-bold); line-height: 1.25; }
#food-review-modal .review-body { gap: var(--space-5); }
/* Totals: one group between two hairlines, value in ink and a quiet unit. */
#food-review-modal #review-totals {
  padding: var(--space-3) 0; border: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  border-radius: 0; background: transparent;
}
#food-review-modal #review-totals :is(.reviewed-portion, .totals-head) { margin: 0 0 var(--space-2); color: var(--ink-3); font-size: var(--fs-label); }
#food-review-modal #review-totals :is(.reviewed-portion strong, .totals-head span) { color: var(--ink-2); font-weight: var(--fw-semibold); }
#food-review-modal #review-totals .nutrient-compact { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); }
#food-review-modal #review-totals .nutrient-compact-item { display: grid; gap: 2px; }
#food-review-modal #review-totals .nutrient-label { color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular); }
#food-review-modal #review-totals .nutrient-value { color: var(--ink); font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: 1.25; }
#food-review-modal #review-totals .nutrient-value .unit { font-size: var(--fs-body); }
#food-review-modal #review-totals .nutrient-status { flex-basis: 100%; color: var(--ink-3); font-size: var(--fs-label); }
/* Disclosure rows: Add note, Nutrient facts and source (same <details>). */
#food-review-modal :is(.review-notes-details, .review-catalog-details) { margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--border); background: transparent; }
#food-review-modal :is(.review-notes-details, .review-catalog-details) > summary {
  position: relative; display: flex; align-items: center; min-height: 48px; padding: 0 var(--space-5) 0 0; list-style: none;
  color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-medium); cursor: pointer;
}
#food-review-modal :is(.review-notes-details, .review-catalog-details) > summary::-webkit-details-marker { display: none; }
#food-review-modal :is(.review-notes-details, .review-catalog-details) > summary::after {
  content: ""; position: absolute; right: 4px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.75px solid var(--ink-4); border-bottom: 1.75px solid var(--ink-4); transform: rotate(45deg); transition: transform var(--dur) var(--ease);
}
#food-review-modal :is(.review-notes-details, .review-catalog-details)[open] > summary::after { transform: rotate(-135deg); margin-top: -1px; }
#food-review-modal :is(.review-notes-details, .review-catalog-details)[open] { padding-bottom: var(--space-3); }
#food-review-modal #review-edit-food {
  display: inline-flex; align-items: center; gap: var(--space-2); justify-self: start; width: auto; min-height: var(--tap);
  padding: 0; border: 0; background: transparent; color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold);
}
#food-review-modal #review-edit-food.hidden { display: none; }
#food-review-modal #review-edit-food .sheet-icon { width: 16px; height: 16px; color: var(--ink-2); }

#food-review-modal :is(.manual-entry-help, #manual-per100-hint, #label-transcription-hint) { margin: 0; padding: 0 4px; color: var(--ink-3); font-size: var(--fs-label); }

/* ---- Desktop: centred, at most 560px, all four corners ---- */
@media (min-width: 601px) {
  .modal-backdrop.s6-sheet > :first-child { width: min(560px, 100%); max-width: 560px; border-radius: var(--radius-sheet); }
}
/* ---------- end S43 ---------- */

/* ============================================================================
   S43B — Sheets above the iPhone keyboard
   ----------------------------------------------------------------------------
   iOS Safari leaves the layout viewport alone when the keyboard opens; only
   the visual viewport shrinks. app.js (SOFTWARE_KEYBOARD_NAV) writes its
   height and pan offset to --vv-h / --vv-top and sets
   body.software-keyboard-open. While that class is on, an open sheet fills the
   visual viewport: header at the top, the body is the only scroll container
   and ends at the keyboard, the footer sits on the keyboard (the home
   indicator is under the keyboard, so the footer drops its safe-area pad).
   Without visualViewport the class is never set and nothing here applies.
   ========================================================================= */
body.software-keyboard-open .modal-backdrop.s6-sheet {
  top: var(--vv-top); bottom: auto; height: var(--vv-h);
  padding: env(safe-area-inset-top) 0 0; align-items: stretch;
}
body.software-keyboard-open .modal-backdrop.s6-sheet > :first-child {
  height: 100%; max-height: 100%; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
body.software-keyboard-open .modal-backdrop.s6-sheet :is(.review-commit-bar, .entry-correction-actions, .review-edit-actions, .plate-meal-footer, .today-sheet-actions),
body.software-keyboard-open .modal-backdrop.s6-sheet:has(#meal-draft-panel:not(.hidden)) .s6-meal-footer {
  padding-bottom: var(--space-3);
}
body.software-keyboard-open .modal-backdrop.s6-sheet :is(.review-body, .entry-correction-scroll, .finder-mode, .meal-draft-panel, .purchase-review-body, #readiness-form, .today-sheet-body) {
  padding-bottom: var(--space-4);
}
/* Add food while typing: the search box, "For meal" and the results are the
   task. The mode switch steps aside until the keyboard closes, and once a
   query is typed the shortcut rows give the results their place. */
body.software-keyboard-open #food-finder-modal:has(#finder-search-mode:not(.hidden)) .finder-mode-toggle { display: none; }
body.software-keyboard-open #finder-search-mode:has(#food-search-input:not(:placeholder-shown)) .finder-shortcuts { display: none; }
/* The empty-search hint is for an empty search only. */
#finder-search-mode:has(#food-search-input:not(:placeholder-shown)) > .finder-hint { display: none; }
/* ---------- end S43B ---------- */

/* ============================================================================
   S48 — The diary's ⋯ menu floats
   ----------------------------------------------------------------------------
   Edit / Duplicate / Delete opened in the row's flow and pushed its nutrient
   details link and the next foods down. It is now the workout ⋯ menu's
   popover: absolute in its row (so it scrolls with it, never pinned), placed
   by app.js placeExercisePopover under "…" or above it (.opens-up) when the
   bottom tab bar would cover it. The cards that round their corners with
   overflow: hidden let it out while it is open.
   ========================================================================= */
#nutrition-panel .food-entry { position: relative; }
#nutrition-panel .food-entry > .mini-actions > .entry-actions-menu {
  position: absolute; z-index: 10; margin: 0;
  width: min(15rem, calc(100vw - 16px)); max-width: none;
}
#nutrition-panel :is(.nutrition-diary-card, #nutrition-diary, .meal-group):has(.entry-actions-menu:not([hidden])) { overflow: visible; }
#nutrition-panel .entry-actions-menu.opens-up { transform-origin: bottom right; }
/* The workout menu's rows: one plain full-width row per action, hairlines between. */
#nutrition-panel .food-entry > .mini-actions > .entry-actions-menu { gap: 0; padding: 0; overflow: hidden; }
#nutrition-panel .food-entry > .mini-actions > .entry-actions-menu button {
  padding: 0 var(--space-4); border-radius: 0; font-size: var(--fs-body);
}
#nutrition-panel .food-entry > .mini-actions > .entry-actions-menu button:not(:last-child) { border-bottom: 1px solid var(--border-soft); }
/* ---------- end S48 ---------- */

/* ============================================================================
   S44 — Sheets, part 2 (spec §2.10, §2.5, §2.2, §2.12)
   ----------------------------------------------------------------------------
   The S43 shell and the S43B keyboard fit, unchanged, now also carry the
   exercise picker and the three delete reviews (`.s6-sheet` on each). This
   block only shapes the bodies: weight is a half sheet on the phone; sleep,
   weight and check-in fields take the label-above 48px box; check-in's
   actions become its pinned footer; the picker gets the 48px search field,
   plain rows and Add food's empty/loading states; a delete review is one
   confirm pattern (title, the sentence, the record, Cancel | Delete).
   ========================================================================= */

/* ---- Today's sheets: label above, a 48px box (same as Review food) ---- */
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4);
  padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible;
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group > label {
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--space-2);
  min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent;
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-regular); line-height: 1.35;
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group > label > :is(input, select, .s6-date-value, .sheet-unit) {
  box-sizing: border-box; width: 100%; height: 48px; min-height: 48px; padding: 0 var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); font-size: var(--fs-body); line-height: 1.3; box-shadow: none;
}
/* The note grows to its own scrollHeight (growSleepNote), so its 1px edge is an
   inset shadow, not a border that would hide two pixels of the last line. */
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group > label > textarea {
  box-sizing: border-box; width: 100%; min-height: 88px; padding: var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); font-size: var(--fs-body); line-height: 1.4; box-shadow: inset 0 0 0 1px var(--border-input);
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group > label > textarea:focus {
  box-shadow: inset 0 0 0 1px var(--ink), 0 0 0 3px var(--focus-ring);
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-unit { display: flex; align-items: center; gap: var(--space-2); }
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-unit > input {
  flex: 1 1 auto; height: 46px; min-height: 46px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--ink); font-size: var(--fs-body);
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-unit > span { flex: 0 0 auto; color: var(--ink-3); font-size: var(--fs-body); white-space: nowrap; overflow-wrap: normal; }
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .s6-date-value { display: flex; align-items: center; }
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) :is(input:not([type=date]), select, textarea):focus,
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) :is(.s6-date-value, .sheet-unit):focus-within {
  border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus-ring); outline: none;
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-unit > input:focus { box-shadow: none; }
:is(#sleep-sheet, #weight-sheet) .body-form-mode:empty { display: none; }
:is(#sleep-sheet, #weight-sheet) :is(.body-form-mode, #sleep-duration) { color: var(--ink-3); font-size: var(--fs-label); }
:is(#sleep-sheet, #weight-sheet) .today-sheet-body { padding-top: var(--space-2); }
/* Sleep: Bedtime | Wake time share a row; the rest take the whole row. */
#sleep-sheet .sheet-field-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#sleep-sheet .sheet-field-group > label:not(:has(#sleep-bed-time, #sleep-wake-time)) { grid-column: 1 / -1; }
/* iOS paints a time value top-centre inside a 48px box; pin it left and
   vertically centred like the date and quality fields (46px = 48 - 2px border). */
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group > label > input[type=time] {
  line-height: 46px; text-align: start;
}
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) .sheet-field-group > label > input[type=time]::-webkit-date-and-time-value {
  display: block; margin: 0; min-height: 46px; line-height: 46px; text-align: start;
}
/* Weight: Date | Weight in one row, so the sheet stays short. */
#weight-sheet .sheet-field-group { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }

/* Footer: as Review food's, the primary is last and takes the rest of the row. */
#sleep-sheet .today-sheet-actions { grid-template-columns: auto minmax(10rem, 1fr); }
#sleep-sheet .today-sheet-actions > .message { grid-column: 1 / -1; }
#sleep-sheet .today-sheet-actions > #save-sleep { grid-column: 1 / -1; grid-row: 2; }
#sleep-sheet .today-sheet-actions:has(#delete-sleep:not(.hidden)) > #save-sleep { grid-column: 2; }
#sleep-sheet .today-sheet-actions > #delete-sleep { grid-column: 1; grid-row: 2; width: auto; padding: 0 var(--space-5); }
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) :is(.today-sheet-actions, .readiness-actions) .message:empty { display: none; }
:is(#readiness-sheet, #sleep-sheet, #weight-sheet) :is(#save-readiness, #save-sleep, #save-weight-sheet) {
  min-height: 52px; margin: 0; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
:is(#readiness-sheet, #sleep-sheet) :is(#discard-readiness-draft, #reload-readiness) {
  min-height: 52px; margin: 0; padding: 0 var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#sleep-sheet #delete-sleep,
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions .danger {
  min-height: 52px; margin: 0; border: 1px solid var(--danger-bg); border-radius: var(--radius);
  background: var(--danger-bg); color: var(--danger); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}

/* ---- Weight: a half sheet on the phone (content-sized, at most 60% of the
   visual viewport), round top corners; with the keyboard up it sits on it. ---- */
@media (max-width: 600px) {
  #weight-sheet > .readiness-sheet { height: auto; max-height: calc(var(--vv-h) * 0.6); }
  body.software-keyboard-open #weight-sheet.s6-sheet { align-items: flex-end; }
}

/* ---- Check-in: scales as grouped rows, fields as above, actions pinned ---- */
#readiness-sheet #readiness-form { padding-bottom: 0; }
#readiness-sheet #readiness-form > p.muted { color: var(--ink-3); font-size: var(--fs-label); }
#readiness-sheet .readiness-scale { margin: 0 0 var(--space-5); }
#readiness-sheet .readiness-scale legend { color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold); }
#readiness-sheet .readiness-scale legend span { color: var(--ink-3); font-size: var(--fs-label); font-weight: var(--fw-regular); }
#readiness-sheet .readiness-values { padding: 0; gap: var(--space-2); background: transparent; }
#readiness-sheet .readiness-scale button { min-height: var(--tap); border-radius: var(--radius-sm); }
#readiness-sheet .sheet-field-group { margin-top: var(--space-2); }
#readiness-sheet #readiness-form > .readiness-actions {
  position: sticky; bottom: 0; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2);
  width: auto; max-width: none; margin: var(--space-2) calc(-1 * var(--space-4)) 0;
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
#readiness-sheet .readiness-actions:has(#discard-readiness-draft:not(.hidden)) { grid-template-columns: auto minmax(10rem, 1fr); }
#readiness-sheet .readiness-actions > :is(.message, #reload-readiness) { grid-column: 1 / -1; margin: 0; }
#readiness-sheet .readiness-actions > #discard-readiness-draft { grid-column: 1; }
#readiness-sheet .readiness-actions > #save-readiness { grid-column: -2 / -1; }
body.software-keyboard-open #readiness-sheet #readiness-form > .readiness-actions { padding-bottom: var(--space-3); }

/* ---- Exercise picker ---- */
#exercise-picker-modal > .exercise-picker-sheet { height: min(760px, calc(100dvh - 48px)); }
@media (max-width: 600px) {
  #exercise-picker-modal > .exercise-picker-sheet { height: 90dvh; }
}
#exercise-picker-modal .exercise-picker-header {
  flex: 0 0 auto; display: grid; grid-template-columns: var(--tap) auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-1);
  min-height: 56px; padding: 6px var(--space-2); margin: 0; background: var(--surface);
}
#exercise-picker-modal .exercise-picker-header h2 {
  margin: 0; text-align: center; color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1.3;
}
#exercise-picker-modal .exercise-picker-header .sheet-link {
  width: auto; min-width: var(--tap); padding: 0 var(--space-2); border: 0; color: var(--ink);
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#exercise-picker-modal .exercise-picker-header .sheet-link:disabled { color: var(--ink-3); }
#exercise-picker-modal .exercise-search-wrap {
  flex: 0 0 auto; display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: var(--space-2);
  min-height: 48px; padding: 0 var(--space-1) 0 var(--space-3); margin: var(--space-1) var(--space-4) var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-3);
}
#exercise-picker-modal .exercise-search-wrap:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus-ring); }
#exercise-picker-modal .exercise-search-wrap input {
  height: 46px; min-height: 46px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--ink); font-size: var(--fs-body);
}
#exercise-picker-modal .new-exercise-form {
  flex: 0 0 auto; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--space-2) var(--space-2);
  margin: 0; padding: 0 var(--space-4) var(--space-3);
}
#exercise-picker-modal .new-exercise-form.hidden { display: none; }
#exercise-picker-modal .new-exercise-form > label { color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-regular); }
#exercise-picker-modal .new-exercise-form input {
  height: 48px; min-height: 48px; padding: 0 var(--space-3); border: 1px solid var(--border-input); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: var(--fs-body);
}
#exercise-picker-modal .new-exercise-form input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus-ring); outline: none; }
#exercise-picker-modal .new-exercise-form button {
  min-height: 48px; padding: 0 var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
#exercise-picker-modal .picker-filters { flex: 0 0 auto; gap: var(--space-2); margin: 0; padding: 0 var(--space-4) var(--space-3); }
#exercise-picker-modal .filter-pill {
  min-height: var(--tap); border: 0; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink);
  font-size: var(--fs-label); font-weight: var(--fw-medium);
}
/* The list is the sheet body: the only scroller, rows edge to edge. */
#exercise-picker-modal .exercise-picker-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 0 calc(var(--space-6) + env(safe-area-inset-bottom));
}
/* Section headers sit above their rows, outside them. */
#exercise-picker-modal .picker-letter {
  margin: 0; padding: var(--space-4) calc(var(--space-4) + 4px) var(--space-2); border: 0;
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.35;
}
#exercise-picker-modal .exercise-picker-row {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--tap); align-items: center; gap: var(--space-3);
  width: 100%; min-height: 60px; padding: 8px var(--space-2) 8px var(--space-4); margin: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--ink); text-align: left;
}
#exercise-picker-modal .exercise-picker-row + .exercise-picker-row::before {
  content: ""; position: absolute; top: 0; left: var(--space-4); right: 0; height: 1px; background: var(--border);
}
#exercise-picker-modal .exercise-picker-row:active { background: var(--surface-2); }
#exercise-picker-modal .exercise-picker-row.selected { background: var(--surface-2); }
#exercise-picker-modal .exercise-thumb { display: none; }
#exercise-picker-modal .exercise-info strong { font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.3; }
#exercise-picker-modal .exercise-info small { margin-top: 1px; color: var(--ink-3); font-size: var(--fs-label); line-height: 1.35; }
#exercise-picker-modal .exercise-row-action {
  display: grid; place-items: center; justify-self: end; width: var(--tap); height: var(--tap); min-width: 0;
  border-radius: var(--radius-pill); background: transparent; color: var(--ink-3);
}
#exercise-picker-modal .exercise-picker-row.selected .exercise-row-action { color: var(--ink); }

/* ---- Delete reviews: one confirm pattern on the shell ---- */
.modal-backdrop.s6-sheet.confirm-sheet > .body-delete-review-sheet { border: 0; }
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-6) var(--space-4) var(--space-4);
}
:is(#body-delete-review, #workout-delete-review, #nutrition-summary-delete-review).s6-sheet h2 {
  margin: 0 0 var(--space-2); color: var(--ink); font-size: var(--fs-h3); font-weight: var(--fw-bold); line-height: 1.25; letter-spacing: 0;
}
.modal-backdrop.s6-sheet.confirm-sheet .confirm-sentence { margin: 0 0 var(--space-4); color: var(--ink-2); font-size: var(--fs-body); line-height: 1.4; }
.modal-backdrop.s6-sheet.confirm-sheet .confirm-sentence strong { font-weight: var(--fw-regular); color: inherit; }
/* The record being deleted: one quiet group between hairlines. */
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-fields {
  gap: 0; margin: 0 0 var(--space-4); border-top: 1px solid var(--border);
}
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-fields > :is(dt, dd) {
  margin: 0; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-label); line-height: 1.35;
}
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-fields > dt { color: var(--ink-3); font-weight: var(--fw-regular); }
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-fields > dd { color: var(--ink); text-align: right; }
#nutrition-summary-delete-review.s6-sheet .body-delete-review-fields > dt { padding-bottom: 0; border-bottom: 0; }
#nutrition-summary-delete-review.s6-sheet .body-delete-review-fields > dd { text-align: left; padding-top: 2px; }
.modal-backdrop.s6-sheet.confirm-sheet :is(.workout-delete-review-sets, .nutrition-summary-delete-review-knowledge) {
  margin: 0 0 var(--space-4); color: var(--ink-2); font-size: var(--fs-label);
}
/* Footer: Cancel, then the destructive action taking the rest of the row. */
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions {
  flex: 0 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2); margin: 0;
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions:has([id$=-delete-retry]:not([hidden])) { grid-template-columns: auto auto minmax(0, 1fr); }
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions .secondary {
  min-height: 52px; margin: 0; padding: 0 var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions .secondary[hidden] { display: none; }
/* The review's status line takes focus the moment Delete is pressed, while it is
   still empty (app.js focuses it before the answer lands); the S6
   `.s6-sheet .message:empty { display: none }` would make it unfocusable. */
.modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-scroll > .message:empty { display: block; margin: 0; }
@media (min-width: 601px) {
  .modal-backdrop.s6-sheet.confirm-sheet > :first-child { width: min(480px, 100%); max-width: 480px; }
}
@media (max-width: 340px) {
  .modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions,
  .modal-backdrop.s6-sheet.confirm-sheet .body-delete-review-actions:has([id$=-delete-retry]:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
}
/* ---------- end S44 ---------- */

/* ============================================================================
   S46 — Log a usual food in one tap
   ----------------------------------------------------------------------------
   A row with a stored usual portion gets a 44px "+" at its right edge, after
   the star; a row without one keeps the slot empty so stars and values stay
   in one column. One quiet line at the bottom of the sheet (above the
   keyboard while it is open, S43B) says what was added and offers Undo.
   Saved meals open as a view inside the sheet.
   ========================================================================= */
#food-finder-modal .food-result-row { grid-template-columns: minmax(0, 1fr) auto auto; }
#food-finder-modal :is(.quick-add-toggle, .quick-add-spacer) { width: var(--tap); min-width: var(--tap); height: var(--tap); }
#food-finder-modal .quick-add-toggle {
  display: grid; place-items: center; min-height: var(--tap); padding: 0; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--ink); box-shadow: none;
}
#food-finder-modal .quick-add-toggle:active { background: var(--surface-2); }
#food-finder-modal .finder-quick-add {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); margin: 0;
  padding: var(--space-1) var(--space-4) calc(var(--space-1) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface); color: var(--ink-2); font-size: var(--fs-label); line-height: 1.35;
}
#food-finder-modal .finder-quick-add[hidden] { display: none; }
#food-finder-modal .finder-quick-add > span:first-child { min-width: 0; overflow-wrap: anywhere; }
#food-finder-modal .finder-quick-add.error > span:first-child { color: var(--danger); }
#food-finder-modal .finder-quick-add .quick-add-action {
  flex: 0 0 auto; width: auto; min-height: var(--tap); padding: 0 var(--space-2); margin: 0 0 0 calc(-1 * var(--space-1)); border: 0; border-radius: var(--radius-sm);
  background: transparent; box-shadow: none; color: var(--ink); font-size: var(--fs-label); font-weight: var(--fw-semibold);
  text-decoration: underline; text-underline-offset: 3px;
}
body.software-keyboard-open #food-finder-modal .finder-quick-add { padding-bottom: var(--space-1); }
#food-finder-modal .finder-saved-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
#food-finder-modal .finder-saved-head h3 { margin: 0; text-align: center; color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold); }
#food-finder-modal .finder-saved-head h3:focus { outline: none; }
#food-finder-modal .finder-saved-head::after { content: ""; width: var(--tap); }
#food-finder-modal .finder-saved-back {
  display: inline-flex; align-items: center; gap: var(--space-1); padding: 0 var(--space-2) 0 0; color: var(--ink); font-size: var(--fs-label);
}
#food-finder-modal .finder-saved-host { display: grid; gap: var(--space-3); }
#food-finder-modal .finder-saved-host .message:empty { display: none; }
/* ---------- end S46 ---------- */
/* ---------- S47 estimated maintenance ---------- */
/* One line beside the suggestion, its working behind the review's own
   "How this is worked out" row. Ink only: it is context, never a verdict. */
#trends-panel .cut-review .cut-review-maintenance { margin: 0 0 var(--space-4); max-width: 65ch; }
#trends-panel .cut-review .cut-review-maintenance-line {
  margin: 0; color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold);
  line-height: var(--lh-snug); font-variant-numeric: tabular-nums;
}
#trends-panel .cut-review .cut-review-maintenance-line.is-quiet {
  color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-regular);
}
/* ---------- end S47 ---------- */
/* ---------- S50 rest timer you can set and notice ---------- */
/* Settings: "Rest timer" and "Sound at end of rest" use the unit row's
   segmented toggle, four (or two) 44px choices that wrap on narrow screens.
   S51 brings every Settings row to the 56px Ledger row. */
#settings-panel .settings-rest-home { padding-block: 7px; }
#settings-panel .settings-rest-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); }
#settings-panel .settings-rest-row > span { color: var(--text-primary); font-size: var(--type-primary); font-weight: var(--fw-semibold); }
#settings-panel .workout-unit-toggle.rest-choice-toggle { display: inline-flex; flex-wrap: wrap; }
#settings-panel .rest-choice-toggle button { width: auto; min-width: 48px; padding: 8px 6px; font-variant-numeric: tabular-nums; }
/* Rest end: the dock's rest half turns ink for 2.4 s. With motion allowed a
   ring ripples out from it; the global reduced-motion block removes the
   ripple and leaves the still, inverted state. JS removes .rest-flash. */
#workouts-panel #workout-session-sheet .rest-pill.card.rest.rest-flash {
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm);
  box-shadow: 0 0 0 var(--space-2) var(--accent);
  animation: rest-end-ripple 800ms ease-out 3;
}
#workouts-panel #workout-session-sheet .rest-pill.card.rest.rest-flash :is(#rest-label, #rest-time, #rest-skip) { color: var(--accent-ink); }
@keyframes rest-end-ripple {
  from { box-shadow: 0 0 0 var(--space-2) var(--accent), 0 0 0 var(--space-2) var(--accent); }
  to { box-shadow: 0 0 0 var(--space-2) var(--accent), 0 0 0 calc(var(--space-2) + 12px) transparent; }
}
/* ---------- end S50 ---------- */
/* ---------- S51 Settings on the new look + theme switch ---------- */
/* Rows read like Today's Ledger rows: a 500-weight ink title, an ink-3 meta
   line, an ink-4 18px chevron, and the row fill (not an underline) on hover. */
#settings-panel .list-row-label strong { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); }
#settings-panel :is(.list-meta, .coaching-profile-status) { color: var(--ink-3); font-size: var(--fs-label); }
#settings-panel .list-row-value { color: var(--ink-3); font-size: var(--fs-label); }
#settings-panel .list-chevron { width: 18px; height: 18px; color: var(--ink-4); }
#settings-panel .list-row:hover .list-row-label strong { text-decoration: none; }
#settings-panel :is(.workout-unit-row, .settings-rest-row) > span { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--ink); }
/* The unit, rest, sound and theme choices are the Trends segmented control
   (its selectors are shared above); here they keep the 44px floor in both
   axes, wrap on a narrow phone and lose the global pressed underline. */
#settings-panel .workout-unit-toggle { display: inline-flex; flex-wrap: wrap; border: 0; }
#settings-panel .workout-unit-toggle button { min-width: var(--tap); padding: 0 var(--space-2); text-decoration: none; }
/* A forced theme also forces the native controls and scrollbars. */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
/* Wide screens: the Settings shell keeps the other tabs' 1440px cap but sits
   centred in the space right of the 232px sidebar instead of hugging it. */
@media (min-width: 1700px) {
  .shell:has(> #app-card:not(.hidden)):has(#settings-panel:not(.hidden)) { margin-left: max(232px, calc(50% - 604px)); }
}
/* ---------- end S51 ---------- */
/* ---------- S52 Lift progress: history sheet + strength chart ---------- */
/* The exercise name is the button that opens its history. It keeps the
   title's type and box exactly: no fill, no border, the head's 44px row. */
#workouts-panel #sets .exercise-head h3 > .exercise-history-open {
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; justify-items: start;
  width: 100%; min-width: 0; min-height: var(--tap); margin: 0; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; box-shadow: none;
  color: inherit; font: inherit; letter-spacing: inherit; line-height: inherit; text-align: start;
  white-space: normal; overflow-wrap: anywhere; cursor: pointer; transform: none;
}
#workouts-panel #sets .exercise-head h3 > .exercise-history-open:active { opacity: .6; transform: none; }
#workouts-panel #sets .exercise-head h3 > .exercise-history-open:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The sheet: the S43 shell, a scrolling body, two stats, then one row per
   session (date and e1RM, then its sets). */
#exercise-history-sheet.s6-sheet .modal-head h2 {
  font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1.3; letter-spacing: 0; color: var(--ink);
}
#exercise-history-sheet .exercise-history-body {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  display: grid; align-content: start; gap: var(--space-4);
  padding: var(--space-2) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}
#exercise-history-sheet .exercise-history-lift {
  margin: 0; color: var(--ink); font-size: var(--fs-h3); font-weight: var(--fw-bold); line-height: var(--lh-snug); letter-spacing: var(--ls-h3);
}
#exercise-history-sheet .exercise-history-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin: 0; }
#exercise-history-sheet .exercise-history-summary:empty { display: none; }
#exercise-history-sheet .exercise-history-summary > div { padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); }
#exercise-history-sheet .exercise-history-summary dt { color: var(--ink-3); font-size: var(--fs-caption); }
#exercise-history-sheet .exercise-history-summary dd { display: grid; gap: 2px; margin: 0; }
#exercise-history-sheet .exercise-history-summary dd strong { color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-semibold); }
#exercise-history-sheet .exercise-history-stat-detail { color: var(--ink-3); font-size: var(--fs-caption); }
#exercise-history-sheet .exercise-history-heading { margin: 0; color: var(--ink-2); font-size: var(--fs-label); font-weight: var(--fw-semibold); }
#exercise-history-sheet:not([data-state="ready"]) .exercise-history-heading { display: none; }
#exercise-history-sheet .exercise-history-list { margin: 0; padding: 0; list-style: none; }
#exercise-history-sheet .exercise-history-session { padding: var(--space-3) 0; }
#exercise-history-sheet .exercise-history-session + .exercise-history-session { border-top: 1px solid var(--border-soft); }
#exercise-history-sheet .exercise-history-session-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin: 0; }
#exercise-history-sheet .exercise-history-session-head strong { color: var(--ink); font-size: var(--fs-body); font-weight: var(--fw-medium); }
#exercise-history-sheet .exercise-history-e1rm { flex: 0 0 auto; color: var(--ink-2); font-size: var(--fs-label); white-space: nowrap; overflow-wrap: normal; }
#exercise-history-sheet .exercise-history-sets { margin: var(--space-1) 0 0; color: var(--ink-3); font-size: var(--fs-label); line-height: 1.4; }

/* Trends: the lift picker above the range control, a label-above 48px box. */
#trends-panel .trends-lift { display: grid; gap: var(--space-2); margin: 0 0 var(--space-4); color: var(--ink-2); font-size: var(--fs-label); }
#trends-panel .trends-lift[hidden] { display: none; }
#trends-panel .trends-lift select {
  box-sizing: border-box; width: 100%; height: 48px; min-height: 48px; padding: 0 var(--space-3);
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--ink); font-size: var(--fs-body);
}
/* ---------- end S52 ---------- */

/* ---------- S53 Park batch: final review fixes ---------- */
/* Food delete opens in its confirm state: one red "Delete entry", the same
   fill as the workout delete review. */
#entry-correction-modal .entry-correction-actions #entry-correction-save.danger {
  min-height: 52px; margin: 0; border: 1px solid var(--danger-bg); border-radius: var(--radius);
  background: var(--danger-bg); color: var(--danger); font-size: var(--fs-body); font-weight: var(--fw-semibold);
}
/* A kept manual food says so, with a visible Clear. */
#food-review-modal .manual-draft-kept {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin: 0 0 var(--space-2); color: var(--ink-3); font-size: var(--fs-caption);
}
#food-review-modal .manual-draft-kept.hidden { display: none; }
#food-review-modal .manual-draft-kept .manual-draft-clear { flex: 0 0 auto; min-height: 44px; color: var(--ink); font-weight: var(--fw-semibold); }
/* A portion over 2,000 g or 3,000 kcal: one line above Add, red ink. */
#food-review-modal .review-commit-bar .review-portion-warning {
  margin: 0 0 var(--space-2); color: var(--danger); font-size: var(--fs-label); font-weight: var(--fw-semibold); line-height: 1.35;
}
/* The food row's "…" is the workout ⋯: the same three-dot icon, size and
   ink, on the same 44px target (it was a small pale text ellipsis). The
   selector must outrank "#nutrition-panel .food-entry > .mini-actions button". */
#nutrition-panel .food-entry > .mini-actions > button.entry-actions-toggle {
  display: grid; place-items: center; width: var(--tap); min-width: var(--tap);
  padding: 0; color: var(--ink-2); letter-spacing: 0; /* height: the panel's 44px (48px wide tier) control rules */
}
#nutrition-panel .food-entry > .mini-actions > button.entry-actions-toggle svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
#nutrition-panel .food-entry > .mini-actions > button.entry-actions-toggle:active,
#nutrition-panel .food-entry > .mini-actions > button.entry-actions-toggle[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
/* ---------- end S53 ---------- */
