/* ===========================================================================
   ForkMath — design system
   ---------------------------------------------------------------------------
   1. Tokens (palette · type · spacing · elevation · motion)
   2. Base & typography
   3. Buttons & inputs
   4. Login screen
   5. App shell (appbar · views · tabbar)
   6. Cards & dashboard hero
   7. Lists
   8. Segmented controls, search & misc components
   9. Modal & toast
   10. Trends, recipes, pantry, household, admin
   11. Motion & accessibility
   =========================================================================== */

/* Display face for hero numerals and big stats — self-hosted (offline PWA,
   no CDNs); SIL OFL license alongside in static/fonts/. Body text stays on
   the system stack: -apple-system already resolves SF Pro natively on every
   Apple device — never ship an SF Pro binary (Apple license, no redistribution). */
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/SpaceGrotesk.var.woff2") format("woff2-variations");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* palette — layered cool neutrals + a calm clinical emerald */
  --bg: #0b0e13;
  --surface: #14181f;
  --surface-2: #1b212a;
  --surface-3: #232b36;
  --input-bg: #10141b;
  --line: rgba(151, 168, 187, 0.11);          /* hairline borders */
  --line-strong: rgba(151, 168, 187, 0.22);
  --ring-track: #232b35;

  --text: #eef2f6;
  --text-2: #b9c4cf;
  --muted: #8694a3;

  --accent: #3ecf8e;                           /* brand emerald */
  --accent-2: #2bb673;                         /* deep end of the gradient */
  --accent-bright: #45d795;                    /* light end of the gradient */
  --accent-dim: rgba(62, 207, 142, 0.13);      /* translucent tint */
  --accent-line: rgba(62, 207, 142, 0.25);     /* emerald hairline */
  --on-accent: #07271a;

  /* macros — one family: matched saturation/lightness */
  --protein: #6aa9ff;
  --carbs: #f5b952;
  --fat: #ef8bbd;

  --danger: #f2545b;
  --danger-dim: rgba(242, 84, 91, 0.12);
  --warn: #e7c66b;
  --warn-dim: rgba(231, 198, 107, 0.12);
  --warn-ink: #e8dcb8;
  --bad: #fca5a5;                              /* trending the wrong way */

  /* water */
  --water: #5fb6ff;
  --water-2: #8fd0ff;

  /* gradients & glows (the "evolution" layer from the design handoff) */
  --grad-primary: linear-gradient(180deg, var(--accent-bright), var(--accent-2));
  --grad-hero: radial-gradient(130% 90% at 50% -10%, rgba(62, 207, 142, 0.08), transparent 55%),
               linear-gradient(165deg, #181f27, #12161d);
  --grad-water: linear-gradient(90deg, var(--water), var(--water-2));
  --grad-coach: radial-gradient(130% 100% at 100% 0%, rgba(106, 169, 255, 0.10), transparent 55%);
  --grad-recomp: radial-gradient(120% 100% at 0% 0%, rgba(62, 207, 142, 0.12), transparent 60%);
  --glow-accent: 0 2px 12px rgba(62, 207, 142, 0.22);
  --glow-ring: drop-shadow(0 4px 14px rgba(43, 201, 138, 0.14));

  /* chart language */
  --chart-projection: rgba(62, 207, 142, 0.55);

  /* type */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, sans-serif;

  /* radius scale */
  --radius: 18px;        /* cards, modals */
  --radius-sm: 13px;     /* rows, inputs */
  --radius-xs: 9px;      /* small buttons, badges */

  /* elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 16px 40px -12px rgba(0, 0, 0, 0.55);
  --focus-ring: 0 0 0 3px rgba(62, 207, 142, 0.28);

  /* motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1); /* gentle spring */
  --t-fast: 0.16s;
  --t-med: 0.3s;

  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Accessibility: device-local text-size multiplier (set from the Text size
     control; applied to the base font + the few fixed-px text rules below).
     Default 1 = the standard look. */
  --text-scale: 1;
}

/* --- 2. base & typography ------------------------------------------------ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: calc(16px * var(--text-scale, 1));
  line-height: 1.45;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;        /* no double-tap zoom; keeps scroll/tap */
  -webkit-text-size-adjust: 100%;    /* don't auto-resize text */
  accent-color: var(--accent);
}
::selection { background: var(--accent-dim); }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85em; }

/* numbers line up in stats, logs and tables */
.chip-val, .tstat-val, .astat-val, .big-kcal, .item .kcal,
#diary-totals, .cal-sub { font-variant-numeric: tabular-nums; }

/* headings: big friendly titles in modals/login, quiet editorial
   uppercase section headers inside views */
h1 { font-size: 1.7em; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.3em; font-weight: 800; letter-spacing: -0.015em; }
h3 { margin: 18px 0 10px; font-size: 1.18em; font-weight: 800; letter-spacing: -0.01em; }
.view h3 {
  margin: 28px 0 12px;
  font-size: 0.74em; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
}
.view h3:first-child { margin-top: 6px; }
h4 {
  margin: 22px 0 10px;
  font-size: 0.7em; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
}

/* thin scrollbars on desktop */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px;
  border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* --- 3. buttons & inputs -------------------------------------------------- */

button {
  font: inherit; cursor: pointer; border: none; border-radius: var(--radius-xs);
  transition: transform var(--t-fast) ease, background var(--t-fast) ease,
              color var(--t-fast) ease, border-color var(--t-fast) ease,
              box-shadow var(--t-fast) ease, opacity var(--t-fast) ease;
}
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.primary {
  background: var(--grad-primary);
  color: var(--on-accent); font-weight: 700; letter-spacing: 0.01em;
  padding: 13px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--glow-accent), var(--shadow-1);
}
.primary:active { filter: brightness(0.94); }
.ghost { background: transparent; color: var(--accent); padding: 10px; font-weight: 600; }
.full { width: 100%; }
.icon-btn {
  background: var(--surface-2); color: var(--text); width: 40px; height: 40px;
  font-size: 18px; border: 1px solid var(--line); border-radius: var(--radius-sm);
}

input, select {
  font: inherit; font-size: calc(16px * var(--text-scale, 1));  /* ≥16px: no iOS focus zoom (only scales up) */
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px 13px; width: 100%; min-width: 0; max-width: 100%;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); outline: none; box-shadow: var(--focus-ring);
}
input::placeholder, textarea::placeholder { color: rgba(134, 148, 163, 0.65); }
textarea {
  font: inherit; font-size: calc(16px * var(--text-scale, 1)); background: var(--input-bg); color: var(--text);
  min-height: 64px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 12px 13px; width: 100%;
  min-width: 0; resize: vertical;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}

/* Normalize text/number/date inputs so iOS native chrome can't overflow the
   container (selects keep their native dropdown arrow). */
input { -webkit-appearance: none; appearance: none; }
input[type="date"], input[type="time"], input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none; display: block;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; min-width: 0; }
input[type="date"]::-webkit-datetime-edit { padding: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { margin-left: auto; }
/* re-enable the native control for checkboxes (the global appearance:none above
   strips their checkmark); accent-color paints it brand emerald. */
input[type="checkbox"] {
  -webkit-appearance: auto; appearance: auto; accent-color: var(--accent);
  width: 20px; height: 20px; padding: 0; flex-shrink: 0;
}
select { text-overflow: ellipsis; }

/* form labels: quiet uppercase captions; controls inside stay normal-case */
label {
  display: flex; flex-direction: column; gap: 7px;
  font-size: 0.72em; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 13px;
}
label input, label select, label textarea {
  color: var(--text); text-transform: none; letter-spacing: normal; font-weight: 400;
}
label .muted { text-transform: none; letter-spacing: normal; font-weight: 500; }
.row { display: flex; gap: 12px; min-width: 0; }
.row label { flex: 1; min-width: 0; }

/* --- 4. login -------------------------------------------------------------- */

.screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 28px 22px; gap: 18px;
}
#login {
  background:
    radial-gradient(90% 45% at 50% -5%, rgba(62, 207, 142, 0.09), transparent 70%),
    var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 24px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-2);
  animation: rise var(--t-med) var(--ease-out) both;
}
.login-card h1 { margin: 0; font-size: 1.5em; }

/* --- auth (login / register) cards --- */
.auth-card { display: flex; flex-direction: column; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-logo { font-size: 1.7em; }
.auth-sub { color: var(--muted); margin: 8px 0 18px; font-size: 0.92em; }
.auth-card label {
  display: block; margin: 0 0 6px; font-size: 0.72em; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}
.auth-card > input, .pw-field { margin-bottom: 14px; }
.auth-card .row { gap: 12px; margin-bottom: 0; }
.auth-card .pw-col { flex: 1; min-width: 0; }
.auth-card .primary.full { margin-top: 6px; }
.auth-card .hh-onboard { margin-top: 4px; }
/* password field with show/hide eye */
.pw-field { position: relative; }
.pw-field input { width: 100%; padding-right: 46px; margin-bottom: 0; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; padding: 8px; font-size: 1.05em;
  line-height: 1; opacity: 0.5; cursor: pointer; border-radius: var(--radius-xs);
}
.pw-toggle.on { opacity: 1; }
.auth-error {
  background: var(--danger-dim); border: 1px solid rgba(242, 84, 91, 0.3);
  color: #ffd7d9; font-size: 0.86em; line-height: 1.4;
  border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 16px;
}
.auth-switch { text-align: center; color: var(--muted); font-size: 0.9em; margin: 16px 0 0; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-switch a:active { opacity: 0.7; }

/* --- 5. app shell ----------------------------------------------------------- */

main { max-width: 640px; margin: 0 auto; padding-bottom: calc(86px + var(--safe-bottom)); }
.appbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
  gap: 10px; padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(11, 14, 19, 0.82);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}
.appbar #user-name { font-weight: 700; letter-spacing: -0.01em; }
.appbar #logout-btn {
  margin-left: auto; flex: none;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 0.85em; font-weight: 600; letter-spacing: -0.01em;
}
.appbar #logout-btn:active { background: var(--line); color: var(--text); }
.view { padding: 18px 18px 30px; animation: viewIn var(--t-med) var(--ease-out) both; }

/* --- tabbar: translucent, iOS-like ---------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: rgba(17, 21, 27, 0.86);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid var(--line);
  max-width: 640px; margin: 0 auto;
  padding: 4px 2px 0; padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1; background: transparent; color: var(--muted); padding: 8px 0 8px;
  font-size: 19px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: 0; transition: color var(--t-fast) ease, transform var(--t-fast) ease;
}
.tab span { font-size: calc(10px * var(--text-scale, 1)); font-weight: 600; letter-spacing: 0.02em; }
.tab.active { color: var(--accent); transform: translateY(-1px); }
.tab:active { transform: scale(0.94); }

/* --- 6. cards & dashboard -------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-1);
}
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.metric .label { color: var(--muted); font-size: 0.78em; text-transform: uppercase; letter-spacing: .04em; }
.metric .value { font-size: 1.7em; font-weight: 800; margin-top: 4px; }
.metric .sub { color: var(--muted); font-size: 0.8em; }
.metric.wide { grid-column: 1 / -1; }

.hero {
  background: var(--grad-hero);
  padding: 22px 18px 18px;
}
.cal-hero { display: flex; flex-direction: column; align-items: center; }
.cal-ring { width: 178px; height: 178px; filter: var(--glow-ring); }
.cal-ring .prog { transition: stroke-dashoffset 1.1s var(--ease-out); }
.cal-sub { color: var(--muted); font-size: 0.85em; margin-top: 6px; }
.macro-bars { margin-top: 20px; display: flex; flex-direction: column; gap: 15px; }
.mrow-top { display: flex; justify-content: space-between; font-size: 0.85em; font-weight: 600; }
.mrow-top .mover { color: var(--danger); }
.mtrack { height: 7px; background: var(--ring-track); border-radius: 5px; overflow: hidden; margin: 7px 0 3px; }
.mfill { height: 100%; width: 0; border-radius: 5px; transition: width 0.9s var(--ease-out); }
.mrow-sub { font-size: 0.72em; color: var(--muted); font-variant-numeric: tabular-nums; }
.warn-note { font-size: 0.8em; margin: -4px 2px 14px; }

/* water card */
.water-card { padding: 16px; }
.water-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 10px; }
.water-ttl { display: inline-flex; align-items: center; gap: 7px; color: var(--water); }
.water-head .muted { font-variant-numeric: tabular-nums; }
.water-track { height: 9px; background: var(--ring-track); border-radius: 6px; overflow: hidden; }
.water-fill { height: 100%; width: 0; border-radius: 6px;
  background: var(--grad-water); transition: width 0.7s var(--ease-out); }
.water-chips { display: flex; gap: 8px; margin-top: 12px; }
.water-chip { flex: 1; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--protein); font-weight: 700; font-size: 0.86em; padding: 10px 4px; border-radius: var(--radius-sm); }
.water-chip.minus { flex: 0 0 44px; color: var(--muted); }
.water-chip:active { background: var(--surface-3); }
.eatback-note { color: var(--accent); font-size: 0.82em; font-weight: 600; margin-top: 4px; }
.copy-day-btn { background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px; margin-top: 4px; }
.inline-toggle { flex-direction: row; align-items: center; gap: 11px; text-transform: none;
  letter-spacing: normal; font-weight: 500; font-size: 0.92em; color: var(--text); }
.inline-toggle input { width: auto; }

/* metric tiles (streak / adaptive TDEE) */
.tiles { display: flex; gap: 12px; margin-bottom: 14px; }
.tile { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-1); }
.tile .label { color: var(--muted); font-size: 0.78em; text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600; }
.tile .value { font-family: var(--font-display); font-size: 1.55em; font-weight: 700;
  margin-top: 4px; letter-spacing: -0.015em; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value.accent { color: var(--accent); }
.tile .sub { color: var(--muted); font-size: 0.8em; }

/* calm reframing note (e.g. over-budget day) */
.card.note-card { padding: 13px 15px; font-size: 0.9em; color: var(--text-2); line-height: 1.5; }
.card.note-card b { color: var(--text); }
.note-card.measure-due { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.note-card.measure-due button { flex: none; }
.logweight-card { padding: 14px; }
.logweight-input {
  width: 100%; font-size: 1.4em; text-align: center; padding: 14px;
  margin-bottom: 12px; font-variant-numeric: tabular-nums;
}
.form-sep { border: none; border-top: 1px solid var(--line); margin: 16px 0 4px; }

/* hero CTA when nothing is logged yet */
.ring-note { text-align: center; color: var(--text-2); font-size: 0.9em; margin: 10px 0 14px; }
.ring-exercise { color: var(--accent); font-size: 0.82em; font-weight: 600; margin-top: 4px; }

/* chart captions (goal ETA lines under charts) */
.chart-caption { font-size: 0.82em; color: var(--muted); margin-top: 10px; font-weight: 600; line-height: 1.5; }
.chart-caption .good { color: var(--accent); }

/* first-run checklist rows (trends empty state) */
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 0;
  color: var(--muted); font-size: 0.95em; font-weight: 600; }
.check-row.done { color: var(--text); }
.check-row .dot { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center; border: 1px dashed var(--line-strong); color: var(--muted); }
.check-row.done .dot { background: var(--accent-dim); border: 1px solid var(--accent-line); color: var(--accent); }

/* stamped Lucide icons inherit currentColor */
[data-icon] { display: inline-flex; flex-shrink: 0; vertical-align: middle; }

/* stat chips */
.chips { display: flex; gap: 12px; margin-bottom: 16px; }
.chip {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 6px 12px; text-align: center; min-width: 0;
  box-shadow: var(--shadow-1);
}
.chip-ico { font-size: 17px; color: var(--muted); display: flex; justify-content: center; }
.chip-val { font-family: var(--font-display); font-size: 1.22em; font-weight: 700; margin-top: 4px; white-space: nowrap; letter-spacing: -0.01em; }
.chip-lab { font-size: 0.64em; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 4px; }

/* weight sparkline */
.spark-card { padding: 16px 14px 14px; }
.spark-head { display: flex; justify-content: space-between; font-size: 0.88em; font-weight: 700; margin-bottom: 8px; }
.spark { width: 100%; }
.spark-svg { width: 100%; height: 56px; display: block; }
.spark-goal { font-size: 0.82em; color: var(--muted); margin-top: 10px; font-weight: 600; }

/* trend direction colors (losing = good = green) */
.down { color: var(--accent); font-weight: 700; }
.up { color: var(--bad); font-weight: 700; }
.flat { color: var(--muted); font-weight: 700; }

/* --- banner ----------------------------------------------------------------- */
.banner {
  background: var(--accent-dim); border: 1px solid rgba(62, 207, 142, 0.25);
  color: var(--text); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px;
  font-size: 0.92em;
}
.banner button { background: var(--accent); color: var(--on-accent); padding: 8px 14px; font-weight: 700; margin-left: auto; border-radius: var(--radius-xs); }

/* --- 7. lists ---------------------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 9px; }
.item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px;
  display: flex; align-items: center; gap: 13px;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease,
              transform var(--t-fast) ease;
  animation: itemIn 0.34s var(--ease-out) both;
}
.item:active { background: var(--surface-2); }
/* staggered entrance — quick, capped so long lists don't crawl */
.item:nth-child(2) { animation-delay: 0.03s; }
.item:nth-child(3) { animation-delay: 0.06s; }
.item:nth-child(4) { animation-delay: 0.09s; }
.item:nth-child(5) { animation-delay: 0.12s; }
.item:nth-child(6) { animation-delay: 0.15s; }
.item:nth-child(7) { animation-delay: 0.18s; }
.item:nth-child(n+8) { animation-delay: 0.2s; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { color: var(--muted); font-size: 0.78em; margin-top: 1px; }
.item .kcal { font-weight: 700; white-space: nowrap; }
.item .src {
  font-size: 0.62em; font-weight: 700; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.item button.add {
  background: var(--accent-dim); color: var(--accent); width: 36px; height: 36px;
  font-size: 19px; border-radius: 10px; border: 1px solid rgba(62, 207, 142, 0.25);
  flex-shrink: 0;
}
.item button.add:active { background: var(--accent); color: var(--on-accent); }
.item button.del { background: transparent; color: var(--danger); font-size: 17px; opacity: 0.85; }

/* --- 8. segmented controls, search & misc ----------------------------------- */

.seg {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 4px;
}
.seg-btn {
  flex: 1; background: transparent; color: var(--muted); padding: 9px 4px;
  font-size: 0.85em; font-weight: 600; border-radius: var(--radius-xs);
}
.seg-btn.active {
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  box-shadow: 0 2px 8px rgba(62, 207, 142, 0.25);
}
.date-nav { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.date-nav input { text-align: center; }

.search-row { display: flex; gap: 9px; margin-bottom: 14px; }
.quick-add { display: flex; gap: 9px; margin-bottom: 10px; }
.quick-add button {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--accent); font-size: 0.9em; font-weight: 600; padding: 12px 6px;
  border-radius: var(--radius-sm);
}
.suggest-btn {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px;
}
.sug-name { font-weight: 700; font-size: 1.08em; margin-bottom: 4px; letter-spacing: -0.01em; }
.sug-items { margin: 6px 0 10px; padding-left: 20px; line-height: 1.65; font-size: 0.9em; }
.sug-prep {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; margin: 2px 0 10px;
  font-size: 0.9em; line-height: 1.55; color: var(--text-2);
}
.cf-hint { margin: 2px 0 12px; font-size: 0.8em; }
.conf {
  display: inline-block; font-size: 0.74em; font-weight: 700; padding: 4px 11px;
  border-radius: 999px; margin: 4px 0 10px; letter-spacing: 0.03em;
}
.conf-high { background: var(--accent-dim); color: var(--accent); }
.conf-medium { background: var(--warn-dim); color: var(--warn); }
.conf-low { background: var(--danger-dim); color: var(--bad); }
.search-note {
  background: var(--warn-dim); border: 1px solid rgba(231, 198, 107, 0.25);
  border-left: 3px solid var(--warn); color: var(--warn-ink);
  font-size: 0.8em; line-height: 1.5; border-radius: var(--radius-xs);
  padding: 10px 12px; margin-bottom: 12px;
}

/* --- meal groups ------------------------------------------------------------ */
.meal-group { margin-bottom: 20px; }
.meal-group h4 { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 9px; }
.meal-head-right { display: flex; align-items: center; gap: 9px; font-variant-numeric: tabular-nums; }
.copy-meal {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--accent);
  width: 30px; height: 28px; border-radius: var(--radius-xs); font-size: 14px;
}
.copy-empty {
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  color: var(--muted); width: 100%; font-size: 0.88em; margin-top: 2px;
  padding: 12px; border-radius: var(--radius-sm);
}

/* --- charts ------------------------------------------------------------------ */
.chart { background: var(--surface); border-radius: var(--radius); padding: 10px; }
.chart svg { width: 100%; height: 160px; display: block; }

/* --- 9. modal & toast --------------------------------------------------------- */

.modal {
  position: fixed; left: 0; right: 0; top: 0; height: 100%;
  background: rgba(4, 6, 9, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.22s ease both;
}
.modal-body {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-bottom: none;
  width: 100%; max-width: 640px; min-width: 0;
  max-height: calc(100% - env(safe-area-inset-top, 0px) - 10px);
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  border-radius: 22px 22px 0 0;
  padding: 26px 20px; padding-bottom: calc(22px + var(--safe-bottom));
  box-shadow: var(--shadow-2);
  animation: sheetUp 0.34s var(--ease-out) both;
}
/* sheet grab-handle */
.modal-body::before {
  content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
  width: 38px; height: 4px; border-radius: 99px;
  background: var(--line-strong);
}
/* Lock the page behind an open modal so it doesn't scroll/jitter on iOS. */
body.modal-open { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }

/* --- AI "thinking" overlay -------------------------------------------------
   While Claude generates, the whole app blurs behind a crisp spinning wheel.
   backdrop-filter blurs only what's BEHIND the layer, so the spinner and label
   (children of the overlay) stay perfectly sharp. Sits above modals (50). */
.ai-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center;
  background: rgba(5, 7, 10, 0.45);
  -webkit-backdrop-filter: blur(14px) saturate(0.85);
  backdrop-filter: blur(14px) saturate(0.85);
  opacity: 0; transition: opacity 0.22s ease;
}
.ai-overlay.show { opacity: 1; }
.ai-spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: ai-spin 0.8s linear infinite;
  filter: drop-shadow(0 0 14px rgba(62, 207, 142, 0.35));
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-overlay-label {
  color: var(--text); font-weight: 650; font-size: 0.98em;
  letter-spacing: -0.01em; max-width: 300px; line-height: 1.45;
}
@media (prefers-reduced-motion: reduce) {
  .ai-spinner { animation-duration: 2s; }
  .ai-overlay { transition: none; }
}
.modal-body h3 { margin-top: 0; }
/* Universal close button: a zero-height sticky bar keeps the ✕ pinned to the
   top-right of the sheet (visible even while the content scrolls) without
   pushing the content down. */
.modal-toolbar { position: sticky; top: 0; z-index: 3; height: 0; display: flex;
  justify-content: flex-end; pointer-events: none; }
.modal-close {
  pointer-events: auto; background: var(--surface-3); color: var(--text-2);
  width: 32px; height: 32px; border-radius: 50%; font-size: 14px; line-height: 1;
  transform: translateY(-8px); box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
}
.modal-close:active { transform: translateY(-8px) scale(0.92); }
/* keep titles clear of the close button */
.modal-body > h3, .modal-head { padding-right: 36px; }

/* centered dialog on bigger screens */
@media (min-width: 700px) {
  .modal { align-items: center; padding: 28px; }
  .modal-body { border-radius: 22px; border-bottom: 1px solid var(--line); max-height: 86vh; }
}

.toast {
  position: fixed; bottom: calc(92px + var(--safe-bottom)); left: 50%;
  background: var(--accent); color: var(--on-accent); padding: 11px 20px;
  border-radius: 999px; font-weight: 700; font-size: 0.92em;
  z-index: 60; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.3s var(--ease-out) both;
}
.toast { display: flex; align-items: center; gap: 12px; }
.toast-action {
  background: rgba(0, 0, 0, 0.22); color: inherit; font-weight: 800;
  padding: 5px 12px; border-radius: 999px; font-size: 0.95em; margin: -2px -6px -2px 0;
}
.toast-action:active { background: rgba(0, 0, 0, 0.34); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.95); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
/* the dialog takes focus on open but shouldn't show a focus ring itself */
.modal-body:focus { outline: none; }

/* --- onboarding checklist (dashboard empty state) --- */
.ob-title { margin: 0 0 4px; }
.ob-steps { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.ob-step {
  display: flex; align-items: center; gap: 13px; text-align: left; width: 100%;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 14px; color: var(--text);
}
.ob-step:active { background: var(--surface-3); }
.ob-check {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 0.9em;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--line);
}
.ob-step.done .ob-check { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.ob-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ob-step-label { font-weight: 600; }
.ob-step.done .ob-step-label { color: var(--muted); text-decoration: line-through; }

/* --- onboarding wizard ------------------------------------------------------ */
.ob-progress {
  font-size: 0.7em; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted); margin-bottom: 6px;
}
.ob-panel h3 { margin: 0 0 6px; }
.ob-panel .seg { margin: 8px 0 4px; }
.choice-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 14px; cursor: pointer;
  color: var(--text); font: inherit;
}
.choice-card.active {
  border-color: var(--accent); background: var(--accent-dim);
}
.goal-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip-btn {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: 0.9em; font-weight: 600;
}
.chip-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.wizard-foot { display: flex; gap: 10px; margin-top: 16px; }
.wizard-foot .ob-back { flex: 0 0 auto; }
.wizard-foot .ob-next { flex: 1; }
.skip-link {
  display: block; width: 100%; background: none; border: none; cursor: pointer;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  font: inherit; font-size: 0.85em; margin-top: 12px; text-align: center;
  line-height: 1.5;
}
.date-reveal { text-align: left; margin: 6px 0 2px; }
.form-hint { margin: -4px 0 14px; }

/* download/restore buttons (anchors styled like tonal buttons) */
.dl-btn {
  flex: 1; min-width: 30%; text-align: center; text-decoration: none;
  background: var(--surface-2); color: var(--accent); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 8px; font-weight: 600; font-size: 0.92em;
  display: inline-flex; align-items: center; justify-content: center;
}
.dl-btn:active { background: var(--surface-3); }
.dl-btn.full { width: 100%; margin-top: 4px; }
.action-row .ghost#import-btn { background: var(--surface-2); border: 1px solid var(--line); }
#scanner-video { width: 100%; max-height: 48vh; object-fit: cover; border-radius: var(--radius-sm);
  background: #000; margin-bottom: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.74em; font-weight: 700; letter-spacing: 0.03em; }
.pos { background: var(--accent-dim); color: var(--accent); }
.neg { background: var(--danger-dim); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.warn { background: rgba(245, 158, 11, 0.14); color: var(--warn); }

/* --- account / public-auth bits ------------------------------------------- */
.tos-row { margin: 4px 0 14px; }
.tos-row a { color: var(--accent); }
.ob-household {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; font-size: 0.92em;
}

/* --- onboarding education: spotlight tour · getting-started · help ----------- */
/* Spotlight tour: a dim layer with a mask cutout, a ring, and a copy bubble. */
.tour-layer { position: fixed; inset: 0; z-index: 48; pointer-events: none; }
.tour-catch { position: fixed; inset: 0; pointer-events: auto; }   /* absorbs stray taps */
.tour-mask { position: fixed; inset: 0; width: 100%; height: 100%; }
.tour-dim { fill: rgba(4, 6, 9, 0.66); }
.tour-ring {
  position: fixed; border: 2px solid var(--accent); border-radius: 14px;
  box-shadow: 0 0 0 4px var(--accent-dim); pointer-events: none;
}
.tour-bubble {
  position: fixed; pointer-events: auto; max-width: min(360px, 92vw);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-2);
}
.tour-count {
  font-size: 0.72em; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.tour-copy { margin: 0 0 14px; line-height: 1.5; }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.tour-foot .tour-skip { margin-right: auto; color: var(--muted); }
.tour-foot .tour-next { padding: 9px 18px; }
@media (prefers-reduced-motion: no-preference) {
  .tour-ring { transition: left 0.18s var(--ease-out), top 0.18s var(--ease-out),
    width 0.18s var(--ease-out), height 0.18s var(--ease-out); }
  .tour-bubble { transition: left 0.18s var(--ease-out), top 0.18s var(--ease-out); }
}

/* "?" help button in the appbar. */
.appbar-help {
  background: var(--surface-2); color: var(--text); width: 30px; height: 30px;
  border-radius: 999px; border: 1px solid var(--line); font-weight: 700;
  font-size: 0.95em; line-height: 1; flex: 0 0 auto;
}
.appbar-help:active { background: var(--surface-3); }

/* Getting-started checklist card (reuses .ob-steps for the rows). */
.gs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.gs-title { font-weight: 700; }
.gs-progress { margin-left: auto; }
.gs-dismiss { color: var(--muted); padding: 4px 8px; }
.gs-intro { margin: 2px 0 6px; }
.gs-grouplabel {
  font-size: 0.7em; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px;
}

/* Teaching empty states. */
.empty-teach { text-align: center; padding: 22px 16px; }
.empty-teach .et-emoji { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.empty-teach .et-title { font-weight: 700; margin-bottom: 4px; }
.empty-teach .et-body { margin: 0 auto 14px; max-width: 30ch; }

/* Help sheet. */
.help-sheet h3 { margin-top: 0; }
.help-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.help-row .help-ico { font-size: 22px; line-height: 1; flex: 0 0 auto; width: 26px; text-align: center; }
.help-row .help-rt { flex: 1 1 auto; min-width: 0; }
.help-row .help-name { font-weight: 600; }
.help-row .ghost.small { flex: 0 0 auto; }
.danger-card { border-color: rgba(242, 84, 91, 0.35); }
.danger-card .ghost.danger, .ghost.danger.full { color: var(--danger); }
.danger-btn { background: var(--danger); }
#email-banner { margin-bottom: 12px; }

/* --- 10a. recipes -------------------------------------------------------------- */

.macrobar {
  display: flex; height: 7px; border-radius: 5px; overflow: hidden;
  background: var(--ring-track); margin: 9px 0 7px;
}
/* .macrobar children reuse the "seg" classname — neutralise the segmented
   control container styles inside the bar */
.macrobar .seg { padding: 0; margin: 0; gap: 0; border: none; border-radius: 0; background: transparent; display: block; }
.macrobar .seg.p { background: var(--protein); }
.macrobar .seg.c { background: var(--carbs); }
.macrobar .seg.f { background: var(--fat); }
.macro-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.78em; font-weight: 600; font-variant-numeric: tabular-nums; }
.macro-legend .p { color: var(--protein); }
.macro-legend .c { color: var(--carbs); }
.macro-legend .f { color: var(--fat); }
.notes-text { white-space: pre-wrap; line-height: 1.6; }
.big-kcal { font-family: var(--font-display); font-size: 1.45em; font-weight: 700; letter-spacing: -0.015em; }
.big-kcal .muted { font-size: 0.58em; font-weight: 600; }
.recipe-card .grow { cursor: pointer; }
.recipe-owner { margin: -4px 0 12px; font-size: 0.8em; }
.recipe-filter { margin-bottom: 12px; }
.card.preview { background: var(--surface-2); border-color: var(--line); }

/* modal header with a back button */
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.modal-head h3 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost.back { padding: 6px 9px; }

/* action row in recipe detail */
.action-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.action-row button { flex: 1; min-width: 30%; padding: 12px 8px; border-radius: var(--radius-sm); }
.action-row .ghost { background: var(--surface-2); border: 1px solid var(--line); }
.action-row .ghost.danger { color: var(--danger); }

/* --- 10b. household onboarding (new-profile form) ------------------------------ */
.hh-onboard { border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 14px 14px 6px; margin: 0 0 14px; }
.hh-onboard legend {
  color: var(--muted); font-size: 0.72em; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; padding: 0 7px;
}
.hh-onboard p { margin: 0 0 12px; text-transform: none; letter-spacing: normal; }

/* --- 10c. pantry ---------------------------------------------------------------- */
.pantry-top { display: flex; align-items: baseline; gap: 10px; }
.pantry-top h3 { margin: 0; }
.ghost.small { padding: 6px 11px; font-size: 0.85em; }
.clear-pantry { margin: 6px 0 14px; }
.pantry-toggle {
  flex-direction: row; align-items: center; gap: 11px; font-size: 0.92em;
  color: var(--text); text-transform: none; letter-spacing: normal; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px; margin: 4px 0 14px;
}
.pantry-toggle input { width: auto; min-width: 0; }
.sug-missing { color: var(--warn); }

/* --- 10d. grocery list ------------------------------------------------------------ */
.grocery-list { margin-bottom: 6px; }
.grocery-hint { font-size: 0.78em; margin: 14px 0 0; }
.grocery-who { margin: -2px 0 10px; }

/* --- 10e. household management (Me) ------------------------------------------------ */
.hh-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 6px; }
.hh-name { font-weight: 700; font-size: 1.1em; letter-spacing: -0.01em; }
.hh-code { font-size: 0.85em; color: var(--muted); }
.hh-code b { color: var(--accent); letter-spacing: 0.1em; font-size: 1.05em; }
.hh-members { margin-top: 10px; }

/* --- 10f. trends ------------------------------------------------------------------- */
.trend-range { margin-bottom: 16px; }
.trend-headline {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-size: 1.25em; font-weight: 700; letter-spacing: -0.015em; margin: 2px 2px 14px;
}
.trend-headline.good { color: var(--accent); }
.recomp-card { background: var(--grad-recomp), var(--surface); border-color: var(--accent-line); }
.recomp-title { font-weight: 800; margin-bottom: 4px; }

/* --- AI coach + diagnosis --- */
.coach-card { background: var(--grad-coach), var(--surface); }
.coach-head { font-weight: 800; letter-spacing: -0.01em; margin-bottom: 10px; }
.coach-summary { margin: 0 0 12px; line-height: 1.55; }
.coach-sec {
  font-size: 0.66em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  margin: 14px 0 4px;
}
.coach-win { color: var(--accent); }
.coach-watch { color: var(--warn); }
.coach-adjust { color: var(--protein); }
.coach-list { margin: 2px 0 4px; padding-left: 20px; line-height: 1.55; font-size: 0.92em; }
.coach-list li { margin-bottom: 4px; }
.coach-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 8px; }
.coach-foot-actions { display: flex; gap: 8px; flex-shrink: 0; }
.coach-foot-actions .ghost.small { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.coach-period { font-size: 0.78em; font-weight: 600; margin-bottom: 8px; }
.coach-archive { margin-top: 4px; }
.coach-archive-det { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 8px; }
.coach-archive-det summary {
  cursor: pointer; font-size: 0.82em; font-weight: 600; color: var(--muted);
  padding: 4px 0; list-style: none;
}
.coach-archive-det summary::-webkit-details-marker { display: none; }
.coach-archive-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  text-align: left; padding: 10px 2px; border: none; border-top: 1px solid var(--line);
  background: none; font-size: 0.9em; cursor: pointer;
}
.diag-btn { margin: 4px 0 16px; }
.diag-cached { font-size: 0.82em; margin: 2px 0 10px; }
.diag-verdict { font-weight: 700; font-size: 1.05em; line-height: 1.45; margin: 4px 0 4px; }
.diag-cause { background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 13px; margin-bottom: 8px; }
.diag-cause-title { font-weight: 700; margin-bottom: 3px; }
.diag-next {
  background: var(--accent-dim); border: 1px solid rgba(62, 207, 142, 0.25);
  border-radius: var(--radius-sm); padding: 13px; line-height: 1.5;
}
.trend-card { animation: rise 0.35s var(--ease-out) both; }
.trend-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.01em; }
.trend-head .muted { font-size: 0.68em; font-weight: 600; }
.trend-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 10px; margin-bottom: 14px; }
.tstat { min-width: 0; }
.tstat-val { font-family: var(--font-display); font-size: 1.12em; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tstat-val.down { color: var(--accent); }
.tstat-val.up { color: var(--bad); }
.tstat-lab { font-size: 0.62em; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 3px; }
.tchart { width: 100%; }
.tsvg { width: 100%; height: 150px; display: block; }
.trend-empty { padding: 12px 4px; line-height: 1.55; }
.trend-cap { font-size: 0.7em; margin-top: 8px; }
.trend-sub { font-size: 0.68em; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 14px 0 7px; }

/* --- 10g. admin dashboard ------------------------------------------------------------ */
.admin-entry { margin-top: 12px; opacity: 0.6; font-size: 0.85em; }

/* Text-size control: A−/A+ stepper on the auth screen + a select in Me. The
   stepper is sized in fixed px (not em) so the control itself never balloons
   with the very setting it adjusts. */
.text-size-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 18px; color: var(--muted); font-size: 14px;
}
.text-size-bar button {
  width: 48px; height: 48px; flex: none; font-size: 19px; font-weight: 700;
  line-height: 1; white-space: nowrap; padding: 0;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.text-size-bar button:active { background: var(--line); }
.text-scale-row { margin-top: 12px; }
.text-scale-row select { width: auto; min-width: 9em; }
.admin-screen { justify-content: flex-start; align-items: stretch; padding: 0; gap: 0; }
.admin-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(11, 14, 19, 0.82);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}
.admin-title { font-weight: 800; font-size: 1.1em; flex: 1; letter-spacing: -0.01em; }
.admin-bar .small { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.admin-nav { margin: 14px auto 0; width: calc(100% - 36px); max-width: 640px; }
.admin-screen .seg-btn { font-size: 0.82em; }
#admin-content { padding: 12px 18px calc(44px + var(--safe-bottom)); max-width: 640px;
  margin: 0 auto; width: 100%; }
.admin-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.astat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-1); }
.astat-val { font-family: var(--font-display); font-size: 1.6em; font-weight: 700; letter-spacing: -0.015em; }
.astat-lab { font-size: 0.64em; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 4px; }
.admin-line { font-size: 0.86em; color: var(--muted); padding: 4px 0; }
.admin-list { margin-top: 14px; }
.admin-badges { display: flex; align-items: center; gap: 6px; font-size: 0.8em; }
.admin-mini { display: flex; gap: 6px; }

/* --- 11. motion & accessibility -------------------------------------------------------- */

@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeUp {       /* kept for compatibility */
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp {
  from { opacity: 0.6; transform: translateY(36px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* admin waitlist (access requests) */
.wl-row { align-items: center; }
.wl-row .wl-meta { font-size: 0.82em; margin-top: 2px; }
.wl-row .wl-meta a { color: var(--accent); text-decoration: none; }
.wl-acts { display: flex; gap: 8px; flex-shrink: 0; }
.wl-acts .ghost.small { background: var(--surface-2); border: 1px solid var(--line); }
.wl-acts .ghost.small.danger { color: var(--danger); }
.wl-row.done { opacity: 0.55; }
.wl-row.done .title { text-decoration: line-through; }
