/* Barlow and Barlow Condensed (SIL Open Font License, see public/fonts/OFL.txt),
   served from the app itself and cached for offline use. Latin only. */
@font-face {
  font-family: "Barlow";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/barlow-condensed-latin-800-normal.woff2") format("woff2");
}

:root {
  --bg: #0a0a0b;
  --surface: #151517;
  --surface-2: #1d1d20;
  --surface-3: #26262a;
  --border: #26262a;
  --text: #f2f2f0;
  --muted: #8b8b92;
  --faint: #5b5b62;
  --accent: #ff5a1f;
  --accent-text: #140700;
  --done: #2fd07a;
  --done-bg: #121a14;
  --done-text: #08130c;
  --danger: #ff5c5c;
  --status-bar: #0a0a0b;
  --radius: 18px;
  /* Body text is Barlow; titles, labels, buttons and numbers are Barlow
     Condensed, mostly in capitals. */
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  /* Type scale: every font size in the app is one of these. */
  --fs-xs: 0.75rem;    /* captions, column heads, chart labels */
  --fs-sm: 0.875rem;   /* secondary text, labels */
  --fs-md: 1rem;       /* body */
  --fs-lg: 1.125rem;   /* buttons */
  --fs-xl: 1.5rem;     /* card titles */
  --fs-2xl: 2rem;      /* screen titles, set figures */
  --fs-3xl: 2.375rem;  /* titles of the three tabs */
  --fs-hero: 3.25rem;  /* the rest countdown */
  color-scheme: dark;
}

/* Light theme: follows the system unless Settings forces one (data-theme on <html>). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f3f1;
    --surface: #ffffff;
    --surface-2: #ebebe8;
    --surface-3: #dcdcd8;
    --border: #dcdcd8;
    --text: #111113;
    --muted: #5f5f66;
    --faint: #86868c;
    --accent: #e8480f;
    --accent-text: #140700;
    --done: #1f9d57;
    --done-bg: #e2f4e9;
    --done-text: #06140b;
    --danger: #d93636;
    --status-bar: #111113;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f3f1;
  --surface: #ffffff;
  --surface-2: #ebebe8;
  --surface-3: #dcdcd8;
  --border: #dcdcd8;
  --text: #111113;
  --muted: #5f5f66;
  --faint: #86868c;
  --accent: #e8480f;
  --accent-text: #140700;
  --done: #1f9d57;
  --done-bg: #e2f4e9;
  --done-text: #06140b;
  --danger: #d93636;
  --status-bar: #111113;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font-body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* Digits all the same width, so weights line up and timers don't jiggle. */
  font-variant-numeric: tabular-nums;
  /* No double-tap zoom (it swallowed quick taps); pinch zoom still works. */
  touch-action: manipulation;
}

/* Behind the iOS status bar in a home-screen app (zero height elsewhere):
   the status bar's symbols are white, so this is the app's background in
   the dark theme and near-black in the light one. Content never scrolls
   under it. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 50;
  background: var(--status-bar);
  pointer-events: none;
}

/* App shell: the page itself never scrolls. It is a column exactly as tall
   as the screen (banners, progress, content, rest timer, tab bar), and only
   the content scrolls. So the browser's own bars never collapse or expand,
   the tab bar never moves, and pull-to-refresh can't reload mid-workout. */
html { overflow: hidden; overscroll-behavior: none; }
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Content is at most 640px wide, centered in the full-width scroll area. */
  padding: max(12px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right), calc((100% - 640px) / 2))
    max(32px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left), calc((100% - 640px) / 2));
}
/* Once the tab bar or rest timer sits below the content, it covers the
   bottom safe area instead. */
.app:has(+ .restbar), .app:has(+ .tabbar) { padding-bottom: 24px; }
.update-banner + .app { padding-top: 12px; }

/* ---- Type ------------------------------------------------------------------------------ */

h1, h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
p { margin: 0.5rem 0; }
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; }

.muted { color: var(--muted); font-size: var(--fs-sm); }
.notes { color: var(--muted); white-space: pre-line; }
.small { font-size: var(--fs-sm); }
.center { text-align: center; }

/* A small capitals label: "PROGRAMS", "SET 6 OF 16". */
.section-label, .col-head, .progress-head, .rest-label, .unit-label, .next-label,
.field > span, .field legend {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---- Icons -------------------------------------------------------------------------------- */

.icon-svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-svg.filled { fill: currentColor; stroke: none; }
.icon-svg .fill { fill: currentColor; }
.icon-svg .knob { fill: var(--bg); }

/* ---- Top bar --------------------------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-bottom: 12px;
}
.bar h1 { flex: 1; }
/* The three tabs' own screens get the biggest titles. */
.bar > h1:first-child { font-size: var(--fs-3xl); }
/* On a narrow phone their buttons drop below the title rather than off the screen. */
.bar:has(> h1:first-child) { flex-wrap: wrap; row-gap: 4px; }
.bar .actions { display: flex; gap: 8px; margin-left: auto; }
.title { margin: 4px 0 8px; }
/* Workout screen: back, the title in the middle, a menu. */
.workout-bar h1 { text-align: center; }
.workout-menu { margin: -4px 0 12px; }

/* ---- Buttons --------------------------------------------------------------------------------- */

button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.with-icon { gap: 4px; padding-left: 12px; }
.btn.ghost { background: transparent; padding: 0 8px; }
.btn.danger { color: var(--danger); background: transparent; }
.btn.small { min-height: 36px; font-size: var(--fs-md); }
.btn.wide { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin: 16px 0; }
.btn .icon-svg { width: 18px; height: 18px; stroke-width: 2.6; }
.btn.primary.ready { background: var(--done); color: var(--done-text); }
/* Round icon-only buttons: back, menus. */
.round-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
}
.round-btn .icon-svg { width: 20px; height: 20px; stroke-width: 2.4; }
.round-btn[aria-expanded="true"] { background: var(--surface-3); }
.icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: none;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: var(--fs-md);
}
.icon.danger { color: var(--danger); }
.icon:disabled { opacity: 0.35; cursor: default; }
.link-btn {
  border: none;
  background: none;
  padding: 0;
  min-height: 40px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.link-btn.danger { color: var(--danger); }
a { color: var(--accent); }

/* ---- Cards and lists --------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 16px;
}
.empty { text-align: left; }
.empty blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 10px 10px 0;
}
.workouts, .exercises { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.workout-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}
.workout-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}
.workout-card .muted { line-height: 1.35; }
.workout-card .muted .pill { margin-left: 8px; }
/* A saved workout: its name and facts, about how long it takes, a chevron. */
.workout-card:has(> .card-main) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 14px 14px 18px;
}
.card-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-minutes { display: flex; flex-direction: column; align-items: flex-end; }
.big-num { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; line-height: 1; }
.unit-label { color: var(--muted); font-size: var(--fs-xs); }
.card-chevron { color: var(--faint); display: grid; }
.card-chevron .icon-svg { stroke-width: 2.4; }
.workout-card.in-progress { box-shadow: inset 0 0 0 2px var(--accent); }
.resume {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.resume-count { margin-left: auto; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 800; }
.section-title { margin: 20px 0 10px; }
.section-label { margin: 18px 0 8px; color: var(--muted); font-size: var(--fs-sm); }
.section-label:first-child { margin-top: 0; }
.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}
.pr-note { margin: 6px 0 0; font-size: var(--fs-sm); }
.merge { flex-direction: column; align-items: stretch; }
.merge p { font-size: var(--fs-sm); }
.nudge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent);
}
.nudge p { margin: 0; flex: 1; font-size: var(--fs-sm); }

/* ---- Workout in progress ------------------------------------------------------------------------ */

/* Progress: a row of the shell above the content, like the rest timer
   below it, so it's always in view. A segment per set: done, next, to do. */
.progress {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right), calc((100% - 640px) / 2)) 12px
    max(16px, env(safe-area-inset-left), calc((100% - 640px) / 2));
  background: var(--bg);
}
.update-banner ~ .progress, .save-banner ~ .progress { padding-top: 10px; }
.progress + .app { padding-top: 8px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: var(--fs-sm); }
.progress-time { display: inline-flex; align-items: center; gap: 5px; }
.progress-time .icon-svg { width: 14px; height: 14px; stroke-width: 2.4; }
.progress.complete .progress-head { color: var(--done); }
.segments { display: grid; gap: 3px; }
.seg { height: 6px; border-radius: 2px; background: var(--surface-3); transition: background-color 0.2s ease; }
.seg.done { background: var(--done); }
.seg.next { background: var(--accent); }
.seg.bar { display: block; overflow: hidden; }
.seg.bar .fill { display: block; height: 100%; background: var(--done); }

.exercise h2 { margin-bottom: 4px; }
.exercise-title { display: flex; align-items: center; gap: 8px; }
.exercise-title h2 { flex: 1; margin: 0; line-height: 1.05; }
.rest-label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-md); letter-spacing: 0.06em; }
.rest-label .icon-svg { width: 15px; height: 15px; stroke-width: 2.4; }
.more-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}
.more-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.last-time { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--muted); font-size: var(--fs-sm); margin: 6px 0 0; }
.last-time .up {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--done-bg);
  color: var(--done);
  font-weight: 600;
  white-space: nowrap;
}
.last-time .up .icon-svg { width: 14px; height: 14px; stroke-width: 2.6; }

/* The sets: number, reps, weight, a big tick button. */
.log-grid {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 56px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.col-head { color: var(--muted); font-size: var(--fs-xs); text-align: center; }
.log-row { display: contents; }
.set-no { text-align: center; color: var(--faint); font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 800; }
.log-row input[type="text"] {
  min-width: 0;
  height: 56px;
  padding: 0 2px;
  border: none;
  border-radius: 12px;
  background: var(--surface-2);
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 800;
}
/* Long values ("BW+22.5") get smaller figures, so they still fit. */
.log-row input.long { font-size: var(--fs-xl); }
.log-row input.longer { font-size: 1.2rem; }
.log-row input::placeholder { color: var(--faint); }
.log-row.done input[type="text"] { background: var(--done-bg); color: var(--done); }
.log-row.next .set-no { color: var(--accent); }
.log-row.next input[type="text"]:first-of-type { box-shadow: inset 0 0 0 2px var(--accent); }
.check {
  display: grid;
  place-items: center;
  width: 100%;
  height: 56px;
  border: 2px solid var(--surface-3);
  border-radius: 12px;
  background: transparent;
  color: var(--faint);
}
.check .icon-svg { width: 24px; height: 24px; stroke-width: 3.2; }
.log-row.done .check { background: var(--done); border-color: var(--done); color: var(--done-text); }
.log-row.next .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
/* Scrolled to after each tick: not flush with the edge. */
.check { scroll-margin: 24px 0; }
/* Sets with different targets: each shows its own above its fields. */
.log-row .target {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.2;
}
.log-row.with-target .set-no { grid-row: span 2; }
.log-row.with-target .target { grid-column: 2 / -1; margin-top: 4px; }
.log-row.with-target input:first-of-type { grid-column: 2; }
.plate-icon { width: 16px; height: 16px; color: var(--accent); stroke-width: 2; }
.row-plates {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  font-size: var(--fs-sm);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
}
.row-error { grid-column: 1 / -1; color: var(--danger); font-size: var(--fs-sm); margin-top: -2px; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.add-set { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.add-set .icon-svg { width: 18px; height: 18px; stroke-width: 2.6; }
.target-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: right;
}
.card-menu {
  display: grid;
  margin-top: 6px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
}
.menu-item {
  min-height: 48px;
  padding: 0 16px;
  border: none;
  border-top: 1px solid var(--surface-3);
  background: transparent;
  text-align: left;
  font-weight: 600;
}
.menu-item:first-child { border-top: none; }
.menu-item.danger { color: var(--danger); }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.inline-form input[type="text"] { flex: 1; min-width: 140px; }
.add-exercise { margin: 12px 0; }
.session-notes { margin-top: 16px; }
.footer-actions { display: flex; justify-content: space-between; margin-top: 20px; }

/* A finished exercise, folded to one line */
.exercise.collapsed { padding: 4px 8px; background: var(--done-bg); }
.collapsed-row {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: none;
  text-align: left;
  padding: 0 8px;
}
.done-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--done);
  color: var(--done-text);
}
.done-mark .icon-svg { width: 15px; height: 15px; stroke-width: 3.4; }
.collapsed-name { flex: none; font-family: var(--font-display); font-size: 1.375rem; font-weight: 800; text-transform: uppercase; }
.collapsed-summary {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Supersets */
.exercise.superset { box-shadow: inset 3px 0 0 var(--accent); }
.exercise.superset:not(.superset-start) { margin-top: -6px; }
.superset-note { margin: 0 0 6px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.superset-pill { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.small-toggle { min-height: 36px; font-size: var(--fs-sm); color: var(--muted); }

/* ---- Rest timer ---------------------------------------------------------------------------------- */

/* A full-width band between the content and the tab bar: what's next, the
   time left in big figures, and a line across the top that runs down. */
.restbar {
  position: relative;
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  padding: 16px max(20px, env(safe-area-inset-right), calc((100% - 640px) / 2)) calc(14px + env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left), calc((100% - 640px) / 2));
  background: var(--accent);
  color: var(--accent-text);
  z-index: 10;
}
.restbar:has(+ .tabbar) { padding-bottom: 14px; }
.rest-line { position: absolute; inset: 0 0 auto; height: 4px; background: rgba(20, 7, 0, 0.2); }
.rest-line-fill { height: 100%; background: var(--accent-text); transition: width 0.25s linear; }
.rest-main { display: flex; flex-direction: column; min-width: 0; }
.rest-label { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rest-time { font-family: var(--font-display); font-size: var(--fs-hero); font-weight: 800; line-height: 1; }
.rest-actions { display: flex; gap: 6px; }
.rest-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 48px;
  height: 48px;
  padding: 0 10px;
  border: 2px solid rgba(20, 7, 0, 0.35);
  border-radius: 12px;
  background: none;
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rest-btn.strong { border: none; background: var(--accent-text); color: #f2f2f0; padding: 0 14px; }
.rest-btn .icon-svg { width: 16px; height: 16px; stroke-width: 2.6; }
.restbar.over { background: var(--done); color: var(--done-text); }
.restbar.over .rest-line { display: none; }
.restbar.over .rest-btn.strong { background: var(--done-text); color: #fff; }
@media (max-width: 359px) {
  .restbar { column-gap: 8px; }
  .rest-time { font-size: 2.5rem; }
  .rest-btn { min-width: 44px; padding: 0 8px; }
}

/* ---- Tab bar ------------------------------------------------------------------------------------------ */

.tabbar {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  max-width: 200px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tab .icon-svg { width: 26px; height: 26px; }
.tab.current { color: var(--accent); }
.tab.current span { color: var(--text); }

/* ---- Programs ---------------------------------------------------------------------------------------------- */

.program-card { display: grid; gap: 12px; }
.program-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
}
.program-head .workout-title { font-size: var(--fs-2xl); }
.next-block {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  text-align: left;
}
.next-block > .icon-svg { width: 28px; height: 28px; }
.next-text { display: flex; flex-direction: column; min-width: 0; }
.next-label { font-size: var(--fs-sm); }
.next-title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 800; line-height: 1.05; text-transform: uppercase; }
.next-block .resume-count { font-size: var(--fs-2xl); }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chips .chip { min-height: 34px; padding: 0 12px; font-size: var(--fs-md); }
.program-days { padding-left: 20px; margin: 10px 0 0; }
.program-days li { margin: 6px 0; }

/* ---- Settings and forms -------------------------------------------------------------------------------------- */

.settings { display: grid; gap: 10px; margin-bottom: 12px; }
.settings h2 { margin-bottom: -2px; }
.settings p { margin: 0; }
.settings h3 {
  margin: 8px 0 -4px;
  font: 700 var(--fs-sm)/1.2 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Account ---------------------------------------------------------------------------------------------------- */

a.btn { text-decoration: none; color: var(--text); background: var(--surface-2); }
.sign-in { display: grid; gap: 10px; }
.sign-in .btn.wide { margin: 0; }
.email-sign-in { display: grid; gap: 8px; margin-top: 4px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form .btn { flex: none; }
.new-account { margin-top: 2px; }
.new-account .link-btn { padding: 0; min-height: 0; font: inherit; text-transform: none; letter-spacing: 0; }
.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sign-in-ways { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sign-in-ways li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  border-bottom: 1px solid var(--surface-2);
}
.sign-in-ways li:last-child { border-bottom: none; }
.sign-in-ways .muted { font-size: var(--fs-sm); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.account-actions { margin-top: 8px; justify-content: space-between; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row code {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.consent { display: grid; gap: 10px; }
.consent p { margin: 0; }
.consent .btn.wide { margin: 0; }
.consent-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.toggle input {
  appearance: none;
  flex: none;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle input:checked { background: var(--done); }
.toggle input:checked::after { transform: translateX(20px); }
.toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.success {
  color: var(--done);
  background: var(--done-bg);
  border-radius: 10px;
  padding: 10px 14px;
}

.field { display: grid; gap: 6px; margin: 0 0 14px; border: none; padding: 0; }
.field > span, .field legend { font-size: var(--fs-sm); color: var(--muted); padding: 0; }
input[type="text"], input[type="email"], textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
}
.card input[type="text"], .card input[type="email"], .card textarea { background: var(--surface-2); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
textarea { resize: vertical; }
textarea.code { font-family: ui-monospace, "SF Mono", Consolas, monospace; word-break: break-all; }

.unit { display: flex; gap: 8px; align-items: center; }
.unit legend { margin-bottom: 6px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* Keep hidden inputs inside their label, not at the page's edge. */
.chip input { position: absolute; opacity: 0; pointer-events: none; }
button.chip { cursor: pointer; }
.chip.selected { background: var(--accent); color: var(--accent-text); }

.exercise.edit { display: grid; gap: 10px; }
.exercise-head { display: flex; gap: 6px; align-items: center; }
.exercise-head .name { flex: 1; font-weight: 600; }
.set-grid {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 40px;
  gap: 6px 8px;
  align-items: center;
}
.set-grid .muted { font-size: var(--fs-xs); }
.set-grid .set-no { font-size: var(--fs-lg); }
.hint { margin: 4px 0 0; }
.link-hint { margin: 20px 0 8px; }

/* ---- History -------------------------------------------------------------------------------------------------- */

/* Sessions | Exercises | Body, and time ranges */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 12px;
  border-radius: 14px;
  background: var(--surface-2);
}
.segment {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.segment.selected { background: var(--text); color: var(--bg); }
.segmented.range { margin: 4px 0 10px; }

.exercise-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-stat { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl); line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  min-width: 0;
}
.card .stat { background: var(--surface-2); }
.stat .stat-value { overflow-wrap: anywhere; }

/* Charts */
.chart { margin: 0 0 8px; padding: 12px 12px 6px; }
.chart figcaption { margin-bottom: 2px; }
.readout { margin: 0 0 6px; font-weight: 600; font-size: var(--fs-sm); min-height: 1.4em; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 700; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .direct-label { fill: var(--text); font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 800; text-transform: uppercase; }
/* Weekly volume: one hue; the week being read is at full strength. */
.chart .bar { fill: var(--accent); opacity: 0.45; }
.chart .bar.selected { opacity: 1; }
.volume-chart { margin-bottom: 12px; }

/* Calendar */
.calendar { margin-bottom: 12px; }
.stats.compact { margin: 0 0 12px; }
.stats.compact .stat { padding: 8px 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head strong { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-family: var(--font-display); font-size: var(--fs-sm); color: var(--muted); font-weight: 700; }
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--muted);
}
.cal-cell.trained { border: none; background: var(--accent); color: var(--accent-text); font-weight: 800; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--text); color: var(--text); }
.cal-cell.trained.today { box-shadow: inset 0 0 0 2px var(--text); }

/* Bodyweight */
.entry-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }

/* ---- Finish screen ------------------------------------------------------------------------------------------------ */

/* A check that pops, a burst of confetti, then the numbers */
.finish { position: relative; overflow: hidden; padding-top: 16px; }
.finish > h1, .finish > .muted { text-align: center; }
.finish > .muted { margin-bottom: 4px; }
.finish-check {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 12px auto 16px;
  border-radius: 50%;
  background: var(--done);
  color: var(--done-text);
  font-size: var(--fs-2xl);
  font-weight: 800;
  animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
/* A ring that ripples out once. */
.finish-check .icon-svg { width: 38px; height: 38px; stroke-width: 3; }
.finish-check::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--done);
  opacity: 0;
  animation: ripple 0.9s ease-out 0.25s;
}
@keyframes pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes ripple {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(1.9); opacity: 0; }
}
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti span {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  animation: confetti 1.6s ease-in var(--d) forwards;
}
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), 460px) rotate(var(--r)); }
}
.finish .stats { margin-top: 16px; }
.change { font-size: var(--fs-xs); font-weight: 600; }
.change.up { color: var(--done); }
.change.down { color: var(--muted); }
.records { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.records li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.finish-notes { margin-top: 8px; }
.finish .btn.wide { margin: 10px 0 0; }

/* ---- Banners, import, errors ---------------------------------------------------------------------------------------- */

.update-banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.update-banner .btn { background: var(--accent-text); color: var(--accent); }
.save-banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  font-size: var(--fs-sm);
}
.save-banner .btn { flex: none; background: #fff; color: var(--danger); }
.save-banner + .app { padding-top: 12px; }

.error {
  color: var(--danger);
  white-space: pre-line;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 12px 0;
}
ul.error { padding-left: 28px; }
.preview ul { margin: 10px 0 0; padding-left: 18px; }
.preview li { margin: 4px 0; }

/* ---- Motion ---------------------------------------------------------------------------------------------------------- */

/* Tappable things give way slightly when pressed, and each screen fades
   in. All of it is off when the phone asks for reduced motion. */
.btn, .chip, .tab, .check, .link-btn, .more-btn, .menu-item, .segment, .rest-btn, .icon, .round-btn,
.workout-card, .program-head, .collapsed-row, .next-block, .target-btn {
  transition: transform 0.08s ease, background-color 0.15s ease, color 0.15s ease;
}
.btn:active, .chip:active, .tab:active, .check:active, .more-btn:active, .segment:active, .rest-btn:active,
.icon:active, .round-btn:active, .workout-card:active, .program-head:active, .collapsed-row:active,
.next-block:active {
  transform: scale(0.97);
}
.link-btn:active, .menu-item:active, .target-btn:active { opacity: 0.7; }
.screen { animation: screen-in 0.18s ease-out; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}
