/* Self-hosted fonts (Fable review P2-3, 2026-07-18): replaces the render-blocking
   fonts.googleapis.com stylesheet link that was removed from index.html. Files live in
   fonts/ and are woff2 "latin" subset only (this app ships English copy only).
   inter-var-latin.woff2 is Inter's variable font instance — Google Fonts itself serves the
   SAME file for every requested static weight (400/500/600/700/800); duplicating the
   @font-face block per weight below mirrors exactly what fonts.googleapis.com returns, so
   the browser's weight matching resolves to the correct instance from the variable axis. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("./fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/poppins-600-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/poppins-700-latin.woff2") format("woff2");
}

:root {
  /* Color */
  --bg: #f4f7fb;
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --surface-soft: #f8fbff;
  --surface-muted: #eef4fb;
  --surface-float: rgba(255, 255, 255, 0.92);
  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-muted: #64748b;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(100, 116, 139, 0.3);
  --accent: #f26e36;
  --accent-strong: #dc5a25;
  --accent-soft: rgba(242, 110, 54, 0.12);
  --accent-glow: rgba(242, 110, 54, 0.18);
  --phase-work: #f26e36;
  --phase-rest: #38bdf8;
  --phase-prep: #f59e0b;
  --phase-round-rest: #818cf8;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --info: #0ea5e9;
  --info-soft: rgba(14, 165, 233, 0.14);
  --danger: #ef4444;
  --chip-bg: #f3f7fc;
  --ghost-bg: rgba(255, 255, 255, 0.8);
  --nav-bg: rgba(255, 255, 255, 0.78);
  --train-ghost-bg: rgba(255, 255, 255, 0.92);
  --train-ghost-ink: #0f172a;

  /* Spacing (4px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Radius */
  --radius-xs: 12px;
  --radius-sm: 16px;
  --radius: 22px;
  --radius-lg: 28px;
  --radius-pill: 9999px;

  /* Typography */
  --font-display: "Poppins", "Inter", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Consolas", monospace;
  --fs-xs: 0.625rem;
  --fs-sm: 0.75rem;
  --fs-base: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;
  --fs-4xl: 2.25rem;
  --fs-5xl: 3rem;
  --fw-500: 500;
  --fw-600: 600;
  --fw-700: 700;
  --fw-800: 800;
  --fw-900: 900;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur: 220ms;
  --dur-slow: 320ms;

  /* Elevation */
  --shadow-card: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-float: 0 22px 55px rgba(15, 23, 42, 0.14);
  --shadow-glow-accent: 0 20px 48px rgba(242, 110, 54, 0.18);
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
  --shadow-medium: 0 22px 55px rgba(15, 23, 42, 0.14);
  --shadow-glow: 0 20px 48px rgba(242, 110, 54, 0.18);
  --focus-ring: 0 0 0 3px rgba(242, 110, 54, 0.22);

  --nav-height: 82px;
  --app-width: 1280px;
  --stable-vh: 100svh;
}

@supports not (height: 100svh) {
  :root {
    --stable-vh: 100vh;
  }
}

body[data-theme="dark"] {
  --bg: #07111f;
  --bg-elevated: rgba(10, 18, 31, 0.78);
  --surface: rgba(11, 20, 36, 0.88);
  --surface-strong: #0c1728;
  --surface-soft: #101e33;
  --surface-muted: #14243d;
  --surface-float: rgba(17, 31, 52, 0.92);
  --ink: #eff6ff;
  --ink-soft: #d8e3f3;
  --muted: #9cb0ca;
  --muted-soft: #7386a1;
  --line: rgba(94, 118, 155, 0.28);
  --line-strong: rgba(125, 149, 184, 0.34);
  --accent-soft: rgba(242, 110, 54, 0.18);
  --accent-glow: rgba(242, 110, 54, 0.22);
  --chip-bg: rgba(18, 33, 57, 0.95);
  --ghost-bg: rgba(17, 31, 52, 0.88);
  --nav-bg: rgba(7, 17, 31, 0.74);
  --train-ghost-bg: rgba(243, 248, 255, 0.92);
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.32);
  --shadow-medium: 0 24px 65px rgba(0, 0, 0, 0.42);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
}

html {
  color-scheme: light dark;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, var(--accent-glow), transparent 30%),
    radial-gradient(circle at 85% 12%, rgba(14, 165, 233, 0.14), transparent 24%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
  overscroll-behavior-y: none;
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at top left, rgba(242, 110, 54, 0.18), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(14, 165, 233, 0.16), transparent 24%),
    linear-gradient(180deg, #08111f 0%, var(--bg) 100%);
}

img {
  max-width: 100%;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inline-icon {
  width: 18px;
  height: 18px;
}

button,
input,
summary,
canvas {
  font: inherit;
}

button,
.chip,
.tab-btn,
.add-exercise-btn,
.sequence-cart {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--ink);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
.chip:focus-visible,
.tab-btn:focus-visible,
.sequence-cart:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

h1,
h2,
h3,
.timer-type,
.time-remaining {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.app-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(16px);
  opacity: 0.45;
  pointer-events: none;
}

.app-orb-left {
  top: -10%;
  left: -6%;
  width: 240px;
  height: 240px;
  background: rgba(242, 110, 54, 0.16);
}

.app-orb-right {
  top: 18%;
  right: -4%;
  width: 220px;
  height: 220px;
  background: rgba(14, 165, 233, 0.14);
}

.mobile-app {
  position: relative;
  z-index: 1;
  width: min(var(--app-width), 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 0;
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.app-header {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 16px;
}

@supports ((backdrop-filter: blur(18px)) or (-webkit-backdrop-filter: blur(18px))) {
  .app-header,
  .bottom-nav,
  .sequence-sheet,
  .checkin-sheet {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
}

.brand-block {
  display: grid;
  gap: 4px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 10px 24px rgba(242, 110, 54, 0.24);
}

.brand-mark span {
  position: absolute;
  inset: 0;
}

.brand-mark span:first-child::before,
.brand-mark span:last-child::before {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.brand-mark span:first-child::before {
  width: 12px;
  height: 2.5px;
  top: 6px;
  left: 6px;
}

.brand-mark span:last-child::before {
  width: 2.5px;
  height: 12px;
  top: 6px;
  right: 6px;
}

.topbar-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill,
.coach-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 8px;
  background: var(--success);
  box-shadow: 0 0 0 5px var(--success-soft);
}

.tab-panels {
  height: calc(100% - 88px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--nav-height) + 30px + env(safe-area-inset-bottom));
}

.tab-panels.train-mode {
  overflow: hidden;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.page-grid {
  display: grid;
  gap: 18px;
}

.build-grid {
  grid-template-columns: minmax(0, 1fr);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(242, 110, 54, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 100%),
    var(--surface);
}

body[data-theme="dark"] .hero-panel {
  background:
    radial-gradient(circle at top right, rgba(242, 110, 54, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 100%),
    var(--surface);
}

.hero-content {
  display: grid;
  gap: 20px;
}

.hero-copy-block {
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.eyebrow,
.section-kicker,
.metric-label {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 5vw, 3.3rem);
  line-height: 1.02;
}

h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  line-height: 1.1;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.hero-copy,
.section-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 118px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 1rem;
  color: var(--ink);
}

.metric-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-strong);
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.metric-card::after {
  content: "";
  display: block;
  width: 34px;
  height: 3px;
  margin-top: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 100%);
}

.setup-panel,
.library-panel,
.coach-proposal,
.train-intro,
.train-sidecard,
.presets-panel,
.history-panel {
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading h2,
.panel-title-row h2,
.panel-title-row h3 {
  margin-bottom: 6px;
}

.panel-title-row,
.inline-actions,
.timer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-presets,
.chips,
.checkin-rpe-chips,
.checkin-completion {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-presets {
  margin-bottom: 16px;
}

.essentials-grid {
  display: grid;
  gap: 12px;
}

.stepper-control {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--surface-soft), transparent 100%);
}

.stepper-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stepper-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

.stepper-row input {
  text-align: center;
  font-size: 1.08rem;
  font-weight: 800;
}

.stepper-btn {
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
}

.advanced-settings {
  margin-top: 18px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.05), transparent 100%);
}

.advanced-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary::after {
  content: "⌄";
  font-size: 1rem;
  color: var(--muted);
  transform: rotate(-90deg);
  transition: transform 160ms ease;
}

.advanced-settings[open] summary::after {
  transform: rotate(0deg);
}

.settings-grid {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="number"],
input[type="text"],
input[type="date"],
input[type="range"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
}

input::placeholder {
  color: var(--muted-soft);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.toggle-row {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.toggle-row label {
  grid-template-columns: 18px 1fr;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.chips {
  margin: 14px 0 18px;
}

.chip {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
}

.chip.active,
.rpe-chip.active,
.completion-chip.active,
.tab-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: var(--shadow-glow);
}

.exercise-grid {
  display: grid;
  gap: 10px;
  contain: layout paint style;
}

.exercise-card {
  position: relative;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 56px;
  align-items: stretch;
  min-height: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface-strong);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  contain: layout paint style;
}

.exercise-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface) 50%, var(--surface-muted) 75%);
}

.exercise-body {
  padding: 14px 8px 14px 14px;
  display: grid;
  align-content: center;
  gap: 6px;
  min-width: 0;
}

.exercise-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.exercise-meta,
.exercise-cue,
.hint,
.seq-meta,
.round-meta,
.next-step {
  color: var(--muted);
}

.exercise-meta,
.exercise-cue {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.exercise-cue {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.add-exercise-btn {
  width: 48px;
  height: 48px;
  align-self: center;
  justify-self: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px rgba(242, 110, 54, 0.28);
}

.add-exercise-btn svg {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.exercise-grid-spacer {
  width: 100%;
  pointer-events: none;
}

.exercise-grid-empty {
  grid-column: 1 / -1;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.coach-proposal {
  display: grid;
  gap: 12px;
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 100%),
    var(--surface);
}

.coach-proposal.hidden {
  display: none;
}

.coach-change-list,
.helper-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
}

.train-grid {
  align-items: start;
}

.train-intro h2,
.train-sidecard h3 {
  margin-bottom: 8px;
}

.train-screen {
  position: relative;
  isolation: isolate;
  min-height: calc(var(--stable-vh) - var(--nav-height) - env(safe-area-inset-bottom) - 132px);
  max-height: calc(var(--stable-vh) - var(--nav-height) - env(safe-area-inset-bottom) - 132px);
  padding: 24px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  overflow: hidden;
  color: #f8fafc;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.16), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 100%),
    linear-gradient(150deg, #0f172a, #1e293b);
  box-shadow: var(--shadow-medium);
  transition: background 220ms ease, transform 220ms ease;
}

.train-screen > * {
  position: relative;
  z-index: 1;
}

.train-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 30%);
  pointer-events: none;
}

.tap-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  justify-items: center;
  padding-top: 18px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 160ms ease;
}

.tap-overlay.hidden {
  opacity: 0;
}

.tap-overlay p {
  margin: 0;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(12px);
}

.timer-type {
  margin: 0;
  min-height: 1.4em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.88rem;
  color: rgba(248, 250, 252, 0.82);
}

.timer-label {
  margin: 0;
  max-width: 14ch;
  text-align: center;
  font-size: clamp(1.45rem, 4vw, 2.1rem);
  line-height: 1.15;
  min-height: 2.4em;
}

.train-exercise-preview {
  width: min(66vw, 300px);
  height: 126px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.train-exercise-preview.hidden {
  visibility: hidden;
}

.train-exercise-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.timer-ring {
  --ring-progress: 0%;
  --ring-color: #f26e36;
  width: min(72vw, 320px);
  aspect-ratio: 1;
  padding: 14px;
  border-radius: 999px;
  background: conic-gradient(var(--ring-color) var(--ring-progress), rgba(241, 245, 249, 0.18) 0%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: --ring-color 300ms ease;
}

.timer-core {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.time-remaining {
  margin: 0;
  font-size: clamp(2.7rem, 12vw, 4.8rem);
  font-variant-numeric: tabular-nums;
}

.round-meta,
.next-step {
  margin: 0;
  max-width: 32ch;
  text-align: center;
  color: rgba(248, 250, 252, 0.82);
  min-height: 1.4em;
}

.progress-grid-compact {
  width: min(100%, 440px);
  display: grid;
  gap: 12px;
}

.progress-wrap {
  display: grid;
  gap: 8px;
}

.progress-wrap label {
  color: rgba(248, 250, 252, 0.88);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.progress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.96);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.timer-actions {
  width: min(100%, 460px);
  justify-content: center;
}

.train-screen.phase-work {
  background:
    radial-gradient(circle at top, rgba(255, 244, 238, 0.2), transparent 34%),
    linear-gradient(155deg, #6f2f16, #b45309, #f26e36);
}

.train-screen.phase-rest,
.train-screen.phase-round-rest {
  background:
    radial-gradient(circle at top, rgba(224, 242, 254, 0.18), transparent 34%),
    linear-gradient(155deg, #11314e, #155e75, #38bdf8);
}

.train-screen.phase-prep {
  background:
    radial-gradient(circle at top, rgba(255, 251, 235, 0.2), transparent 34%),
    linear-gradient(155deg, #7c4a03, #d97706, #facc15);
}

.train-screen.phase-complete {
  background:
    radial-gradient(circle at top, rgba(236, 253, 245, 0.2), transparent 34%),
    linear-gradient(155deg, #14532d, #15803d, #22c55e);
}

button.accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(242, 110, 54, 0.24);
}

button.ghost {
  background: var(--ghost-bg);
  color: var(--ink);
  border-color: var(--line);
}

.train-screen .ghost {
  background: var(--train-ghost-bg);
  color: var(--train-ghost-ink);
  border-color: rgba(255, 255, 255, 0.24);
}

button.small {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

.save-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.preset-list,
.reference-list,
.sequence-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.preset-item,
.reference-item,
.sequence-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
}

.preset-item,
.reference-item {
  padding: 14px;
}

.preset-item strong {
  display: block;
  margin-bottom: 6px;
}

.chart-shell {
  margin-top: 14px;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-soft), transparent 100%);
}

#historyChart {
  width: 100%;
  max-width: 100%;
  min-height: 260px;
  border-radius: 16px;
  background: var(--surface-strong);
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.sequence-cart {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px);
  z-index: 40;
  width: min(calc(100% - 32px), 540px);
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-glow);
}

.sequence-cart.hidden {
  display: none;
}

.sequence-drawer,
.checkin-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.sequence-drawer.open,
.checkin-modal:not(.hidden) {
  display: block;
}

.sequence-backdrop,
.checkin-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sequence-sheet,
.checkin-sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 1;
  padding: 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-medium);
}

.sequence-sheet {
  max-height: min(76vh, 720px);
  overflow-y: auto;
}

.sheet-handle {
  width: 56px;
  height: 5px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: var(--line-strong);
}

.sequence-empty-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sequence-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.sequence-item img {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
}

.seq-name {
  margin: 0 0 4px;
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--ink);
}

.seq-meta {
  margin: 0;
  font-size: 0.82rem;
}

.seq-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.seq-edit input {
  width: 72px;
  min-height: 40px;
  padding: 8px 10px;
}

.checkin-sheet {
  display: grid;
  gap: 16px;
}

.checkin-group {
  display: grid;
  gap: 10px;
}

.checkin-label {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.rpe-chip {
  min-width: 42px;
  justify-content: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
  width: min(calc(100% - 32px), 560px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-medium);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  transform: translateX(-50%);
}

.tab-btn {
  min-height: 50px;
  display: grid;
  justify-items: center;
  gap: 4px;
  border-radius: 18px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-icon {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.tab-label {
  line-height: 1;
}

.hidden {
  display: none;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--surface-soft), transparent 100%);
}

.empty-state .icon-wrap {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.empty-state strong {
  font-size: 0.98rem;
  color: var(--ink);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

@media (hover: hover) and (pointer: fine) {
  button:hover,
  .chip:hover,
  .tab-btn:hover {
    transform: translateY(-1px);
  }

  button.accent:hover {
    box-shadow: 0 16px 28px rgba(242, 110, 54, 0.3);
  }

  button.ghost:hover,
  .stepper-btn:hover,
  .chip:hover,
  .tab-btn:hover {
    border-color: var(--line-strong);
    background: var(--surface-strong);
  }

  .exercise-card:hover,
  .preset-item:hover,
  .sequence-item:hover,
  .metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
  }

  .add-exercise-btn:hover {
    transform: scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: rgba(71, 85, 105, 0.42);
    --line-strong: rgba(51, 65, 85, 0.54);
  }

  body[data-theme="dark"] {
    --line: rgba(148, 163, 184, 0.44);
    --line-strong: rgba(203, 213, 225, 0.48);
  }
}

@media (max-width: 759px) {
  .app-header {
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .train-intro {
    display: none;
  }

  .tab-panels.train-mode {
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }

  .tab-panels.train-mode #tab-train {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .tab-panels.train-mode .train-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0;
    gap: 0;
  }

  .train-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    max-height: none;
    padding: 10px;
    gap: 4px;
  }

  .train-exercise-preview {
    height: auto;
    max-height: 100px;
    flex: 0 1 100px;
    width: min(60vw, 220px);
    border-radius: 12px;
  }

  .timer-ring {
    width: min(50vw, 220px);
    max-height: min(50vw, 220px);
    padding: 8px;
    flex: 0 1 auto;
  }

  .time-remaining {
    font-size: clamp(1.8rem, 6vw, 2.5rem);
  }

  .timer-label {
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    min-height: 1.5em;
    margin-bottom: 0;
  }

  .timer-type, .round-meta, .next-step {
    font-size: 0.85rem;
    min-height: 1.2em;
    margin: 0;
  }

  .progress-grid-compact {
    gap: 6px;
    margin: 2px 0;
    flex: 0 0 auto;
  }

  .progress-wrap {
    gap: 4px;
  }

  .progress-wrap label {
    font-size: 0.7rem;
  }

  .progress {
    height: 6px;
  }

  .timer-actions {
    gap: 6px;
    margin-top: 4px;
    flex: 0 0 auto;
  }

  .timer-actions button {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 36px;
  }

  .app-header,
  .bottom-nav,
  .sequence-sheet,
  .checkin-sheet {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (min-width: 760px) {
  .mobile-app {
    padding-left: 22px;
    padding-right: 22px;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toggle-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .essentials-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .save-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .sequence-sheet,
  .checkin-sheet {
    left: 50%;
    right: auto;
    width: min(calc(100% - 40px), 760px);
    transform: translateX(-50%);
  }
}

@media (min-width: 980px) {
  .build-grid {
    grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
    align-items: start;
  }

  .hero-panel {
    grid-column: 1 / -1;
  }

  .setup-panel {
    grid-column: 1;
  }

  .coach-proposal {
    grid-column: 1;
  }

  .library-panel {
    grid-column: 2;
    grid-row: 2 / span 2;
  }

  .train-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .train-intro {
    grid-column: 1 / -1;
  }

  .progress-grid {
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    align-items: start;
  }
}

@media (min-width: 1200px) {
  .tab-panels {
    padding-bottom: 40px;
    padding-left: 100px;
  }

  .bottom-nav {
    top: 50%;
    left: max(18px, calc((100vw - var(--app-width)) / 2 + 20px));
    bottom: auto;
    width: 84px;
    padding: 10px;
    grid-template-columns: 1fr;
    transform: translateY(-50%);
  }

  .tab-btn {
    min-height: 72px;
    padding: 12px 8px;
    line-height: 1.1;
  }

  .tab-icon {
    font-size: 1.1rem;
  }

  .sequence-cart {
    left: calc(50% + 48px);
  }
}

@media (max-height: 760px) {
  .app-header {
    margin-bottom: 14px;
    padding: 12px 14px;
  }

  .hero-panel,
  .setup-panel,
  .library-panel,
  .coach-proposal,
  .train-intro,
  .train-sidecard,
  .presets-panel,
  .history-panel {
    padding: 18px;
  }

  .train-screen {
    padding: 20px 16px;
    gap: 10px;
  }

  .train-exercise-preview {
    height: 104px;
  }

  .timer-ring {
    width: min(62vw, 250px);
  }

  .time-remaining {
    font-size: clamp(2.2rem, 10vw, 3.8rem);
  }

  .bottom-nav {
    padding: 6px;
  }
}

/* --- Modern train element base rules (structural) ---
   These are the minimal layout rules for .modern-* elements.
   Visual overrides live in the body.train-page-active blocks below. */

.modern-timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 1rem 0;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1/1;
}

.modern-timer-core {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
}

.modern-round-meta {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.modern-time-remaining {
  font-family: var(--font-display, "Poppins", "Inter", sans-serif);
  font-size: clamp(3rem, 15vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  margin: 0;
}

.modern-timer-type { display: none; }
.modern-timer-label { display: none; }

.modern-next-step {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modern-next-step .next-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
}

.modern-next-step-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}

.modern-timer-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.modern-timer-actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  transition: transform 0.2s;
  padding: 0.75rem 0.5rem;
}

.modern-timer-actions button:active { transform: scale(0.95); }

.modern-timer-actions svg {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: 0.25rem;
}

.modern-btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 20px rgba(242, 110, 54, 0.3);
}

.modern-btn-primary svg { width: 2rem; height: 2rem; }

.modern-btn-primary span {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.modern-btn-secondary {
  background: var(--surface-float);
  border: 1px solid var(--line);
  color: var(--ink);
}

.modern-btn-secondary span {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.modern-btn-reset {
  grid-column: span 3;
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  padding: 0.75rem;
  border-radius: 0.75rem;
}

.modern-btn-reset span {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.train-page-active {
  background: #121212;
}

body.train-page-active .app-orb,
body.train-page-active .app-header {
  display: none;
}

body.train-page-active .mobile-app {
  width: 100%;
  max-width: none;
  padding: 0;
  background: #121212;
}

body.train-page-active .tab-panels {
  height: 100%;
  padding-left: 0;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

body.train-page-active .tab-panels.train-mode {
  overflow: hidden;
}

body.train-page-active #tab-train.active {
  height: 100%;
}

body.train-page-active #tabTrainBtn .tab-icon {
  fill: currentColor;
  stroke: currentColor;
}

body.train-page-active .train-screen {
  position: relative;
  min-height: calc(var(--stable-vh) - var(--nav-height) - env(safe-area-inset-bottom));
  max-width: 430px;
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) 20px 24px;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: hidden;
  color: #ffffff;
  background: #121212;
  box-shadow: none;
}

body.train-page-active .train-screen::before {
  display: none;
}

body.train-page-active .train-screen > * {
  z-index: 1;
}

body.train-page-active .tap-overlay {
  inset: auto 20px calc(var(--nav-height) + env(safe-area-inset-bottom) + 92px) 20px;
  padding-top: 0;
  justify-items: stretch;
}

body.train-page-active .tap-overlay p {
  padding: 10px 14px;
  border: 1px solid rgba(255, 107, 0, 0.22);
  border-radius: 14px;
  background: rgba(30, 30, 30, 0.92);
  color: #d8dee9;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}


.train-coach-card {
  padding: 16px 16px 15px;
  border-left: 4px solid #ff6b00;
  border-radius: 18px;
  background: linear-gradient(90deg, #1e1e1e 0%, rgba(18, 18, 18, 0.96) 100%);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.24);
}

.train-coach-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.train-coach-icon {
  width: 14px;
  height: 14px;
  color: #ff9d54;
}

.train-coach-title {
  margin: 0;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.train-coach-copy {
  margin: 0;
  color: #c8cdd8;
  font-size: 0.92rem;
  line-height: 1.35;
}

body.train-page-active .train-exercise-preview {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.train-page-active .train-exercise-preview.hidden {
  visibility: hidden;
}

.train-timer-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
  flex: 1;
  align-items: center;
}

body.train-page-active .modern-timer-container {
  max-width: 276px;
}

body.train-page-active .timer-ring {
  width: 100%;
  padding: 0;
  background: none;
  box-shadow: none;
}

.timer-ring-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.timer-ring-track,
.timer-ring-accent,
.timer-ring-progress {
  fill: none;
  transform-origin: 50% 50%;
}

.timer-ring-track {
  stroke: #1d2940;
  stroke-width: 2.6;
}

.timer-ring-accent {
  stroke: var(--ring-color, #ff6b00);
  stroke-width: 3.8;
  stroke-linecap: round;
  stroke-dasharray: 18 10 24 11 20 11 22 9;
  opacity: 1;
  transition: stroke 300ms ease;
}

.timer-ring-progress {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1.4;
  stroke-dasharray: var(--ring-progress, 0%) 100%;
  opacity: 0;
}

body.train-page-active .timer-core {
  background: none;
  border: 0;
}

body.train-page-active .modern-round-meta {
  margin-bottom: 9px;
  color: #767f90;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

body.train-page-active .modern-time-remaining {
  color: #ffffff;
  font-size: clamp(3.6rem, 18vw, 5rem);
  font-weight: 900;
  letter-spacing: -0.08em;
}

body.train-page-active .modern-next-step {
  margin-top: 12px;
  gap: 4px;
}

body.train-page-active .modern-next-step .next-label {
  color: #ff6b00;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

body.train-page-active .modern-next-step-text {
  max-width: 16ch;
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

body.train-page-active .timer-actions {
  width: 100%;
}

body.train-page-active .modern-timer-actions {
  gap: 12px;
}

body.train-page-active .modern-timer-actions button {
  min-height: 70px;
  padding: 14px 10px 12px;
  border-radius: 16px;
}

.train-control-button {
  gap: 6px;
}

.train-control-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.train-resume-icon {
  display: none;
}

.train-control-button.is-resume .train-pause-icon {
  display: none;
}

.train-control-button.is-resume .train-resume-icon {
  display: block;
}

body.train-page-active .modern-btn-secondary {
  background: #1e1e1e !important;
  border: 1px solid #263247 !important;
  color: #ffffff !important;
}

body.train-page-active .modern-btn-secondary span {
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

body.train-page-active .modern-btn-primary {
  background: #ff6b00 !important;
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.28) !important;
}

body.train-page-active .modern-btn-primary span {
  font-size: 0.82rem;
  letter-spacing: 0.14em;
}

.train-reset-button {
  min-height: 42px !important;
}

body.train-page-active .modern-btn-reset {
  background: transparent !important;
  border: 1px dashed #39445d !important;
  color: #6f7687 !important;
  border-radius: 14px !important;
}

body.train-page-active .modern-btn-reset span {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

body.train-page-active .train-screen.phase-ready,
body.train-page-active .train-screen.phase-work,
body.train-page-active .train-screen.phase-rest,
body.train-page-active .train-screen.phase-prep,
body.train-page-active .train-screen.phase-complete {
  background: #121212;
}

body.train-page-active .train-screen.phase-prep .train-coach-card {
  border-left-color: #f59e0b;
}

body.train-page-active .train-screen.phase-rest .train-coach-card {
  border-left-color: #38bdf8;
}

body.train-page-active .train-screen.phase-complete .train-coach-card {
  border-left-color: #22c55e;
}

body.train-page-active .train-screen.phase-prep .timer-ring-accent {
  stroke: #f59e0b;
}

body.train-page-active .train-screen.phase-rest .timer-ring-accent {
  stroke: #38bdf8;
}

body.train-page-active .train-screen.phase-complete .timer-ring-accent {
  stroke: #22c55e;
}

@media (max-width: 759px) {
  body.train-page-active .train-screen {
    padding: calc(22px + env(safe-area-inset-top)) 20px 20px;
    gap: 22px;
  }

  body.train-page-active .modern-timer-container {
    max-width: 262px;
  }

  body.train-page-active .modern-time-remaining {
    font-size: clamp(3.4rem, 16vw, 4.5rem);
  }

  body.train-page-active .modern-timer-actions button {
    min-height: 68px;
  }
}

@media (max-height: 760px) {
  body.train-page-active .train-screen {
    gap: 18px;
    padding-top: calc(18px + env(safe-area-inset-top));
  }

  body.train-page-active .train-coach-card {
    padding: 14px 14px 13px;
  }

  body.train-page-active .modern-timer-container {
    max-width: 232px;
  }

  body.train-page-active .modern-time-remaining {
    font-size: clamp(3rem, 13vw, 4rem);
  }

  body.train-page-active .modern-next-step {
    margin-top: 8px;
  }

  body.train-page-active .modern-timer-actions button {
    min-height: 62px;
    padding-top: 12px;
    padding-bottom: 10px;
  }
}

@media (max-height: 700px) {
  body.train-page-active .train-screen {
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  }

  .train-coach-card {
    padding: 12px 12px 11px;
    border-radius: 16px;
  }

  .train-coach-title-row {
    margin-bottom: 8px;
  }

  .train-coach-title {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
  }

  .train-coach-copy {
    font-size: 0.82rem;
    line-height: 1.2;
  }

  body.train-page-active .train-timer-shell {
    flex: 0 0 auto;
  }

  body.train-page-active .modern-timer-container {
    max-width: 194px;
  }

  body.train-page-active .modern-round-meta {
    margin-bottom: 6px;
    font-size: 0.62rem;
  }

  body.train-page-active .modern-time-remaining {
    font-size: clamp(2.75rem, 11vw, 3.75rem);
  }

  body.train-page-active .modern-next-step {
    margin-top: 6px;
    gap: 2px;
  }

  body.train-page-active .modern-next-step-text {
    font-size: 0.72rem;
    line-height: 1.15;
  }

  body.train-page-active .modern-timer-actions {
    gap: 8px;
  }

  body.train-page-active .modern-timer-actions button {
    min-height: 54px;
    padding: 9px 7px 8px;
  }

  .train-control-button {
    gap: 4px;
  }

  .train-control-icon {
    width: 20px;
    height: 20px;
  }

  body.train-page-active .modern-btn-secondary span,
  body.train-page-active .modern-btn-primary span {
    font-size: 0.66rem;
  }

  .train-reset-button {
    min-height: 36px !important;
  }

  body.train-page-active .modern-btn-reset span {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
  }
}

/* Literal code.html parity overrides */
body.train-page-active .train-screen,
body.train-page-active .train-workout-view,
body.train-page-active .train-bottom-nav {
  font-family: var(--font-body);
}

body.train-page-active .train-screen {
  max-width: 430px;
  padding: 0;
  gap: 0;
}

body.train-page-active .train-workout-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 24px;
  padding: 16px 24px calc(96px + env(safe-area-inset-bottom));
  overflow: hidden;
}

body.train-page-active .train-tips-section {
  padding: 16px;
  border-left: 4px solid #ff6b00;
  border-radius: 18px;
  background: linear-gradient(90deg, #1e1e1e 0%, #121212 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

body.train-page-active .train-coach-title-row {
  gap: 8px;
  margin-bottom: 8px;
}

body.train-page-active .train-coach-icon {
  width: 16px;
  height: 16px;
  color: #ff6b00;
}

body.train-page-active .train-coach-title {
  font-size: 0.625rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

body.train-page-active .train-coach-copy {
  color: #d1d5db;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
}

body.train-page-active .train-main-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

body.train-page-active .train-circular-timer-container {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.train-page-active .timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

body.train-page-active .timer-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

body.train-page-active .timer-ring-track {
  stroke: #1f2937;
  stroke-width: 4;
}

body.train-page-active .timer-ring-progress {
  stroke: var(--ring-color, #ff6b00);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  transition: stroke 300ms ease;
}

body.train-page-active .train-timer-copy {
  position: relative;
  inset: auto;
  z-index: 1;
  background: none;
}

body.train-page-active .modern-round-meta {
  margin-bottom: 4px;
  color: #a0a0a0;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

body.train-page-active .modern-time-remaining {
  font-size: 3.75rem;
  font-weight: 900;
  letter-spacing: -0.06em;
}

body.train-page-active .modern-next-step {
  margin-top: 8px;
}

body.train-page-active .modern-next-step .next-label {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #ff6b00;
}

body.train-page-active .modern-next-step-text {
  color: #ffffff;
  font-size: 0.75rem;
}

body.train-page-active .train-workout-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

body.train-page-active .modern-timer-actions button {
  min-height: 72px;
  padding: 16px 8px 14px;
  border-radius: 16px;
}

body.train-page-active .train-control-button {
  gap: 4px;
}

body.train-page-active .train-control-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 0;
}

body.train-page-active .modern-btn-secondary {
  background: #1e1e1e !important;
  border: 1px solid #1f2937 !important;
  color: #ffffff !important;
}

body.train-page-active .modern-btn-secondary span {
  font-size: 0.625rem;
  font-weight: 700;
}

body.train-page-active .modern-btn-primary {
  background: #ff6b00 !important;
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.3) !important;
}

body.train-page-active .modern-btn-primary .train-control-icon {
  width: 32px;
  height: 32px;
}

body.train-page-active .modern-btn-primary span {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

body.train-page-active .modern-btn-reset {
  min-height: 48px !important;
  border: 1px dashed #374151 !important;
  border-radius: 12px !important;
  color: #6b7280 !important;
}

body.train-page-active .modern-btn-reset span {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

@media (max-height: 760px) {
  body.train-page-active .train-workout-view {
    gap: 18px;
    padding: 12px 20px calc(84px + env(safe-area-inset-bottom));
  }

  body.train-page-active .train-circular-timer-container {
    max-width: 220px;
  }

  body.train-page-active .modern-time-remaining {
    font-size: 3.2rem;
  }

  body.train-page-active .modern-timer-actions button {
    min-height: 62px;
    padding: 12px 7px 10px;
  }
}

@media (max-height: 700px) {
  body.train-page-active .train-workout-view {
    gap: 14px;
    padding: 10px 18px calc(74px + env(safe-area-inset-bottom));
  }

  body.train-page-active .train-tips-section {
    padding: 12px;
  }

  body.train-page-active .train-coach-copy {
    font-size: 0.7rem;
  }

  body.train-page-active .train-circular-timer-container {
    max-width: 188px;
  }

  body.train-page-active .modern-round-meta {
    font-size: 0.58rem;
  }

  body.train-page-active .modern-time-remaining {
    font-size: 2.85rem;
  }

  body.train-page-active .modern-next-step {
    margin-top: 6px;
  }

  body.train-page-active .modern-next-step-text {
    font-size: 0.7rem;
    line-height: 1.1;
  }

  body.train-page-active .train-workout-controls {
    gap: 10px;
  }

  body.train-page-active .modern-timer-actions button {
    min-height: 54px;
    padding: 10px 6px 8px;
  }

  body.train-page-active .train-control-icon {
    width: 20px;
    height: 20px;
  }

  body.train-page-active .modern-btn-primary .train-control-icon {
    width: 24px;
    height: 24px;
  }

  body.train-page-active .modern-btn-secondary span,
  body.train-page-active .modern-btn-primary span,
  body.train-page-active .modern-btn-reset span {
    font-size: 0.58rem;
  }

}

@keyframes train-status-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Build + Stats dark shell */
body[data-active-tab="build"],
body[data-active-tab="progress"] {
  --bg: #121212;
  --bg-elevated: rgba(32, 32, 32, 0.98);
  --surface: #1e1e1e;
  --surface-strong: #202020;
  --surface-soft: #1a1a1a;
  --surface-muted: #141414;
  --ink: #ffffff;
  --ink-soft: #d1d5db;
  --muted: #a0a0a0;
  --muted-soft: #6b7280;
  --line: #2a3446;
  --line-strong: #374151;
  --chip-bg: #181818;
  --nav-bg: rgba(18, 18, 18, 0.9);
  background: #121212;
}

body[data-active-tab="build"] .app-orb,
body[data-active-tab="progress"] .app-orb {
  display: none;
}

body[data-active-tab="build"] .mobile-app,
body[data-active-tab="progress"] .mobile-app {
  width: min(var(--app-width), 100%);
  max-width: none;
  padding: 0;
  background: #121212;
}

body[data-active-tab="build"] .app-header,
body[data-active-tab="progress"] .app-header {
  position: sticky;
  top: 0;
  margin-bottom: 0;
  padding: calc(48px + env(safe-area-inset-top)) 24px 16px;
  border-bottom: 1px solid #1f2937;
  background: #121212;
  box-shadow: none;
  z-index: 40;
}

.app-header-copy {
  display: flex;
  flex-direction: column;
}

.app-page-title {
  margin: 0;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.app-status-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.app-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  animation: train-status-pulse 1.6s ease-in-out infinite;
}

.app-status-label {
  color: #a0a0a0;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.app-release-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 107, 0, 0.2);
  border-radius: 999px;
  background: rgba(255, 107, 0, 0.08);
  color: #ffb27f;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-theme-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #374151;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #1e1e1e;
  color: #ff6b00;
  box-shadow: none;
}

.app-theme-toggle:hover {
  transform: none;
}

.app-theme-icon {
  width: 20px;
  height: 20px;
}

.app-theme-icon-sun {
  display: none;
}

body[data-theme="dark"] .app-theme-icon-sun {
  display: block;
}

body[data-theme="dark"] .app-theme-icon-moon {
  display: none;
}

body[data-active-tab="build"] .tab-panels,
body[data-active-tab="progress"] .tab-panels {
  height: 100%;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  background: #121212;
  scroll-padding-top: 108px;
  scroll-padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

body[data-active-tab="build"] #tab-build,
body[data-active-tab="progress"] #tab-progress {
  padding: 18px 20px 0;
}

body[data-active-tab="build"] .library-panel,
body[data-active-tab="build"] .exercise-card,
body[data-active-tab="build"] .add-exercise-btn,
body[data-active-tab="progress"] .presets-panel,
body[data-active-tab="progress"] .history-panel {
  scroll-margin-top: 112px;
}

body[data-active-tab="build"] .page-grid,
body[data-active-tab="progress"] .page-grid {
  gap: 16px;
}

body[data-active-tab="build"] .panel,
body[data-active-tab="progress"] .panel,
body[data-active-tab="build"] .sequence-sheet,
body[data-active-tab="build"] .checkin-sheet,
body[data-active-tab="progress"] .checkin-sheet {
  background: #1e1e1e;
  border-color: #1f2937;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

body[data-active-tab="build"] .hero-panel {
  padding: 22px;
  background:
    radial-gradient(circle at top right, rgba(255, 107, 0, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 100%),
    #1e1e1e;
}

body[data-active-tab="build"] .eyebrow,
body[data-active-tab="build"] .section-kicker,
body[data-active-tab="build"] .metric-label,
body[data-active-tab="progress"] .section-kicker {
  color: #ff6b00;
}

body[data-active-tab="build"] h1,
body[data-active-tab="build"] h2,
body[data-active-tab="build"] h3,
body[data-active-tab="progress"] h2,
body[data-active-tab="progress"] h3,
body[data-active-tab="build"] .metric-card strong,
body[data-active-tab="progress"] .preset-item strong,
body[data-active-tab="build"] .exercise-title,
body[data-active-tab="build"] .seq-name,
body[data-active-tab="progress"] .empty-state strong {
  color: #ffffff;
}

body[data-active-tab="build"] .hero-copy,
body[data-active-tab="build"] .section-copy,
body[data-active-tab="build"] .topbar-copy,
body[data-active-tab="build"] .metric-card p,
body[data-active-tab="build"] .hint,
body[data-active-tab="build"] .exercise-meta,
body[data-active-tab="build"] .exercise-cue,
body[data-active-tab="build"] .seq-meta,
body[data-active-tab="progress"] .section-copy,
body[data-active-tab="progress"] .hint,
body[data-active-tab="progress"] .empty-state p,
body[data-active-tab="progress"] .preset-item,
body[data-active-tab="progress"] .history-panel,
body[data-active-tab="build"] label,
body[data-active-tab="build"] .stepper-label {
  color: #a0a0a0;
}

body[data-active-tab="build"] .metric-card {
  min-height: 110px;
  background: #202020;
  border-color: #2a3446;
  box-shadow: none;
}

body[data-active-tab="build"] .metric-icon {
  color: #ff6b00;
}

body[data-active-tab="build"] .metric-card::after {
  background: linear-gradient(90deg, #ff6b00 0%, transparent 100%);
}

body[data-active-tab="build"] .stepper-control,
body[data-active-tab="build"] .advanced-settings,
body[data-active-tab="build"] .toggle-row label,
body[data-active-tab="build"] .exercise-card,
body[data-active-tab="progress"] .preset-item,
body[data-active-tab="progress"] .chart-shell,
body[data-active-tab="progress"] .empty-state {
  background: #202020;
  border-color: #2a3446;
  box-shadow: none;
}

body[data-active-tab="build"] .stepper-btn,
body[data-active-tab="build"] input,
body[data-active-tab="build"] select,
body[data-active-tab="build"] textarea,
body[data-active-tab="progress"] input,
body[data-active-tab="build"] .seq-edit input,
body[data-active-tab="progress"] #historyChart {
  background: #141414;
  border-color: #30343f;
  color: #ffffff;
}

body[data-active-tab="build"] input::placeholder,
body[data-active-tab="progress"] input::placeholder {
  color: #6b7280;
}

body[data-active-tab="build"] .advanced-settings summary {
  color: #ffffff;
}

body[data-active-tab="build"] .advanced-settings summary::after {
  color: #6b7280;
}

body[data-active-tab="build"] .toggle-row label {
  color: #d1d5db;
}

body[data-active-tab="build"] .chips .chip,
body[data-active-tab="build"] .rpe-chip,
body[data-active-tab="build"] .completion-chip {
  background: #181818;
  border-color: #30343f;
  color: #cdd3dc;
  box-shadow: none;
}

body[data-active-tab="build"] .chip.active,
body[data-active-tab="build"] .rpe-chip.active,
body[data-active-tab="build"] .completion-chip.active,
body[data-active-tab="progress"] .tab-btn.active,
body[data-active-tab="build"] .tab-btn.active {
  background: transparent;
  box-shadow: none;
}

body[data-active-tab="build"] button.ghost,
body[data-active-tab="progress"] button.ghost {
  background: #1a1a1a;
  color: #f3f4f6;
  border-color: #2a3446;
}

body[data-active-tab="build"] button.accent,
body[data-active-tab="progress"] button.accent {
  background: #ff6b00;
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.28);
}

body[data-active-tab="build"] .exercise-card img,
body[data-active-tab="build"] .sequence-item img {
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface) 50%, var(--surface-muted) 75%);
}

body[data-active-tab="build"] .exercise-card,
body[data-active-tab="build"] .preset-item,
body[data-active-tab="build"] .sequence-item,
body[data-active-tab="progress"] .preset-item {
  border-radius: 18px;
}

body[data-active-tab="build"] .add-exercise-btn {
  background: #141414;
  color: #ff6b00;
  border: 1px solid rgba(255, 107, 0, 0.14);
  box-shadow: 0 6px 18px rgba(255, 107, 0, 0.12);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

body[data-active-tab="build"] .add-exercise-btn:hover {
  background: rgba(255, 107, 0, 0.12);
  border-color: rgba(255, 107, 0, 0.28);
  color: #ffffff;
}

body[data-active-tab="build"] .add-exercise-btn:active {
  transform: scale(0.92);
  background: #ff6b00;
  border-color: #ff6b00;
  color: #ffffff;
  box-shadow:
    0 0 0 6px rgba(255, 107, 0, 0.14),
    0 10px 24px rgba(255, 107, 0, 0.28);
}

body[data-active-tab="build"] .exercise-card {
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease,
    background-color 140ms ease;
}

body[data-active-tab="build"] .exercise-card:has(.add-exercise-btn:hover) {
  border-color: #3a4a63;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

body[data-active-tab="build"] .exercise-card:has(.add-exercise-btn:active) {
  border-color: rgba(255, 107, 0, 0.42);
  background: linear-gradient(180deg, rgba(255, 107, 0, 0.08), transparent 100%), #202020;
  box-shadow: 0 16px 28px rgba(255, 107, 0, 0.14);
  transform: translateY(-1px);
}

body[data-active-tab="build"] .coach-proposal {
  background:
    linear-gradient(90deg, #1e1e1e 0%, #121212 100%);
  border-left: 4px solid #ff6b00;
}

body[data-active-tab="build"] .coach-badge {
  background: #121212;
  border-color: #1f2937;
  color: #ffffff;
}

body[data-active-tab="build"] .sequence-cart {
  width: min(calc(100% - 32px), 390px);
  border-radius: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.3);
}

body[data-active-tab="build"] .sequence-backdrop,
body[data-active-tab="progress"] .checkin-backdrop,
body[data-active-tab="build"] .checkin-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

body[data-active-tab="build"] .sequence-sheet,
body[data-active-tab="build"] .checkin-sheet,
body[data-active-tab="progress"] .checkin-sheet {
  border-radius: 24px;
}

body[data-active-tab="progress"] .history-panel .inline-actions {
  justify-content: flex-end;
}

body[data-active-tab="progress"] .chart-shell {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 100%), #202020;
}

body[data-active-tab="build"] .empty-state .icon-wrap,
body[data-active-tab="progress"] .empty-state .icon-wrap {
  background: rgba(255, 107, 0, 0.12);
  color: #ff6b00;
}

body[data-active-tab="build"] button.ghost:hover,
body[data-active-tab="progress"] button.ghost:hover {
  background: #202020;
  border-color: #374151;
  color: #ffffff;
}

body[data-active-tab="build"] button.accent:hover,
body[data-active-tab="progress"] button.accent:hover {
  box-shadow: 0 10px 24px rgba(255, 107, 0, 0.32);
}

body[data-active-tab="build"] .chip:hover,
body[data-active-tab="build"] .rpe-chip:hover,
body[data-active-tab="build"] .completion-chip:hover {
  background: #202020;
  border-color: #374151;
  color: #ffffff;
}

@media (max-height: 760px) {
  body[data-active-tab="build"] .app-header,
  body[data-active-tab="progress"] .app-header {
    padding: calc(22px + env(safe-area-inset-top)) 20px 12px;
  }

  body[data-active-tab="build"] #tab-build,
  body[data-active-tab="progress"] #tab-progress {
    padding: 14px 18px 0;
  }
}

/* Shared Train-page template port for Build + Stats */
body[data-active-tab="build"] #tab-build,
body[data-active-tab="progress"] #tab-progress {
  padding: 0;
}

body[data-active-tab="build"] .app-page-screen,
body[data-active-tab="progress"] .app-page-screen {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

body[data-active-tab="build"] .app-page-view,
body[data-active-tab="progress"] .app-page-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px 24px calc(96px + env(safe-area-inset-bottom));
}

body[data-active-tab="build"] .template-panel,
body[data-active-tab="progress"] .template-panel {
  padding: 16px;
  border: 1px solid #1f2937;
  border-radius: 18px;
  background: linear-gradient(90deg, #1e1e1e 0%, #121212 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

body[data-active-tab="build"] .template-highlight-panel,
body[data-active-tab="progress"] .template-highlight-panel {
  border-left: 4px solid #ff6b00;
}

body[data-active-tab="build"] .hero-panel.template-panel {
  overflow: visible;
  background: linear-gradient(90deg, #1e1e1e 0%, #121212 100%);
}

body[data-active-tab="build"] .template-panel .train-coach-title-row,
body[data-active-tab="progress"] .template-panel .train-coach-title-row {
  margin-bottom: 12px;
}

body[data-active-tab="build"] .template-panel .train-coach-title,
body[data-active-tab="progress"] .template-panel .train-coach-title {
  font-size: 0.625rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

body[data-active-tab="build"] .template-panel .train-coach-copy,
body[data-active-tab="progress"] .template-panel .train-coach-copy {
  color: #d1d5db;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
}

body[data-active-tab="build"] .template-mini-card {
  min-height: 0;
  background: #202020;
  border-color: #1f2937;
  box-shadow: none;
}

body[data-active-tab="build"] .template-panel .section-heading,
body[data-active-tab="progress"] .template-panel .section-heading,
body[data-active-tab="build"] .template-panel .panel-title-row,
body[data-active-tab="progress"] .template-panel .panel-title-row {
  margin-bottom: 16px;
}

body[data-active-tab="build"] .template-panel .section-heading:last-child,
body[data-active-tab="progress"] .template-panel .section-heading:last-child {
  margin-bottom: 0;
}

body[data-active-tab="build"] .setup-panel,
body[data-active-tab="build"] .library-panel,
body[data-active-tab="build"] .coach-proposal,
body[data-active-tab="progress"] .presets-panel,
body[data-active-tab="progress"] .history-panel {
  padding: 16px;
}

body[data-active-tab="build"] .hero-content {
  gap: 16px;
}

body[data-active-tab="build"] .hero-copy-block {
  gap: 8px;
}

body[data-active-tab="build"] .hero-copy,
body[data-active-tab="build"] .section-copy,
body[data-active-tab="progress"] .section-copy {
  font-size: 0.9rem;
  line-height: 1.45;
}

body[data-active-tab="build"] .hero-metrics {
  gap: 10px;
}

body[data-active-tab="build"] .metric-card strong {
  margin: 8px 0 4px;
}

body[data-active-tab="build"] .metric-card p {
  font-size: 0.8rem;
  line-height: 1.45;
}

body[data-active-tab="build"] .metric-card::after {
  margin-top: 10px;
}

body[data-active-tab="build"] .setup-panel .quick-presets,
body[data-active-tab="build"] .setup-panel .essentials-grid,
body[data-active-tab="build"] .setup-panel .advanced-settings,
body[data-active-tab="progress"] .presets-panel .save-row {
  margin-top: 0;
}

body[data-active-tab="build"] .advanced-settings,
body[data-active-tab="build"] .stepper-control,
body[data-active-tab="build"] .toggle-row label,
body[data-active-tab="build"] .exercise-card,
body[data-active-tab="progress"] .preset-item,
body[data-active-tab="progress"] .chart-shell,
body[data-active-tab="progress"] .empty-state {
  background: #202020;
  border-color: #1f2937;
  box-shadow: none;
}

body[data-active-tab="build"] .stepper-btn,
body[data-active-tab="build"] input,
body[data-active-tab="build"] select,
body[data-active-tab="build"] textarea,
body[data-active-tab="progress"] input,
body[data-active-tab="build"] .seq-edit input,
body[data-active-tab="progress"] #historyChart {
  background: #141414;
  border-color: #30343f;
  color: #ffffff;
}

body[data-active-tab="build"] .chips,
body[data-active-tab="build"] .inline-actions,
body[data-active-tab="progress"] .inline-actions {
  gap: 10px;
}

body[data-active-tab="progress"] .history-panel .inline-actions {
  justify-content: flex-end;
}

body[data-active-tab="progress"] .chart-shell {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 100%), #202020;
}

@media (max-height: 760px) {
  body[data-active-tab="build"] .app-page-view,
  body[data-active-tab="progress"] .app-page-view {
    gap: 18px;
    padding: 12px 20px calc(84px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 700px) {
  body[data-active-tab="build"] .app-header,
  body[data-active-tab="progress"] .app-header {
    padding: calc(20px + env(safe-area-inset-top)) 20px 12px;
  }

  body[data-active-tab="build"] .app-page-view,
  body[data-active-tab="progress"] .app-page-view {
    gap: 14px;
    padding: 10px 18px calc(74px + env(safe-area-inset-bottom));
  }

  body[data-active-tab="build"] .template-panel,
  body[data-active-tab="progress"] .template-panel {
    padding: 12px;
  }

  body[data-active-tab="build"] .hero-copy,
  body[data-active-tab="build"] .section-copy,
  body[data-active-tab="progress"] .section-copy,
  body[data-active-tab="progress"] .template-panel .train-coach-copy {
    font-size: 0.78rem;
  }
}

/* Canonical shared dock: identical across Build / Train / Stats */
.bottom-nav.train-bottom-nav {
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px calc(16px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
  background: rgba(18, 18, 18, 0.9);
  border-top: 1px solid #1f2937;
  box-shadow: none;
  transform: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.bottom-nav.train-bottom-nav .tab-btn {
  position: relative;
  min-height: auto;
  flex: 1 1 0;
  padding: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  color: #6b7280;
  box-shadow: none;
}

.bottom-nav.train-bottom-nav .tab-btn:not(.active) {
  color: #6b7280 !important;
}

.bottom-nav.train-bottom-nav .tab-btn:hover {
  border-color: transparent;
  background: transparent;
  color: #6b7280;
}

.bottom-nav.train-bottom-nav .tab-icon {
  width: 24px;
  height: 24px;
}

.bottom-nav.train-bottom-nav .tab-icon-active-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav.train-bottom-nav .tab-active-dot {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #ff6b00;
  transform: translateX(-50%);
  opacity: 0;
}

.bottom-nav.train-bottom-nav .tab-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.bottom-nav.train-bottom-nav .tab-btn.active {
  color: #ff6b00 !important;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.bottom-nav.train-bottom-nav .tab-btn.active .tab-active-dot {
  opacity: 1;
}

.bottom-nav.train-bottom-nav .tab-btn.active::after {
  display: none;
}

.bottom-nav.train-bottom-nav .tab-btn:active {
  transform: scale(0.96);
}

.bottom-nav.train-bottom-nav .tab-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.22);
}

@media (max-height: 760px) {
  .bottom-nav.train-bottom-nav {
    padding: 16px 32px calc(16px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 700px) {
  .bottom-nav.train-bottom-nav {
    padding: 8px 24px calc(8px + env(safe-area-inset-bottom));
  }

  .bottom-nav.train-bottom-nav .tab-icon {
    width: 20px;
    height: 20px;
  }

  .bottom-nav.train-bottom-nav .tab-icon-active-wrap {
    width: 20px;
    height: 20px;
  }

  .bottom-nav.train-bottom-nav .tab-label {
    font-size: 0.62rem;
  }
}

/* Full-page Train template parity for Build / Stats */
body[data-active-tab="build"],
body[data-active-tab="progress"] {
  --bg: #121212;
  --bg-elevated: rgba(18, 18, 18, 0.98);
  --surface: #1e1e1e;
  --surface-strong: #1e1e1e;
  --surface-soft: #1e1e1e;
  --surface-muted: #121212;
  --surface-float: rgba(30, 30, 30, 0.96);
  --ink: #ffffff;
  --ink-soft: #d1d5db;
  --muted: #a0a0a0;
  --muted-soft: #6b7280;
  --line: #1f2937;
  --line-strong: #374151;
  --accent: #ff6b00;
  --accent-strong: #ff6b00;
  --accent-soft: rgba(255, 107, 0, 0.12);
  --accent-glow: rgba(255, 107, 0, 0.22);
  --chip-bg: #1e1e1e;
  --ghost-bg: #1e1e1e;
  --nav-bg: rgba(18, 18, 18, 0.9);
  --shadow-glow: 0 20px 48px rgba(255, 107, 0, 0.22);
  --focus-ring: 0 0 0 3px rgba(255, 107, 0, 0.22);
  background: #121212;
}

body[data-active-tab="build"] .app-orb,
body[data-active-tab="progress"] .app-orb {
  display: none;
}

body[data-active-tab="build"] .mobile-app,
body[data-active-tab="progress"] .mobile-app {
  width: 100%;
  max-width: none;
  height: 100dvh;
  padding: 0;
}

body[data-active-tab="build"] .app-header,
body[data-active-tab="progress"] .app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  width: min(100%, 430px);
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top)) 24px 16px;
  border: 0;
  border-bottom: 1px solid #1f2937;
  border-radius: 0;
  background: #121212;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body[data-active-tab="build"] .tab-panels,
body[data-active-tab="progress"] .tab-panels {
  height: 100%;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  background: #121212;
  scroll-padding-top: 120px;
  scroll-padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

body[data-active-tab="build"] #tab-build,
body[data-active-tab="progress"] #tab-progress {
  padding: 0;
}

body[data-active-tab="build"] .app-page-screen,
body[data-active-tab="progress"] .app-page-screen {
  width: min(100%, 430px);
  min-height: calc(var(--stable-vh) - var(--nav-height) - env(safe-area-inset-bottom));
  margin: 0 auto;
  background: #121212;
  color: #ffffff;
}

body[data-active-tab="build"] .app-page-view,
body[data-active-tab="progress"] .app-page-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px 24px calc(96px + env(safe-area-inset-bottom));
}

body[data-active-tab="build"] .page-grid,
body[data-active-tab="progress"] .page-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

body[data-active-tab="build"] .template-panel,
body[data-active-tab="progress"] .template-panel,
body[data-active-tab="build"] .sequence-sheet,
body[data-active-tab="progress"] .checkin-sheet,
body[data-active-tab="build"] .checkin-sheet {
  padding: 16px;
  background: linear-gradient(90deg, #1e1e1e 0%, #121212 100%);
  border: 1px solid #1f2937;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

body[data-active-tab="build"] .template-highlight-panel,
body[data-active-tab="progress"] .template-highlight-panel {
  border-left: 4px solid #ff6b00;
  background:
    linear-gradient(90deg, #1e1e1e 0%, rgba(18, 18, 18, 0.96) 100%);
}

body[data-active-tab="build"] .hero-panel {
  padding: 16px;
}

body[data-active-tab="build"] .hero-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body[data-active-tab="build"] .hero-copy-block h1 {
  margin-bottom: 8px;
  color: #ffffff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1.8rem, 6vw, 2.25rem);
  font-style: italic;
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 0.96;
}

body[data-active-tab="build"] .hero-metrics {
  gap: 12px;
}

body[data-active-tab="build"] .template-mini-card {
  min-height: 0;
  padding: 14px 14px 12px;
  border: 1px solid #1f2937;
  border-radius: 18px;
  background: #1e1e1e;
  box-shadow: none;
}

body[data-active-tab="build"] .template-mini-card::after {
  background: linear-gradient(90deg, #ff6b00 0%, transparent 100%);
}

body[data-active-tab="build"] .eyebrow,
body[data-active-tab="build"] .section-kicker,
body[data-active-tab="build"] .metric-label,
body[data-active-tab="progress"] .section-kicker {
  color: #ff6b00;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

body[data-active-tab="build"] h1,
body[data-active-tab="build"] h2,
body[data-active-tab="build"] h3,
body[data-active-tab="progress"] h2,
body[data-active-tab="progress"] h3,
body[data-active-tab="build"] .metric-card strong,
body[data-active-tab="progress"] .preset-item strong,
body[data-active-tab="build"] .exercise-title,
body[data-active-tab="build"] .seq-name,
body[data-active-tab="progress"] .empty-state strong {
  color: #ffffff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body[data-active-tab="build"] .hero-copy,
body[data-active-tab="build"] .section-copy,
body[data-active-tab="build"] .metric-card p,
body[data-active-tab="build"] .hint,
body[data-active-tab="build"] .exercise-meta,
body[data-active-tab="build"] .exercise-cue,
body[data-active-tab="build"] .seq-meta,
body[data-active-tab="progress"] .section-copy,
body[data-active-tab="progress"] .hint,
body[data-active-tab="progress"] .empty-state p,
body[data-active-tab="progress"] .preset-item,
body[data-active-tab="progress"] .history-panel,
body[data-active-tab="build"] label,
body[data-active-tab="build"] .stepper-label {
  color: #a0a0a0;
}

body[data-active-tab="build"] .metric-card,
body[data-active-tab="build"] .stepper-control,
body[data-active-tab="build"] .advanced-settings,
body[data-active-tab="build"] .toggle-row label,
body[data-active-tab="build"] .exercise-card,
body[data-active-tab="progress"] .preset-item,
body[data-active-tab="progress"] .chart-shell,
body[data-active-tab="progress"] .empty-state {
  background: #1e1e1e;
  border-color: #1f2937;
  box-shadow: none;
}

body[data-active-tab="build"] .metric-icon {
  color: #ff6b00;
}

body[data-active-tab="build"] button.ghost,
body[data-active-tab="progress"] button.ghost {
  background: #1e1e1e;
  color: #ffffff;
  border-color: #1f2937;
}

body[data-active-tab="build"] button.accent,
body[data-active-tab="progress"] button.accent {
  background: #ff6b00;
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.3);
}

body[data-active-tab="build"] .chips .chip,
body[data-active-tab="build"] .rpe-chip,
body[data-active-tab="build"] .completion-chip {
  background: #1e1e1e;
  border-color: #1f2937;
  color: #cdd3dc;
  box-shadow: none;
}

body[data-active-tab="build"] .stepper-btn,
body[data-active-tab="build"] input,
body[data-active-tab="build"] select,
body[data-active-tab="build"] textarea,
body[data-active-tab="progress"] input,
body[data-active-tab="build"] .seq-edit input,
body[data-active-tab="progress"] #historyChart {
  background: #121212;
  border-color: #374151;
  color: #ffffff;
}

body[data-active-tab="build"] .coach-proposal {
  background:
    linear-gradient(90deg, #1e1e1e 0%, rgba(18, 18, 18, 0.96) 100%);
  border-left: 4px solid #ff6b00;
}

body[data-active-tab="build"] .section-heading,
body[data-active-tab="progress"] .section-heading,
body[data-active-tab="build"] .panel-title-row,
body[data-active-tab="progress"] .panel-title-row {
  align-items: flex-start;
  margin-bottom: 16px;
}

body[data-active-tab="build"] .sequence-cart {
  width: min(calc(100% - 32px), 390px);
  border-radius: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.3);
}

body[data-active-tab="progress"] .history-panel .inline-actions {
  justify-content: flex-end;
}

body[data-active-tab="progress"] .chart-shell {
  background: linear-gradient(90deg, #1e1e1e 0%, #121212 100%);
}

@media (max-height: 760px) {
  body[data-active-tab="build"] .app-header,
  body[data-active-tab="progress"] .app-header {
    padding: calc(22px + env(safe-area-inset-top)) 20px 12px;
  }

  body[data-active-tab="build"] .app-page-view,
  body[data-active-tab="progress"] .app-page-view {
    gap: 14px;
    padding: 14px 18px calc(88px + env(safe-area-inset-bottom));
  }

  body[data-active-tab="build"] .template-panel,
  body[data-active-tab="progress"] .template-panel {
    padding: 14px;
    border-radius: 18px;
  }
}

@media (max-height: 700px) {
  body[data-active-tab="build"] .app-page-view,
  body[data-active-tab="progress"] .app-page-view {
    gap: 14px;
    padding: 12px 16px calc(78px + env(safe-area-inset-bottom));
  }

  body[data-active-tab="build"] .template-panel,
  body[data-active-tab="progress"] .template-panel {
    padding: 12px;
    border-radius: 18px;
  }

  body[data-active-tab="build"] .hero-copy-block h1 {
    font-size: 1.5rem;
  }

  body[data-active-tab="build"] .template-mini-card {
    padding: 12px;
  }
}

/* ============================================================
   Phase 2 (engo slice) — phase color, motion, Train background
   ============================================================ */

/* Interpolatable phase-current so the cross-fade actually animates.
   Falls back to plain color on browsers that ignore @property. */
@property --phase-current {
  syntax: "<color>";
  inherits: true;
  initial-value: #f26e36;
}

:root {
  --phase-current: var(--phase-work);
}

/* Smooth 300ms cross-fade on the phase color at the root.
   Consumers (ring stroke, dot row, vignette, meta label) read
   --phase-current and inherit the transition. */
:root {
  transition: --phase-current 300ms ease;
}

/* Remove decorative orbs on Train only — they stay on Build/Progress. */
body.train-page-active .app-orb-left,
body.train-page-active .app-orb-right {
  display: none !important;
}

/* Full-bleed dark Train background + phase-tinted radial vignette from top. */
body.train-page-active {
  background: var(--bg, #0A0F1A);
}

body.train-page-active .train-screen {
  position: relative;
  background: var(--bg, #0A0F1A);
}

body.train-page-active .train-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    ellipse 120% 60% at 50% 0%,
    var(--phase-current) 0%,
    transparent 60%
  );
  opacity: 0.08;
  transition: background 300ms ease;
}

body.train-page-active .train-screen > * {
  position: relative;
  z-index: 1;
}

/* Ring progress stroke reads phase-current and cross-fades. */
body.train-page-active .timer-ring-progress,
body.train-page-active .timer-ring-accent {
  stroke: var(--phase-current);
  transition: stroke 300ms ease;
}

/* Phase color tints "Round 2/5" meta label above the timer. */
body.train-page-active .modern-round-meta {
  color: var(--phase-current);
  transition: color 300ms ease;
}

/* Round-dot indicator row (active dots take phase color). */
body.train-page-active .round-dot-row .round-dot.is-active,
body.train-page-active .round-dot-row .round-dot.is-filled {
  background: var(--phase-current);
  transition: background 300ms ease;
}

/* ============================================================
   Phase 2 (engy slice) — slim header, dots, ring unify, controls,
   preview overlay, tips-below-controls. Appended at EOF so these
   win the cascade without !important duels.
   ============================================================ */

/* Reveal the slim header only on Train; elsewhere hide it. */
.train-slim-header { display: none; }
body.train-page-active .train-slim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 4px;
  margin-bottom: 8px;
  color: var(--ink, #eff6ff);
}

body.train-page-active .train-slim-back {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
body.train-page-active .train-slim-back:active { transform: scale(0.94); }
body.train-page-active .train-slim-back .icon {
  width: 20px;
  height: 20px;
  display: block;
  color: currentColor;
  fill: none;
  stroke: currentColor;
}

body.train-page-active .train-slim-coach {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  border: 0;
  padding: 4px 6px;
  margin: 0;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
body.train-page-active .train-slim-coach:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}
body.train-page-active .train-slim-coach-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--phase-current, var(--accent, #f26e36));
  box-shadow: 0 0 8px var(--phase-current, var(--accent, #f26e36));
  animation: train-status-pulse 1.6s ease-in-out infinite;
}
body.train-page-active .train-slim-coach[aria-pressed="false"] {
  color: rgba(255, 255, 255, 0.35);
}
body.train-page-active .train-slim-coach[aria-pressed="false"] .train-slim-coach-dot {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: none;
  animation: none;
}

/* --- Unified ring (replaces old MODERN TRAIN SCREEN ring overrides) --- */
body.train-page-active .train-main-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 4px;
}

body.train-page-active .train-circular-timer-container,
body.train-page-active .modern-timer-container {
  position: relative;
  width: 280px;
  max-width: 280px;
  height: 280px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

body.train-page-active .timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: none;
  box-shadow: none;
  border-radius: 999px;
}

body.train-page-active .timer-ring-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  transform: rotate(-90deg);
}

body.train-page-active .timer-ring-track {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 6;
  fill: none;
}

body.train-page-active .timer-ring-accent {
  /* Legacy second circle — keep invisible; progress uses timer-ring-progress. */
  stroke: transparent;
  stroke-width: 0;
  stroke-dasharray: none;
  opacity: 0;
}

body.train-page-active .timer-ring-progress {
  stroke: var(--phase-current, var(--accent, #f26e36));
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-progress, 0) 100;
  fill: none;
  opacity: 1;
  filter: drop-shadow(0 0 10px var(--phase-current, var(--accent, #f26e36)));
  transition: stroke 300ms ease;
}

/* Timer core text block, centered on top of the ring. */
body.train-page-active .train-timer-copy,
body.train-page-active .modern-timer-core {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  z-index: 2;
  text-align: center;
}

body.train-page-active .modern-round-meta {
  margin: 0 0 6px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--phase-current, var(--accent, #f26e36));
}

body.train-page-active .modern-time-remaining {
  margin: 0;
  font-family: var(--font-display, "Poppins", "Inter", sans-serif);
  font-size: clamp(3.4rem, 16vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

body.train-page-active .modern-next-step {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
body.train-page-active .modern-next-step .next-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent, #f26e36);
}
body.train-page-active .modern-next-step-text {
  margin: 0;
  max-width: 20ch;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
}

/* --- Exercise preview: faint ring-center fade-in overlay during first 3s of work --- */
body.train-page-active .train-exercise-preview {
  position: absolute;
  inset: 14px;
  width: auto;
  height: auto;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.3;
  z-index: 1;
  transition: opacity 400ms ease;
  /* reset any legacy sr-only clip rules */
  clip: auto;
  margin: 0;
  padding: 0;
  white-space: normal;
  border: 0;
}
body.train-page-active .train-exercise-preview.hidden {
  opacity: 0;
  visibility: visible;
}
body.train-page-active .train-exercise-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.85) contrast(0.95);
}

/* --- Round-dot indicator (5 dots, phase color) --- */
body.train-page-active .train-round-dots {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
body.train-page-active .round-dot-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
body.train-page-active .round-dot-row .round-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  transition: background 300ms ease, transform 200ms ease;
}
body.train-page-active .round-dot-row .round-dot.is-active {
  transform: scale(1.15);
  box-shadow: 0 0 10px var(--phase-current, var(--accent, #f26e36));
}
body.train-page-active .train-round-dots-label {
  margin: 0;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

/* --- Controls: 3-col grid, 72px tall, no !important duels --- */
body.train-page-active .train-workout-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}
body.train-page-active .train-workout-controls .train-control-button {
  min-height: 72px;
  padding: 12px 10px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 150ms ease, background 200ms ease, border-color 200ms ease;
  font-family: var(--font-body, "Inter", sans-serif);
}
body.train-page-active .train-workout-controls .train-control-button:active {
  transform: scale(0.97);
}
body.train-page-active .train-workout-controls .modern-btn-secondary {
  background: var(--surface, #121A2B);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  box-shadow: none;
}
body.train-page-active .train-workout-controls .modern-btn-primary {
  background: var(--accent, #f26e36);
  border: 0;
  color: #ffffff;
  box-shadow: 0 0 24px rgba(242, 110, 54, 0.35);
}
body.train-page-active .train-workout-controls .train-control-icon {
  width: 22px;
  height: 22px;
  margin: 0;
}
body.train-page-active .train-workout-controls .modern-btn-primary .train-control-icon {
  width: 28px;
  height: 28px;
}
body.train-page-active .train-workout-controls .train-control-button span {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: inherit;
}

/* Reset: dashed full-width ghost button below the grid */
body.train-page-active .train-reset-button {
  grid-column: 1 / -1;
  min-height: 44px;
  padding: 10px 12px;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-body, "Inter", sans-serif);
  cursor: pointer;
}
body.train-page-active .train-reset-button span {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* --- Workout view gap / order (tip card is last, below controls) --- */
body.train-page-active .train-workout-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) 20px calc(88px + env(safe-area-inset-bottom));
  overflow: hidden;
}

/* --- Flow-state tip strip: slim, accent-bordered, below controls --- */
body.train-page-active .train-tips-section {
  padding: 12px 14px;
  border: 0;
  border-left: 3px solid var(--accent, #f26e36);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: none;
  margin-top: 4px;
}
body.train-page-active .train-tips-section .train-coach-title-row {
  margin-bottom: 4px;
  gap: 6px;
}
body.train-page-active .train-tips-section .train-coach-title {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent, #f26e36);
}
body.train-page-active .train-tips-section .train-coach-copy {
  font-size: 0.78rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.82);
}

/* --- Short-height accommodations --- */
@media (max-height: 720px) {
  body.train-page-active .train-circular-timer-container,
  body.train-page-active .modern-timer-container {
    width: 232px;
    max-width: 232px;
    height: 232px;
  }
  body.train-page-active .modern-time-remaining {
    font-size: clamp(2.8rem, 13vw, 3.6rem);
  }
  body.train-page-active .train-workout-controls .train-control-button {
    min-height: 62px;
  }
}

/* Keep status-pulse defined (already elsewhere), but guard if cascade ordered later. */
@keyframes train-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* =========================================================
   Phase 3 — Build screen redesign (engy slice)
   Appended at EOF so these rules win without !important duels.
   Scope: Build tab only (body[data-active-tab="build"]).
   ========================================================= */

/* Kill the old hero panel + its overrides globally. DOM is gone, but many
   legacy selectors remain in the sheet; this ensures nothing leaks. */
.hero-panel,
.hero,
.hero-content,
.hero-copy-block,
.hero-metrics,
.metric-card,
body[data-active-tab="build"] .hero-panel,
body[data-active-tab="build"] .hero-content,
body[data-active-tab="build"] .hero-copy-block,
body[data-active-tab="build"] .hero-metrics,
body[data-active-tab="build"] .metric-card {
  display: none !important;
}

/* Kill the orbs on the Build tab (Phase 2 only hid them on Train). */
body[data-active-tab="build"] .app-orb-left,
body[data-active-tab="build"] .app-orb-right,
body[data-active-tab="build"] .app-orb {
  display: none !important;
}

/* Compact top strip (replaces hero) */
.build-topstrip {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  margin: 0;
}
.build-topstrip-greeting {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.build-topstrip-hello {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xl);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.build-topstrip-week {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.6;
  white-space: nowrap;
}
.build-topstrip-coach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.build-topstrip-coach-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: train-status-pulse 2.4s ease-in-out infinite;
}

/* Quick preset pills — horizontal scroll row */
body[data-active-tab="build"] .quick-presets.preset-pill-row {
  display: flex;
  flex-direction: row;
  gap: var(--space-3);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-2) 2px var(--space-3);
  margin: 0 calc(var(--space-4) * -1);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  scrollbar-width: none;
}
body[data-active-tab="build"] .quick-presets.preset-pill-row::-webkit-scrollbar {
  display: none;
}
body[data-active-tab="build"] .preset-pill {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 140px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  text-align: left;
  font-family: inherit;
}
body[data-theme="light"] .preset-pill {
  border-color: rgba(15, 23, 42, 0.06);
}
body[data-active-tab="build"] .preset-pill:active {
  transform: translateY(1px);
}
body[data-active-tab="build"] .preset-pill.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 8px 24px var(--accent-glow);
}
.preset-pill-icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
  margin-bottom: 2px;
}
.preset-pill-timing {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.preset-pill-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Stepper cards — focal element */
body[data-active-tab="build"] .stepper-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
body[data-active-tab="build"] .stepper-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.04);
  min-width: 0;
}
body[data-theme="light"] .stepper-card {
  border-color: rgba(15, 23, 42, 0.05);
}
body[data-active-tab="build"] .stepper-card .stepper-label {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}
body[data-active-tab="build"] .stepper-card .stepper-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
}
body[data-active-tab="build"] .stepper-btn-round {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
body[data-theme="light"] .stepper-btn-round {
  border-color: rgba(15, 23, 42, 0.1);
}
body[data-active-tab="build"] .stepper-btn-round:hover {
  border-color: var(--accent);
  color: var(--accent);
}
body[data-active-tab="build"] .stepper-btn-round:active {
  transform: scale(0.94);
  background: var(--accent-soft);
}
body[data-active-tab="build"] .stepper-input-big {
  flex: 1 1 auto;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 56px;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: none;
  padding: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  -moz-appearance: textfield;
  appearance: textfield;
  min-width: 0;
  width: 100%;
}
@media (min-width: 380px) {
  body[data-active-tab="build"] .stepper-input-big {
    font-size: 64px;
  }
}
body[data-active-tab="build"] .stepper-input-big::-webkit-outer-spin-button,
body[data-active-tab="build"] .stepper-input-big::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
body[data-active-tab="build"] .stepper-input-big:focus {
  outline: none;
}

/* Coach Proposal — distinct treatment above stepper */
body[data-active-tab="build"] .coach-proposal-card {
  position: relative;
  border: 1px solid var(--accent);
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 80%),
    var(--surface);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 10px 40px var(--accent-glow);
  transition: max-height var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out), padding var(--dur) var(--ease-out);
  overflow: hidden;
}
body[data-active-tab="build"] .coach-proposal-card.is-collapsed {
  max-height: 64px;
  opacity: 0.72;
}
body[data-active-tab="build"] .coach-proposal-card.is-collapsed .coach-change-list,
body[data-active-tab="build"] .coach-proposal-card.is-collapsed #coachProposalSummary,
body[data-active-tab="build"] .coach-proposal-card.is-collapsed .inline-actions {
  display: none;
}
body[data-active-tab="build"] .coach-proposal-card .coach-proposal-apply {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: 0 6px 16px var(--accent-glow);
}
body[data-active-tab="build"] .coach-proposal-card .coach-proposal-apply:hover {
  background: var(--accent-strong);
}

/* Hide the setup panel heading kicker/copy clutter — the steppers speak for themselves. */
body[data-active-tab="build"] .setup-panel .section-heading .section-copy {
  display: none;
}

/* ============================================================
   Phase 3 (engo slice) — Build: library grid, category chips,
   advanced-settings sub-cards. Appended at EOF so these rules
   win the cascade without !important duels (except where the
   earlier dark-tab overrides use !important).
   ============================================================ */

/* --- Exercise library: 2-column grid, larger image, pinned 56px + CTA --- */
.exercise-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.exercise-card {
  /* Replace the old image|body|btn 3-col layout with a stacked card:
     image top, body below, + CTA pinned bottom-right. */
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  height: auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
  border-radius: 18px;
}

.exercise-card-image {
  width: 100%;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface) 50%, var(--surface-muted) 75%);
}

.exercise-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: transparent;
}

.exercise-card .exercise-body {
  padding: 12px 14px 68px; /* reserve room at bottom-right for the pinned + CTA */
  display: grid;
  gap: 6px;
  align-content: start;
}

.exercise-card .exercise-title {
  font-size: 0.98rem;
  line-height: 1.2;
  font-weight: 700;
  margin: 0;
}

.exercise-category-pill {
  display: inline-block;
  align-self: start;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(242, 110, 54, 0.12);
  border: 1px solid rgba(242, 110, 54, 0.3);
  width: max-content;
  max-width: 100%;
}

.exercise-card .exercise-meta {
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0.85;
  margin: 0;
}

/* Cue is hidden by default; revealed on long-press via .is-showing-cue */
.exercise-card .exercise-cue {
  display: none !important;
}

.exercise-card.is-showing-cue .exercise-cue {
  display: -webkit-box !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 8px 10px;
  margin: 4px 0 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.exercise-card.is-showing-cue {
  box-shadow: 0 0 0 1px rgba(242, 110, 54, 0.4), 0 12px 28px rgba(0, 0, 0, 0.35);
}

/* Pinned + CTA — 56px circular, solid accent, white plus icon from sprite.
   position:absolute takes it out of the grid flow; the body's bottom padding
   reserves the space. */
.exercise-card .add-exercise-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(242, 110, 54, 0.4);
  z-index: 2;
  padding: 0;
  align-self: auto;
  justify-self: auto;
}

.exercise-card .add-exercise-btn svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

/* Beat the earlier dark-tab overrides that make the + button transparent. */
body[data-active-tab="build"] .exercise-card .add-exercise-btn,
body[data-active-tab="build"] .exercise-card .add-exercise-btn:hover {
  background: var(--accent);
  color: #fff;
  border: 0;
  box-shadow: 0 10px 24px rgba(242, 110, 54, 0.4);
}

body[data-active-tab="build"] .exercise-card .add-exercise-btn:active {
  transform: scale(0.94);
  background: var(--accent-strong, var(--accent));
  box-shadow: 0 6px 16px rgba(242, 110, 54, 0.5);
}

body[data-active-tab="build"] .exercise-card {
  border-radius: 18px;
}

/* --- Category chips: count badge via ::after, full-pill active state --- */
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Count badge. Rendered via ::after so textContent stays clean — Playwright
   innerText assertions on .chip still read just the category label. */
.category-chip[data-count]:not([data-count="0"])::after {
  content: " · " attr(data-count);
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
  font-weight: 600;
}

/* Active chip: solid accent fill (full pill), lift shadow. Beats the earlier
   dark-tab override that stripped the active background to transparent. */
body[data-active-tab="build"] .chips .category-chip.active,
.category-chip.active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 8px 20px rgba(242, 110, 54, 0.35) !important;
  transform: translateY(-1px);
}

body[data-active-tab="build"] .chips .category-chip.active::after,
.category-chip.active::after {
  opacity: 0.95;
  color: #fff;
}

/* --- Advanced Settings sub-cards (Audio / Progression / Voice) --- */
.settings-groups {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.settings-subcard {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 12px;
  background: var(--surface-strong);
}

.settings-subcard-label {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-subcard-body {
  display: grid;
  gap: 10px;
}

.settings-subcard-body > label {
  display: grid;
  gap: 6px;
  margin: 0;
}

.settings-subcard-body > label.toggle-line {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.88rem;
}

body[data-active-tab="build"] .settings-subcard {
  background: #181c25;
  border-color: #2a3446;
}

body[data-active-tab="build"] .settings-subcard-label {
  color: #8a94a7;
}

body[data-active-tab="build"] .settings-subcard-body > label.toggle-line {
  background: #141820;
  border-color: #2a3446;
  color: #d1d5db;
}

/* ============================================================
   Phase 4 (engo slice) — modal + drawer + motion polish
   ============================================================ */

/* --- RPE gradient chips (10-point scale, single row) -------- */
.checkin-rpe-chips {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  flex-wrap: nowrap;
}

.rpe-chip {
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.92rem;
  justify-content: center;
  display: flex;
  align-items: center;
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
              background 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.rpe-chip[data-rpe="1"]  { --rpe-c: #22c55e; }
.rpe-chip[data-rpe="2"]  { --rpe-c: #4ade80; }
.rpe-chip[data-rpe="3"]  { --rpe-c: #86d34b; }
.rpe-chip[data-rpe="4"]  { --rpe-c: #c4d334; }
.rpe-chip[data-rpe="5"]  { --rpe-c: #eab308; }
.rpe-chip[data-rpe="6"]  { --rpe-c: #f59e0b; }
.rpe-chip[data-rpe="7"]  { --rpe-c: #f97316; }
.rpe-chip[data-rpe="8"]  { --rpe-c: #f26e36; }
.rpe-chip[data-rpe="9"]  { --rpe-c: #ef4444; }
.rpe-chip[data-rpe="10"] { --rpe-c: #dc2626; }

.rpe-chip {
  border-color: color-mix(in srgb, var(--rpe-c, #94a3b8) 35%, transparent);
  background: color-mix(in srgb, var(--rpe-c, #94a3b8) 10%, transparent);
}

.rpe-chip.active {
  background: var(--rpe-c) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rpe-c) 35%, transparent),
              0 6px 16px color-mix(in srgb, var(--rpe-c) 40%, transparent);
  transform: translateY(-1px);
}

@media (max-width: 420px) {
  .checkin-rpe-chips {
    grid-template-columns: repeat(10, minmax(28px, 1fr));
    gap: 4px;
  }
  .rpe-chip {
    font-size: 0.84rem;
    border-radius: 12px;
  }
}

/* --- Completion chips: equal 3-up full-row buttons --------- */
.checkin-completion {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.completion-chip {
  min-height: 48px;
  border-radius: 14px;
  font-weight: 800;
}

/* --- Modal + drawer open/close motion ---------------------- */
.sequence-drawer.open .sequence-backdrop,
.checkin-modal:not(.hidden) .checkin-backdrop {
  animation: phase4-backdrop-fade 200ms ease;
}

@keyframes phase4-backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sequence-drawer.open .sequence-sheet {
  animation: phase4-sheet-slide 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.checkin-modal:not(.hidden) .checkin-sheet {
  animation: phase4-modal-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes phase4-sheet-slide {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes phase4-modal-in {
  from { transform: translateY(16px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* --- Slim sequence drawer header --------------------------- */
.sequence-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--line);
}

.sequence-sheet-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.sequence-sheet-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.icon-btn-close {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1), background 160ms ease;
}

.icon-btn-close:hover { background: var(--surface-strong); }
.icon-btn-close:active { transform: scale(0.94); }

/* Retire the thick sheet handle in the sequence drawer. */
.sequence-sheet .sheet-handle {
  display: none;
}

/* --- Exercise-library empty state polish ------------------- */
.exercise-grid-empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.exercise-grid-empty::before {
  content: "";
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--accent) 14%, transparent) 0%,
    transparent 70%);
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--line));
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--surface) 40%, transparent);
}

/* --- Saved-sequence empty hint below stepper cards --------- */
.sequence-below-stepper-hint {
  margin: 8px 0 0;
  padding: 10px 14px;
  border: 1px dashed color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.sequence-below-stepper-hint.hidden { display: none; }

/* --- Micro-motion: pressed states (120ms scale 0.97) ------- */
.btn-primary,
.accent,
.preset-pill,
.stepper-btn-round,
.add-exercise-btn,
.completion-chip {
  transition-property: transform, background, color, border-color, box-shadow, opacity;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.btn-primary:active,
.accent:active,
.preset-pill:active,
.stepper-btn-round:active,
.add-exercise-btn:active,
.category-chip:active,
.completion-chip:active,
.rpe-chip:active {
  transform: scale(0.97);
  transition-duration: 120ms;
}

.category-chip.active:active {
  transform: translateY(-1px) scale(0.97);
}

/* --- Tab-panel slide-in on switch -------------------------- */
.tab-panel-enter {
  animation: phase4-tab-slide 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes phase4-tab-slide {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Reduced-motion guard (explicit, in addition to global rule). */
@media (prefers-reduced-motion: reduce) {
  .sequence-drawer.open .sequence-backdrop,
  .sequence-drawer.open .sequence-sheet,
  .checkin-modal:not(.hidden) .checkin-backdrop,
  .checkin-modal:not(.hidden) .checkin-sheet,
  .tab-panel-enter {
    animation: none !important;
  }
  .btn-primary:active,
  .accent:active,
  .preset-pill:active,
  .stepper-btn-round:active,
  .add-exercise-btn:active,
  .category-chip:active,
  .completion-chip:active,
  .rpe-chip:active {
    transform: none;
  }
}

/* ========================================================================
   Phase 4 (engy slice) — Progress tab redesign
   Segmented control, stat tiles, recent workouts list, empty states,
   DPR-aware chart with tooltip.
   ======================================================================== */

.progress-grid-v2 {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.progress-segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  isolation: isolate;
}

.progress-segmented .segmented-control-btn {
  position: relative;
  z-index: 2;
  background: transparent;
  border: 0;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border-radius: 999px;
  cursor: pointer;
  transition: color 160ms ease;
}

.progress-segmented .segmented-control-btn[aria-selected="true"] {
  color: #fff;
}

.progress-segmented .segmented-indicator {
  position: absolute;
  z-index: 1;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 6px 18px rgba(242, 110, 54, 0.35);
  transform: translateX(0);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.progress-segmented[data-active="presets"] .segmented-indicator {
  transform: translateX(100%);
}

.progress-panel-v2 {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-panel-v2.hidden {
  display: none;
}

/* Stat tiles — Build-stepper typography parity. */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-tiles.hidden { display: none; }

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 84px;
}

.stat-tile-value {
  font-family: "Poppins", "Inter", sans-serif;
  font-weight: 800;
  font-size: clamp(1.75rem, 7vw, 2.25rem);
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-tile-label {
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

/* Chart shell (Progress-tab scoped, doesn't clobber legacy history-panel). */
.progress-panel-v2 .chart-shell {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  min-height: 220px;
}

.progress-panel-v2 .chart-shell.hidden { display: none; }

.progress-panel-v2 #historyChart {
  display: block;
  width: 100%;
  height: 220px;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #0A0F1A;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
  border: 1px solid var(--accent);
  white-space: nowrap;
}

.chart-tooltip.is-visible { opacity: 1; }

/* Recent workouts list. */
.history-recent-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-recent-wrap.hidden { display: none; }

.history-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-panel-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
}

.history-recent-title {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.history-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}

.history-recent-item {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.85rem;
}

.history-recent-date {
  color: var(--ink);
  font-weight: 600;
}

.history-recent-duration {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-recent-exercises {
  color: var(--muted);
  font-size: 0.75rem;
}

/* RPE chip scoped to the history list (engo owns .rpe-chip base). */
.history-recent-rpe {
  min-width: 50px;
  min-height: 0;
  padding: 3px 8px;
  font-size: 0.7rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-recent-rpe.is-muted {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

/* Empty states (Progress tab scoped). */
.progress-panel-v2 .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 16px;
  text-align: center;
}

.progress-panel-v2 .empty-state.hidden { display: none; }

.progress-panel-v2 .empty-state-icon {
  width: 56px;
  height: 56px;
  color: var(--accent);
  opacity: 0.9;
}

.progress-panel-v2 .empty-state-text {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  font-size: 1rem;
  max-width: 260px;
}

.progress-panel-v2 .empty-state button {
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
}

#historySummary.hidden { display: none; }

/* ========================================================================
   Phase 5 (engo slice) — Training heatmap, share codes, SW update toast
   ======================================================================== */

/* --- Training heatmap (Progress > History) ------------------------------ */
.heatmap-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.heatmap-shell.hidden { display: none; }

.heatmap-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heatmap-layout {
  --heatmap-cell: 13px;
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: auto 1fr;
  gap: 4px 6px;
  width: max-content;
  min-width: 100%;
}

.heatmap-months {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--heatmap-cell);
  gap: 3px;
}

.heatmap-month-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.heatmap-weekday-rail {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(7, var(--heatmap-cell));
  gap: 3px;
  align-items: center;
}

.heatmap-weekday-rail span {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

.heatmap-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--heatmap-cell));
  grid-auto-columns: var(--heatmap-cell);
  gap: 3px;
}

.heatmap-cell {
  width: var(--heatmap-cell);
  height: var(--heatmap-cell);
  padding: 0;
  border: none;
  border-radius: 3px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.heatmap-cell:active { transform: scale(0.88); }
.heatmap-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.heatmap-cell.is-future {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.heatmap-cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 25%, var(--surface-strong)); box-shadow: none; }
.heatmap-cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 48%, var(--surface-strong)); box-shadow: none; }
.heatmap-cell[data-level="3"] { background: color-mix(in srgb, var(--accent) 72%, var(--surface-strong)); box-shadow: none; }
.heatmap-cell[data-level="4"] { background: var(--accent); box-shadow: none; }

.heatmap-cell.is-today {
  box-shadow: inset 0 0 0 2px var(--ink);
}

.heatmap-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #0A0F1A;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
  border: 1px solid var(--accent);
  white-space: nowrap;
  z-index: 2;
}

.heatmap-tooltip.is-visible { opacity: 1; }

/* --- Interval-program share codes ---------------------------------------- */
.share-code-textarea {
  width: 100%;
  min-height: 84px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  font-family: "SFMono-Regular", "Consolas", "Menlo", monospace;
  font-size: 0.82rem;
  line-height: 1.4;
  word-break: break-all;
  resize: none;
}

.import-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
}

.import-code-row input {
  min-width: 0;
}

.import-code-status.is-error {
  color: #dc2626;
}

/* --- SW update toast ------------------------------------------------------ */
.sw-update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px);
  z-index: 45;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-medium);
  font-size: 0.85rem;
  font-weight: 700;
  animation: phase5-toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sw-update-toast.hidden { display: none; }

.sw-update-toast-btn {
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
}

@keyframes phase5-toast-in {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sw-update-toast { animation: none !important; }
  .heatmap-cell { transition: none !important; }
}
