/* Gym & Health — design system (direction "D": A's layout, B's slate + amber).
   Tokens live on :root. Components below are shared by every view.
   Rule of thumb: amber = "you / now / do this"; green/amber/red only carry meaning
   (effort, pain), never decoration. */

:root {
  color-scheme: dark light;

  /* Surfaces (dark is the default) */
  --bg: #14181f;
  --surface: #1b212b;
  --raised: #262d39;
  --border: #3a4352;
  --done-bg: #231d10;

  /* Text */
  --text: #e6e9ef;
  --muted: #8d97a8;
  --faint: #5f6878;           /* decoration only (dots, rules) — not for text */

  /* Accent */
  --accent: #ffb020;          /* fills: buttons, ticks, side tags */
  --on-accent: #14181f;       /* text on an accent fill */
  --accent-text: #ffb020;     /* accent used as text on --bg/--surface */
  --accent-mark: #ffb020;     /* accent for chart marks (bars, lines): >= 3:1 on --surface */

  /* Meaning-only colours */
  --good: #3ecf8e;
  --warn: #ffb020;
  --bad: #ff5c5c;
  --good-bg: #13291f;
  --warn-bg: #2a2212;
  --bad-bg: #2e1719;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-num: 32px;             /* weight × reps */
  --fs-hero: 40px;

  /* Shape + space */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 16px;
  --r-pill: 999px;
  --tap: 48px;
  --tick: 56px;
  --gap: 8px;
  --pad: 16px;

  /* Safe areas (status bar is opaque "default", so no top inset is needed) */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --tabbar-h: 60px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Light theme — warm paper, amber kept for fills, darkened for text (AA). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f2ec;
    --surface: #fffdf9;
    --raised: #ece7dd;
    --border: #d6cfc2;
    --done-bg: #fbefd6;
    --text: #1a1f27;
    --muted: #5a6372;
    --faint: #9aa1ad;
    --accent-text: #985a00;
    --accent-mark: #c77d00;
    --good: #187a4c;
    --warn: #985a00;
    --bad: #b42a27;
    --good-bg: #e3f3ea;
    --warn-bg: #fbefd6;
    --bad-bg: #fbe4e2;
  }
}
:root[data-theme="light"] {
  --bg: #f5f2ec; --surface: #fffdf9; --raised: #ece7dd; --border: #d6cfc2; --done-bg: #fbefd6;
  --text: #1a1f27; --muted: #5a6372; --faint: #9aa1ad; --accent-text: #985a00; --accent-mark: #c77d00;
  --good: #187a4c; --warn: #985a00; --bad: #b42a27;
  --good-bg: #e3f3ea; --warn-bg: #fbefd6; --bad-bg: #fbe4e2;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }   /* decorative only; informational text uses --muted */
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Shell ---------- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--pad);
  background: var(--bg);
}
.topbar h1 { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.01em; }
.view {
  flex: 1;
  padding: 4px var(--pad) calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
body.no-tabs .view { padding-bottom: calc(var(--safe-bottom) + 24px); }
body.no-tabs .tabbar, body.no-tabs .topbar { display: none; }

/* Sync status: quiet unless something needs attention.
   The button is a 48px hit area; the visible pill (.sync-pill) stays small. */
.sync {
  display: inline-flex; align-items: center; justify-content: flex-end;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0; margin-right: -6px;
  border: 0; background: none;
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
}
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 8px; border-radius: var(--r-pill);
}
.sync-pill::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.sync[data-state="syncing"] .sync-pill::before { animation: pulse 1s var(--ease) infinite alternate; }
.sync[data-state="offline"] .sync-pill::before { background: none; box-shadow: inset 0 0 0 2px currentColor; }
.sync[data-state="error"] { color: var(--bad); }
.sync[data-state="error"] .sync-pill { background: var(--bad-bg); padding: 0 10px; min-height: 32px; }
@keyframes pulse { from { opacity: 1; } to { opacity: .3; } }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tabbar-h);
  color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent-text); }

/* ---------- Type helpers ---------- */
.eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.title { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -0.015em; }
.meta { font-size: var(--fs-sm); color: var(--muted); }
.cue { font-size: var(--fs-sm); color: var(--accent-text); }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px var(--pad);
}
.card + .card { margin-top: var(--gap); }
.card.raised { background: var(--raised); }
.stack > * + * { margin-top: var(--gap); }
.section { margin-top: 24px; }
.section > .eyebrow { margin-bottom: 8px; }

/* ---------- Set row (weight × reps + tick) ---------- */
.set-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 10px 10px 10px 12px;
  margin-bottom: var(--gap);
  outline: 2px solid transparent; outline-offset: -2px;
  transition: background-color .2s var(--ease);
}
.set-row .n { width: 22px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.set-row .v { flex: 1; font-size: var(--fs-num); font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.set-row .v small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.set-row.next { outline-color: var(--accent); }
.set-row.done { background: var(--done-bg); }

.tick {
  flex: none;
  width: var(--tick); height: var(--tick);
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  background: transparent;
  color: var(--border);
  font-size: 26px; font-weight: 800; line-height: 1;
  transition: background-color .15s var(--ease), transform .1s var(--ease);
}
.tick:active { transform: scale(.94); }
.tick[aria-pressed="true"], .set-row.done .tick {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}

/* ---------- Pills / side tag ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--raised); color: var(--muted);
  font-size: var(--fs-xs); font-weight: 700;
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.side {
  display: inline-block; vertical-align: middle;
  padding: 2px 8px; margin-left: 6px; border-radius: 6px;
  background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .04em;
}

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap);
  padding: 14px 18px;
  border: 0; border-radius: var(--r-lg);
  background: var(--raised); color: var(--text);
  font-size: 17px; font-weight: 700; text-decoration: none;
  transition: transform .1s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 800; min-height: 56px; }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }

/* Bottom-anchored primary action (sits above the tab bar). */
.action-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  margin: 16px calc(-1 * var(--pad)) 0;
  padding: 12px var(--pad);
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}
body.no-tabs .action-bar { bottom: var(--safe-bottom); }

/* Segmented choice (effort: Had more / About right / Maxed) */
.choices { display: flex; gap: 6px; }
.choices button {
  flex: 1; min-height: var(--tap); padding: 10px 4px;
  border: 2px solid transparent; border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: var(--fs-xs); font-weight: 700;
}
.choices button[aria-pressed="true"] { border-color: var(--accent); background: var(--done-bg); }
.choices .good[aria-pressed="true"] { border-color: var(--good); background: var(--good-bg); }
.choices .bad[aria-pressed="true"] { border-color: var(--bad); background: var(--bad-bg); }

/* ---------- Banner ---------- */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--raised); color: var(--text);
  font-size: 15px;
}
.banner strong { display: block; }
.banner.warn { background: var(--warn-bg); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.bad { background: var(--bad-bg); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 45%, transparent); }
.banner.good { background: var(--good-bg); }

/* ---------- Form fields ---------- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.input {
  width: 100%; min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font-size: 17px;               /* ≥16px stops iOS zooming on focus */
}
.input:focus { outline: none; border-color: var(--accent); }
.error-text { color: var(--bad); font-size: var(--fs-sm); font-weight: 600; min-height: 1.4em; margin-top: 12px; }

/* ---------- Slider (pain 0–10 etc.) ---------- */
.slider { width: 100%; height: var(--tap); margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.slider::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--raised); }
.slider::-moz-range-track { height: 8px; border-radius: 4px; background: var(--raised); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 32px; height: 32px; margin-top: -12px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--bg);
}
.slider::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); }
.slider-value { font-size: var(--fs-num); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Empty state ---------- */
.empty { padding: 40px 4px 0; }
.empty .title { margin: 6px 0 8px; }
.empty p { color: var(--muted); max-width: 34ch; }

/* ---------- Login ---------- */
.login {
  min-height: calc(100dvh - var(--safe-bottom) - 24px);
  display: flex; flex-direction: column;
  padding-top: 12vh;
}
.login .mark {
  width: 56px; height: 56px; border-radius: var(--r-md);
  background: var(--accent); display: grid; place-items: center; margin-bottom: 20px;
}
.login .mark svg { width: 34px; height: 34px; fill: var(--on-accent); }
.login h1 { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.login .lede { margin: 8px 0 32px; color: var(--muted); }
.login form { display: flex; flex-direction: column; flex: 1; }
.login .spacer { flex: 1; min-height: 24px; }

/* Boot splash while the session is checked */
.boot { min-height: 60vh; display: grid; place-items: center; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Today ---------- */
.section-tight { margin-top: 12px; }
.long { color: var(--warn); font-weight: 700; }
.long-note { margin-top: 4px; color: var(--warn); font-size: var(--fs-sm); font-weight: 600; }
.choices.num-choices button { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-item { background: var(--surface); border-radius: var(--r-md); padding: 12px 14px; }
.plan-item + .plan-item { margin-top: 6px; }
.plan-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.plan-name { font-weight: 700; }
.plan-target { flex: none; font-size: var(--fs-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.plan-target small { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.badge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.badge-row .meta { flex: 1 1 100%; }
.btn.btn-small { width: auto; min-height: var(--tap); padding: 8px 14px; font-size: var(--fs-sm); border-radius: 12px; }

/* ---------- Workout ---------- */
.top-stack {
  position: sticky; top: 68px; z-index: 9;     /* just under the sticky topbar */
  margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad);
  background: var(--bg);
}
.top-stack > * { margin-bottom: 8px; }
.rest[hidden], .save-error[hidden] { display: none; }
.save-error { width: 100%; min-height: var(--tap); border: 0; text-align: left; font: inherit; }
.action-bar .error-text:empty { display: none; }
.action-bar .error-text { margin: 0 0 8px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--bad-bg); }
.rest-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 0; border-radius: var(--r-md);
  background: var(--surface); color: var(--text); text-align: left;
}
.rest-btn small { display: block; font-size: var(--fs-sm); color: var(--muted); }
.rest-btn .t { display: block; font-size: 34px; font-weight: 800; line-height: 1.1; color: var(--accent-text); }
.rest-side { text-align: right; }
.ex { margin-top: 22px; }
.ex-name { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.ex .meta { margin: 4px 0 10px; }
.ex .cue { margin: 4px 0 6px; }
.set-v {
  min-height: var(--tick); padding: 0; border: 0; background: none; color: inherit; text-align: left;
}
.set-edit {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: -4px 0 var(--gap); padding: 10px 12px; border-radius: var(--r-lg); background: var(--raised);
}
.stepper { display: flex; align-items: center; gap: 6px; flex: 1 1 100%; }
.stepper > span { width: 36px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.stepper .input { flex: 1; min-width: 0; text-align: center; font-size: var(--fs-lg); font-weight: 700; }
.step {
  flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 24px; font-weight: 700;
}
.set-edit [data-close] { margin-left: auto; }
.ex-links { display: flex; gap: 18px; font-size: var(--fs-sm); }
.ex-links a, .banner a { color: var(--accent-text); font-weight: 600; }
.ex-links a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 4px; margin: 0 -4px; }
.how { font-size: var(--fs-sm); color: var(--muted); }
.how summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.how ul { margin: 0 0 6px; padding-left: 18px; }
.feedback { margin-top: 10px; }
.feedback > * + * { margin-top: 12px; }
.feedback .field + .field { margin-top: 8px; }
.field.pain > span { display: flex; justify-content: space-between; }
.field.pain b { color: var(--text); font-size: var(--fs-md); }

/* ---------- Morning check ---------- */
.morning-banner { margin-bottom: 4px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.mc-title { font-size: var(--fs-lg); font-weight: 800; }
.morning-banner .meta { margin: 2px 0 12px; }
.mc > .btn + .btn { margin-top: var(--gap); }
.mc-detail { margin-top: 14px; }
.mc-detail[hidden], .knee-only[hidden], .ext-only[hidden] { display: none; }
.mc .error-text:empty, .card .error-text:empty { display: none; }
/* Unselected choices need contrast against a card surface. */
.card .choices button[aria-pressed="false"] { background: var(--raised); }

/* ---------- Home routine ---------- */
.streak-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.hero-num { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; color: var(--accent-text); }
.hero-num small { font-size: var(--fs-lg); font-weight: 700; color: var(--muted); letter-spacing: 0; }
.streak-today { padding-bottom: 6px; font-weight: 600; }
.check-list { list-style: none; margin: 16px 0 0; padding: 0; }
.check-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border-radius: var(--r-md); padding: 12px 12px 4px 14px;
  transition: background-color .2s var(--ease);
}
.check-item + .check-item { margin-top: 6px; }
.check-item.done { background: var(--done-bg); }
.check-text { flex: 1; min-width: 0; }
.check-text .plan-name { display: block; }
.check-target { display: block; margin-top: 2px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.check-text .how { margin-top: 2px; }

/* ---------- Entry forms (body, rehab) ---------- */
.big-input { font-size: var(--fs-xl); font-weight: 800; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.pair .field + .field { margin-top: 0; }
.choices.stacked { flex-direction: column; }
.choices.stacked button { font-size: var(--fs-sm); text-align: left; padding: 10px 14px; }
.lsi-readout { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; }
.lsi-readout:empty { min-height: 0; margin: 0; }
.lsi-value { font-size: var(--fs-num); font-weight: 800; letter-spacing: -0.02em; }
.kv-list { list-style: none; margin: 12px 0 0; }
.kv-list:not(.card) { padding: 0; }
.kv-list.card { margin-top: 0; padding-top: 4px; padding-bottom: 4px; }
.knee-only { margin-top: 14px; }
.confirm { margin-top: 12px; }
.confirm-actions { display: flex; gap: 8px; margin-top: 10px; }
.confirm-actions .btn { flex: 1; }
.card > .pair:first-child { margin-top: 0; }
.kv-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--border); font-size: var(--fs-sm);
}
.kv-list.card li:first-child { border-top: 0; }
.kv-list .num { font-weight: 700; text-align: right; }
.kv-list small { color: var(--muted); font-weight: 600; }

/* ---------- Charts ---------- */
.chart { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ref { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--good); font-size: 11px; font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .line.left { stroke: var(--accent-mark); }
.chart .line.right { stroke: var(--muted); }
.chart .line.raw { stroke: none; }
.chart .dot.left { fill: var(--accent-mark); }
.chart .dot.right, .chart .dot.raw { fill: var(--muted); }
.chart-title { margin-top: 14px; font-size: var(--fs-sm); font-weight: 700; }
.chart-card > .chart-title:first-child { margin-top: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.key { display: inline-block; width: 12px; height: 4px; margin-right: 6px; vertical-align: middle; border-radius: 2px; background: var(--muted); }
.key.left { background: var(--accent-mark); }
.key.ref { height: 0; border-top: 2px dashed var(--good); background: none; }
.chart-summary { list-style: none; margin: 6px 0 0; padding: 0; font-size: var(--fs-sm); color: var(--text); font-variant-numeric: tabular-nums; }
.chart-summary li + li { margin-top: 2px; }
.chart-empty { color: var(--muted); font-size: var(--fs-sm); }
.chart-link { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--accent-text); font-size: var(--fs-sm); font-weight: 600; }

/* ---------- Settings ---------- */
.file-btn { position: relative; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.err-list { margin: 8px 0 0; padding-left: 18px; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.err-list li + li { margin-top: 4px; }
.preview-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: var(--fs-sm); table-layout: fixed; }
.preview-table th { text-align: left; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 8px 6px 0; }
.preview-table th:first-child { width: 45%; }
.preview-table td { vertical-align: top; padding: 10px 8px 10px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.preview-table td > * { display: block; }
.pair input[type="date"] { min-width: 0; width: 100%; }
.preview-table .pill { display: inline-flex; margin-bottom: 4px; }
.preview-target { font-weight: 700; }
.diff-list { margin: 4px 0 0; padding: 0; list-style: none; }
.diff-list li { margin: 2px 0; }
.safety-warning ul { margin: 6px 0 0; padding-left: 18px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li + li { margin-top: var(--gap); }
.history { padding-top: 0; padding-bottom: 0; }
.history summary { display: block; min-height: var(--tap); padding: 12px 0; cursor: pointer; list-style: none; }
.history summary::-webkit-details-marker { display: none; }
.history-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.history-line .meta { flex: none; }
.history-reason { display: block; margin-top: 4px; }
.history summary::after { content: "Show changes"; display: block; margin-top: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--accent-text); }
.history[open] summary::after { content: "Hide changes"; }
.why-list { list-style: none; margin: 0; padding: 0 0 12px; }
.why-list li { padding: 8px 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.why-list .meta { display: block; margin-top: 2px; }

/* ---------- Red flags ---------- */
.flag-card { font-size: var(--fs-md); }
.flag-card p { margin-top: 6px; }
.flag-card p strong { display: inline; }
.flag-card ul { margin: 6px 0 0; padding-left: 1.2em; }
.flag-card li { margin-top: 4px; }
.flag-card li strong { display: inline; }
.flag-head { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -0.01em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Eat: recipes and meal plan ---------- */
.recipe-row {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: var(--tap); padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); color: var(--text); text-decoration: none;
}
.recipe-row:active { background: var(--raised); }
.recipe-title { margin: 4px 0 6px; }
.method { margin: 0; padding-left: 2.2em; }
.method li { padding: 6px 0 6px 4px; }
.method li::marker { font-weight: 800; color: var(--accent-text); }
.week-switch button { font-size: var(--fs-sm); }
.check-row { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check-row input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.treat-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; }
.treat-row .plan-name { flex: 1 1 100%; overflow-wrap: anywhere; }
.treat-count { display: inline-flex; align-items: center; gap: 6px; }
.treat-n { min-width: 28px; text-align: center; font-size: var(--fs-lg); font-weight: 800; }
.treat-row .btn-small { margin-left: auto; }
.treat-add { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.treat-add .field { flex: 1; min-width: 0; }
.treat-add .btn-small { min-height: 52px; }
.card > .meta[data-allowance] { margin-top: 10px; }
.day-est .plan-line { margin-bottom: 8px; flex-wrap: wrap; }
progress.est {
  display: block; width: 100%; height: 8px; margin-top: 6px;
  border: 0; border-radius: 4px; background: var(--raised); overflow: hidden;
  -webkit-appearance: none; appearance: none;
}
progress.est::-webkit-progress-bar { background: var(--raised); }
progress.est::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
progress.est::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
progress.est.protein::-webkit-progress-value { background: var(--good); }
progress.est.protein::-moz-progress-bar { background: var(--good); }
.card .field select.input { appearance: auto; }
.banner.warn > div { min-width: 0; }

/* ---------- Eat: today's meals ---------- */
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
.day-head .step:disabled { opacity: .3; }
.day-title { text-align: center; }
.day-title .meta { display: block; }
.totals { margin-top: 10px; font-size: var(--fs-md); font-weight: 700; text-align: center; }
.meal-row.ate { background: var(--done-bg); }
.meal-row .plan-line { flex-wrap: wrap; }
.meal-recipe { margin: 2px 0 10px; overflow-wrap: anywhere; }
.meal-row .choices button { font-size: var(--fs-sm); }
.extra-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.extra-text { min-width: 0; flex: 1; }
.extra-text .plan-name { overflow-wrap: anywhere; }
.extra-text .meta { display: block; }
.quick-note { margin-bottom: 8px; }
.quick-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; margin-top: 8px; }
.quick-btn { flex-direction: column; gap: 0; padding: 8px 8px; font-size: var(--fs-sm); line-height: 1.25; text-align: center; background: var(--raised); }
.quick-btn small { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.extra-form { margin-top: var(--gap); }
.extra-form .eyebrow { margin-bottom: 8px; }
.extra-form .error-text { margin-top: 4px; }
.score-list { list-style: none; margin: 0; padding: 0; }
.score-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; column-gap: 10px; align-items: center; min-height: var(--tap); padding: 6px 0; }
.score-row + .score-row { border-top: 1px solid var(--border); }
.score-label { font-weight: 600; }
.score-value { font-weight: 800; text-align: right; }
.score-rating { grid-column: 2 / 4; margin-top: -4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

/* ---------- Shopping list ---------- */
.shop-group + .shop-group { margin-top: 20px; }
.shop-group > .eyebrow { margin-bottom: 8px; }
.shop-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--tap); padding: 10px 14px;
  background: var(--surface); color: var(--text); border: 0; border-radius: var(--r-md);
  font: inherit; text-align: left; cursor: pointer;
}
.shop-line { display: flex; gap: 6px; align-items: stretch; }
.shop-line + .shop-line { margin-top: 6px; }
.shop-line .shop-row { flex: 1; min-width: 0; width: auto; }
.shop-remove { flex: none; min-width: var(--tap); }
.shop-row:active { background: var(--raised); }
.shop-box {
  flex: none; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--muted);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; line-height: 1; color: var(--on-accent);
}
.shop-row[aria-checked="true"] .shop-box { background: var(--accent); border-color: var(--accent); }
.shop-row[aria-checked="true"] .shop-box::after { content: "\2713"; }
.shop-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.shop-qty { flex: none; max-width: 45%; text-align: right; font-size: var(--fs-sm); color: var(--muted); }
.shop-row[aria-checked="true"] .shop-name,
.shop-row[aria-checked="true"] .shop-qty { text-decoration: line-through; color: var(--muted); }
.shop-add .pair { align-items: end; }
.shop-actions { display: flex; gap: 8px; }
.shop-actions .btn { flex: 1; }
.shop-status { margin-top: 10px; min-height: 1.4em; }
.shop-copy { width: 100%; min-height: 160px; margin-top: 10px; font: inherit; font-size: var(--fs-sm); }
.banner .btn-small { margin-top: 8px; }
.reminders { display: grid; gap: 8px; }
.banner.reminder { align-items: center; justify-content: space-between; }
.banner.reminder .reminder-link { flex: 1; min-width: 0; display: flex; align-items: center; min-height: 48px; }
.banner.reminder .btn-small { margin-top: 0; flex: none; }

/* ---------- Analytics (Progress tab) ---------- */
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 4px; border-radius: var(--r-md); background: var(--raised);
}
.seg button {
  min-height: var(--tap); padding: 0 6px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: var(--fs-sm); font-weight: 700;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.range-note { margin-top: 8px; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-top: 16px; }
.stat { display: flex; flex-direction: column; min-width: 0; padding: 12px; border-radius: var(--r-md); background: var(--surface); }
.stat-num { font-size: var(--fs-num); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.stat-label { margin-top: 6px; font-size: var(--fs-sm); font-weight: 700; line-height: 1.2; }
.stat-sub { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.25; }
.pb-list { list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); }
.pb-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.pb-name { min-width: 0; }
.pb-val { flex: none; font-weight: 700; text-align: right; }
.pb-val .meta { font-weight: 400; }
.pb-list li:first-child { padding-top: 0; border-top: 0; }
.pb-list li:last-child { padding-bottom: 0; }
.chart .bar { fill: var(--accent-mark); }
.key.bar { width: 10px; height: 10px; background: var(--accent-mark); }
.chart .line.test { stroke: none; }
.chart .dot.test { r: 4.5px; fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.key.test { width: 10px; height: 10px; border: 2px solid var(--text); border-radius: 50%; background: none; }

/* Apple Health token */
.token-field { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-sm); text-overflow: ellipsis; }
.token-box { border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Padel path ---------- */
.level-card { padding: 0; }
.level-card > summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 12px 16px; font-weight: 700; cursor: pointer; list-style: none;
}
.level-card > summary::-webkit-details-marker { display: none; }
.level-card[open] > summary { padding-bottom: 4px; }
.level-card > .meta { padding: 0 16px 14px; }
.check-list { list-style: none; margin: 0; padding: 0 16px 8px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.check:first-child { border-top: 0; }
.check-icon {
  flex: none; width: 28px; height: 28px; border-radius: var(--r-pill); display: grid; place-items: center;
  font-weight: 800; background: var(--raised); color: var(--muted);
}
.check-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.check-label { font-weight: 600; }
.check-detail, .check-need { font-size: var(--fs-sm); color: var(--muted); }
.check-need a { color: var(--accent-text); font-weight: 600; display: inline-block; min-height: var(--tap); line-height: var(--tap); }
.status-word { color: var(--text); }
.status-met .check-icon { background: var(--good-bg); color: var(--good); }
.status-not .check-icon { background: var(--warn-bg); color: var(--warn); }
.status-unknown .check-icon, .status-advice .check-icon { background: var(--raised); color: var(--muted); }
.check-tick { margin-top: 8px; }
.check-tick button { min-height: var(--tap); }
.unlock-card .card-title { font-size: var(--fs-lg, 1.125rem); font-weight: 800; }

/* ---------- ACL-RSI questionnaire ---------- */
.rsi-item { margin: 0 0 12px; padding: 14px; border: 2px solid transparent; border-radius: var(--r-md); background: var(--surface); min-width: 0; }
.rsi-item legend { float: left; width: 100%; padding: 0; margin: 0 0 10px; font-size: var(--fs-md); font-weight: 700; line-height: 1.3; }
.rsi-item legend + * { clear: both; }
.rsi-item.unanswered { border-color: var(--warn); }
.rsi-num { color: var(--muted); font-weight: 600; margin-right: 4px; }
.rsi-scale { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.rsi-scale button {
  min-height: var(--tap); padding: 0;
  border: 2px solid transparent; border-radius: 12px;
  background: var(--raised); color: var(--text);
  font-size: var(--fs-md); font-weight: 700; font-variant-numeric: tabular-nums;
}
.rsi-scale button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.rsi-anchors { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.rsi-anchors span:last-child { text-align: right; }
.rsi-result { font-size: var(--fs-num); font-weight: 800; letter-spacing: -0.02em; }

/* ---------- Progress photos ---------- */
.photo-add > .btn { margin-top: var(--gap); }
.photo-add > .meta:first-child { margin: 0 0 4px; }
.photo-add > .meta:last-child { margin-top: 12px; }
.photo-add [data-busy]:empty { display: none; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.photo-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.photo-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.photo-frame {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 3 / 4; overflow: hidden; padding: 4px;
  border-radius: var(--r-sm); background: var(--surface);
  color: var(--muted); font-size: var(--fs-xs); text-align: center;
}
.photo-frame:has(img) { padding: 0; }
.photo-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-compare .photo-frame img { object-fit: contain; }
.photo-cap { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.photo-badge { align-self: stretch; justify-content: center; padding: 4px 6px; border-radius: var(--r-sm); text-align: center; }
.photo-tile .btn.btn-small { width: 100%; padding: 8px 4px; }
/* Delete sits at the bottom of every tile, so a row lines up whether or not a tile has a badge. */
.photo-tile .photo-del { margin-top: auto; }
.photo-badge.bad { overflow-wrap: anywhere; }
.card .photo-frame { background: var(--raised); }

/* Analytics: hop test lines (four series), gate list, notes */
.chart .line.hop1 { stroke: var(--accent-mark); }
.chart .line.hop2 { stroke: var(--good); stroke-dasharray: 12 4; }
.chart .line.hop3 { stroke: var(--text); stroke-dasharray: 6 3; }
.chart .line.hop4 { stroke: var(--muted); stroke-dasharray: 2 3; }
.chart .dot.hop1 { fill: var(--accent-mark); }
.chart .dot.hop2 { fill: var(--good); }
.chart .dot.hop3 { fill: var(--text); }
.chart .dot.hop4 { fill: var(--muted); }
.key.hop1 { background: var(--accent-mark); }
.key.hop2 { background: var(--good); }
.key.hop3 { background: var(--text); }
.key.hop4 { background: var(--muted); }
.chart-note { margin-top: 8px; }
.gate-list { padding: 0; margin-top: 4px; }
