/* ==========================================================================
   VNEGym — design system and screen styles
   --------------------------------------------------------------------------
   Phone screens only. Light theme leads; dark is a user preference and is
   deliberately not very dark. Everything an implementer needs is a token here
   or a component class below — see docs/DESIGN.md for the contract.
   ========================================================================== */

/* ---------- 1. tokens --------------------------------------------------- */

:root {
  /* surfaces */
  --bg:         #F5F6FA;
  --surface:    #FFFFFF;
  --surface-2:  #F0F2F7;
  --line:       #E6E9F0;
  --line-2:     #EEF0F5;
  --scrim:      rgba(14, 19, 32, .46);

  /* ink */
  --ink:        #0E1320;
  --ink-2:      #3B4252;
  --muted:      #5B6373;   /* 5.6:1 on --bg, 5.4:1 on --surface-2 */
  --faint:      #8A92A3;   /* placeholders and chevrons only, never text */

  /* brand */
  --brand:        #2F5BEA;
  --brand-strong: #2347C5;
  --brand-soft:   #E8EEFD;
  --brand-ink:    #1D3FB0;
  --on-brand:     #FFFFFF;

  /* semantic: the bright token fills, the -ink token is for text on the
     soft tint or the page (every pair clears 4.5:1 in both themes) */
  --good:        #16A34A;
  --good-strong: #15803D;   /* fills that carry white text (GO button) */
  --good-soft:   #E6F6EC;
  --good-ink:    #0F6B32;
  --on-good:     #FFFFFF;
  /* Text on the strong fills (GO, the heroes, the brandmark), on the amber
     fills (--warn, --pr) and on --danger; the fills that carry them. */
  --on-strong:   #FFFFFF;
  --on-amber:    #241300;
  --on-light:    #0B0B0B;   /* text on a light data fill (chart segments) */
  --on-danger:   #FFFFFF;
  --knob:        #FFFFFF;
  --hero-fill:   linear-gradient(135deg, #3A66EE 0%, #2F5BEA 55%, #2142BE 100%);
  --resume-fill: linear-gradient(135deg, #15803D, #0F7A3A 55%, #0C6A30);
  --brandmark-fill: linear-gradient(150deg, #3A66EE, #2F5BEA 55%, #1B3AA8);
  --timer-go-fill: linear-gradient(170deg, var(--good-soft), #C9F2D8);
  --timer-count-fill: linear-gradient(170deg, var(--warn-soft), #FFE9C2);
  /* Photos are always shown on a dark stage, in both themes. */
  --photo-stage: #0B0E14;
  --photo-ink:   #F3F5F9;
  --photo-ink-2: #DDE2EC;
  --photo-muted: #C9CFDB;
  --photo-on:    #FFFFFF;
  --photo-chip:  rgba(14,19,32,.7);
  --photo-chip-strong: rgba(14,19,32,.78);
  --photo-btn:   rgba(255,255,255,.12);
  --photo-danger-fill: #3F1F2B;
  --photo-danger-ink:  #FB7185;
  --photo-brand: #2F5BEA;
  --photo-handle-ink: #0E1320;
  /* Heart-rate zones 1-5 (fills only, never text). */
  --zone-1: #94A3B8; --zone-2: #38BDF8; --zone-3: #22C55E; --zone-4: #F59E0B; --zone-5: #EF4444;
  --pr:          #D97706;
  --pr-soft:     #FEF3DF;
  --pr-ink:      #92400E;
  --up:          #16A34A;
  --down:        #DC2626;
  --down-soft:   #FDECEC;
  --down-ink:    #B91C1C;
  --flat:        #5B6373;
  --warn:        #F59E0B;
  --warn-soft:   #FEF4E2;
  --warn-ink:    #92400E;
  --danger:      #E11D48;
  --danger-soft: #FDE8EE;
  --danger-ink:  #BE123C;
  --warmup:      #7C8AA5;
  --warmup-soft: #EEF1F7;
  --warmup-ink:  #4E5A73;
  --done:        #E6F6EC;
  --done-ink:    #0F6B32;

  /* muscle groups (ids match catalog.js): the bright token for fills, bars
     and dots; -soft for tinted backgrounds; -ink for the group's name as text */
  --g-arms: #EA580C;      --g-arms-soft: #FFF0E6;      --g-arms-ink: #C2410C;
  --g-push: #DC2626;      --g-push-soft: #FDECEC;      --g-push-ink: #B91C1C;
  --g-back: #7C3AED;      --g-back-soft: #F1EAFE;      --g-back-ink: #6D28D9;
  --g-quads: #059669;     --g-quads-soft: #E4F6EF;     --g-quads-ink: #047857;
  --g-posterior: #0891B2; --g-posterior-soft: #E2F4F9; --g-posterior-ink: #0E7490;
  --g-wrists: #B45309;    --g-wrists-soft: #FBF0E1;    --g-wrists-ink: #92400E;
  --g-abs: #DB2777;       --g-abs-soft: #FDEAF3;       --g-abs-ink: #BE185D;
  --g-neck: #0D9488;      --g-neck-soft: #E1F5F2;      --g-neck-ink: #0F766E;
  --g-cardio: #C026D3;    --g-cardio-soft: #FBE8FD;    --g-cardio-ink: #A21CAF;

  /* shared chart / muscle-map hooks (charts.css and musclemap.css read these) */
  --chart-line: var(--brand);
  --chart-area: rgba(47, 91, 234, .10);
  --chart-grid: var(--line);
  --chart-axis: var(--muted);
  --chart-bar: var(--brand);
  --chart-tip-bg: var(--ink);
  --chart-tip-ink: var(--surface);
  --chart-pos: var(--good);
  --chart-neg: var(--down);
  --chart-pr: var(--pr);
  --mm-base: var(--surface-2);
  --mm-outline: var(--line);
  --mm-1: #C9D8FF;
  --mm-2: #8FABFF;
  --mm-3: #4F7BFF;
  --mm-4: var(--brand-strong);
  --mm-secondary: rgba(47, 91, 234, .25);

  /* typography */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-display: 40px;
  --fs-h1: 28px;
  --fs-h2: 22px;
  --fs-h3: 18px;
  --fs-body: 17px;
  --fs-sm: 15px;
  --fs-cap: 13px;
  --fs-micro: 11px;

  /* spacing */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --pad: 16px;

  /* radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r: 18px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(14,19,32,.04), 0 4px 14px rgba(14,19,32,.05);
  --shadow-2: 0 2px 6px rgba(14,19,32,.06), 0 10px 28px rgba(14,19,32,.09);
  --shadow-3: 0 14px 40px rgba(14,19,32,.18);
  --shadow:   var(--shadow-1);
  --shadow-lg: var(--shadow-3);

  /* motion */
  --ease: cubic-bezier(.2, .8, .3, 1);
  --t-fast: 120ms;
  --t-base: 200ms;

  /* touch */
  --tap: 48px;
  --tap-lg: 56px;
  --tap-xl: 64px;

  /* safe areas and chrome */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 62px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #11161F;
  --surface: #1A2030;
  --surface-2: #222A3C;
  --line: #2B3447;
  --line-2: #242C3E;
  --scrim: rgba(0, 0, 0, .55);
  --ink: #F3F5F9;
  --ink-2: #D2D7E1;
  --muted: #A0A9BA;
  --faint: #7E8798;
  --brand: #5B82FF;
  --brand-strong: #4A6FEA;
  --brand-soft: #22305A;
  --brand-ink: #A9BEFF;
  --on-brand: #0B1330;      /* the lifted brand is too light for white text */
  --good: #34C26A;
  --good-strong: #15803D;
  --good-soft: #163A28;
  --good-ink: #8FE0AE;
  --on-good: #06240F;
  --on-danger: #2A0712;     /* the lifted danger is too light for white text */
  --timer-go-fill: linear-gradient(170deg, #163A28, #0F2A1D);
  --timer-count-fill: linear-gradient(170deg, #3F3215, #2A2210);
  --pr: #F3A33B;
  --pr-soft: #3F2E13;
  --pr-ink: #FFD08A;
  --down: #F0606A;
  --down-soft: #3E1F24;
  --down-ink: #FCA5A5;
  --flat: #A0A9BA;
  --warn-soft: #3F3215;
  --warn-ink: #FCD34D;
  --danger: #F2567B;
  --danger-soft: #3F1F2B;
  --danger-ink: #FB7185;
  --warmup: #8E9AB5;
  --warmup-soft: #242C3E;
  --warmup-ink: #B4BED3;
  --done: #163A28;
  --done-ink: #8FE0AE;
  --chart-area: rgba(91, 130, 255, .14);
  --mm-1: #2A3A66; --mm-2: #3B55A8; --mm-3: #5B82FF; --mm-4: #A9BEFF;
  --g-arms-soft: #3B2416; --g-push-soft: #3B1C1C; --g-back-soft: #2C2144; --g-quads-soft: #163528;
  --g-posterior-soft: #15303A; --g-wrists-soft: #3A2A14; --g-abs-soft: #3B1A2C; --g-neck-soft: #14332F;
  --g-cardio-soft: #3A1540;
  --g-arms-ink: #FB923C; --g-push-ink: #F87171; --g-back-ink: #A78BFA; --g-quads-ink: #34D399;
  --g-posterior-ink: #22D3EE; --g-wrists-ink: #FBBF24; --g-abs-ink: #F472B6; --g-neck-ink: #2DD4BF;
  --g-cardio-ink: #E879F9;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 10px 28px rgba(0,0,0,.35);
  --shadow-3: 0 14px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ---------- 2. base ------------------------------------------------------ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* the hidden attribute always wins, whatever display a component sets */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
input, textarea { -webkit-appearance: none; appearance: none; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: var(--brand); text-decoration: none; }
/* One keyboard focus ring for every control, in the brand colour (3:1 or
   more against the ground and cards in both themes). Fields draw their own
   border ring instead. Rows inside a clipped group ring inside themselves. */
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.list-group.joined > :focus-visible, .sheet :focus-visible, .seg > :focus-visible { outline-offset: -3px; }
svg.ico { width: 22px; height: 22px; display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
svg.ico.sm { width: 18px; height: 18px; }
svg.ico.lg { width: 28px; height: 28px; }

/* Read by screen readers, not shown. */
.sr-only { position: absolute; top: 0; left: 0; max-width: 100vw; margin: 0; clip-path: inset(50%); pointer-events: none; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.center { text-align: center; }
.bold { font-weight: 800; }
.cap { font-size: var(--fs-cap); font-weight: 650; color: var(--muted); }
.k { font-size: var(--fs-cap); font-weight: 700; color: var(--muted); }
.sub { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.eyebrow {
  font-size: 12px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.section-title { font-size: var(--fs-sm); font-weight: 800; color: var(--ink-2); margin: 8px 2px -4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-title .more { font-size: var(--fs-cap); font-weight: 800; color: var(--brand); min-height: 44px; display: inline-flex; align-items: center; gap: 2px; }
button.section-title { min-height: 44px; }
.good { color: var(--good-ink); }
.pr-ink { color: var(--pr-ink); }
.down-ink { color: var(--down-ink); }
.up-ink { color: var(--good-ink); }

/* ---------- 3. layout --------------------------------------------------- */

.app {
  padding: calc(var(--safe-t) + 8px) var(--pad) calc(var(--safe-b) + var(--nav-h) + 24px);
  max-width: 560px;
  margin: 0 auto;
}
.app.no-tabs { padding-bottom: calc(var(--safe-b) + 110px); }

/* Single-column grids: minmax(0, 1fr) so an over-wide child (a nowrap chip
   row, a long word) is clipped inside its card instead of widening the card
   past the viewport. */
.stack    { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.stack.sm { gap: 8px; }
.row      { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread   { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow     { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Screen header: optional back/leading button, title + sub, trailing action. */
.screen-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; min-height: 48px; }
.screen-head h1 { font-size: var(--fs-h1); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.screen-head h1.sm { font-size: 23px; }
.screen-head .sub { margin-top: 2px; }

/* ---------- 4. buttons -------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap-lg); padding: 0 20px;
  border-radius: var(--r-md); background: var(--surface); color: var(--ink);
  font-size: var(--fs-body); font-weight: 700; border: 1px solid var(--line);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
  touch-action: manipulation; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn.block  { display: flex; width: 100%; }
.btn.primary{ background: var(--brand); color: var(--on-brand); border-color: transparent; box-shadow: 0 6px 16px rgba(47,91,234,.26); }
.btn.go     { background: var(--good-strong); color: var(--on-strong); border-color: transparent; box-shadow: 0 6px 16px rgba(21,128,61,.26); }
.btn.soft   { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.btn.ghost  { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger-ink); border-color: transparent; background: var(--danger-soft); }
.btn.lg     { min-height: var(--tap-xl); font-size: 19px; border-radius: 16px; }
.btn.sm     { min-height: 44px; padding: 0 14px; font-size: var(--fs-sm); border-radius: 11px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.icon-btn {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
  font-size: 20px; font-weight: 800; color: var(--ink-2);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.plain { background: transparent; border-color: transparent; }

.chip {
  min-height: 44px; padding: 0 16px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip:active { transform: scale(.96); }
.chip.on { background: var(--brand); border-color: transparent; color: var(--on-brand); }
.chip.soft { background: var(--surface-2); border-color: transparent; }
.chip.swatch::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--g, var(--brand)); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.pill.good  { background: var(--good-soft); color: var(--good-ink); }
.pill.pr    { background: var(--pr-soft); color: var(--pr-ink); }
.pill.warn  { background: var(--warn-soft); color: var(--warn-ink); }
.pill.g     { background: var(--g-soft, var(--surface-2)); color: var(--g-ink, var(--ink-2)); }

/* Segmented control. */
.seg { display: flex; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); gap: 2px; }
.seg button { flex: 1; min-height: 44px; border-radius: 11px; font-size: var(--fs-sm); font-weight: 750; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- 5. cards & tiles ------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.card.tight { padding: 12px; }
.card.flat  { box-shadow: none; border: 1px solid var(--line); }
.card.accent { position: relative; overflow: hidden; padding-left: 20px; }
.card.accent::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--g, var(--brand)); }
.card.soft { background: var(--g-soft, var(--brand-soft)); box-shadow: none; }
.card-link  { display: block; width: 100%; text-align: left; color: inherit; }
.card-link:active { transform: scale(.985); }
.card h2 { font-size: var(--fs-h2); font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.card h3 { font-size: var(--fs-h3); font-weight: 800; letter-spacing: -.01em; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles.three .tile { padding: 12px 10px 10px; }
.tiles.three .tile .v { font-size: 21px; }
.tiles.three .tile .l { font-size: 11px; }
.tile {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1);
  padding: 14px 14px 12px; display: grid; gap: 2px; min-width: 0; text-align: left; color: inherit;
}
.tile.wide { grid-column: 1 / -1; }
.tile .v { font-size: 26px; font-weight: 850; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v small { font-size: 14px; font-weight: 750; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.tile .l { font-size: 12px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .d { font-size: var(--fs-cap); font-weight: 750; margin-top: 2px; }
.tile .d.up { color: var(--good-ink); }
.tile .d.down, .tile .d.flat { color: var(--muted); } /* a drop is neutral: green is the only verdict */
.tile.ringed { grid-template-columns: 1fr auto; align-items: center; }
.tile.ringed .ring-wrap { grid-row: 1 / span 3; }

.stat-row { display: flex; gap: 18px; margin-top: 12px; }
.stat { display: grid; gap: 1px; min-width: 0; }
.stat b { font-size: 22px; font-weight: 800; white-space: nowrap; }
.stat span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Progress ring: an SVG from ui.ringSvg(). */
.ring-wrap { position: relative; display: grid; place-items: center; }
.ring-svg { display: block; }
.ring-svg .track { fill: none; stroke: var(--line-2); }
.ring-svg .bar { fill: none; stroke: var(--g, var(--brand)); stroke-linecap: round; transition: stroke-dashoffset .5s var(--ease); }
.ring-wrap .in { position: absolute; font-weight: 850; letter-spacing: -.02em; }

/* List rows: leading badge, title + meta, trailing value / chevron. */
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; color: inherit;
  min-height: 60px; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--line); font-weight: 700;
}
.list-row:active { background: var(--surface-2); }
.list-row .t { display: block; font-weight: 800; font-size: var(--fs-body); }
.list-row .m { display: block; font-size: var(--fs-cap); font-weight: 650; color: var(--muted); margin-top: 1px; }
.list-row .chev { color: var(--faint); }
.list-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.list-group.joined { gap: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); overflow: hidden; }
.list-group.joined .list-row { border: 0; border-radius: 0; border-bottom: 1px solid var(--line-2); }
.list-group.joined .list-row:last-child { border-bottom: 0; }

.badge {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 13px;
  display: grid; place-items: center; font-weight: 850; font-size: 14px; letter-spacing: .02em;
  background: var(--g-soft, var(--brand-soft)); color: var(--g-ink, var(--brand-ink));
}
.badge.sm { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; font-size: 12px; }
.badge.lg { width: 54px; height: 54px; flex-basis: 54px; border-radius: 16px; font-size: 17px; }
.badge.round { border-radius: 50%; }

/* ---------- 6. tab bar -------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(var(--safe-b) + 6px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: grid; justify-items: center; gap: 3px; padding: 6px 0 2px; min-height: 50px;
  font-size: 11px; font-weight: 750; color: var(--muted); letter-spacing: .01em;
  border-radius: 12px; position: relative;
}
.tab .ico { width: 24px; height: 24px; }
.tab.on { color: var(--brand); }
.tab.on .ico { stroke-width: 2.4; }
.tab .live { position: absolute; top: 4px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 2px var(--surface); }

/* ---------- 7. forms ---------------------------------------------------- */

.field { display: grid; gap: 6px; }
.field label { font-size: var(--fs-cap); font-weight: 800; color: var(--muted); margin-left: 4px; }
.field input, .field select, .field textarea {
  min-height: var(--tap-lg); padding: 0 16px; width: 100%;
  border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface);
  font-size: var(--fs-body); color: var(--ink);
}
.field textarea { padding: 12px 16px; min-height: 96px; resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); }
.field select { font-weight: 800; text-align: center; }
.rest-wheels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.rest-preview { font-size: 56px; font-weight: 900; text-align: center; margin: 14px 0 10px; letter-spacing: -.02em; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch { position: relative; width: 54px; height: 32px; flex: 0 0 54px; border-radius: var(--r-pill); background: var(--line); transition: background .15s; }
.switch::before { content: ""; position: absolute; inset: -6px -8px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(22px); }
.err { color: var(--danger-ink); font-weight: 700; font-size: 14px; text-align: center; }

/* Steppers: − value + ; the numeral shrinks (--fit) rather than clipping. */
.stepper { display: grid; gap: 6px; min-width: 0; }
.stepper .cap { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper .ctl { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 4px; }
.stepper .val { min-width: 0; text-align: center; font-weight: 850; letter-spacing: -.02em; font-size: var(--fit, 32px); line-height: 1.1; white-space: nowrap; }
.step-btn {
  height: 52px; min-width: 48px; border-radius: var(--r-md); background: var(--surface-2);
  font-size: 24px; font-weight: 800; color: var(--ink-2); display: grid; place-items: center;
}
.step-btn:active { background: var(--brand-soft); color: var(--brand); transform: scale(.95); }

/* ---------- 8. login ---------------------------------------------------- */

.login-wrap { min-height: 82dvh; display: grid; align-content: center; gap: 22px; }
.brandmark {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 26px;
  display: grid; place-items: center; color: var(--on-strong);
  background: var(--brandmark-fill);
  box-shadow: 0 14px 34px rgba(47,91,234,.35);
  font-weight: 900; font-size: 30px; letter-spacing: -.04em;
}
.brandmark .ico { width: 44px; height: 44px; stroke-width: 2.2; }
.login-title { font-size: 32px; font-weight: 850; text-align: center; letter-spacing: -.03em; }
.faceid { font-size: 22px; }

/* ---------- 9. home ----------------------------------------------------- */

.hero-start {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 18px 18px; border-radius: var(--r-lg); color: var(--on-strong);
  background: var(--hero-fill);
  box-shadow: 0 12px 30px rgba(47,91,234,.32); min-height: 84px;
}
.hero-start:active { transform: scale(.985); }
.hero-start .big { font-size: 22px; font-weight: 850; letter-spacing: -.02em; display: block; }
.hero-start .hint { font-size: var(--fs-cap); font-weight: 650; display: block; margin-top: 2px; }
.hero-start .ico-wrap { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 15px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.hero-start .ico { width: 28px; height: 28px; }
.hero-start.resume { background: var(--resume-fill); box-shadow: 0 12px 30px rgba(21,128,61,.3); }

.pr-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.pr-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); min-height: 56px; width: 100%; text-align: left; color: inherit; }
.pr-row:last-child { border-bottom: 0; }
.pr-row .ico-wrap { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; display: grid; place-items: center; background: var(--pr-soft); color: var(--pr); }
.pr-row .t { font-weight: 800; display: block; font-size: var(--fs-sm); }
.pr-row .m { font-size: 12px; font-weight: 650; color: var(--muted); display: block; }
.pr-row .v { font-weight: 850; font-size: var(--fs-body); white-space: nowrap; }

.groups-week { display: flex; flex-wrap: wrap; gap: 8px; }

.compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.compare .side { display: grid; gap: 1px; min-width: 0; }
.compare .side.r { text-align: right; }
/* A big total never gets cut: the unit (in <small>) drops under the number when it has to. */
.compare .side b { font-size: 20px; font-weight: 850; letter-spacing: -.02em; line-height: 1.15; }
.compare .side b small { font-size: 14px; font-weight: 750; color: var(--muted); letter-spacing: 0; }
.compare .side span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.compare .mid { font-size: var(--fs-cap); font-weight: 800; padding: 4px 8px; border-radius: var(--r-pill); background: var(--surface-2); white-space: nowrap; }
.compare .mid.up { background: var(--good-soft); color: var(--good-ink); } /* .down stays neutral */

.activity { display: grid; grid-template-columns: minmax(0, 1fr); }
.activity .a-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); min-height: 56px; width: 100%; text-align: left; color: inherit; }
.activity .a-row:last-child { border-bottom: 0; }
.activity .t { font-weight: 800; display: block; font-size: var(--fs-sm); }
.activity .m { font-size: 12px; font-weight: 650; color: var(--muted); display: block; }

/* ---------- 10. calendar ------------------------------------------------ */

.cal { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head h2 { font-size: var(--fs-h3); }
.cal-dow, .cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow span { text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.cal-dow span.we { color: var(--brand); }
.cal-label { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; margin: 2px 0 -4px; }

.day {
  position: relative; min-height: 48px; padding: 5px 2px 4px;
  border-radius: 12px; background: transparent; border: 1.5px solid transparent;
  display: grid; justify-items: center; align-content: start; gap: 3px; color: inherit;
}
.day .d { font-size: 16px; font-weight: 750; }
.day.we    { background: var(--surface-2); }
.day.other { opacity: .6; }
.day.future .d { color: var(--muted); }
.day.today { border-color: var(--brand); }
.day.today .d { color: var(--brand); }
.day.done  { background: var(--good-soft); }
.day.done .d { color: var(--good-ink); }
.day.sel   { background: var(--brand); border-color: var(--brand); }
.day.sel .d { color: var(--on-brand); }
.day.sel .dot { background: var(--on-brand); }
.dots { display: flex; gap: 3px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--g, var(--brand)); }

/* ---------- 11. group cards (picker) ----------------------------------- */

.group-card {
  display: flex; align-items: center; gap: 14px; width: 100%; color: inherit;
  padding: 12px 14px; border-radius: var(--r); background: var(--surface);
  box-shadow: var(--shadow-1); text-align: left; min-height: 76px;
}
.group-card:active { transform: scale(.985); }
.group-card .name { font-size: var(--fs-body); font-weight: 800; letter-spacing: -.01em; display: block; }
.group-card .meta { font-size: var(--fs-cap); font-weight: 600; color: var(--muted); margin-top: 4px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px 0; }
.group-card .chev { color: var(--faint); }

/* ---------- 12. active workout ---------------------------------------- */

.session-head {
  position: sticky; top: 0; z-index: 20; margin: 0 calc(var(--pad) * -1) 12px;
  padding: calc(var(--safe-t) + 8px) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-2);
}
/* Back · title over its meta line · timer · options. Nothing is cut short:
   a long title wraps, and the meta line breaks between its parts. Under
   360 px the buttons make a toolbar and the title and meta line run the full
   width beneath it. */
.session-bar {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 44px;
  grid-template-areas: "back title clock menu" "back sub clock menu";
  align-items: center; column-gap: 10px; row-gap: 1px;
}
.session-bar .sb-back { grid-area: back; }
.session-bar .sb-menu { grid-area: menu; }
.session-bar .clock-btn { grid-area: clock; }
.session-title { grid-area: title; align-self: end; margin: 0; font-size: var(--fs-h3); font-weight: 850; letter-spacing: -.01em; line-height: 1.2; overflow-wrap: anywhere; }
.session-sub { grid-area: sub; align-self: start; margin: 0; font-size: var(--fs-cap); font-weight: 700; color: var(--muted); line-height: 1.35; }
.session-sub span { white-space: nowrap; }
.clock-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line);
  font-weight: 850; font-size: var(--fs-sm); color: var(--ink);
}
.clock-btn.paused { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.clock-btn.done { background: var(--good-soft); color: var(--good-ink); border-color: transparent; }
.clock-btn .ico { width: 18px; height: 18px; }

.ex-card { padding: 14px 14px 12px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1); }
.ex-head { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; color: inherit; }
.ex-name { font-size: var(--fs-body); font-weight: 800; letter-spacing: -.01em; display: block; }
.ex-prev { font-size: var(--fs-cap); font-weight: 650; color: var(--muted); margin-top: 2px; display: block; }
.ex-prev b { color: var(--ink-2); font-weight: 750; }
.ex-note { margin: 8px 0 0; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-cap); font-weight: 650; color: var(--ink-2); white-space: pre-wrap; }
.ex-count {
  width: 42px; height: 40px; flex: 0 0 42px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 850; font-size: 13px; letter-spacing: -.02em;
  background: var(--surface-2); color: var(--muted);
}
.ex-count.has { background: var(--good-soft); color: var(--good-ink); }

/* Set table: # | previous | weight | reps | done */
.set-table { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 12px; }
.set-cols, .set-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr) 52px;
  align-items: center; gap: 6px;
}
.set-cols { padding: 0 2px; }
.set-cols span { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-row { border-radius: var(--r-md); padding: 3px 2px; }
.set-row.done { background: var(--done); }
.set-row.warmup { background: var(--warmup-soft); }
.set-row.warmup.done { background: var(--done); }
.set-row.pr { background: var(--pr-soft); }
.set-row.sel { box-shadow: inset 0 0 0 2px var(--brand); }
.set-no {
  height: 46px; border-radius: 11px; display: grid; place-items: center; align-content: center; gap: 1px;
  font-weight: 850; font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface-2);
}
/* Last time's set under the number (320 px): in the number's own ink, which is
   chosen for each row state's fill (muted on a done row's green fails AA in dark). */
.set-no small { display: none; font-size: 9.5px; font-weight: 750; color: inherit; line-height: 1; white-space: nowrap; }
.set-row.warmup .set-no { color: var(--warmup-ink); background: color-mix(in srgb, var(--warmup) 14%, transparent); }
.set-row.done .set-no { color: var(--good-ink); background: color-mix(in srgb, var(--good) 14%, transparent); }
.set-row.pr .set-no { color: var(--pr-ink); background: color-mix(in srgb, var(--pr) 18%, transparent); }
.set-prev { height: 46px; min-width: 0; display: grid; place-items: center; border-radius: 11px; font-size: var(--fs-cap); font-weight: 700; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-prev:active { background: var(--surface-2); }
.set-in {
  height: 46px; width: 100%; min-width: 0; border-radius: 11px; text-align: center;
  font-size: 20px; font-weight: 850; letter-spacing: -.01em; border: 1.5px solid transparent;
  background: var(--surface); color: var(--ink); padding: 0 4px;
}
.set-row.done .set-in { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.set-in:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.set-in::placeholder { color: var(--faint); font-weight: 750; }
.set-in.bw { font-size: 17px; }
.set-done {
  height: 46px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
}
.set-done .ico { width: 24px; height: 24px; stroke-width: 2.6; }
.set-done.on { background: var(--good); color: var(--on-good); }
.set-done:active { transform: scale(.93); }

/* Tools strip for the selected set row. */
.set-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 8px 2px 4px; }
.set-tools .steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.set-tools .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.set-tools .pair .step-btn { height: 46px; font-size: 20px; }
.set-tools .pair .step-btn small { font-size: 11px; font-weight: 800; margin-left: 3px; color: var(--muted); }
.rpe-row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; min-width: 0; } /* 4 px dead space keeps RPE 6–10 and the scale toggle on one line at 390 */
.rpe-row .chip { min-width: 44px; padding: 0 10px; font-size: 14px; justify-content: center; }
.rpe-row .chip.on { background: var(--ink); color: var(--surface); }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.tool-row .chip { flex: 1 1 calc(33.33% - 4px); min-width: 0; font-size: 14px; padding: 0 8px; justify-content: center; }
.tool-row .chip.warm.on { background: var(--warmup-ink); color: var(--surface); }
.tool-row .chip.del { color: var(--danger-ink); }

.add-set { margin-top: 8px; min-height: 48px; border-style: dashed; border-color: var(--line); color: var(--ink-2); font-size: var(--fs-sm); }
.copy-last { margin-top: 10px; }

.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.quick .chip { min-height: 44px; min-width: 44px; padding: 0 13px; font-size: 14px; justify-content: center; }
.quick .caption { min-width: 0; padding: 0 2px; border-color: transparent; background: transparent; color: var(--muted); font-weight: 700; }

.finish-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px var(--pad) calc(var(--safe-b) + 10px);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.finish-bar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }

/* ---------- 13. summary ------------------------------------------------- */

.summary-hero { text-align: center; padding: 22px 16px 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); display: grid; gap: 6px; justify-items: center; }
.summary-hero .mark { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--good-soft); color: var(--good); }
.summary-hero .mark .ico { width: 34px; height: 34px; stroke-width: 2.6; }
.summary-hero .mark.pr { background: var(--pr-soft); color: var(--pr); }
.summary-hero h1 { font-size: 26px; font-weight: 850; letter-spacing: -.02em; }
.summary-hero p { color: var(--muted); font-weight: 650; font-size: var(--fs-sm); }

.cmp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); min-height: 56px; width: 100%; text-align: left; color: inherit; }
.cmp-row:last-child { border-bottom: 0; }
.cmp-row .t { font-weight: 800; display: block; font-size: var(--fs-sm); }
.cmp-row .m { font-size: 12px; font-weight: 650; color: var(--muted); display: block; margin-top: 1px; }
.cmp-row .delta { font-weight: 850; font-size: var(--fs-sm); white-space: nowrap; padding: 6px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); }
.cmp-row .delta.up { background: var(--good-soft); color: var(--good-ink); } /* .down stays neutral */
.cmp-row .delta.pr { background: var(--pr-soft); color: var(--pr-ink); }

/* ---------- 14. sheets / dialogs --------------------------------------- */

.sheet-back {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 10px var(--pad) calc(var(--safe-b) + 18px);
  animation: rise .2s var(--ease);
}
.sheet:focus { outline: none; } /* the dialog itself takes focus on opening; its controls show the ring */
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { font-size: 20px; font-weight: 850; margin-bottom: 10px; }
.sheet .lead { color: var(--muted); font-weight: 650; font-size: var(--fs-sm); margin: -4px 0 12px; }
.pick-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; color: inherit;
  min-height: 60px; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--line); font-weight: 700;
}
.pick-row:active { background: var(--surface-2); }
.pick-row .k { font-size: 12px; font-weight: 800; color: var(--muted); display: block; }
.pick-row.danger { color: var(--danger-ink); }
.pick-row.added { background: var(--good-soft); border-color: transparent; }
.pick-row.added > .ico { color: var(--good-ink); }
/* The field is the box (so its focus ring is on the thing that has focus);
   the magnifier sits inside it. */
.search { position: relative; margin-bottom: 10px; }
.search > .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  display: block; width: 100%; min-height: 50px; padding: 0 14px 0 42px;
  border-radius: var(--r-md); background: var(--surface); border: 1.5px solid var(--line); font-size: var(--fs-body);
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(24px) } }
@keyframes drop { from { transform: translate(-50%, -16px); opacity: 0 } }
@keyframes toast-in { from { transform: translate(-50%, 14px); opacity: 0 } }
@keyframes pop { from { transform: scale(.7); opacity: .3 } }
@keyframes shimmer { from { background-position: -200% 0 } to { background-position: 200% 0 } }

/* ---------- 15. rest timer -------------------------------------------- */

.timer-full {
  position: fixed; inset: 0; z-index: 80;
  background: linear-gradient(170deg, var(--surface), var(--brand-soft) 65%, var(--brand-soft));
  display: grid; grid-template-rows: auto 1fr auto; gap: 8px;
  padding: calc(var(--safe-t) + 14px) var(--pad) calc(var(--safe-b) + 18px);
  animation: fade .15s ease;
}
.timer-full.go { background: var(--timer-go-fill); }
.timer-full.count { background: var(--timer-count-fill); }
.timer-full:focus { outline: none; } /* the dialog takes focus on opening; its controls show the ring */
.timer-mid { display: grid; place-items: center; position: relative; border-radius: var(--r-lg); cursor: pointer; }
.ring { width: min(78vw, 340px); aspect-ratio: 1; }
.ring circle { fill: none; stroke-linecap: round; }
.ring .bg { stroke: color-mix(in srgb, var(--brand) 14%, transparent); }
.ring .fg { stroke: var(--brand); transition: stroke-dashoffset .25s linear; }
.timer-num { position: absolute; font-size: min(23vw, 110px); font-weight: 850; letter-spacing: -.04em; line-height: 1; }
.timer-count { font-size: min(58vw, 300px); font-weight: 850; line-height: .9; color: var(--warn-ink); animation: pop .4s ease; }
.timer-go { display: grid; gap: 10px; place-items: center; text-align: center; }
.timer-go .big { font-size: min(17vw, 76px); font-weight: 850; color: var(--good-ink); letter-spacing: -.02em; }
.timer-go .sub { font-size: 20px; font-weight: 800; color: var(--good-ink); }
.timer-label { text-align: center; font-size: var(--fs-sm); font-weight: 800; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; }
.timer-label.pr { color: var(--pr-ink); text-transform: none; letter-spacing: 0; font-size: var(--fs-body); }
.timer-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.timer-pill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 92px); z-index: 50;
  display: flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 10px 18px; border-radius: var(--r-pill);
  background: var(--brand); color: var(--on-brand); font-weight: 850; font-size: 18px;
  box-shadow: var(--shadow-3);
}
.timer-pill .ico { width: 20px; height: 20px; }
.timer-pill.warn { background: var(--warn); color: var(--on-amber); }

/* ---------- 16. charts (Phase 1 minimal; charts.css extends these) ---- */

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); padding: 14px; min-width: 0; }
.kpi b { display: block; font-size: 24px; font-weight: 850; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.chart { width: 100%; height: 190px; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid-l { stroke: var(--chart-grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--g, var(--chart-line)); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--g, var(--chart-line)); opacity: .1; }
.chart .pt { fill: var(--surface); stroke: var(--g, var(--chart-line)); stroke-width: 2.5; }
.chart .bar { fill: var(--g, var(--chart-bar)); opacity: .85; }
.chart text { font-size: 11px; font-weight: 700; fill: var(--chart-axis); }
.chart .val-label { font-size: 13px; font-weight: 800; fill: var(--g, var(--chart-line)); }
.spark { width: 84px; height: 32px; flex: 0 0 84px; }
.spark path { fill: none; stroke: var(--g, var(--chart-line)); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.hist-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); min-height: 52px; }
.hist-row:last-child { border-bottom: 0; }
.hist-row .date { font-size: 14px; font-weight: 800; width: 78px; flex: 0 0 78px; }

/* ---------- 17. feedback states --------------------------------------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  /* Above the tab bar, in the thumb zone, never over a screen header. The
     rest-timer overlay sits above it and carries the record line itself. */
  bottom: calc(var(--safe-b) + var(--nav-h) + 14px); z-index: 70;
  padding: 13px 20px; border-radius: var(--r-md); width: max-content; max-width: min(90vw, 480px); text-align: center;
  background: var(--ink); color: var(--surface); font-weight: 750; font-size: var(--fs-sm);
  box-shadow: var(--shadow-3); animation: toast-in .18s ease;
}
.app.no-tabs ~ .toast { bottom: calc(var(--safe-b) + 98px); }
/* While a toast shows during a workout, the minimised timer pill steps up. */
.toast:not([hidden]) ~ .overlay-root .timer-pill { bottom: calc(var(--safe-b) + 156px); }
/* With a sheet up, the toast shows in the scrim above it, never over what the sheet holds. */
body:has(.sheet-back) > #toast { top: calc(var(--safe-t) + 12px); bottom: auto; }
.toast.pr { background: var(--pr); color: var(--on-amber); }
.toast.err { background: var(--danger); color: var(--on-danger); }

.empty { text-align: center; padding: 26px 16px; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.empty .glyph { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.empty .glyph .ico { width: 28px; height: 28px; }
.empty p { font-weight: 650; font-size: var(--fs-sm); max-width: 28ch; }
.empty h3 { color: var(--ink); font-size: var(--fs-h3); font-weight: 800; }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); font-size: var(--fs-cap); font-weight: 750; min-height: 44px; }
.banner.offline { background: var(--warn-soft); color: var(--warn-ink); }
.banner.error { background: var(--danger-soft); color: var(--danger-ink); }
.banner.info { background: var(--brand-soft); color: var(--brand-ink); }
.banner.good { background: var(--good-soft); color: var(--good-ink); }
.sheet .banner { margin-bottom: 12px; }

.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-2) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; min-height: 16px; }

.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); display: inline-block; flex: 0 0 auto; }
.status-dot.pending, .status-dot.syncing { background: var(--warn); }
.status-dot.offline { background: var(--faint); }
.status-dot.error { background: var(--danger); }
.status-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; }

.version { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding: 6px 0 2px; }

.avatar-lg { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; font-size: 24px; font-weight: 900; color: var(--brand-ink); background: var(--brand-soft); letter-spacing: -.02em; }

/* ---------- 18. shared extras (body, cardio, recovery, nutrition) ----- */

/* A number field with its unit inside the box: <div class="unit-field"><input><span>kg</span></div> */
.unit-field { position: relative; display: flex; align-items: center; min-width: 0; }
.unit-field input {
  width: 100%; min-width: 0; min-height: var(--tap-lg); padding: 0 52px 0 16px;
  border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface);
  font-size: 20px; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums;
}
.unit-field input::placeholder { color: var(--faint); font-weight: 600; font-size: 16px; }
.unit-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.unit-field input[aria-invalid="true"] { border-color: var(--danger); }
.unit-field > span { position: absolute; right: 14px; font-size: 15px; font-weight: 750; color: var(--muted); pointer-events: none; }
.unit-field.big input { min-height: 68px; font-size: 30px; font-weight: 850; letter-spacing: -.02em; }
.unit-field.big input::placeholder { font-size: 26px; font-weight: 750; }
.unit-field.big > span { font-size: 18px; }
.unit-field.sm input { padding-right: 40px; font-size: 18px; }
.unit-field.sm input::placeholder { font-size: 14px; }
.unit-field.sm > span { right: 12px; font-size: 14px; }
.field-err { color: var(--danger-ink); font-size: 12px; font-weight: 700; margin: 0 2px; line-height: 1.3; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.pair .field { min-width: 0; }
.rest-wheels.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rest-wheels.three .field select { padding: 0 6px; }

/* A change pill: neutral by default, green only when a goal says which way is progress. */
.delta { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-cap); font-weight: 800; white-space: nowrap; max-width: 100%; }
.delta.good { background: var(--good-soft); color: var(--good-ink); }
.delta.flat { color: var(--muted); }
.delta .pct { font-weight: 700; }
.delta .suffix { font-weight: 650; color: var(--muted); white-space: normal; }
.delta.good .suffix { color: inherit; }
.delta.plain { background: none; padding: 0; border-radius: 0; }
.delta .ico.xs { width: 14px; height: 14px; stroke-width: 2.4; }
svg.ico.xs { width: 14px; height: 14px; stroke-width: 2.4; }

/* A screen's big number (today's weight, this week's cardio). */
.hero-num { font-size: 46px; font-weight: 850; letter-spacing: -.035em; line-height: 1; color: var(--ink); white-space: nowrap; }
.hero-num small { font-size: 18px; font-weight: 750; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-side { display: grid; justify-items: end; gap: 1px; text-align: right; }
.hero-side span { font-size: 12px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.hero-side b { font-size: 19px; font-weight: 800; color: var(--ink-2); white-space: nowrap; }

/* Section header with an optional trailing action, between cards. */
.section-title .act { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px 0 12px; font-size: var(--fs-cap); font-weight: 800; color: var(--brand); }

/* A simple progress bar (water, calories). */
.bar { display: block; height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.bar.over i { background: var(--warn); }

/* Day navigation: ‹ Today › */
.day-nav { display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px; align-items: center; gap: 8px; }
.day-nav b { text-align: center; font-size: var(--fs-body); font-weight: 850; }
.day-nav .icon-btn[aria-disabled="true"] { opacity: .35; }

/* ---------- 19. responsive & motion ----------------------------------- */

@media (max-width: 359px) {
  :root { --fs-h1: 25px; --fs-h2: 20px; --pad: 14px; }
  .session-bar { grid-template-areas: "back . clock menu" "title title title title" "sub sub sub sub"; row-gap: 2px; }
  .session-bar .session-title { margin-top: 6px; }
  .set-cols, .set-row { grid-template-columns: 48px minmax(0, 1.2fr) minmax(0, 1fr) 46px; gap: 4px; }
  .set-cols span:nth-child(2), .set-prev { display: none; }
  .set-no { font-size: 14px; }
  .set-no small { display: block; }
  .set-in { font-size: 18px; padding: 0 2px; }
  .tool-row .chip { flex-basis: calc(50% - 3px); }
  .rpe-row .k { flex-basis: 100%; }
  .tile .v { font-size: 22px; }
  .compare .side b { font-size: 18px; }
  .tile .l { font-size: 11px; letter-spacing: .03em; }
  .tile.ringed .ring-svg { width: 44px; height: 44px; }
  .tile { padding: 12px 12px 10px; }
  .tiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-num { font-size: 40px; }
  .pair.stack-narrow { grid-template-columns: minmax(0, 1fr); }
  .hero-start .big { font-size: 19px; }
  .stat-row { gap: 12px; }
  .stat b { font-size: 19px; }
  .tab { font-size: 10px; }
}

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