/* Rebound Soccer design system — cinematic editorial: warm near-black canvas, one
   racing-red accent used sparingly, sharp corners, medium-weight display type,
   uppercase tracked labels, hairlines instead of shadows. Mobile first. */
:root {
  color-scheme: dark;

  /* Surfaces: brightness steps carry elevation */
  --bg: #181818;            /* canvas — never pure black */
  --surface: #303030;       /* cards, panels */
  --surface-2: #242424;     /* inset rows inside cards, flat panels */
  --surface-3: #3c3c3c;     /* tracks, index plates */
  --border: #303030;        /* hairline on canvas */
  --border-strong: #4a4a4a; /* hairline on cards / inputs */

  /* Text */
  --text: #ffffff;
  --text-2: #969696;        /* body on dark */
  --muted: #8f8f8f;

  /* The single brand voltage */
  --accent: #da291c;
  --accent-active: #b01e0a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(218, 41, 28, 0.16);
  --accent-gradient: linear-gradient(180deg, #a00c01, #da291c 64%);
  --dark-gradient: linear-gradient(180deg, #3c3c3c, #030303 64%);

  /* Data marks stay neutral so red keeps its meaning */
  --chart: #d2d2d2;

  /* Semantic */
  --info: #4c98b9;
  --success: #03904a;
  --warn: #f6a623;
  --danger: #f13a2c;
  --focus: #f6e500;

  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* 8px ladder: xxxs 4 · xxs 8 · xs 16 · sm 24 · md 32 · lg 48 · xl 64 */
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px; --s7: 64px;
  --r-input: 4px; --r-dialog: 12px; --r-pill: 9999px;
  --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  --tap: 48px;
  --rail: 240px;
  --tabbar: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img, svg, video { max-width: 100%; display: block; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.ic { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.2em; flex: none; }
.chip .ic { width: 16px; height: 16px; }
h2 .ic, h3 .ic { vertical-align: -0.15em; }

/* ---------- Typography: display at 500, never bold or italic */
h1, h2, h3 { margin: 0 0 var(--s3); }
h1 { font-size: clamp(32px, 5.2vw, 56px); font-weight: 500; line-height: 1.08; letter-spacing: -0.02em; }
h2 { font-size: 26px; font-weight: 500; line-height: 1.25; letter-spacing: 0.005em; }
h3 { font-size: 18px; font-weight: 700; line-height: 1.25; }
.card h2, .hero h2 { font-size: 18px; font-weight: 700; line-height: 1.25; }
p { margin: 0 0 var(--s3); }
.eyebrow, .label-caps {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-2); margin-bottom: var(--s2);
}
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.big-num { font-size: 36px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ---------- Layout shell */
.shell { min-height: 100vh; }
.rail { display: none; }
.main { padding: var(--s4) var(--s3) calc(var(--tabbar) + var(--s6)); max-width: 1280px; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); height: 64px; padding: 0 var(--s3);
  position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3em;
}
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand b { font-weight: inherit; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; height: var(--tabbar);
  display: flex; background: var(--bg); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0;
  color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.65px; text-decoration: none;
  border-top: 2px solid transparent; margin-top: -1px;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a:hover { color: var(--text); }
.tabbar a[aria-current='page'] { color: var(--text); border-top-color: var(--accent); }
.tabbar a.tab-train { border-top-color: transparent; }
.tabbar a.tab-train span.circle { width: 52px; height: 44px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.tabbar a.tab-train span.circle svg { width: 20px; height: 20px; }
.tabbar a.tab-train span.label { display: none; }
.tabbar a.tab-train[aria-current='page'] span.circle { background: var(--accent-active); }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); }
  .rail { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; padding: var(--s4) 0; border-right: 1px solid var(--border); background: var(--bg); }
  .rail .brand { padding: 0 var(--s4) var(--s5); }
  .rail a.nav {
    display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); padding: 0 var(--s4);
    color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.65px;
    border-left: 2px solid transparent;
  }
  .rail a.nav svg { width: 20px; height: 20px; }
  .rail a.nav:hover { color: var(--text); background: var(--surface-2); }
  .rail a.nav[aria-current='page'] { color: var(--text); border-left-color: var(--accent); background: var(--surface-2); }
  .rail .spacer { flex: 1; }
  .rail p { padding: 0 var(--s4) !important; }
  .tabbar, .topbar .brand { display: none; }
  .topbar { justify-content: flex-end; padding: 0 var(--s6); }
  .main { padding: var(--s6) var(--s6) var(--s7); }
}

/* ---------- Grid helpers */
.stack > * + * { margin-top: var(--s3); }
.stack-lg > * + * { margin-top: var(--s6); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--s3); }
.grid-2 { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: var(--s2); grid-template-columns: repeat(3, 1fr); }
.cards { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) { .cards { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Cards: sharp, flat, brightness-stepped */
.card { background: var(--surface); border: 1px solid var(--border); padding: var(--s4); }
.card.pad-lg { padding: var(--s5); }
.card.flat { background: var(--surface-2); border-color: var(--surface-2); }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color 0.15s, background 0.15s; }
.card-link:hover { text-decoration: none; border-color: var(--text-2); }
.card h3 { margin-bottom: var(--s1); }
.hero {
  position: relative; overflow: hidden; padding: var(--s5) var(--s4);
  background: var(--dark-gradient); border: 1px solid var(--border); border-top: 2px solid var(--accent);
}
.hero > * { position: relative; z-index: 1; }

.stat { background: var(--surface); padding: var(--s3); }
.stat .label { font-size: 11px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; }
.stat .value { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: var(--s1); }
.stat .value small { font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--text-2); }

/* ---------- Buttons: sharp, uppercase, 1.4px tracking */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap);
  padding: 0 var(--s5); border-radius: 0; border: 1px solid var(--text); background: transparent;
  color: var(--text); font-size: 14px; font-weight: 700; line-height: 1; text-transform: uppercase; letter-spacing: 1.4px;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { text-decoration: none; background: rgba(255, 255, 255, 0.06); }
.btn:active { background: rgba(255, 255, 255, 0.12); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-active); border-color: var(--accent-active); }
.btn-primary:active { background: var(--accent-active); }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(241, 58, 44, 0.1); }
.btn-lg { min-height: 56px; font-size: 15px; padding: 0 var(--s5); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: 12px; letter-spacing: 1.1px; }
.btn-icon { width: var(--tap); padding: 0; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.4; pointer-events: none; }

/* ---------- Chips (filters) & badges (the only pills) */
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; min-height: 40px; padding: 0 var(--s3); border-radius: 0; border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.65px;
}
.chip:hover { border-color: var(--text-2); color: var(--text); }
.chip[aria-pressed='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; background: var(--surface-3); color: var(--text);
}
.badge.accent { background: var(--text); color: var(--bg); }
.badge.warn { background: rgba(246, 166, 35, 0.16); color: var(--warn); }
.badge.danger { background: rgba(241, 58, 44, 0.16); color: #ff8a80; }
.badge.info { background: rgba(76, 152, 185, 0.18); color: #8cc4dc; }
.badge svg { width: 13px; height: 13px; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 10px; height: 3px; background: var(--surface-3); }
.dots i.on { background: var(--text); }
.meta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); color: var(--text-2); font-size: 13px; align-items: center; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { width: 15px; height: 15px; }

/* ---------- Forms */
.field { display: block; }
.field + .field { margin-top: var(--s3); }
.field > span.label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-2); margin-bottom: var(--s2); }
.field .hint { font-size: 13px; color: var(--muted); margin-top: var(--s1); }
.field .error { font-size: 13px; color: #ff8a80; margin-top: var(--s1); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 12px 16px; border-radius: var(--r-input); border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--text); outline: none; }
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.input[aria-invalid='true'] { border-color: var(--danger); }
.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; padding: var(--s2) 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin-top: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--border-strong); }
.switch-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 52px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 2px; background: var(--surface-3); transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 1px; background: var(--text); transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.segmented { display: flex; border: 1px solid var(--border-strong); }
.segmented button {
  flex: 1; min-height: 44px; border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px;
}
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button[aria-pressed='true'] { background: var(--text); color: var(--bg); }
.form-error { background: rgba(241, 58, 44, 0.1); border-left: 3px solid var(--danger); color: #ffb3ad; padding: var(--s3); font-weight: 600; margin-bottom: var(--s3); }

/* ---------- Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--border-strong); }
.list > li:last-child { border-bottom: 0; }
.numbered { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.numbered li { counter-increment: step; position: relative; padding: 2px 0 var(--s3) 44px; min-height: 32px; }
.numbered li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; background: var(--text); color: var(--bg);
  font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.bullets { padding-left: 20px; margin: 0; }
.bullets li { margin-bottom: 6px; }
.bullets li::marker { color: var(--accent); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border-strong); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.table th { color: var(--text-2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; background: var(--bg); }
.table td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }

/* ---------- Drill / workout cards */
.drill-card { display: flex; flex-direction: column; gap: var(--s3); padding: 0; }
.drill-card > div:last-child { padding: 0 var(--s3) var(--s3); }
.drill-card .thumb { aspect-ratio: 5 / 3; overflow: hidden; background: #222; }
.drill-card .thumb svg { width: 100%; height: 100%; }
.workout-card .mins { font-size: 48px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; color: var(--accent); font-variant-numeric: tabular-nums; }
.workout-card .mins small { font-size: 12px; font-weight: 600; letter-spacing: 1.1px; text-transform: uppercase; color: var(--text-2); margin-left: 6px; }
.block-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-2); margin: var(--s4) 0 var(--s2); }
.item-row { display: flex; gap: var(--s3); align-items: center; padding: var(--s3); background: var(--surface-2); text-decoration: none; }
.item-row + .item-row { margin-top: 2px; }
.item-row .idx { width: 32px; height: 32px; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 14px; }

/* ---------- Progress ring & bars */
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--accent); stroke-linecap: butt; transition: stroke-dashoffset 0.6s ease; }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 20px; font-weight: 700; line-height: 1; }
.ring .center small { display: block; font-size: 9px; font-weight: 600; color: var(--text-2); margin-top: 2px; text-transform: uppercase; letter-spacing: 1.1px; }
.bar { height: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--text); transition: width 0.4s; }
.week-dots { display: flex; gap: 4px; }
.week-dots span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.week-dots span i { display: block; height: 28px; background: var(--surface-3); margin-bottom: 6px; }
.week-dots span.on i { background: var(--text); }
.week-dots span.today { color: var(--text); }
.week-dots span.today i { box-shadow: inset 0 -3px 0 var(--accent); }

/* ---------- Achievements */
.award-grid { display: grid; gap: 2px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .award-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .award-grid { grid-template-columns: repeat(4, 1fr); } }
.award { text-align: center; padding: var(--s4) var(--s3); background: var(--surface); }
.award .medal { width: 64px; height: 64px; margin: 0 auto var(--s3); border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.award .medal svg { width: 28px; height: 28px; }
.award.earned .medal { background: var(--accent-gradient); color: var(--accent-ink); }
.award h3 { font-size: 15px; margin-bottom: var(--s1); }
.award p { font-size: 13px; color: var(--text-2); margin: 0 0 var(--s2); }

/* ---------- Diagram */
.diagram { width: 100%; height: auto; background: #222; }
.demo { overflow: hidden; background: #222; position: relative; border: 1px solid var(--border); }
.demo .tag { position: absolute; left: var(--s2); top: var(--s2); z-index: 2; }
.demo video, .demo img, .demo iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; object-fit: cover; background: #000; }

/* ---------- Academy */
.academy-grid { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 640px) { .academy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .academy-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.academy-card { padding: 0; display: flex; flex-direction: column; border-top: 2px solid var(--accent); }
.academy-card .thumb { background: #222; }
.academy-card-body { padding: var(--s3); }
.academy-card h3 { display: flex; gap: 8px; align-items: center; }
.academy-card p { margin: var(--s2) 0 0; }
.lead { font-size: 18px; line-height: 1.5; }
.input-lg { min-height: 56px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Animated drill player */
.demo-anim { border: 1px solid var(--border); background: var(--surface-2); max-width: 760px; }
.anim-stage { background: #222; }
.anim-svg { display: block; width: 100%; height: auto; aspect-ratio: 5 / 3; }
.anim-ui { padding: var(--s3); display: grid; gap: var(--s3); }
.anim-caption { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-height: 44px; }
.anim-step { font-size: 11px; font-weight: 700; letter-spacing: 1.1px; color: var(--bg); background: var(--text); padding: 2px 6px; font-variant-numeric: tabular-nums; }
.anim-label { font-weight: 600; font-size: 16px; }
.anim-note { flex-basis: 100%; color: var(--text-2); font-size: 14px; }
.anim-note:empty { display: none; }
.anim-progress { position: relative; height: 24px; cursor: pointer; touch-action: none; }
.anim-progress::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 4px; background: var(--surface-3); }
.anim-fill { position: absolute; left: 0; top: 10px; height: 4px; background: var(--accent); }
.anim-tick { position: absolute; top: 6px; width: 2px; height: 12px; background: var(--muted); }
.anim-progress:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.anim-controls { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.anim-controls .btn-icon { width: 48px; height: 48px; }
.anim-controls .anim-play { width: 64px; }
.anim-speed { margin-left: auto; min-width: 150px; }
@media (max-width: 420px) { .anim-speed { margin-left: 0; flex: 1 1 100%; } }
.anim-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.anim-checklist li { font-size: 12px; font-weight: 600; padding: 4px 8px; border: 1px solid var(--border-strong); color: var(--text-2); }
.anim-checklist li.done { background: var(--surface-3); color: var(--text); }
.anim-checklist li.done::before { content: '✓ '; }
.anim-checklist li.now { border-color: var(--focus); color: var(--text); }
.anim-legend { display: flex; flex-wrap: wrap; gap: var(--s3); font-size: 12px; color: var(--text-2); }
.anim-legend i { display: inline-block; width: 22px; height: 0; margin-right: 6px; vertical-align: middle; border-top: 2px dashed; }
.anim-legend .lg-dribble { border-color: var(--accent); }
.anim-legend .lg-run { border-color: var(--info); border-top-style: dotted; }
.anim-legend .lg-ball { border-color: #fff; border-top-style: solid; }

/* ---------- Charts (single series, neutral marks) */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis-label { fill: var(--text-2); font-size: 11px; font-weight: 500; }
.chart .value-label { fill: var(--text); font-size: 11px; font-weight: 700; }
.chart .mark { fill: var(--chart); }
.chart .mark-line { stroke: var(--chart); stroke-width: 2; fill: none; }
.chart .mark-dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .mark.hover { fill: var(--text); }
.chart-tip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--border-strong); padding: 6px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; }
.chart-tip small { display: block; color: var(--text-2); font-weight: 500; }
details.table-toggle summary { cursor: pointer; color: var(--text-2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.1px; margin-top: var(--s2); }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; max-width: 340px; }
.heat div { aspect-ratio: 1; background: var(--surface-2); position: relative; }
.heat div[data-level='1'] { background: #5a5a5a; }
.heat div[data-level='2'] { background: #9a9a9a; }
.heat div[data-level='3'] { background: #ffffff; }
.heat div.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.heat-head { max-width: 340px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; font-size: 11px; color: var(--text-2); text-align: center; font-weight: 600; margin-bottom: var(--s1); }

/* ---------- States */
.empty { text-align: center; padding: var(--s6) var(--s3); color: var(--text-2); }
.empty .icon { width: 56px; height: 56px; margin: 0 auto var(--s3); background: var(--surface-3); display: grid; place-items: center; color: var(--text); }
.empty .icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); }
.loading { display: grid; place-items: center; padding: var(--s7); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: var(--s3); padding: var(--s3); background: var(--surface-2); border-left: 3px solid var(--info); font-size: 15px; }
.notice.warn { border-left-color: var(--warn); }
.notice.danger { border-left-color: var(--danger); background: rgba(241, 58, 44, 0.08); }
.notice.good { border-left-color: var(--success); }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }

/* ---------- Toasts & dialogs */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px); z-index: 100; display: flex; flex-direction: column; gap: var(--s2); width: min(92vw, 420px); }
.toast { background: var(--surface); border: 1px solid var(--border-strong); border-left: 3px solid var(--text); padding: var(--s3); box-shadow: var(--shadow); font-weight: 600; animation: pop 0.2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
@media (min-width: 960px) { .toasts { bottom: 24px; } }
dialog.modal { border: 1px solid var(--border-strong); border-radius: var(--r-dialog); background: var(--surface); color: var(--text); padding: var(--s4); width: min(92vw, 460px); }
dialog.modal h2 { font-size: 22px; }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.75); }
dialog.modal .actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s4); flex-wrap: wrap; }

/* ---------- Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s4) var(--s3); background: var(--dark-gradient); }
.auth .panel { width: min(100%, 440px); }
.auth .brand { justify-content: center; font-size: 16px; margin-bottom: var(--s5); display: flex !important; }
.auth .brand svg { width: 40px; height: 40px; }
.auth .card { background: var(--bg); border-color: var(--border-strong); border-top: 2px solid var(--accent); }

/* ---------- Guided training (full screen) */
body.training .tabbar, body.training .rail, body.training .topbar { display: none !important; }
body.training .shell { display: block; }
body.training .main { padding: 0; max-width: none; }
.trainer { min-height: 100vh; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; padding: var(--s2) var(--s3) var(--s3); }
.trainer-top { display: flex; align-items: center; gap: var(--s2); }
.trainer-top .btn { border-color: transparent; }
.trainer-top .btn[aria-pressed='true'] { color: var(--text); }
.trainer-top .btn[aria-pressed='false'] { color: var(--muted); }
.trainer-top .count { font-weight: 700; font-size: 13px; letter-spacing: 1.1px; color: var(--text-2); white-space: nowrap; }
.trainer-progress { flex: 1; display: flex; gap: 2px; }
.trainer-progress i { flex: 1; height: 3px; background: var(--surface-3); }
.trainer-progress i.done { background: var(--text); }
.trainer-progress i.current { background: var(--accent); }
.trainer-body { flex: 1; display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s3); }
.trainer h2 { font-size: clamp(28px, 7vw, 40px); font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
.trainer .phase { font-size: 11px; font-weight: 600; letter-spacing: 1.1px; text-transform: uppercase; color: var(--text-2); }
.trainer .phase.rest { color: var(--info); }
.clock-wrap { display: flex; align-items: center; justify-content: center; gap: var(--s4); padding: var(--s2) 0; }
.clock { position: relative; width: min(56vw, 240px); aspect-ratio: 1; }
.clock svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.clock .track { stroke: var(--surface-3); }
.clock .fill { stroke: var(--accent); stroke-linecap: butt; }
.clock.rest .fill { stroke: var(--info); }
.clock .readout { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.clock .readout b { font-size: clamp(48px, 15vw, 72px); font-weight: 700; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.clock .readout small { display: block; color: var(--text-2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 1.1px; margin-top: var(--s1); }
.rep-btn {
  width: min(56vw, 240px); aspect-ratio: 1; border: 0; cursor: pointer; background: var(--accent-gradient); color: var(--accent-ink);
  display: grid; place-items: center; text-align: center; touch-action: manipulation;
}
.rep-btn:active { background: var(--accent-active); }
.rep-btn b { font-size: clamp(56px, 17vw, 88px); font-weight: 700; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.rep-btn small { display: block; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; margin-top: var(--s1); }
.trainer-controls {
  display: grid; grid-template-columns: 56px 1fr 56px; gap: var(--s2); align-items: center; position: sticky; bottom: 0;
  padding: var(--s3) 0 calc(var(--s2) + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%);
}
.trainer-controls .btn-icon { width: 56px; height: 56px; border-color: var(--border-strong); }
.trainer-controls > * { min-width: 0; }
.trainer-controls .row { gap: var(--s2); }
.trainer-controls .row .btn { padding: 0 var(--s3); }
.cue-flash { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; pointer-events: none; background: rgba(24, 24, 24, 0.85); }
.cue-flash b { font-size: clamp(72px, 22vw, 160px); font-weight: 700; line-height: 1; letter-spacing: -0.04em; color: var(--text); border-bottom: 8px solid var(--accent); animation: pop 0.15s; }
.countdown-overlay { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(24, 24, 24, 0.95); }
.countdown-overlay b { font-size: 180px; font-weight: 700; line-height: 1; letter-spacing: -0.05em; color: var(--accent); animation: pop 0.25s; }
.stepper { display: flex; align-items: center; gap: var(--s2); justify-content: center; }
.stepper .btn-icon { width: 56px; height: 56px; font-size: 24px; letter-spacing: 0; }
.stepper input { width: 120px; text-align: center; font-size: 32px; font-weight: 700; }
.feel { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.feel button {
  min-height: 80px; border: 1px solid var(--border-strong); background: transparent; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px;
}
.feel button svg { width: 26px; height: 26px; }
.feel button[aria-pressed='true'] { border-color: var(--text); background: var(--text); color: var(--bg); }
.celebrate { text-align: center; }
.celebrate .trophy { width: 88px; height: 88px; margin: 0 auto var(--s3); border-radius: 50%; display: grid; place-items: center; background: var(--accent-gradient); color: var(--accent-ink); animation: pop 0.4s; }
.celebrate .trophy svg { width: 40px; height: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
