/* Training app. Palette borrows Olympic bumper-plate colors, used only to carry meaning:
   blue = act, yellow = rest timer, green = done, red = missed. Numbers are the hero type. */

@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url(/fonts/barlow-condensed-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(/fonts/barlow-condensed-700.woff2) format("woff2"); }

:root {
  /* One token block for both themes: light-dark() picks by color-scheme, which kit theme.css sets
     from <html data-theme> (Auto follows the OS). Dark values are written once. */
  --chalk:   light-dark(#F2F4F3, #14191C);  /* page */
  --surface: light-dark(#FFFFFF, #1E2528);  /* cards, inputs */
  --sunk:    light-dark(#E7EBEA, #283034);  /* pressed / inset */
  --raised:  light-dark(#FFFFFF, #424D52);  /* selected segment */
  --ink:     light-dark(#1D2427, #E6EBEB);
  --muted:   light-dark(#5F6A6E, #98A4A8);
  --faint:   light-dark(#8A9599, #6E7A7E);  /* decoration only (dots, chevrons, empty rings), never text: 2.8:1 */
  --line:    light-dark(#D9DEDF, #2C3438);
  --blue:    light-dark(#1F5FBF, #5B8FE0);  /* 20 kg plate: actions */
  --yellow:  light-dark(#E3A81B, #F0BC3A);  /* 15 kg plate: rest */
  --amber-text: light-dark(#8C6200, #F0BC3A); /* yellow, darkened for text on light backgrounds */
  --green:   light-dark(#2E7D4F, #4FAE77);  /* 10 kg plate: done */
  --red:     light-dark(#B8423A, #E06A5F);  /* 25 kg plate: missed */
  /* Text and icons on a plate-color fill, per theme (>= 4.5:1; white on the brighter dark-mode
     green and red was 2.7 and 3.3). */
  --on-blue:  light-dark(#FFFFFF, #0E1A2E);
  --on-green: light-dark(#FFFFFF, #0C1F14);
  --on-red:   light-dark(#FFFFFF, #250B08);
  --on-yellow: #1D2427;
  --tint-green: color-mix(in srgb, var(--green) 11%, var(--surface));
  --tint-blue: color-mix(in srgb, var(--blue) 9%, var(--surface));
  --shadow: 0 1px 2px light-dark(rgba(20, 30, 35, 0.06), transparent), 0 2px 8px light-dark(rgba(20, 30, 35, 0.04), transparent);

  --num: "Barlow Condensed", ui-rounded, system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", sans-serif;
  --t-xs: 0.75rem;  --t-s: 0.875rem;  --t-b: 1.0625rem;  --t-m: 1.25rem;  --t-l: 1.625rem;  --t-xl: 2.375rem;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r: 12px; --r-s: 8px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabs-h: calc(58px + var(--safe-b));
  --rail-w: 88px;   /* the tab bar as a side rail, from 900px */
  /* Safe areas (iPhone Duo home-screen app: right 84 for the status column, bottom 34, top 0).
     Each side pads its own inset, never one value for both. --corner is extra room when there's
     no top inset (Duo, Mac; 0 under a slab iPhone's status bar): header and page column both get
     it, so their edges stay lined up. */
  --corner: clamp(0px, 24px - env(safe-area-inset-top, 0px), 8px);
  --pad-l: calc(env(safe-area-inset-left, 0px) + var(--corner) + var(--s4));
  --pad-r: calc(env(safe-area-inset-right, 0px) + var(--corner) + var(--s4));
  /* App bar top: 24px with no top inset, the bare inset under a status bar (slab iPhone unchanged). */
  --bar-top: max(var(--safe-t), 24px);

  /* The shared UI kit (public/kit/) reads these; mapped once, so a theme change carries over. */
  --kit-bg: var(--chalk); --kit-surface: var(--surface); --kit-surface-2: var(--sunk);
  --kit-ink: var(--ink); --kit-muted: var(--muted); --kit-line: var(--line);
  --kit-accent: var(--blue); --kit-on-accent: var(--on-blue);
  --kit-danger: var(--red); --kit-on-danger: var(--on-red);
  --kit-scrim: rgba(10, 15, 18, 0.4); --kit-shadow: none; --kit-gutter: var(--s4);
  --kit-radius-lg: 18px;
  --kit-toast-offset: calc(58px + var(--s4)); /* above the tab bar */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--chalk); color: var(--ink);
  font: 400 var(--t-b)/1.45 var(--text);
  padding-bottom: var(--tabs-h);
  -webkit-font-smoothing: antialiased;
}
body.mode-workout { padding-bottom: 0; }
body.mode-workout #tabs { display: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: var(--t-l); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--t-m); font-weight: 650; }
h3 { font-size: var(--t-b); font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--blue); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a, summary, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: var(--t-s); }
.center { text-align: center; }
.gap { margin-bottom: var(--s4); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: 0.01em; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

#app { max-width: 640px; margin: 0 auto; padding: 0 var(--pad-r) var(--s6) var(--pad-l); }
/* Swipe back from the logger: Today sits under it (workout.js), the logger covers it until it's gone. */
.swipe-under { position: fixed; inset: 0; z-index: 0; overflow: hidden; max-width: 640px; margin: 0 auto; padding: 0 var(--pad-r) 0 var(--pad-l); }
body.revealing #app { position: relative; z-index: 25; background: var(--chalk); box-shadow: -1px 0 0 var(--line); }
body.mode-workout.revealing #tabs { display: flex; }
/* Screens without an app bar (loading, errors) clear the status bar themselves. */
.loading-msg { color: var(--muted); padding: calc(var(--safe-t) + var(--s6)) 0 var(--s6); text-align: center; }
.empty { padding: calc(var(--safe-t) + var(--s6)) 0 var(--s6); }
.empty h2 { margin-bottom: var(--s2); }

/* ---------- tabs ---------- */
#tabs {
  position: fixed; inset: auto 0 0 0; height: var(--tabs-h); padding-bottom: var(--safe-b);
  /* Background edge to edge, tabs inside the side insets. */
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  display: flex; background: color-mix(in srgb, var(--chalk) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line); z-index: 20;
}
#tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: var(--t-xs); font-weight: 600;
}
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a[aria-current="page"] { color: var(--blue); }
#tabs a:active { opacity: 0.6; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; color: var(--ink); transition: transform 0.08s, opacity 0.08s;
}
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.block { display: flex; width: 100%; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--blue); padding: 0 var(--s2); }
.btn.danger { color: var(--red); }
.btn.quiet-danger { background: transparent; border-color: transparent; color: var(--red); }
.btn.danger-fill { background: var(--red); border-color: var(--red); color: var(--on-red); }
.btn.signout { margin-top: var(--s5); color: var(--red); }
.btn:disabled { opacity: 0.45; transform: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.mod { width: 18px; height: 18px; stroke-width: 1.8; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
}
.icon-btn:active { background: var(--sunk); }
.icon-btn .icon { width: 22px; height: 22px; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small .icon { width: 16px; height: 16px; }
.tag {
  display: inline-flex; align-items: center; font-size: var(--t-xs); font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px var(--s2); white-space: nowrap; line-height: 1.5;
}
.tag.accent { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); background: var(--tint-blue); }

/* ---------- app bar ---------- */
/* The kit's app bar (kit/app-bar.css: sticky, opaque page color, 44pt row under the status bar,
   8px fade below). Fitness was one of its sources. Every view's header and the workout logger's
   use it through appBar() in ui.js. It sits inside #app's column, so it bleeds to the column's
   edges with negative margins; outside the column there is no content to scroll under it. */
.page-head { margin: 0 calc(-1 * var(--pad-r)) var(--kit-fade) calc(-1 * var(--pad-l)); }
/* The column's own padding (insets + --corner + gutter), so the bar's edges match the page's.
   Top per --bar-top (kit's is the bare inset). */
.kit-bar { padding-top: var(--bar-top); padding-left: var(--pad-l); padding-right: var(--pad-r); }
.page-head .kit-bar__row { justify-content: space-between; gap: var(--s2); }
.page-head .kit-bar__title { font-size: var(--t-m); letter-spacing: -0.01em; }

/* ---------- Today ---------- */
.context { margin-bottom: var(--s4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); font-size: var(--t-s); }
.context a { font-weight: 600; display: inline-flex; align-items: center; min-height: 32px; }
.context .focus { flex-basis: 100%; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; margin: 0 calc(-1 * var(--s1)) var(--s4); }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s2) 0 var(--s2);
  border: 0; border-radius: var(--r); background: transparent; color: var(--muted); font-size: var(--t-xs); font-weight: 500;
}
.day .dn { font-size: 1.35rem; line-height: 1.1; color: var(--ink); font-weight: 500; }
.day.is-today .wd, .day.is-today .dn { color: var(--blue); font-weight: 700; }
.day[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.day:active { background: var(--sunk); }
.day .dots { display: flex; gap: 3px; height: 9px; margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--faint); }
.dot.optional { border-style: dotted; }
.dot.done { background: var(--green); border-color: var(--green); }
.dot.missed { border-color: var(--red); }
.dot.today { border-color: var(--blue); background: var(--tint-blue); }
.dot.planned { border-color: var(--faint); }
.dot.extra { background: var(--green); border-color: var(--green); opacity: 0.5; }

.session { background: var(--surface); border-radius: 16px; padding: var(--s4); margin-bottom: var(--s3); box-shadow: var(--shadow); }
.eyebrow { font-size: var(--t-s); color: var(--muted); font-weight: 600; margin-bottom: var(--s2); }
.meta-row { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-s); margin-bottom: 2px; }
.meta-row .tag { margin-left: auto; }
.session h2 { font-size: var(--t-l); margin-bottom: var(--s3); }
.session .intensity { margin: calc(-1 * var(--s2)) 0 var(--s3); font-size: var(--t-s); color: var(--muted); }
.session.rest h2 { margin-bottom: var(--s4); }
.done-line { display: flex; align-items: center; gap: var(--s2); color: var(--green); font-weight: 600; font-size: var(--t-s); margin-bottom: var(--s3); }
.done-line .icon { width: 18px; height: 18px; }
.missed-line { color: var(--red); font-weight: 600; font-size: var(--t-s); margin-bottom: var(--s3); }
.session.done h2 { color: var(--muted); }
.rx { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.rx li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding: 9px 0; border-top: 1px solid var(--line); }
.rx li:last-child { border-bottom: 1px solid var(--line); }
.rx li .name { min-width: 0; text-wrap: balance; }
.rx li .dose { white-space: nowrap; color: var(--muted); font-size: var(--t-s); font-variant-numeric: tabular-nums; }
.session > .btn, .session > a.btn { margin: var(--s4) 0 var(--s3); }
.session > .btn:last-child, .session > a.btn:last-child { margin-bottom: 0; }
.session > .notes, .session > .md { margin-top: var(--s2); }
.next-up {
  display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: var(--tap); padding: var(--s2) var(--s3);
  border: 1px solid var(--line); border-radius: var(--r); background: var(--chalk); text-align: left; margin-bottom: var(--s2);
}
.next-up .t { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-up .icon:last-child { color: var(--faint); width: 16px; height: 16px; }
.next-up:active { background: var(--sunk); }
.watch-note { margin-top: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.extra-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); background: var(--surface); border-radius: var(--r); margin-bottom: var(--s3); }
.extra-row .t { flex: 1; font-weight: 600; }

.resume {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s3);
  background: var(--tint-blue); border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent); border-radius: var(--r); color: var(--ink);
}
.resume .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.resume .go { color: var(--blue); font-weight: 700; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* coach text */
.md p + p, .md p + ul, .md p + ol, .md ul + p, .md ol + p, .md h3 + p { margin-top: var(--s2); }
.md ul, .md ol { margin: var(--s2) 0 0; padding-left: 1.25em; }
.md li + li { margin-top: 3px; }
.md li, .md p { text-wrap: pretty; }
.md h3 { font-size: var(--t-s); margin-top: var(--s3); }
.md strong { font-weight: 650; }
.session .md, .sess-detail .md { color: var(--muted); font-size: var(--t-s); line-height: 1.5; }
.notes { position: relative; }
.notes.collapsed .md { max-height: 4.6em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.more { border: 0; background: none; padding: var(--s1) 0; color: var(--blue); font-weight: 600; font-size: var(--t-s); min-height: 32px; }

/* recovery */
.readiness { margin: var(--s5) 0 var(--s3); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s1); }
.section-head h2 { font-size: var(--t-b); }
.section-head .icon-btn { margin-right: calc(-1 * var(--s3)); }
.ribbon { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: var(--s3); }
.metric { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.metric .l { font-size: var(--t-xs); color: var(--muted); font-weight: 600; white-space: nowrap; }
.metric .v { font-family: var(--num); font-weight: 700; font-size: 1.75rem; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric .v small { font-family: var(--text); font-size: var(--t-xs); font-weight: 500; color: var(--muted); margin-left: 2px; }
.metric .v.dim { color: var(--muted); }
.metric .d { font-size: var(--t-xs); white-space: nowrap; }
.metric .d.good { color: var(--green); font-weight: 600; }
.metric .d.watch { color: var(--amber-text); font-weight: 600; }

.links { display: flex; flex-direction: column; margin-top: var(--s4); border-top: 1px solid var(--line); }
.links .link {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 60px; padding: var(--s2) 0;
  border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%;
}
.links .link:active { opacity: 0.6; }
.links .link > .icon { color: var(--faint); width: 16px; height: 16px; }
.stack-text { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.stack-text .sub, .link .sub { font-weight: 400; font-size: var(--t-s); color: var(--muted); }

/* ---------- segmented controls & chips ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; background: var(--sunk); border-radius: var(--r); }
.seg button { min-height: 40px; border: 0; border-radius: calc(var(--r) - 3px); background: transparent; font-weight: 600; font-size: var(--t-s); color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: var(--shadow); }
.seg button:active { opacity: 0.7; }
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 0 var(--s1); margin-bottom: var(--s3); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.fade { margin-left: calc(-1 * var(--s4)); margin-right: calc(-1 * var(--s4)); padding-left: var(--s4); padding-right: var(--s4); scroll-padding: 0 var(--s4);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--s4), #000 calc(100% - var(--s5)), transparent); mask-image: linear-gradient(90deg, transparent, #000 var(--s4), #000 calc(100% - var(--s5)), transparent); }
.chip { flex: none; min-height: 36px; padding: 0 var(--s3); border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: var(--t-s); font-weight: 600; white-space: nowrap; color: var(--ink); }
.chip.small { min-height: 32px; min-width: 40px; padding: 0 var(--s2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--chalk); }
.chip:active { opacity: 0.7; }
.chip-gap { flex: none; width: 1px; background: var(--line); margin: 6px 2px; }

/* ---------- sheets ---------- */
/* The kit's <dialog> sheet (kit/sheet.css + sheet.js): bottom sheet on a phone, a 440px panel on
   the right from 900px. Fitness keeps its own look: page-colored panel, round close button. */
.kit-sheet__panel { background: var(--chalk); --kit-gutter: calc(var(--s4) + var(--corner)); } /* same side room as the page (--corner) */
@media (max-width: 899px) { .kit-sheet__panel { max-width: 640px; margin: 0 auto; } }
.sheet-head { justify-content: space-between; background: var(--chalk); margin-bottom: var(--s2); }
.sheet-head h2 { font-size: var(--t-m); }
/* The side panel (900px+) runs to the top edge and its head sticks there once it scrolls: with no
   top inset it starts 24px down, like the app bar. */
@media (min-width: 900px) { .kit-sheet--side .sheet-head { padding-top: max(var(--s2), 24px - var(--safe-t)); } }
.sheet-head .icon-btn { margin-right: calc(-1 * var(--s1)); background: var(--sunk); width: 32px; height: 32px; }
.sheet-head .icon-btn .icon { width: 16px; height: 16px; }
.kit-sheet .md { color: var(--ink); }
/* Technique sheet: cues first (glanceable mid-set), then video, steps, mistakes. */
.form-sheet h3 { font-size: var(--t-s); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: var(--s5) 0 var(--s2); }
.form-sheet .cues { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.form-sheet .cues li { font-size: var(--t-m); font-weight: 600; line-height: 1.25; padding-left: var(--s4); position: relative; }
.form-sheet .cues li::before { content: ""; position: absolute; left: 0; top: 0.45em; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.form-sheet .steps, .form-sheet .mistakes { margin: 0; padding-left: 1.3em; display: grid; gap: var(--s2); }
.form-sheet li { text-wrap: pretty; }
.form-sheet .videos { display: grid; gap: var(--s2); margin-top: var(--s4); }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-s); overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
/* A transparent button over the player takes every tap, so YouTube's own overlay never appears. */
.video-shield { position: absolute; inset: 0; border: 0; padding: 0; background: transparent; cursor: pointer; }
.video-shield .play { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; background: rgba(10, 15, 18, 0.65); display: grid; place-items: center; }
.video.started .video-shield .play { display: none; }
.video-shield .play .icon { width: 28px; height: 28px; color: #fff; fill: #fff; stroke: none; margin-left: 3px; }
.vc { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s1); }
.vc-play { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--sunk); color: var(--ink); display: grid; place-items: center; }
.vc-play .icon { width: 18px; height: 18px; fill: currentColor; }
.vc-time { flex: none; font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.vc-scrub { flex: 1; min-width: 0; height: 40px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; --pct: 0%; }
.vc-scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--blue) var(--pct), var(--line) var(--pct)); }
.vc-scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--blue); border: 2px solid var(--surface); box-shadow: var(--shadow); }
.vc-scrub::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--blue) var(--pct), var(--line) var(--pct)); }
.vc-scrub::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 2px solid var(--surface); }
.video-rows { display: grid; gap: var(--s1); }
.video-row { display: grid; grid-template-columns: 96px 1fr; gap: var(--s3); align-items: center; padding: var(--s1); border: 1px solid transparent; border-radius: var(--r-s); background: none; text-align: left; color: var(--ink); }
.video-row[aria-current="true"] { border-color: var(--line); background: var(--surface); }
.video-row img { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; display: block; }
.video-row > span { display: grid; gap: 2px; min-width: 0; }
.form-link { background: none; border: 0; padding: 8px 0; margin: -8px 0; /* taller tap target, same layout */ font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
@keyframes fade { from { opacity: 0; } }
.stack { display: flex; flex-direction: column; gap: var(--s2); }
.row-actions { display: flex; gap: var(--s2); margin-top: var(--s3); }
.row-actions .btn { flex: 1; }
textarea, .search { width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: var(--s3); font-size: 1rem; resize: vertical; }
textarea { min-height: 64px; margin: var(--s3) 0; }
.search { margin-bottom: var(--s1); }
.scale { margin-bottom: var(--s3); }
.scale-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: var(--s1); font-size: var(--t-s); }
.scale-word { color: var(--blue); }
.scale .seg button { font-family: var(--num); font-size: var(--t-m); }
.scale-ends { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--muted); margin-top: 2px; padding: 0 var(--s2); }
.setting { margin-bottom: var(--s4); }
.setting h3 { margin-bottom: var(--s2); font-size: var(--t-s); color: var(--muted); }
.picker-list { list-style: none; margin: var(--s2) 0 0; padding: 0; }
.picker-list button { width: 100%; text-align: left; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); background: none; display: flex; flex-direction: column; justify-content: center; padding: var(--s2) 0; }
.picker-list button:active { opacity: 0.6; }
.picker-list .meta { color: var(--muted); font-size: var(--t-xs); }

/* ---------- Plan ---------- */
.goal { color: var(--muted); margin-bottom: var(--s5); }
.about { margin-bottom: var(--s5); }
.about > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s2); min-height: 44px; }
.about > summary::-webkit-details-marker { display: none; }
.about > summary .goal { margin: 0; flex: 1; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.about[open] > summary .goal { -webkit-line-clamp: unset; color: var(--ink); }
.about-body { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: var(--s4); margin-top: var(--s2); }
.about-sec + .about-sec { margin-top: var(--s4); }
.about-sec h3 { font-size: var(--t-s); font-weight: 650; margin-bottom: var(--s1); }
.about-sec .md { font-size: var(--t-s); }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; border: 0; background: none; padding: 0; font: inherit; color: var(--muted); text-align: left; width: 100%; cursor: pointer; }
.clamp.open { -webkit-line-clamp: unset; }
.plan-block { margin-bottom: var(--s6); }
.block-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.block-focus { margin: var(--s1) 0 var(--s3); font-size: var(--t-s); }
.pending { padding: var(--s3) 0; }
.weeks { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; margin-top: var(--s3); }
.week-row + .week-row { border-top: 1px solid var(--line); }
.week-row > summary, .fold > summary, .sess details > summary { list-style: none; cursor: pointer; }
.week-row > summary::-webkit-details-marker, .fold > summary::-webkit-details-marker, .sess details > summary::-webkit-details-marker { display: none; }
.week-row > summary { display: flex; align-items: center; gap: var(--s3); min-height: 60px; padding: var(--s3) var(--s4); }
.week-row > summary:active, .sess details > summary:active { background: var(--sunk); }
.wk { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wk-title { font-weight: 650; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1) var(--s2); }
.wk-title .muted { font-weight: 500; }
.wk-focus { font-size: var(--t-s); color: var(--muted); text-wrap: balance; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.week-row[open] .wk-focus { -webkit-line-clamp: unset; }
.wk-count { display: flex; flex-direction: column; align-items: flex-end; font-size: var(--t-xs); line-height: 1.1; }
.wk-count .num { font-size: var(--t-m); }
.chev { width: 16px; height: 16px; color: var(--faint); transition: transform 0.15s; }
details[open] > summary .chev { transform: rotate(90deg); }
.sess-list { list-style: none; margin: 0; padding: 0 0 var(--s2); }
.sess details > summary { display: grid; grid-template-columns: 36px 20px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s2) var(--s4); min-height: 56px; }
.sess .date { display: flex; flex-direction: column; align-items: center; font-size: var(--t-xs); color: var(--muted); line-height: 1.15; }
.sess .date .num { font-size: var(--t-m); color: var(--ink); }
.sess.is-today .date, .sess.is-today .date .num { color: var(--blue); }
.sess .icon.mod { color: var(--muted); }
.sess .t { min-width: 0; display: flex; flex-direction: column; }
.sess .title { font-weight: 600; text-wrap: balance; }
.sess .sub { font-size: var(--t-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { font-size: var(--t-xs); font-weight: 700; white-space: nowrap; }
.state.done { color: var(--green); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--tint-green); }
.state.done .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.state.missed { color: var(--red); }
.state.today { color: var(--blue); }
.sess-detail { padding: 0 var(--s4) var(--s4) calc(var(--s4) + 36px + var(--s3)); }
.sess-detail .rx { margin-bottom: var(--s2); }
.sess-detail .btn { margin-top: var(--s3); }
.sess-detail .done-line { margin: var(--s2) 0 0; }
.fold { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); margin-bottom: var(--s3); }
.fold > summary { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 var(--s4); font-weight: 650; }
.fold-body { padding: 0 var(--s4) var(--s4); }
.fold .md { color: var(--ink); font-size: var(--t-s); }
.history { margin: 0; list-style: none; }
.history li { padding: var(--s3) 0; border-top: 1px solid var(--line); }
.history li p { margin: var(--s1) 0; font-size: var(--t-s); }
.history .row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.banner { background: var(--tint-blue); border-radius: var(--r); padding: var(--s3) var(--s4); margin-bottom: var(--s4); font-size: var(--t-s); }

/* ---------- Progress ---------- */
.consistency { background: var(--surface); border-radius: 16px; padding: var(--s3) var(--s4); box-shadow: var(--shadow); margin: var(--s2) 0 var(--s4); }
.consistency .d { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.readout { min-height: 5em; margin: var(--s1) 0 var(--s2); }
.readout .v { font-family: var(--num); font-weight: 700; font-size: var(--t-xl); line-height: 1; font-variant-numeric: tabular-nums; }
.readout .v small { font-family: var(--text); font-size: var(--t-s); font-weight: 500; color: var(--muted); margin-left: var(--s1); }
.readout .v.dim { color: var(--muted); }
.readout .change { color: var(--ink); font-weight: 600; margin-top: 1px; }
.chart-box { transition: opacity 0.15s; }
.chart-box.loading { opacity: 0.4; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--blue); }
.chart .pt.faint { opacity: 0.28; }
.chart .bar { fill: var(--blue); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--text); font-variant-numeric: tabular-nums; }
.chart .cursor { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: var(--surface); stroke: var(--blue); stroke-width: 2.5; }
.seg.range { margin-top: var(--s3); }
.chart-note { margin-top: var(--s3); color: var(--muted); font-size: var(--t-s); }

/* ---------- workout logger ---------- */
.wo-head { padding-left: calc(env(safe-area-inset-left, 0px) + var(--corner) + var(--s3)); } /* back button nearer the edge */
.wo-head .kit-bar__row { justify-content: flex-start; }
.wo-head .title { flex: 1; min-width: 0; }
.wo-head .sub { display: flex; gap: var(--s3); font-size: var(--t-xs); line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; align-items: baseline; }
.wo-head .clock { font-size: var(--t-s); color: var(--ink); }
.wo-head .finish-top { min-height: calc(var(--tap) - var(--s2)); padding: 0 var(--s3); } /* compact control inside the 44pt row */
.wo-head .counter { font-weight: 600; }
.wo-head .counter:empty { display: none; }
.wo-head.guided .finish-top { display: none; }
.sync-state.pending { color: var(--amber-text); font-weight: 600; }
.wo-intro { margin-bottom: var(--s5); }
.wo-intro .md { color: var(--muted); font-size: var(--t-s); }
.wo-intro .guide { background: var(--surface); border-radius: 16px; padding: var(--s4); box-shadow: var(--shadow); margin-bottom: var(--s4); }
.wo-intro .guide .md { color: var(--ink); font-size: var(--t-b); line-height: 1.55; }
.wo-intro .guide li + li { margin-top: var(--s1); }
.guide ul:has(.check-item), .guide ol:has(.check-item) { list-style: none; padding-left: 0; }
.guide li.check-item { display: flex; align-items: flex-start; gap: var(--s1); }
.check-item .tick { flex: 1 1 auto; width: auto; min-width: 0; }
.check-item .move-info { margin-top: 6px; color: var(--blue); }
.tick { display: flex; align-items: flex-start; gap: var(--s3); width: 100%; min-height: var(--tap); padding: var(--s2) 0; border: 0; background: none; text-align: left; line-height: 1.4; }
.tick .icon { flex: none; width: 24px; height: 24px; padding: 3px; border-radius: 50%; border: 2px solid var(--line); color: transparent; margin-top: -1px; }
.tick.on .icon { background: var(--green); border-color: var(--green); color: var(--on-green); }
.tick.on span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.wo-intro > .btn + p { margin-top: var(--s2); }

.ex { margin-bottom: var(--s6); }
.ex-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: nowrap; }
.ex-head h2 { flex: 1; min-width: 0; }
.ex-head .icon-btn { margin-right: calc(-1 * var(--s3)); color: var(--blue); }
.ex.complete .ex-head h2 { color: var(--muted); }
.ex .target { margin-top: 2px; font-size: var(--t-s); }
.ex .target strong { font-weight: 650; }
.ex .last { font-size: var(--t-s); color: var(--muted); margin-top: 2px; }
.sets { margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s2); container-type: inline-size; }
.set {
  position: relative; display: grid; grid-template-columns: 20px minmax(0, 1.3fr) minmax(0, 1fr) 54px; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s2) var(--s3); background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
}
.set .idx { color: var(--muted); font-size: var(--t-s); font-weight: 600; text-align: center; }
.set.done { background: var(--tint-green); box-shadow: none; }
.set.warmup .idx { color: var(--amber-text); }
.stepper-wrap { min-width: 0; }
.stepper { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; }
.stepper .step {
  height: 34px; width: 34px; border: 0; border-radius: 50%; background: var(--sunk); color: var(--ink);
  font-size: 1.3rem; line-height: 1; padding: 0; display: grid; place-items: center;
}
.set.done .stepper .step { background: transparent; color: var(--muted); }
.stepper .step:active { background: var(--line); }
.stepper input {
  width: 100%; min-width: 0; border: 0; background: transparent; text-align: center; padding: 0;
  font-family: var(--num); font-weight: 700; font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1; height: var(--tap);
  border-radius: var(--r-s);
}
.stepper input:placeholder-shown { box-shadow: inset 0 0 0 1.5px var(--line); }
.stepper input::placeholder { color: var(--muted); font-size: 1.1rem; }
.stepper input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }
.set .unit { display: block; text-align: center; font-size: var(--t-xs); color: var(--muted); margin-top: -2px; white-space: nowrap; }
/* A narrow column (the Duo's home-screen app folded: 466 minus the 84pt status column) left the
   reps field 26px wide; smaller step buttons and gaps give it back. Phones (>= 343) keep the 34s. */
@container (max-width: 340px) {
  .set { gap: var(--s1); }
  .stepper { grid-template-columns: 30px minmax(0, 1fr) 30px; }
  .stepper .step { width: 30px; height: 30px; }
}
.check {
  width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--faint);
  display: grid; place-items: center; justify-self: end; transition: transform 0.1s;
}
.check:active { transform: scale(0.92); }
.set.done .check { background: var(--green); border-color: var(--green); color: var(--on-green); }
.check svg { width: 26px; height: 26px; stroke-width: 2.6; }
.set-wrap { display: flex; flex-direction: column; gap: var(--s1); }
.rir { display: flex; align-items: center; gap: var(--s1); padding: 0 var(--s1) 0 var(--s3); animation: fade 0.2s; }
.rir .muted { margin-right: auto; }
.add-set { margin-top: var(--s1); }
.add-ex { margin-bottom: var(--s6); }

.restbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) calc(env(safe-area-inset-right, 0px) + var(--s4)) calc(var(--s3) + var(--safe-b)) calc(env(safe-area-inset-left, 0px) + var(--s4));
  background: var(--yellow); color: var(--on-yellow);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
}
.restbar .rest-main { flex: 1; min-width: 0; }
.restbar .t { font-family: var(--num); font-weight: 700; font-size: 2.5rem; line-height: 1; font-variant-numeric: tabular-nums; }
.restbar .t small { font-family: var(--text); font-size: var(--t-s); font-weight: 650; margin-left: var(--s2); }
.restbar .next { font-size: var(--t-xs); font-weight: 600; opacity: 0.85; line-height: 1.3; margin-top: 2px; text-wrap: balance; }
.restbar button { min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r); border: 0; background: rgba(0, 0, 0, 0.12); color: inherit; font-weight: 650; }
.restbar button:active { background: rgba(0, 0, 0, 0.22); }
.restbar.over { background: var(--green); color: var(--on-green); }
.restbar.over button { background: color-mix(in srgb, var(--on-green) 16%, transparent); }
body.resting #app { padding-bottom: 130px; }

.rpe-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2); margin: var(--s2) 0; }
.rpe-grid button { height: 48px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-family: var(--num); font-weight: 700; font-size: var(--t-m); }
.rpe-grid button[aria-checked="true"] { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.rpe-label { min-height: 1.4em; font-size: var(--t-s); color: var(--muted); font-weight: 600; }

/* Toast: the kit's single live region (kit/toast.css), in fitness's pill shape. Its distance from
   the bottom (plus the safe area) clears the tab bar, or the rest timer in the logger. */
.kit-toast { border-radius: 999px; padding: var(--s2) var(--s4); font-size: var(--t-s); text-align: center; }
body.mode-workout { --kit-toast-offset: var(--s5); }
body.resting { --kit-toast-offset: 110px; }

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

/* ---------- wide: the iPhone Duo open (951x543), iPads, desktop ---------- */
/* From 900px the tab bar becomes a side rail (it gives back ~60pt of a 543pt-tall window) and
   Today splits in two: the day on the left, recovery and check-in on the right. Phones never
   reach 900, so their layout is unchanged. Sheets turn into a right-side panel at the same
   width (kit sheet.css). */
@media (min-width: 900px) {
  :root { --kit-toast-offset: var(--s4); }
  body { padding-bottom: 0; padding-left: calc(var(--rail-w) + env(safe-area-inset-left, 0px)); }
  body.mode-workout { padding-left: 0; }
  /* The rail carries the left inset. */
  body:not(.mode-workout) #app { --pad-l: calc(var(--corner) + var(--s4)); }
  #tabs {
    inset: 0 auto 0 0; width: calc(var(--rail-w) + env(safe-area-inset-left, 0px)); height: auto;
    flex-direction: column; justify-content: flex-start; gap: var(--s2);
    padding: var(--bar-top) 0 var(--safe-b) env(safe-area-inset-left, 0px);
    border-top: 0; border-right: 1px solid var(--line);
  }
  /* Tabs keep clear of the rail's top corner (--corner side room with no top inset); icons and
     labels are centered, so nothing visible moves. */
  #tabs a { flex: none; min-height: 64px; margin-inline: calc(var(--corner) + var(--s3)); }
  body[data-view="today"] #app { max-width: 1000px; }
  .today-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s6); align-items: start; }
  .today-side .readiness { margin-top: 0; }
}
