/* ==========================================================================
   Exercise by Age Explainer
   Mid-Century Swiss Editorial Design System (Light + Dark Modes)
   ========================================================================== */

@property --fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

:root {
  /* Core 5-color palette (exact tokens) */
  --dark-slate-grey: #335c67ff;
  --vanilla-custard: #fff3b0ff;
  --honey-bronze: #e09f3eff;
  --brown-red: #9e2a2bff;
  --night-bordeaux: #540b0eff;

  /* Raw light & dark semantic values (WCAG AA/AAA verified) */
  --bg-light: #fcf7e3;
  --bg-dark: #1b0a0c;

  --surface-light: #fffdf5;
  --surface-dark: #281114;

  --surface-alt-light: #f6ecc9;
  --surface-alt-dark: #331619;

  --surface-custard-light: #fff3b0;
  --surface-custard-dark: #243b42;

  --surface-slate-light: #335c67;
  --surface-slate-dark: #213d45;

  --ink-light: #540b0e;
  --ink-dark: #fff3b0;

  --ink-body-light: #3c1618;
  --ink-body-dark: #f4ebd0;

  --ink-muted-light: #5e3839;
  --ink-muted-dark: #d7c7a5;

  --accent-red-light: #9e2a2b;
  --accent-red-dark: #e67677;

  --accent-slate-light: #335c67;
  --accent-slate-dark: #84bac8;

  --accent-honey-text-light: #87550d;
  --accent-honey-text-dark: #e8b057;

  --border-light: color-mix(in oklab, var(--night-bordeaux) 18%, transparent);
  --border-dark: color-mix(in oklab, var(--vanilla-custard) 20%, transparent);

  --border-strong-light: color-mix(in oklab, var(--night-bordeaux) 34%, transparent);
  --border-strong-dark: color-mix(in oklab, var(--vanilla-custard) 36%, transparent);

  --anat-body-light: #e7dec0;
  --anat-body-dark: #3c2225;

  --anat-grid-light: color-mix(in oklab, var(--dark-slate-grey) 22%, transparent);
  --anat-grid-dark: color-mix(in oklab, var(--vanilla-custard) 16%, transparent);

  --anat-line-light: color-mix(in oklab, var(--night-bordeaux) 32%, transparent);
  --anat-line-dark: color-mix(in oklab, var(--vanilla-custard) 32%, transparent);

  --mv-halo-light: #fff3b0;
  --mv-halo-dark: #381a1e;

  --mv-ground-light: #335c67;
  --mv-ground-dark: #84bac8;

  --fig-head-light: #540b0e;
  --fig-head-dark: #fff3b0;

  --backdrop-light: color-mix(in oklab, var(--night-bordeaux) 58%, transparent);
  --backdrop-dark: color-mix(in oklab, #0c0304 78%, transparent);

  --scrollbar-thumb-light: #6d494b;
  --scrollbar-thumb-dark: #a68b67;
  --scrollbar-track-light: #f2e8c7;
  --scrollbar-track-dark: #250f12;

  /* Active semantic tokens (Light fallback default) */
  --bg: var(--bg-light);
  --surface: var(--surface-light);
  --surface-alt: var(--surface-alt-light);
  --surface-custard: var(--surface-custard-light);
  --surface-slate: var(--surface-slate-light);
  --ink: var(--ink-light);
  --ink-body: var(--ink-body-light);
  --ink-muted: var(--ink-muted-light);
  --accent-red: var(--accent-red-light);
  --accent-slate: var(--accent-slate-light);
  --accent-honey-text: var(--accent-honey-text-light);
  --border: var(--border-light);
  --border-strong: var(--border-strong-light);
  --anat-body: var(--anat-body-light);
  --anat-grid: var(--anat-grid-light);
  --anat-line: var(--anat-line-light);
  --anat-stroke-contrast: var(--surface-light);
  --mv-halo: var(--mv-halo-light);
  --mv-ground: var(--mv-ground-light);
  --fig-head: var(--fig-head-light);
  --backdrop: var(--backdrop-light);
  --focus-ring: var(--accent-red);
  --scrollbar-thumb: var(--scrollbar-thumb-light);
  --scrollbar-track: var(--scrollbar-track-light);
  --form-accent: var(--accent-red-light);

  /* Body system indicator colors */
  --sys-muscular: var(--accent-red);
  --sys-skeletal: var(--honey-bronze);
  --sys-cardio: var(--accent-slate);
  --sys-neural: var(--honey-bronze);
  --sys-joints: var(--accent-slate);

  /* Typography */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout & radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --container-max: 1220px;

  /* Mandatory root color-scheme base (always light dark; overridden by meta via :has) */
  color-scheme: light dark;
  accent-color: var(--form-accent);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);

  /* Fallback for browsers without light-dark() when OS is dark */
  @media (prefers-color-scheme: dark) {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-alt: var(--surface-alt-dark);
    --surface-custard: var(--surface-custard-dark);
    --surface-slate: var(--surface-slate-dark);
    --ink: var(--ink-dark);
    --ink-body: var(--ink-body-dark);
    --ink-muted: var(--ink-muted-dark);
    --accent-red: var(--accent-red-dark);
    --accent-slate: var(--accent-slate-dark);
    --accent-honey-text: var(--accent-honey-text-dark);
    --border: var(--border-dark);
    --border-strong: var(--border-strong-dark);
    --anat-body: var(--anat-body-dark);
    --anat-grid: var(--anat-grid-dark);
    --anat-line: var(--anat-line-dark);
    --anat-stroke-contrast: var(--surface-dark);
    --mv-halo: var(--mv-halo-dark);
    --mv-ground: var(--mv-ground-dark);
    --fig-head: var(--fig-head-dark);
    --backdrop: var(--backdrop-dark);
    --scrollbar-thumb: var(--scrollbar-thumb-dark);
    --scrollbar-track: var(--scrollbar-track-dark);
    --form-accent: var(--honey-bronze);
  }

  /* Reflect manual meta[name="color-scheme"] override in CSS */
  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-alt: var(--surface-alt-dark);
    --surface-custard: var(--surface-custard-dark);
    --surface-slate: var(--surface-slate-dark);
    --ink: var(--ink-dark);
    --ink-body: var(--ink-body-dark);
    --ink-muted: var(--ink-muted-dark);
    --accent-red: var(--accent-red-dark);
    --accent-slate: var(--accent-slate-dark);
    --accent-honey-text: var(--accent-honey-text-dark);
    --border: var(--border-dark);
    --border-strong: var(--border-strong-dark);
    --anat-body: var(--anat-body-dark);
    --anat-grid: var(--anat-grid-dark);
    --anat-line: var(--anat-line-dark);
    --anat-stroke-contrast: var(--surface-dark);
    --mv-halo: var(--mv-halo-dark);
    --mv-ground: var(--mv-ground-dark);
    --fig-head: var(--fig-head-dark);
    --backdrop: var(--backdrop-dark);
    --scrollbar-thumb: var(--scrollbar-thumb-dark);
    --scrollbar-track: var(--scrollbar-track-dark);
    --form-accent: var(--honey-bronze);
  }

  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
    --bg: var(--bg-light);
    --surface: var(--surface-light);
    --surface-alt: var(--surface-alt-light);
    --surface-custard: var(--surface-custard-light);
    --surface-slate: var(--surface-slate-light);
    --ink: var(--ink-light);
    --ink-body: var(--ink-body-light);
    --ink-muted: var(--ink-muted-light);
    --accent-red: var(--accent-red-light);
    --accent-slate: var(--accent-slate-light);
    --accent-honey-text: var(--accent-honey-text-light);
    --border: var(--border-light);
    --border-strong: var(--border-strong-light);
    --anat-body: var(--anat-body-light);
    --anat-grid: var(--anat-grid-light);
    --anat-line: var(--anat-line-light);
    --anat-stroke-contrast: var(--surface-light);
    --mv-halo: var(--mv-halo-light);
    --mv-ground: var(--mv-ground-light);
    --fig-head: var(--fig-head-light);
    --backdrop: var(--backdrop-light);
    --scrollbar-thumb: var(--scrollbar-thumb-light);
    --scrollbar-track: var(--scrollbar-track-light);
    --form-accent: var(--accent-red-light);
  }

  /* Modern light-dark() resolution (follows computed color-scheme seamlessly) */
  @supports (color: light-dark(white, black)) {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface-alt: light-dark(var(--surface-alt-light), var(--surface-alt-dark));
    --surface-custard: light-dark(var(--surface-custard-light), var(--surface-custard-dark));
    --surface-slate: light-dark(var(--surface-slate-light), var(--surface-slate-dark));
    --ink: light-dark(var(--ink-light), var(--ink-dark));
    --ink-body: light-dark(var(--ink-body-light), var(--ink-body-dark));
    --ink-muted: light-dark(var(--ink-muted-light), var(--ink-muted-dark));
    --accent-red: light-dark(var(--accent-red-light), var(--accent-red-dark));
    --accent-slate: light-dark(var(--accent-slate-light), var(--accent-slate-dark));
    --accent-honey-text: light-dark(var(--accent-honey-text-light), var(--accent-honey-text-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --border-strong: light-dark(var(--border-strong-light), var(--border-strong-dark));
    --anat-body: light-dark(var(--anat-body-light), var(--anat-body-dark));
    --anat-grid: light-dark(var(--anat-grid-light), var(--anat-grid-dark));
    --anat-line: light-dark(var(--anat-line-light), var(--anat-line-dark));
    --anat-stroke-contrast: light-dark(var(--surface-light), var(--surface-dark));
    --mv-halo: light-dark(var(--mv-halo-light), var(--mv-halo-dark));
    --mv-ground: light-dark(var(--mv-ground-light), var(--mv-ground-dark));
    --fig-head: light-dark(var(--fig-head-light), var(--fig-head-dark));
    --backdrop: light-dark(var(--backdrop-light), var(--backdrop-dark));
    --scrollbar-thumb: light-dark(var(--scrollbar-thumb-light), var(--scrollbar-thumb-dark));
    --scrollbar-track: light-dark(var(--scrollbar-track-light), var(--scrollbar-track-dark));
    --form-accent: light-dark(var(--accent-red-light), var(--honey-bronze));
  }
}

/* Legacy scrollbar fallback */
@supports not (scrollbar-color: auto) {
  :root::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }
  :root::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
  }
  :root::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink-body);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 12% 0%, color-mix(in oklab, var(--honey-bronze) 9%, transparent) 0%, transparent 42%),
    radial-gradient(circle at 88% 8%, color-mix(in oklab, var(--dark-slate-grey) 9%, transparent) 0%, transparent 38%);
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.14;
  letter-spacing: -0.015em;
  margin-top: 0;
}

p {
  margin-top: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

::selection {
  background-color: var(--honey-bronze);
  color: var(--night-bordeaux);
}

:where(a:any-link, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* Canonical Accessible Visually Hidden Utility */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--night-bordeaux);
  color: var(--vanilla-custard);
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--honey-bronze);
}

.container {
  width: min(var(--container-max), 100% - 2.25rem);
  margin-inline: auto;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-slate);
  margin-bottom: 0.55rem;
}

/* ==========================================================================
   Header & Two-State Theme Toggle
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: color-mix(in oklab, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-block-size: 4.25rem;
  padding-block: 0.45rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.96rem, 3.4vw, 1.2rem);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.primary-nav {
  display: none;
}

@media (min-width: 820px) {
  .primary-nav {
    display: block;
  }
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list a {
  display: inline-block;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-body);
  transition: background-color 0.16s ease, color 0.16s ease;
}

.nav-list a:hover {
  background-color: var(--surface-alt);
  color: var(--ink);
}

/* Two-state Theme Toggle (CSS-driven state visibility, zero JS flash) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-block-size: 2.5rem;
  min-inline-size: 2.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.theme-toggle svg {
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--surface-alt);
  border-color: var(--accent-slate);
}

.theme-option {
  align-items: center;
  gap: 0.45rem;
}

/* Default (light): show "Switch to dark" */
.theme-to-dark {
  display: inline-flex;
}
.theme-to-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-dark {
    display: none;
  }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-light {
    display: inline-flex;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-dark {
  display: none;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-light {
  display: inline-flex;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-to-dark {
  display: inline-flex;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-to-light {
  display: none;
}

/* ==========================================================================
   Masthead & Exact-Age Finder
   ========================================================================== */

.masthead {
  padding-block: clamp(1.8rem, 4vw, 3rem) clamp(1.4rem, 3vw, 2.2rem);
}

.masthead-grid {
  display: grid;
  gap: 1.75rem;
  align-items: end;
}

@media (min-width: 920px) {
  .masthead-grid {
    grid-template-columns: 1.25fr 0.95fr;
    gap: 2.5rem;
  }
}

.masthead h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.35rem);
  font-weight: 650;
  margin-bottom: 0.85rem;
  max-width: 17ch;
}

.lead {
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  color: var(--ink-muted);
  max-width: 58ch;
  margin-bottom: 0;
}

.age-finder-card {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: 0 10px 28px color-mix(in oklab, var(--night-bordeaux) 7%, transparent);
}

.age-finder-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.age-finder-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-slate);
}

.age-output {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 4.2vw, 1.55rem);
  font-weight: 700;
  color: var(--accent-red);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.age-slider {
  width: 100%;
  min-block-size: 2rem;
  cursor: pointer;
  margin: 0.15rem 0;
  accent-color: var(--form-accent);
}

/* Brand-consistent range slider fallback when accent-color is unsupported */
@supports not (accent-color: #9e2a2b) {
  .age-slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
  }
  .age-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(
      to right,
      var(--form-accent) var(--progress, 10%),
      var(--border-strong) var(--progress, 10%)
    );
    border-radius: 999px;
  }
  .age-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--form-accent);
    margin-top: -6px;
    cursor: pointer;
  }
  .age-slider::-moz-range-track {
    width: 100%;
    height: 8px;
    background: var(--border-strong);
    border-radius: 999px;
  }
  .age-slider::-moz-range-progress {
    background: var(--form-accent);
    height: 8px;
    border-radius: 999px;
  }
  .age-slider::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border: 0;
    border-radius: 50%;
    background: var(--form-accent);
    cursor: pointer;
  }
}

.age-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}

.age-match-summary {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.45;
  min-block-size: 1.35rem;
  margin-bottom: 0.65rem;
}

.age-match-summary strong {
  color: var(--ink);
}

.age-match-chips {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  min-block-size: 5.35rem;
  align-content: start;
}

@media (min-width: 480px) {
  .age-match-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    min-block-size: 2.45rem;
  }
}

.match-chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.35rem 0.65rem;
  block-size: 2.45rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--ink);
  font-size: 0.79rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.match-chip-btn[aria-current="true"] {
  background: var(--honey-bronze);
  color: var(--night-bordeaux);
  border-color: var(--night-bordeaux);
}

.match-chip-btn:hover {
  border-color: var(--accent-red);
}

/* ==========================================================================
   7-Stage Horizontal Lifespan Tabs (Single-Row Scroll + Edge-Fade Mask)
   ========================================================================== */

.stage-nav-band {
  border-block: 1.5px solid var(--border);
  background: var(--surface);
  scroll-margin-top: 4.5rem;
}

.stage-tablist-wrap {
  position: relative;
}

.stage-tablist {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: inline proximity;
  scroll-padding-inline: 3rem;
  scrollbar-width: none;
  padding-block: 0.65rem 0.5rem;

  /* Scroll-driven edge-fade mask */
  --fade-size: 2.75rem;
  --fade-dir: right;
  --fade-start-pos: 0;
  --fade-end-pos: 100%;
  mask:
    linear-gradient(black, black) no-clip subtract,
    linear-gradient(to var(--fade-dir), black, transparent) var(--fade-start-pos) 0 / var(--fade-start) 100% no-repeat no-clip,
    linear-gradient(to var(--fade-dir), transparent, black) var(--fade-end-pos) 0 / var(--fade-end) 100% no-repeat no-clip;
  animation: reveal-fade-start linear both, hide-fade-end linear both;
  animation-timeline: scroll(self inline);
  animation-range: 0 var(--fade-size), calc(100% - var(--fade-size)) 100%;
}

.stage-tablist::-webkit-scrollbar {
  display: none;
}

@keyframes reveal-fade-start {
  to {
    --fade-start: var(--fade-size);
  }
}

@keyframes hide-fade-end {
  from {
    --fade-end: var(--fade-size);
  }
}

/* IntersectionObserver fallback when scroll-driven animations aren't supported */
@supports not (animation-timeline: scroll()) {
  .stage-tablist {
    animation: none;
    transition: --fade-start 0.2s ease, --fade-end 0.2s ease;
  }
  .stage-tablist.more-start {
    --fade-start: var(--fade-size);
  }
  .stage-tablist.more-end {
    --fade-end: var(--fade-size);
  }
}

.stage-tab {
  position: relative;
  flex: none;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-inline-size: 8.6rem;
  min-block-size: 3.6rem;
  padding: 0.55rem 0.95rem 0.72rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

@media (min-width: 1120px) {
  .stage-tab {
    flex: 1 0 0;
    min-inline-size: 0;
  }
}

.stage-tab:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.stage-tab-range {
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stage-tab-name {
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Matching exact-age indicator pill (shape + color, never color alone) */
.stage-tab.is-age-match::before {
  content: "★";
  position: absolute;
  top: 0.42rem;
  right: 0.55rem;
  font-size: 0.72rem;
  color: var(--accent-honey-text);
  line-height: 1;
}

.stage-tab.is-age-match {
  background: color-mix(in oklab, var(--honey-bronze) 15%, transparent);
}

/* Selected state styled directly from aria-selected (zero layout jump) */
.stage-tab[aria-selected="true"] {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--border-strong);
  border-bottom-color: transparent;
}

.stage-tab[aria-selected="true"] .stage-tab-range {
  color: var(--accent-red);
}

.stage-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  border-block-end: 4px solid var(--accent-red);
}

/* ==========================================================================
   Stage Editorial Hero
   ========================================================================== */

.stage-hero {
  padding-block: clamp(2rem, 4vw, 3.2rem) clamp(2rem, 3.5vw, 3rem);
}

.stage-hero-grid {
  display: grid;
  gap: 2rem;
  align-items: start;
}

@media (min-width: 960px) {
  .stage-hero-grid {
    grid-template-columns: 1.05fr 1fr;
    gap: 2.75rem;
    align-items: center;
  }
}

.stage-title {
  font-size: clamp(1.85rem, 3.4vw, 2.75rem);
  margin-bottom: 0.5rem;
  width: fit-content;
  view-transition-name: stage-title-vt;
}

.stage-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.08rem, 1.5vw, 1.24rem);
  color: var(--accent-red);
  margin-bottom: 0.9rem;
}

.stage-overview {
  color: var(--ink-body);
  font-size: 1rem;
  max-width: 60ch;
  margin-bottom: 1.3rem;
}

.stage-meta-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
  margin: 0 0 1.3rem;
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
}

.stage-meta-item dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-slate);
  margin-bottom: 0.22rem;
}

.stage-meta-item dd {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.guidance-duo {
  display: grid;
  gap: 0.9rem;
}

@media (min-width: 620px) {
  .guidance-duo {
    grid-template-columns: 1fr 1fr;
  }
}

.guidance-box {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
}

.guidance-focus {
  background: var(--surface-custard);
  border-color: color-mix(in oklab, var(--honey-bronze) 55%, var(--border));
}

.guidance-guardrails {
  background: var(--surface);
  border-left: 4px solid var(--accent-red);
}

.guidance-box h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.55rem;
}

.guidance-focus .guidance-glyph {
  color: var(--accent-slate);
}

.guidance-guardrails .guidance-glyph {
  color: var(--accent-red);
}

.guidance-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.87rem;
  line-height: 1.48;
  color: var(--ink-body);
}

.guidance-list li + li {
  margin-top: 0.38rem;
}

/* Framed Editorial Poster Illustration */
.stage-poster-frame {
  margin: 0;
  padding: 0.85rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 18px 42px color-mix(in oklab, var(--night-bordeaux) 12%, transparent);
  view-transition-name: stage-poster;
}

.stage-poster-frame picture {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--vanilla-custard);
}

.stage-poster-frame img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.poster-caption {
  margin-top: 0.7rem;
  padding-inline: 0.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* ==========================================================================
   Section Framing & Training Mix Grid
   ========================================================================== */

.section-block {
  padding-block: clamp(2.25rem, 4.5vw, 3.75rem);
  border-top: 1px solid var(--border);
  scroll-margin-top: 4.5rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem 2rem;
  margin-bottom: 1.75rem;
}

.section-title {
  font-size: clamp(1.55rem, 2.7vw, 2.15rem);
  margin-bottom: 0;
}

.section-lead {
  color: var(--ink-muted);
  max-width: 48ch;
  font-size: 0.95rem;
  margin-bottom: 0;
}

.mix-section {
  background: color-mix(in oklab, var(--surface) 60%, var(--bg));
}

.mix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}

.mix-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, background-color 0.16s ease;
}

.mix-card:hover {
  border-color: var(--accent-slate);
}

@media (prefers-reduced-motion: no-preference) {
  .mix-card:hover {
    transform: translateY(-2px);
  }
}

.mix-card[aria-pressed="true"] {
  border-color: var(--accent-red);
  background: var(--surface-alt);
  box-shadow: inset 0 0 0 1px var(--accent-red);
}

.mix-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mix-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  color: var(--ink);
  font-size: 0.98rem;
}

.mix-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--accent-slate);
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.62rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-core {
  background: var(--brown-red);
  color: var(--vanilla-custard);
}

.status-high {
  background: var(--dark-slate-grey);
  color: var(--vanilla-custard);
}

.status-moderate {
  background: var(--honey-bronze);
  color: var(--night-bordeaux);
}

.status-adapt {
  background: var(--surface-alt);
  color: var(--ink);
  border-color: var(--border-strong);
}

.status-caution {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--border-strong);
  border-style: dashed;
}

.mix-bar-track {
  position: relative;
  height: 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  overflow: hidden;
  border: 1px solid var(--border);
}

.mix-bar-fill {
  height: 100%;
  width: var(--score, 50%);
  border-radius: var(--radius-pill);
  background: var(--accent-slate);
  transition: width 0.35s ease;
}

.mix-bar-fill.tone-core {
  background: var(--brown-red);
}
.mix-bar-fill.tone-high {
  background: var(--dark-slate-grey);
}
.mix-bar-fill.tone-moderate {
  background: var(--honey-bronze);
}
.mix-bar-fill.tone-adapt {
  background: var(--accent-honey-text);
}
.mix-bar-fill.tone-caution {
  background: var(--ink-muted);
  opacity: 0.45;
}

.mix-note {
  font-size: 0.86rem;
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.45;
}

/* ==========================================================================
   Filter Bar & Two-Column Exercise + Anatomy Atlas
   ========================================================================== */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.6rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-block-size: 2.35rem;
  padding: 0.42rem 0.9rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-body);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-pill:hover {
  background: var(--surface-alt);
}

.filter-pill[aria-pressed="true"] {
  background: var(--night-bordeaux);
  color: var(--vanilla-custard);
  border-color: var(--night-bordeaux);
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .filter-pill[aria-pressed="true"] {
  background: var(--honey-bronze);
  color: var(--night-bordeaux);
  border-color: var(--honey-bronze);
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .filter-pill[aria-pressed="true"] {
    background: var(--honey-bronze);
    color: var(--night-bordeaux);
    border-color: var(--honey-bronze);
  }
}

.filter-count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  opacity: 0.85;
}

.atlas-layout {
  display: grid;
  gap: 1.75rem;
  align-items: start;
}

@media (min-width: 980px) {
  .atlas-layout {
    grid-template-columns: 1.38fr 0.92fr;
    gap: 2.1rem;
  }
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.15rem;
}

.exercise-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.exercise-card:hover,
.exercise-card:focus-within,
.exercise-card.is-highlighted {
  border-color: var(--accent-red);
  box-shadow: 0 12px 28px color-mix(in oklab, var(--night-bordeaux) 11%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .exercise-card:hover {
    transform: translateY(-2px);
  }
}

.exercise-card-visual {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.6rem 0.2rem;
}

.exercise-card-visual .movement-svg {
  width: 100%;
  height: auto;
  max-height: 148px;
}

.exercise-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1.05rem 1.15rem 1.15rem;
  flex: 1;
}

.exercise-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.modality-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.62rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-slate);
  color: var(--vanilla-custard);
}

.modality-pill.mod-strength {
  background: var(--brown-red);
  color: var(--vanilla-custard);
}

.modality-pill.mod-power,
.modality-pill.mod-balance {
  background: var(--honey-bronze);
  color: var(--night-bordeaux);
}

.modality-pill.mod-hiit {
  background: var(--night-bordeaux);
  color: var(--vanilla-custard);
}

.effort-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.exercise-card-title {
  font-size: 1.16rem;
  margin-bottom: 0;
}

.exercise-card-summary {
  font-size: 0.89rem;
  color: var(--ink-muted);
  margin-bottom: 0;
  line-height: 1.5;
}

.system-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.sys-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.18rem 0.52rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--border);
}

.sys-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-block-size: 2.6rem;
  margin-top: 0.35rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: transparent;
  color: var(--ink);
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.card-cta-btn:hover {
  background: var(--brown-red);
  border-color: var(--brown-red);
  color: var(--vanilla-custard);
}

.empty-state {
  padding: 2rem;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
}

/* Sticky Interactive Anatomical Body-Impact Card */
.anatomy-column {
  position: static;
}

@media (min-width: 980px) {
  .anatomy-column {
    position: sticky;
    top: 5.25rem;
  }
}

.anatomy-card {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.25rem 1.3rem;
  box-shadow: 0 14px 34px color-mix(in oklab, var(--night-bordeaux) 9%, transparent);
}

.anatomy-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.anatomy-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-red);
  margin-bottom: 0.2rem;
}

.anatomy-title {
  font-size: 1.25rem;
  margin-bottom: 0;
}

.text-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-slate);
  cursor: pointer;
  white-space: nowrap;
}

.text-btn:hover {
  background: var(--surface-alt);
}

.anatomy-svg-host {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem;
  display: flex;
  justify-content: center;
}

.anatomy-svg {
  width: 100%;
  max-width: 245px;
  height: auto;
}

.anat-body-fill {
  fill: var(--anat-body);
  stroke: var(--anat-line);
  stroke-width: 1.3;
}

.anat-zone {
  opacity: 0;
  transition: opacity 0.28s ease;
}

.anat-zone.is-active {
  opacity: 1;
}

.system-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  justify-content: center;
  margin-block: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
}

.swatch-muscular {
  background: var(--sys-muscular);
}
.swatch-skeletal {
  background: var(--sys-skeletal);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--honey-bronze) 35%, transparent);
}
.swatch-cardio {
  background: var(--sys-cardio);
}
.swatch-neural {
  background: transparent;
  border: 2px dashed var(--sys-neural);
}

.anatomy-headline {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--ink);
  margin-bottom: 0.55rem;
  line-height: 1.35;
}

.anatomy-mechanisms {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.anatomy-mechanisms li {
  font-size: 0.84rem;
  color: var(--ink-body);
  padding-left: 0.85rem;
  border-left: 3px solid var(--accent-slate);
  line-height: 1.42;
}

.anatomy-mechanisms li[data-system="muscular"] {
  border-left-color: var(--sys-muscular);
}
.anatomy-mechanisms li[data-system="skeletal"] {
  border-left-color: var(--sys-skeletal);
}
.anatomy-mechanisms li[data-system="cardiovascular"] {
  border-left-color: var(--sys-cardio);
}
.anatomy-mechanisms li[data-system="neuromuscular"] {
  border-left-color: var(--sys-neural);
}

/* ==========================================================================
   Lifespan Comparison Matrix
   ========================================================================== */

.matrix-section {
  background: var(--surface);
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  font-size: 0.84rem;
  color: var(--ink-muted);
  margin-bottom: 1.15rem;
}

.sym-core { color: var(--accent-red); }
.sym-high { color: var(--accent-slate); }
.sym-moderate { color: var(--accent-honey-text); }
.sym-adapt { color: var(--ink); }
.sym-caution { color: var(--ink-muted); }

.matrix-scroll {
  overflow-x: auto;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.lifespan-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.lifespan-table th,
.lifespan-table td {
  padding: 0.78rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.lifespan-table th:first-child,
.lifespan-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 2;
  min-width: 185px;
}

.lifespan-table thead th {
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink);
}

.matrix-col-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  width: 100%;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.45rem;
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
}

.matrix-col-btn:hover {
  border-color: var(--accent-slate);
  background: var(--surface);
}

.matrix-col-btn[aria-current="true"] {
  background: var(--brown-red);
  color: var(--vanilla-custard);
}

.matrix-col-sub {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.85;
}

.matrix-row-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  color: var(--ink);
}

.matrix-cell-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.24rem 0.6rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 600;
  white-space: nowrap;
}

.lifespan-table td.is-active-col {
  background: color-mix(in oklab, var(--honey-bronze) 12%, transparent);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 2px solid var(--border-strong);
  background: var(--night-bordeaux);
  color: var(--vanilla-custard);
  padding-block: 2.25rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.footer-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--vanilla-custard);
}

.disclaimer {
  font-size: 0.84rem;
  line-height: 1.55;
  max-width: 72ch;
  color: color-mix(in oklab, var(--vanilla-custard) 86%, var(--honey-bronze));
  margin: 0;
}

.palette-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, #ffffff 8%, transparent);
  border: 1px solid color-mix(in oklab, var(--vanilla-custard) 25%, transparent);
}

.palette-dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--swatch);
  border: 1.5px solid color-mix(in oklab, var(--vanilla-custard) 65%, transparent);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-block-size: 2.65rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--brown-red);
  color: var(--vanilla-custard);
  border-color: var(--brown-red);
}

.btn-primary:hover {
  background: var(--night-bordeaux);
  border-color: var(--night-bordeaux);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-alt);
  border-color: var(--accent-slate);
}

/* ==========================================================================
   Interactive Exercise Walkthrough Modal (<dialog> Top-Layer Best Practices)
   ========================================================================== */

/* Base closed/exit state (NOTE: never set display unconditionally on dialog) */
.exercise-dialog {
  width: min(1040px, 100% - 1.5rem);
  max-height: min(90dvh, 860px);
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--ink-body);
  box-shadow: 0 28px 70px color-mix(in oklab, #000000 40%, transparent);
  opacity: 0;

  /* Mandatory top-layer discrete transitions (transition-behavior separate) */
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.26s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;

  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(12px) scale(0.97);
  }
}

.exercise-dialog[open] {
  display: flex;
  flex-direction: column;
}

/* Mandatory pure-CSS background scroll lock (no html/body overflow: hidden!) */
.exercise-dialog:modal {
  overscroll-behavior: contain;
}

.exercise-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: transparent;
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.26s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

/* Open visible state (guarded by :not([data-closing]) for non-overlay browsers) */
:is(.exercise-dialog[open]):where(:not([data-closing])) {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0) scale(1);

    @starting-style {
      transform: translateY(12px) scale(0.97);
    }
  }

  &::backdrop {
    background-color: var(--backdrop);
    backdrop-filter: blur(3px);

    @starting-style {
      background-color: transparent;
      backdrop-filter: blur(0px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .exercise-dialog,
  .exercise-dialog::backdrop {
    transition-duration: 0.1s;
  }
}

.dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  overflow: hidden;
}

.dialog-header {
  padding: 1.15rem 1.4rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dialog-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.stage-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg);
}

.dialog-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  font-size: clamp(1.35rem, 2.3vw, 1.8rem);
  margin: 0;
}

.icon-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 2.5rem;
  min-block-size: 2.5rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-close-btn:hover {
  background: var(--brown-red);
  border-color: var(--brown-red);
  color: var(--vanilla-custard);
}

.dialog-body {
  display: grid;
  gap: 1.35rem;
  padding: 1.35rem 1.4rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (min-width: 820px) {
  .dialog-body {
    grid-template-columns: 0.96fr 1.04fr;
    gap: 1.65rem;
  }
}

.dialog-visuals {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.studio-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem;
}

.studio-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.studio-heading {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-slate);
  margin: 0;
}

.play-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-block-size: 2rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.play-toggle-btn:hover {
  border-color: var(--accent-red);
  background: var(--surface-alt);
}

.movement-stage {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  margin-bottom: 0.75rem;
}

.movement-stage .movement-svg {
  width: 100%;
  height: auto;
}

.phase-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.phase-btn {
  min-block-size: 2.2rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.phase-btn[aria-pressed="true"] {
  background: var(--dark-slate-grey);
  border-color: var(--dark-slate-grey);
  color: var(--vanilla-custard);
}

.phase-active-cue {
  margin: 0;
  font-size: 0.87rem;
  color: var(--ink-body);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border-left: 3px solid var(--honey-bronze);
}

.zone-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.dialog-anatomy-split {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 0.85rem;
  align-items: center;
}

.dialog-anatomy-svg {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
}

.dialog-anatomy-svg .anatomy-svg {
  max-width: 140px;
  margin-inline: auto;
}

.zone-tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.zone-tag-list li {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  padding: 0.22rem 0.52rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
}

/* Right Coaching Details */
.dialog-details {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
}

.dosage-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
}

.dosage-bar dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-slate);
  margin-bottom: 0.15rem;
}

.dosage-bar dd {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}

.detail-callout {
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius-md);
  background: var(--surface-custard);
  border: 1.5px solid color-mix(in oklab, var(--honey-bronze) 55%, var(--border));
}

.detail-callout h3,
.detail-block h3,
.scale-card h3 {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-slate);
  margin-bottom: 0.45rem;
}

.detail-callout p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-body);
}

.impact-headline {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
  margin-bottom: 0.55rem;
}

.mechanism-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mechanism-list li {
  font-size: 0.88rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3.5px solid var(--accent-slate);
}

.mechanism-list li[data-system="muscular"] { border-left-color: var(--sys-muscular); }
.mechanism-list li[data-system="skeletal"] { border-left-color: var(--sys-skeletal); }
.mechanism-list li[data-system="cardiovascular"] { border-left-color: var(--sys-cardio); }
.mechanism-list li[data-system="neuromuscular"] { border-left-color: var(--sys-neural); }

.step-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.step-list li {
  margin: 0;
}

.step-item-btn {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.87rem;
  color: var(--ink-body);
}

.step-item-btn[aria-current="step"] {
  border-color: var(--accent-red);
  background: var(--surface-alt);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--dark-slate-grey);
  color: var(--vanilla-custard);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}

.scaling-grid {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 560px) {
  .scaling-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.scale-card {
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
}

.scale-easier {
  border-top: 3px solid var(--accent-slate);
}

.scale-harder {
  border-top: 3px solid var(--accent-red);
}

.scale-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-body);
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.4rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.dialog-counter {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ==========================================================================
   View Transitions & Reduced Motion
   ========================================================================== */

::view-transition-old(stage-poster),
::view-transition-new(stage-poster) {
  height: 100%;
  animation-duration: 0.28s;
}

::view-transition-old(stage-title-vt),
::view-transition-new(stage-title-vt) {
  animation-duration: 0.24s;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* Coarse pointers get generous 44px+ tap targets */
@media (pointer: coarse) {
  .theme-toggle,
  .filter-pill,
  .phase-btn,
  .match-chip-btn,
  .btn {
    min-block-size: 2.75rem;
  }

  .match-chip-btn {
    block-size: 2.75rem;
  }

  .age-match-chips {
    min-block-size: 5.95rem;
  }

  @media (min-width: 480px) {
    .age-match-chips {
      min-block-size: 2.75rem;
    }
  }
}

/* ==========================================================================
   Forced Colors Mode (Windows High Contrast)
   ========================================================================== */

@media (forced-colors: active) {
  .stage-tab[aria-selected="true"]::after {
    border-block-end-color: Highlight;
  }

  .mix-card,
  .exercise-card,
  .anatomy-card,
  .age-finder-card,
  .stage-poster-frame,
  .exercise-dialog,
  .status-pill,
  .filter-pill,
  .modality-pill {
    border: 1.5px solid CanvasText;
  }

  .filter-pill[aria-pressed="true"],
  .phase-btn[aria-pressed="true"],
  .match-chip-btn[aria-current="true"],
  .matrix-col-btn[aria-current="true"] {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }

  .mix-bar-fill {
    background: Highlight;
  }
}
