:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --series-1: #2a78d6;
  --series-2: #008300;
  --series-6: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --accent-bright: #4fa3ff;
  --accent-soft: rgba(42,120,214,0.10);
  --meter-track: #cde2fb;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255,255,255,0.10);
    --series-1: #3987e5;
    --series-2: #008300;
    --series-6: #d95926;
    --good-text: #0ca30c;
    --accent: #3987e5;
    --accent-bright: #6ab4ff;
    --accent-soft: rgba(57,135,229,0.14);
    --meter-track: #184f95;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --ink-1: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255,255,255,0.10);
  --series-1: #3987e5;
  --series-2: #008300;
  --series-6: #d95926;
  --good-text: #0ca30c;
  --accent: #3987e5;
  --accent-bright: #6ab4ff;
  --accent-soft: rgba(57,135,229,0.14);
  --meter-track: #184f95;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; width: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink-1);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation; /* no double-tap zoom */
  overscroll-behavior-x: none; /* no rubber-band side-scroll on iOS */
}
#app { overflow-x: hidden; max-width: 100vw; }
#app { display: flex; flex-direction: column; min-height: 100dvh; }

header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(10px);
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.topdate { color: var(--muted); font-size: 12.5px; }
.theme-btn {
  border: 1px solid var(--border); background: none; color: var(--ink-2);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.syncnote { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.syncnote.offline { color: var(--serious); border-color: var(--serious); }
.topright { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.headnav { display: flex; align-items: center; gap: 4px; }
.avatar-btn {
  width: 24px; height: 32px; border-radius: 6px; overflow: hidden; flex-shrink: 0;
  border: 1.5px solid var(--border); background: var(--page);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-btn .avatar-placeholder { font-size: 12px; color: var(--muted); line-height: 1; }
.hn-btn {
  border: 1px solid var(--border); background: none; color: var(--ink-1);
  border-radius: 8px; min-width: 32px; height: 32px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
  position: relative; overflow: hidden; /* clip the native date input — it ignores width:100% on iOS */
}
.hn-date { font-size: 13.5px; font-weight: 700; min-width: 72px; text-align: center; }
.hn-cal { font-size: 14px; }
.hn-cal input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; padding: 0; border: 0; }
.hn-today { font-size: 12px; font-weight: 600; color: var(--accent); border-color: var(--accent); padding: 0 8px; }

main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 14px 90px; }
@media (min-width: 900px) { main { max-width: 860px; padding-bottom: 40px; } }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 9px 2px 8px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: inherit;
}
nav.tabs button .ico { font-size: 19px; line-height: 1; }
nav.tabs button.active { color: var(--accent); font-weight: 600; }
@media (min-width: 900px) {
  nav.tabs { position: sticky; top: 46px; bottom: auto; border-top: none; border-bottom: 1px solid var(--border); }
  nav.tabs button { flex-direction: row; gap: 7px; font-size: 13px; padding: 11px; }
}

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 15px; margin-bottom: 12px;
}
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 2px 8px; font-weight: 600; }
h2.section:first-child { margin-top: 2px; }

/* hero */
.hero-label { font-size: 13px; color: var(--ink-2); }
.hero-value { font-size: 48px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; margin: 2px 0; }
.hero-sub { font-size: 13px; color: var(--muted); }
.delta-good { color: var(--good-text); font-weight: 600; }
.delta-bad { color: var(--critical); font-weight: 600; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 12px 13px;
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tile-ghost { position: fixed; z-index: 90; opacity: .92; pointer-events: none; box-shadow: 0 10px 28px rgba(0,0,0,.35); transform: scale(1.04); }
.tile-slot { opacity: .35; border-style: dashed; }

/* whole day-section reordering — grabbed only by the ⠿ handle, never the card body */
.day-section { position: relative; }
.ds-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ds-head h2.section { flex: 1; margin-bottom: 8px; }
.ds-grip {
  color: var(--muted); font-size: 13px; letter-spacing: -3px; line-height: 1;
  padding: 8px 10px; margin-top: 10px; cursor: grab; touch-action: none; user-select: none; flex-shrink: 0;
}
.ds-grip-float {
  position: absolute; top: 8px; right: 8px; z-index: 2; margin-top: 0;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
}
.day-section.section-slot { opacity: .35; }
.section-ghost { position: fixed; z-index: 95; pointer-events: none; opacity: .96; box-shadow: 0 12px 32px rgba(0,0,0,.35); border-radius: 14px; }
.tile .t-label { font-size: 12px; color: var(--ink-2); }
.tile .t-value { font-size: 22px; font-weight: 600; margin-top: 1px; }
.tile .t-value small { font-size: 12px; font-weight: 400; color: var(--muted); }
.tile .t-delta { font-size: 11.5px; margin-top: 1px; color: var(--muted); }

/* profile photo — portrait (3:4), not square: a square crop clipped the top of a close-up
   face shot and left no room for a full-body photo. Sized to comfortably clear the height of
   the stacked action buttons beside it (Take photo / Choose from library / Remove). */
.profile-photo-row { display: flex; align-items: flex-start; gap: 16px; }
.profile-photo-preview {
  width: 130px; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; flex-shrink: 0;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
}
.profile-photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-photo-preview .avatar-placeholder { font-size: 48px; color: var(--muted); }
.profile-photo-actions { display: flex; flex-direction: column; gap: 8px; }
.birthday-row { display: flex; gap: 8px; }
.birthday-row select { flex: 1; width: auto; min-width: 0; }
.tile svg.spark { display: block; margin-top: 6px; width: 100%; height: 26px; }

/* meters */
.meter { margin-top: 8px; }
.meter .m-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 3px; }
.meter .m-row b { font-weight: 600; }
.meter .m-track { position: relative; height: 8px; border-radius: 4px; background: var(--meter-track); overflow: hidden; }
.meter .m-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
.meter .m-fill.over { background: var(--serious); }
.meter .m-fill.excess {
  left: auto; right: 0; background: var(--critical); border-radius: 0 4px 4px 0;
  background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.32) 0 3px, transparent 3px 7px);
}
.meter .m-fill.excess.benign { background-color: var(--accent-bright); }
.meter .m-target-line { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink-1); opacity: .5; }
/* larger variant — the calorie bar, sized up for primary-metric prominence above the macro bars */
.meter-lg { margin-top: 10px; }
.meter-lg .m-row { font-size: 13.5px; }
.meter-lg .m-track { height: 14px; border-radius: 7px; }
.meter-lg .m-fill { border-radius: 7px; }
.meter-lg .m-fill.excess { border-radius: 0 7px 7px 0; }
.meter-lg .m-target-line { top: -3px; bottom: -3px; }

/* verdicts */
.verdict { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-1); margin-bottom: 8px; }
.verdict .v-ico { font-size: 16px; line-height: 1.3; }
.verdict .v-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.verdict .v-text { font-size: 13.5px; color: var(--ink-2); margin-top: 1px; }
.v-good .v-tag { color: var(--good-text); }
.v-warn .v-tag { color: #8a6100; }
:root[data-theme="dark"] .v-warn .v-tag { color: var(--warning); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .v-warn .v-tag { color: var(--warning); } }
.v-bad .v-tag { color: var(--critical); }
.v-info .v-tag { color: var(--accent); }

/* meals */
.meal { border-top: 1px solid var(--grid); padding: 10px 0; }
.meal:first-of-type { border-top: none; }
.meal .m-head { display: flex; justify-content: space-between; align-items: baseline; }
.meal .m-title { font-weight: 600; font-size: 14px; }
.meal .m-headright { display: flex; align-items: center; gap: 8px; }
.meal .m-time { color: var(--muted); font-size: 12px; }
.meal .meal-del { border: none; background: none; font-size: 13px; padding: 2px 2px; cursor: pointer; line-height: 1; opacity: .6; }
.meal .meal-del:active { opacity: 1; }
.meal .m-food { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; padding: 6px 2px; margin: 0 -2px; border-radius: 8px; }
.meal .m-food:active { background: var(--accent-soft); }
.m-food-check { flex-shrink: 0; width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.m-food-content { flex: 1; min-width: 0; display: flex; justify-content: space-between; cursor: pointer; }
.meal .m-macros { font-size: 12px; color: var(--muted); margin-top: 3px; }
.est-flag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.m-food-edit { padding: 8px 0; }
.m-food-edit input[type=text] { margin-bottom: 6px; }
.ef-field label { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .02em; }
.ef-serving-field { margin-bottom: 6px; }
.ef-serving-row { display: flex; align-items: center; gap: 8px; }
.ef-serving-row input { flex: 1; }
.ef-unit { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.ef-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }

/* forms */
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--axis); border-radius: 10px;
  background: var(--page); color: var(--ink-1); font: inherit;
  font-size: 16px; /* ≥16px prevents iOS input-focus auto-zoom */
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.f-label { display: block; font-size: 12.5px; color: var(--ink-2); margin: 10px 0 4px; font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: none; padding: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--border); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); margin-top: -7px; cursor: pointer; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; }
input[type=range]:disabled { opacity: .4; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: none; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  background: var(--accent-soft); color: var(--ink-1); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer; font-family: inherit;
  text-align: left;
}
.chip small { color: var(--muted); }
.chip.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.notice { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink-2); margin-bottom: 10px; }

/* charts */
.chart-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 13px 8px 6px 4px; margin-bottom: 12px; position: relative;
  /* the press-and-hold gesture that opens the focused chart (see initChartFocusHold) races
     against iOS Safari's own long-press text-selection/callout — without this, holding a beat
     too long selects the chart's text and shows the copy menu instead of (or on top of) opening
     the overlay. Same fix already used for the tile press-hold-drag gesture below. */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* ...except the table view, which is explicitly excluded from the hold gesture itself
   (initChartFocusHold skips anything inside .tblview) — no reason to also block copying a
   number out of it */
.chart-card .tblview { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 4px 12px; }
.chart-title { font-size: 14px; font-weight: 600; }
.chart-latest { font-size: 13px; color: var(--ink-2); }
.legend { display: flex; gap: 14px; padding: 2px 12px 6px; flex-wrap: wrap; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend .sw { width: 14px; height: 3px; border-radius: 2px; }
.legend .sw.dot { width: 8px; height: 8px; border-radius: 50%; }
svg.chart { display: block; width: 100%; height: 190px; touch-action: pan-y; }
.chart-focus-hint { text-align: center; padding: 0 8px 2px; }
.chart-focus-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.85);
  display: flex; flex-direction: column; padding: 16px; overflow-y: auto;
}
.chart-focus-overlay .scan-head { color: #fff; }
.chart-focus-overlay .scan-head b { font-size: 16px; }
.chart-focus-overlay .chart-card { margin-bottom: 0; }
.chart-focus-overlay svg.chart { height: 55vh; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-1);
  border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.12);
  border-radius: 9px; padding: 6px 10px; font-size: 12px; z-index: 5; display: none; min-width: 90px;
}
.tooltip .tt-d { color: var(--muted); font-size: 11px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.tooltip .tt-row .sw { width: 8px; height: 8px; border-radius: 50%; }
.tooltip b { font-variant-numeric: tabular-nums; }
.range-row { display: flex; gap: 6px; margin: 2px 2px 12px; }
.range-row button {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--ink-2);
  border-radius: 8px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.range-row button.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* OpenRouter model chooser — scrollable pick list */
.or-model-list {
  max-height: 320px; overflow-y: auto; border: 1px solid var(--axis); border-radius: 10px;
  background: var(--page); margin-top: 2px;
}
.or-sortbar {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 6px;
  background: var(--surface-1); padding: 8px 10px; border-bottom: 1px solid var(--grid);
}
.or-sortbar .chip { font-size: 12px; padding: 5px 11px; }
.or-group {
  position: sticky; top: 41px; z-index: 1; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); background: var(--surface-1); padding: 6px 12px 5px;
  border-bottom: 1px solid var(--grid);
}
.or-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--grid); cursor: pointer;
}
.or-row:last-child { border-bottom: none; }
.or-row:active { background: var(--accent-soft); }
.or-row.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.or-row .or-name { font-size: 13.5px; font-weight: 600; min-width: 0; }
.or-row .or-name small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); word-break: break-all; }
.or-row .or-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.or-price { font-size: 11px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.or-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  border-radius: 6px; padding: 2px 6px; background: var(--accent-soft); color: var(--accent);
}
.or-tag.free { background: rgba(12,163,12,.14); color: var(--good-text); }
/* Trends category filter — pill-shaped (vs. the range row's rectangular tabs below it) so the
   two controls read as distinct kinds of choice: which charts, then how far back. */
.cat-row { display: flex; gap: 6px; margin: 2px 2px 10px; flex-wrap: wrap; }
.cat-row button {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--ink-2);
  border-radius: 999px; padding: 5px 13px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.cat-row button.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* badges earned (Trainerize-style) */
.badge-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 4px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 74px; }
.badge-hex {
  position: relative; width: 58px; height: 64px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: var(--accent-soft); color: var(--accent);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}
.badge-count {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px; line-height: 1.5;
}
.badge-shield {
  width: 54px; height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  clip-path: polygon(0% 0%, 100% 0%, 100% 70%, 50% 100%, 0% 70%);
}
.badge-shield b { font-size: 19px; line-height: 1.1; }
.badge-shield span { font-size: 13px; line-height: 1; }
.badge-label { font-size: 10.5px; color: var(--ink-2); text-align: center; font-weight: 600; }

/* chat */
#chatlog { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.coach { align-self: flex-start; background: var(--surface-1); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 12.5px; text-align: center; }
.msg-time { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.msg.user .msg-time { color: rgba(255,255,255,.75); text-align: right; }
.chat-daydivider { align-self: center; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; margin: 6px 0 2px; }
.chat-bottom { position: sticky; bottom: 86px; background: var(--page); padding-top: 6px; }
@media (min-width: 900px) { .chat-bottom { bottom: 12px; } }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { resize: none; height: 46px; max-height: 160px; overflow-y: auto; }
#coachProposals:not(:empty) { margin-bottom: 8px; }
#coachProposals .card { max-height: 40vh; overflow-y: auto; }
.typing { color: var(--muted); font-size: 13px; padding: 4px 2px; }

/* readiness */
.ready-wrap { display: flex; gap: 14px; align-items: center; }
.score-ring {
  width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--ring-color, var(--good)) calc(var(--sc, 0) * 1%), var(--meter-track) 0);
  display: flex; align-items: center; justify-content: center;
}
.score-ring > div {
  width: 60px; height: 60px; border-radius: 50%; background: var(--surface-1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-ring b { font-size: 21px; font-weight: 700; line-height: 1; }
.score-ring small { font-size: 10px; color: var(--muted); margin-top: 1px; }
.ready-copy h3 { font-size: 15.5px; margin-bottom: 2px; }
.ready-copy p { font-size: 13px; color: var(--ink-2); }

/* weekly plan */
.plan-row { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--grid); padding: 8px 0; cursor: pointer; }
.plan-row:first-of-type { border-top: none; }
.plan-row:active { opacity: .6; }
.plan-day { font-weight: 700; font-size: 11px; letter-spacing: .04em; color: var(--muted); width: 36px; flex-shrink: 0; }
.plan-row .p-focus { font-weight: 600; font-size: 13.5px; }
.plan-row .p-detail { font-size: 12.5px; color: var(--muted); }
.plan-row.today .plan-day, .plan-row.today .p-focus { color: var(--accent); }
.plan-row .p-trail { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.plan-row em { font-style: normal; font-size: 11px; color: var(--muted); }
.plan-row.today em { color: var(--accent); font-weight: 700; }
.plan-row .p-chev { color: var(--muted); font-size: 16px; line-height: 1; }

/* labs */
.lab-row { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--grid); padding: 8px 0; font-size: 13.5px; }
.lab-row:first-of-type { border-top: none; }
.lab-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex-shrink: 0; }
.lab-dot.watch { background: var(--warning); }
.lab-row .l-name { flex: 1; }
.lab-row .l-name small { display: block; color: var(--muted); font-size: 11.5px; }
.lab-row b { font-variant-numeric: tabular-nums; }
.lab-interp { font-size: 13.5px; color: var(--ink-2); white-space: pre-wrap; margin-top: 10px; border-top: 1px solid var(--grid); padding-top: 10px; }
input[type=file] { width: 100%; font-size: 13px; color: var(--ink-2); }

.med-note { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 10px; }

/* daily checklist */
.check-row { display: flex; gap: 11px; align-items: flex-start; border-top: 1px solid var(--grid); padding: 10px 0; }
.check-row:first-child { border-top: none; }
.check-dot {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 2px solid var(--axis); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.check-dot.done { background: var(--good); border-color: var(--good); }
.cr-title { font-weight: 600; font-size: 14px; }
.cr-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.cr-trail { flex-shrink: 0; align-self: center; }
.hint:empty { display: none; }

/* workout detail + session */
.wo-instructions { white-space: pre-line; font-size: 13.5px; color: var(--ink-2); margin-top: 10px; border-top: 1px solid var(--grid); padding-top: 10px; }
.wo-ex { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; border-top: 1px solid var(--grid); padding: 9px 0; }
.wo-ex:first-child { border-top: none; }
.set-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 13.5px; }
.set-row span:first-child { width: 44px; color: var(--muted); flex-shrink: 0; }
.set-row input { width: 84px; text-align: center; padding: 8px 6px; }
.set-row .set-x {
  border: none; background: none; color: var(--muted); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 4px 6px; margin-left: auto; font-family: inherit;
}
.ex-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.ex-move { display: flex; gap: 4px; flex-shrink: 0; }
.ex-move button {
  border: 1px solid var(--border); background: none; color: var(--ink-2); border-radius: 8px;
  width: 32px; height: 30px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.ex-move button:disabled { opacity: .3; cursor: default; }
.rest-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.rest-row .rest-label { font-size: 12.5px; color: var(--muted); margin-left: 2px; }
.rest-row b { font-variant-numeric: tabular-nums; font-size: 14px; min-width: 40px; text-align: center; }
.rest-adj {
  border: 1px solid var(--border); background: none; color: var(--ink-1); border-radius: 8px;
  width: 30px; height: 30px; font-size: 16px; cursor: pointer; font-family: inherit; line-height: 1;
}
.rest-count { color: var(--accent); font-size: 17px !important; }
.ex-note { margin-top: 10px; font-size: 13px; }
.achieve { font-size: 13.5px; padding: 4px 0; }

/* progress photo overlay */
.photo-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: pointer;
}
.photo-overlay img { max-width: 94vw; max-height: 84vh; border-radius: 10px; }
.photo-overlay .photo-date { color: #fff; font-size: 13px; }
.photo-session { margin-bottom: 12px; }
.photo-session:last-of-type { margin-bottom: 8px; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.photo-thumb {
  position: relative; flex: 0 0 auto; width: 92px; height: 122px; padding: 0;
  border: 1px solid var(--border); background: var(--accent-soft); border-radius: 10px;
  overflow: hidden; cursor: pointer; font-family: inherit;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pose {
  position: absolute; left: 4px; bottom: 4px; z-index: 1; text-transform: capitalize;
  background: rgba(0,0,0,.6); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 5px;
}

.qs-sel { font-size: 13px; padding: 8px 6px; }

/* guided physique camera */
.guide-frame { position: relative; overflow: hidden; border-radius: 10px; }
#guideVideo { width: 100%; max-height: 58vh; object-fit: cover; background: #000; display: block; }
.guide-lines { position: absolute; inset: 0; pointer-events: none; }
.g-line {
  position: absolute; left: 6%; right: 6%; border-top: 2px dashed var(--accent);
  display: flex; justify-content: center; gap: 44px; opacity: .9;
}
.g-line em {
  position: absolute; left: 0; top: -9px; font-style: normal; font-size: 10.5px; font-weight: 700;
  color: #fff; background: var(--accent); border-radius: 6px; padding: 1px 7px; letter-spacing: .04em;
}
.g-eyes { top: 10%; }
.g-eyes .g-dot { width: 13px; height: 13px; border: 2.5px solid var(--accent); border-radius: 50%; margin-top: -8px; background: rgba(0,0,0,.15); }
.g-hips { top: 82%; }
.guide-lines.mode-full .g-eyes { top: 15%; }
.guide-lines.mode-full .g-hips { top: 60%; }
.g-center { position: absolute; top: 5%; bottom: 5%; left: 50%; border-left: 1.5px dashed var(--accent); opacity: .45; }
.g-count {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 96px; font-weight: 800; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.65);
}

/* pose diagram — which stance goes with which shot */
.g-pose-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.g-pose-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; border-radius: 10px; border: 1.5px solid var(--border); color: var(--muted);
  opacity: .55; transition: opacity .15s, border-color .15s, color .15s;
}
.g-pose-card .g-pose-icon { width: 26px; height: 39px; }
.g-pose-card .g-pose-icon svg { width: 100%; height: 100%; display: block; }
.g-pose-card .g-pose-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.g-pose-card.active { opacity: 1; border-color: var(--accent); color: var(--accent); }
.g-pose-card.done { opacity: .7; border-color: var(--good); color: var(--good); }
.g-pose-card.done::after {
  content: '✓'; position: absolute; top: 1px; right: 5px; font-size: 11px; font-weight: 800; color: var(--good);
}

/* captured-shot review strip */
.g-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 2px; }
.g-thumb { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; }
.g-thumb img { width: 64px; height: 88px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #000; }
.g-thumb-label { font-size: 10.5px; color: var(--ink-2); font-weight: 600; text-align: center; }
.g-thumb-placeholder {
  width: 64px; height: 88px; border-radius: 8px; border: 1.5px dashed var(--accent); background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.g-thumb-pending .g-thumb-label { color: var(--accent); }

/* readiness explanation popup */
.score-ring-tap { cursor: pointer; }
.score-ring-tap:active { transform: scale(.96); }
.info-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.info-box {
  background: var(--surface-1); border-radius: 14px; padding: 14px;
  width: 100%; max-width: 440px; max-height: 84vh; overflow-y: auto;
}
.review-photo-img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 10px; background: #000; }
.ri-part { border-top: 1px solid var(--grid); padding: 9px 0; }
.ri-part .ri-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 600; }
.ri-part .ri-head b { font-variant-numeric: tabular-nums; }
.ri-part .ri-val { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.ing-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--grid); padding: 9px 0; }
.ing-row:first-child { border-top: none; }

/* barcode camera scan overlay */
.scan-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; padding: 16px; }
.scan-dismiss {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; z-index: 101;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.scan-box { background: var(--surface-1); border-radius: 14px; padding: 14px; width: 100%; max-width: 420px; }
.scan-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#scanVideo { width: 100%; border-radius: 10px; background: #000; max-height: 50vh; object-fit: cover; display: block; }
.scan-frame { position: relative; overflow: hidden; border-radius: 10px; }
.scan-target {
  position: absolute; left: 8%; right: 8%; top: 28%; bottom: 28%;
  border: 2px solid var(--accent); border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.3); /* dims everything outside the aim box */
}

/* meal-match confirmation bar */
.match-bar {
  position: fixed; left: 12px; right: 12px; bottom: 78px; z-index: 40;
  background: var(--surface-1); border: 1px solid var(--accent); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.match-bar span { display: block; font-size: 13.5px; margin-bottom: 8px; }
.match-actions { display: flex; gap: 8px; }
@media (min-width: 900px) { .match-bar { left: auto; right: 16px; bottom: 16px; max-width: 380px; } }

/* food search */
.food-row { border-top: 1px solid var(--grid); padding: 8px 0; font-size: 13.5px; }
.food-row:first-child { border-top: none; }
.fr-main { cursor: pointer; }
.fr-main small { color: var(--muted); }
.fr-add { margin-top: 6px; }
.fr-add-label { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .02em; }
.fr-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fr-add-row input { width: 84px; }
.fr-add-row select.fr-mult { width: 68px; flex-shrink: 0; }
.fr-preview { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 8px; border-bottom: 1px solid var(--grid); }
table.data td { padding: 5px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
details.tblview summary { font-size: 12.5px; color: var(--muted); cursor: pointer; padding: 4px 12px 8px; }
.hidden { display: none !important; }
