/* ===== Tokens ===== */
:root {
  --bg: #0F1216;
  --surface: #171B21;
  --surface-raised: #1F242C;
  --border: rgba(255,255,255,0.08);
  --text: #F5F3EE;
  --muted: #8A93A3;
  --work: #FF4D2E;
  --work-dim: rgba(255,77,46,0.16);
  --rest: #3BA7FF;
  --rest-dim: rgba(59,167,255,0.16);
  --radius-lg: 22px;
  --radius-md: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

.hidden { display: none !important; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
}

h1, h2 { font-family: 'Oswald', 'Inter', sans-serif; font-weight: 600; margin: 0; letter-spacing: 0.01em; }

button { font-family: inherit; border: none; cursor: pointer; background: none; color: inherit; }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 16px;
  padding: 16px 28px;
  border-radius: 100px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn-primary:active { transform: scale(0.96); }

.btn-ghost {
  color: var(--muted);
  font-weight: 600;
  padding: 14px;
  font-size: 15px;
}

/* ===== Screens ===== */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ===== Home ===== */
#screen-home {
  padding: calc(var(--safe-top) + 28px) 20px calc(var(--safe-bottom) + 28px);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.home-header { margin-bottom: 28px; }
.home-header h1 { font-size: 38px; }

.workout-list { display: flex; flex-direction: column; gap: 14px; flex: 1; }

.workout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.workout-card:active { transform: scale(0.985); border-color: rgba(255,77,46,0.4); }

.workout-card .wc-title { font-family: 'Oswald', sans-serif; font-size: 21px; font-weight: 600; }
.workout-card .wc-desc { color: var(--muted); font-size: 14px; margin: 2px 0 10px; line-height: 1.4; }
.workout-card .wc-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.workout-card .wc-meta span::before { content: "●"; color: var(--work); margin-right: 6px; font-size: 8px; }

.home-footnote {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 24px;
  text-align: center;
}
.home-footnote code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11.5px;
}

/* ===== Sheet (level picker) ===== */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end;
  z-index: 20;
}
.sheet {
  background: var(--surface);
  width: 100%;
  border-radius: 26px 26px 0 0;
  padding: 24px 22px calc(var(--safe-bottom) + 24px);
  border-top: 1px solid var(--border);
  animation: sheetUp 0.22s ease;
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet h2 { font-size: 24px; margin-bottom: 18px; }

.level-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.level-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}
.level-btn .lb-name { font-weight: 700; font-size: 16px; }
.level-btn .lb-detail { color: var(--muted); font-size: 13px; margin-top: 2px; }
.level-btn:active { border-color: var(--work); }

/* ===== Player ===== */
#screen-player {
  padding: calc(var(--safe-top) + 14px) 20px calc(var(--safe-bottom) + 20px);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  align-items: stretch;
}

.player-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 6px;
}
.player-topbar .icon-btn { justify-self: start; }
.player-topbar .round-dots { justify-self: center; }
.player-topbar .mode-pill { justify-self: end; }
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 100px;
}
.mode-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 100px;
}
.mode-pill.on { color: var(--bg); background: var(--text); }

.round-dots { display: flex; gap: 7px; flex-wrap: wrap; max-width: 140px; justify-content: center; }
.round-dots .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.round-dots .dot.filled { background: var(--work); border-color: var(--work); }
.round-dots .dot.current { background: var(--text); border-color: var(--text); }

.sub-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 0;
}
.sub-dots .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.sub-dots .dot.filled { background: var(--work); border-color: var(--work); opacity: 0.75; }
.sub-dots .dot.current { background: var(--text); border-color: var(--text); }

.ring-wrap {
  position: relative;
  width: min(78vw, 320px);
  aspect-ratio: 1;
  margin: 10px auto 18px;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track {
  fill: none;
  stroke: var(--surface);
  stroke-width: 14;
}
.ring-progress {
  fill: none;
  stroke: var(--work);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 848;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.phase-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--work);
  margin: 0 0 2px;
  transition: color 0.3s ease;
}
.time-remaining {
  font-family: 'Oswald', sans-serif;
  font-size: 76px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.start-btn {
  background: var(--text);
  color: var(--bg);
  font-family: 'Oswald', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}
.start-btn:active { transform: scale(0.95); }
body.phase-ready .time-remaining { display: none; }
body.phase-ready .next-banner,
body.phase-ready .player-controls { display: none; }
body.phase-ready .ring-progress { stroke: var(--text); }
body.phase-ready .phase-label { color: var(--text); }
body.phase-ready .round-dots .dot.current,
body.phase-ready .sub-dots .dot.current { background: var(--text); border-color: var(--text); }
.next-banner {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 18px;
  margin: 0 auto 14px;
  max-width: 100%;
}
.next-banner-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.next-banner-name {
  font-family: 'Oswald', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-align: center;
  margin-bottom: 16px;
}
.exercise-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
}
.exercise-icon-wrap {
  width: 96px;
  height: 96px;
  margin: 0 auto 6px;
  color: var(--work);
  transition: color 0.3s ease;
}
.exercise-icon-wrap svg { width: 100%; height: 100%; display: block; }
body.phase-rest .exercise-icon-wrap { color: var(--rest); }
body.phase-set .exercise-icon-wrap { color: var(--text); }
.exercise-name {
  font-size: 24px;
  margin-bottom: 8px;
}
.exercise-cue {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0;
}

.player-controls {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding-top: 6px;
}
.ctrl { width: 52px; height: 52px; font-size: 22px; }
.ctrl-main { flex: 1; max-width: 220px; text-align: center; }

/* Rest phase color swap */
body.phase-rest .ring-progress { stroke: var(--rest); }
body.phase-rest .phase-label { color: var(--rest); }
body.phase-rest .round-dots .dot.filled { background: var(--rest); border-color: var(--rest); }
body.phase-rest .round-dots .dot.current { background: var(--rest); border-color: var(--rest); }
body.phase-rest .sub-dots .dot.filled { background: var(--rest); border-color: var(--rest); }
body.phase-rest .sub-dots .dot.current { background: var(--rest); border-color: var(--rest); }

/* Set phase (self-paced, sets/reps workouts) - neutral, no time pressure */
body.phase-set .ring-progress { stroke: var(--text); }
body.phase-set .phase-label { color: var(--text); }
body.phase-set .round-dots .dot.filled { background: var(--text); border-color: var(--text); }
body.phase-set .sub-dots .dot.filled { background: var(--text); border-color: var(--text); }

/* ===== Done screen ===== */
#screen-done {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.done-wrap h1 { font-size: 34px; margin: 6px 0 14px; }
.done-stats { color: var(--muted); font-size: 15px; margin-bottom: 8px; line-height: 1.6; }
.done-prompt {
  font-family: 'Oswald', sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 26px;
}
.done-buttons { display: flex; flex-direction: column; align-items: center; gap: 10px; }

@media (min-width: 520px) {
  .time-remaining { font-size: 88px; }
}
