:root {
  --bg: #14161a;
  --surface: #1e2127;
  --surface-2: #272b33;
  --text: #f3f4f6;
  --muted: #9aa1ad;
  --accent: #ff4f7b;
  --accent-soft: rgba(255, 79, 123, 0.16);
  --done: #3ecf8e;
  --done-soft: rgba(62, 207, 142, 0.16);
  --break: #4aa3ff;
  --break-soft: rgba(74, 163, 255, 0.16);
  --ready: #f5b83d;
  --ready-soft: rgba(245, 184, 61, 0.16);
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.4;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button[disabled] { opacity: 0.4; cursor: default; }
h1 { font-size: 20px; margin: 0; }
h2 { margin: 0 0 4px; font-size: 18px; }
p { margin: 6px 0 12px; }

.app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; min-height: 40px; }
.topbar h1 { flex: 1; min-width: 0; }
.subtitle { margin: -10px 0 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; font-size: 18px; flex: none; }
.eyebrow { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 0 8px; }
.eyebrow.first { margin-top: 0; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.card.next-up { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid rgba(255, 79, 123, 0.35); }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; }
.spaced { margin-top: 12px; }
.text-left { text-align: left; }
.center-text { text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 14px; background: var(--surface-2); font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.block { width: 100%; }
.btn.wide { min-width: 60%; margin-top: 18px; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.done { background: var(--done-soft); color: var(--done); }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }

.week-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.week-chip { background: var(--surface); border-radius: 12px; padding: 10px 6px; text-align: center; position: relative; }
.week-chip .num { font-size: 18px; font-weight: 700; }
.week-chip .meta { font-size: 11px; color: var(--muted); }
.week-chip.complete { background: var(--done-soft); }
.week-chip.complete .num { color: var(--done); }
.week-chip.started { box-shadow: inset 0 0 0 1px rgba(255, 79, 123, 0.5); }
.week-chip.current::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--done); border-radius: 3px; }
.bar.progress { margin: 12px 0 4px; }
.bar.progress > span { background: var(--accent); }

.workout-item { display: flex; align-items: center; gap: 12px; width: 100%; }
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface-2); flex: none; display: grid; place-items: center; font-size: 15px; }
.check.on { background: var(--done); border-color: var(--done); color: #0d2a1d; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: 2px; }

.segmented { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; padding: 9px 4px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.segmented button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.item-list { margin: 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
.group { border-left: 3px solid var(--surface-2); padding: 2px 0 2px 12px; margin: 12px 0; }
.group h3 { margin: 0 0 4px; font-size: 15px; }
.group ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.break-line { color: var(--break); font-size: 13px; margin: 8px 0; }

.switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.switch.first { padding-top: 0; }
.toggle { width: 46px; height: 28px; border-radius: 14px; background: var(--surface-2); position: relative; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); }
.sticky-bottom { position: sticky; bottom: 0; padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }

.player { display: flex; flex-direction: column; min-height: calc(100vh - 32px); }
.context { text-align: center; }
.context .part { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.context .group-name { font-weight: 600; margin-top: 2px; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 8px 0; }
.kind { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 10px; border-radius: 8px; margin-bottom: 10px; }
.kind.exercise, .kind.amrap { background: var(--accent-soft); color: var(--accent); }
.kind.rest, .kind.break { background: var(--break-soft); color: var(--break); }
.kind.ready { background: var(--ready-soft); color: var(--ready); }
.ring { position: relative; width: min(72vw, 280px); aspect-ratio: 1; }
.ring.small { width: min(40vw, 150px); }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--surface-2); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring.rest .fill, .ring.break .fill { stroke: var(--break); }
.ring.ready .fill { stroke: var(--ready); }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; }
.ring .time { font-size: clamp(44px, 14vw, 68px); font-weight: 700; font-variant-numeric: tabular-nums; }
.ring.small .time { font-size: 32px; }
.ring-row { display: flex; justify-content: center; margin-top: 8px; }
.reps-big { font-size: clamp(64px, 22vw, 110px); font-weight: 800; line-height: 1; }
.amrap-card .reps-big { font-size: 56px; }
.reps-label { color: var(--muted); margin-bottom: 14px; }
.step-title { font-size: 26px; font-weight: 700; margin: 14px 0 4px; }
.step-note { color: var(--muted); }
.amrap-card { background: var(--surface); border-radius: var(--radius); padding: 16px; width: 100%; margin-top: 14px; }
.amrap-card .step-title { font-size: 22px; margin-top: 4px; }
.amrap-card .btn.wide { width: 100%; margin-top: 14px; }
.up-next { background: var(--surface); border-radius: 12px; padding: 10px 14px; font-size: 14px; color: var(--muted); margin-top: 12px; }
.up-next b { color: var(--text); }
.controls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; margin-top: 14px; }
.controls .btn { padding: 16px 8px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: end center; padding: 16px; z-index: 10; }
.modal { background: var(--surface); border-radius: 20px; padding: 20px; width: 100%; max-width: 520px; margin-bottom: env(safe-area-inset-bottom); }
.modal .btn { margin-top: 10px; }
.restore-opt { display: block; width: 100%; text-align: left; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.restore-opt-label { font-weight: 600; }
.io-status { margin-top: 12px; min-height: 18px; }

.finish { text-align: center; padding-top: 12vh; }
.finish .big { font-size: 64px; }
.finish-card { margin: 24px 0; }
.finish-time { font-size: 32px; font-weight: 700; }
