:root {
  --bg: #0d0e10;
  --surface: #17191c;
  --line: #262a2f;
  --text: #f4f1ec;
  --muted: #9a968f;
  --prep: #f5b83d;
  --work: #ff4d3d;
  --rest: #3dd6b5;
  --phase: var(--work);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body.phase-prep { --phase: var(--prep); }
body.phase-work { --phase: var(--work); }
body.phase-rest { --phase: var(--rest); }
body.is-paused { --phase: var(--muted); }

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Header */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 6px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}
.brand {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}
.brand span { color: var(--work); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
}
.icon-btn svg { width: 20px; height: 20px; }
#sound .off, #sound[aria-pressed="false"] .on { display: none; }
#sound[aria-pressed="false"] .off { display: block; color: var(--muted); }

main {
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 18px 16px;
  display: flex;
  flex-direction: column;
}

/* Overview */
.date {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 2px;
  color: var(--muted);
  font-weight: 500;
}
.badge {
  font-size: 12px; font-weight: 700;
  color: var(--rest);
  border: 1px solid color-mix(in srgb, var(--rest) 50%, transparent);
  padding: 2px 8px; border-radius: 999px;
}
#overview h1, #done h1 {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(44px, 12vw, 64px);
  line-height: 0.95;
  letter-spacing: 0.01em;
  margin: 0 0 18px;
}
.length {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  margin: 0 0 10px;
  font-weight: 600;
}
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 22px;
  line-height: 1;
}
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper output {
  min-width: 76px;
  text-align: center;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 28px;
  line-height: 1;
  padding-top: 3px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 22px;
}
.stats div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.stats dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.stats dd {
  margin: 2px 0 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 28px;
  line-height: 1;
}
.rounds-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
  color: var(--work);
  margin: 0 0 8px;
}
.list { list-style: none; margin: 0; padding: 0; counter-reset: ex; }
.list li {
  counter-increment: ex;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.thumb {
  flex: none;
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 3px solid var(--cat);
  padding: 4px;
}
.thumb svg { width: 100%; height: 100%; display: block; }
.thumb .stick path, .thumb .stick circle { stroke-width: 5.5; }
.list li div { flex: 1; min-width: 0; }
.list strong { display: block; font-size: 17px; }
.list span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.list em { font-style: normal; font-weight: 700; color: var(--muted); }
.cat-cardio { --cat: #ff4d3d; }
.cat-legs { --cat: #f5b83d; }
.cat-push { --cat: #5aa9ff; }
.cat-core { --cat: #3dd6b5; }
.note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 16px 0 0; }
.all-link, .back-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--work);
  padding-bottom: 2px;
}
.back-link { margin: 6px 0 14px; align-self: flex-start; border: 0; color: var(--muted); }

/* Gallery */
#gallery h1 {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(44px, 12vw, 64px);
  line-height: 0.95;
  margin: 0 0 8px;
}
.cat-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 13px;
  color: var(--cat);
  margin: 22px 0 10px;
}
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.demo {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}
.demo svg { width: 100%; aspect-ratio: 1; display: block; }
.demo strong { display: block; font-size: 15px; margin-top: 4px; }
.demo span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }

/* Player */
#player {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}
.phase {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  font-size: 14px;
  color: var(--phase);
}
.ex {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-weight: 400;
  font-size: clamp(48px, 14vw, 84px);
  line-height: 0.95;
  margin: 6px 0 4px;
}
.cue { margin: 0 0 12px; color: var(--muted); max-width: 30ch; min-height: 2.6em; line-height: 1.3; }
.ring {
  position: relative;
  width: min(72vw, 40vh, 320px);
  aspect-ratio: 1;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: var(--line); }
.ring .fill {
  stroke: var(--phase);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}
.ring .figure {
  position: absolute;
  inset: 11%;
  width: 78%;
  height: 78%;
  transition: opacity 0.3s;
}
.ring .figure.dim { opacity: 0.45; }
.time {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: min(24vw, 12vh, 110px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-top: 6px;
  color: var(--phase);
}

/* Stick figures */
.stick path, .stick circle { stroke: var(--text); stroke-width: 4.4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.stick circle { fill: var(--text); }
.stick .far { opacity: 0.4; }
.stick .floor { stroke: var(--line); stroke-width: 1.5; }
.stick circle.weight { fill: var(--prep); stroke: none; }
.stick circle.weight.far { opacity: 0.45; }
.stick .bench { stroke: var(--muted); stroke-width: 3; stroke-linecap: butt; fill: none; }
.stick .bar { stroke: var(--muted); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.meta { margin: 8px 0 0; font-weight: 600; }
.next { margin: 4px 0 0; color: var(--muted); min-height: 1.4em; }

/* Done */
#done {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.done-mark { font-size: 72px; margin-bottom: 8px; }
.done-text { color: var(--muted); margin: 0 0 24px; }
.btn-secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
}

/* Controls */
.controls {
  position: sticky;
  bottom: 0;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 18px calc(env(safe-area-inset-bottom) + 18px);
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--phase); transition: width 0.1s linear; }
.times {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin: 6px 0 10px;
}
.buttons { display: flex; align-items: center; justify-content: center; gap: 28px; }
.ctrl {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
}
.ctrl svg { width: 22px; height: 22px; }
.play {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 72px;
  min-width: 72px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--phase);
  color: #111;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 8px 28px color-mix(in srgb, var(--phase) 35%, transparent);
  transition: transform 0.1s, background 0.3s;
}
.play:active { transform: scale(0.96); }
.play svg { width: 26px; height: 26px; }
.play .i-pause, .play.is-running .i-play { display: none; }
.play.is-running .i-pause { display: block; }
.mode-overview .play { width: 100%; }
.mode-player .play { padding: 0; width: 80px; height: 80px; }
.mode-player .play-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
