/* HIIT 20 — styles */
:root {
  --bg: #0b0b0f;
  --panel: #15151c;
  --panel-2: #1e1e28;
  --line: #2b2b39;
  --text: #f5f5f8;
  --muted: #9b9bb0;
  --spotify: #1ed760;
  --accent: #ff5a36;
  --work: #e8321f;
  --work-deep: #8f150a;
  --rest: #0f5fd6;
  --rest-deep: #082f6b;
  --prep: #ffb020;
  --danger: #ff4d4d;
  --radius: 18px;
  --font-display: 'Bebas Neue', Impact, 'Arial Narrow Bold', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body { min-height: 100dvh; overflow-x: hidden; }
a { color: var(--spotify); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
[hidden] { display: none !important; }

.screen {
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px calc(140px + env(safe-area-inset-bottom));
}

/* ---------- type ---------- */
.masthead { margin: 8px 0 28px; }
.wordmark {
  font-family: var(--font-display);
  font-size: clamp(64px, 14vw, 104px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  margin: 0;
}
.wordmark span { color: var(--accent); }
.tagline { margin: 12px 0 0; font-size: 17px; color: var(--muted); max-width: 40ch; }
h2 {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.03em;
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 12px;
}
.step {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 20px; line-height: 1; padding-top: 2px;
}
.muted { color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.warn { color: #ffcf6b; background: rgba(255, 176, 32, 0.12); border: 1px solid rgba(255, 176, 32, 0.35); padding: 10px 12px; border-radius: 10px; margin: 10px 0 0; }
.big { font-size: 26px; font-weight: 700; margin: 0 0 6px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  vertical-align: middle;
}
.pill--premium { color: var(--spotify); border-color: rgba(30, 215, 96, 0.4); }

/* ---------- mode tabs ---------- */
.modes { display: flex; gap: 8px; margin: 0 0 18px; }
.mode-tab {
  flex: 1; appearance: none; border: 1px solid var(--line); cursor: pointer;
  background: var(--panel); color: var(--muted);
  font: inherit; font-weight: 700; font-size: 15px;
  padding: 12px; border-radius: 12px;
}
.mode-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cap-note { font-size: 13px; margin: -4px 0 14px; }

/* ---------- layout ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 0 16px;
}
.card--accent { border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.field { display: block; margin: 0 0 14px; }
.field__label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
input[type="text"], select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copyrow { display: flex; gap: 8px; align-items: center; }
.copyrow code {
  flex: 1; min-width: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; overflow-wrap: anywhere;
}
.toggles { display: grid; gap: 10px; margin: 6px 0 16px; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 700; font-size: 16px;
  padding: 13px 20px; border-radius: 999px;
  transition: transform 0.06s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn--ghost:not(:disabled):hover { background: #262635; }
.btn--sm { padding: 9px 14px; font-size: 14px; }
.btn--spotify { background: var(--spotify); color: #06200f; }
.btn--danger { color: var(--danger); }
.btn--big {
  width: 100%;
  font-family: var(--font-display);
  font-weight: 400; font-size: 30px; letter-spacing: 0.05em;
  padding: 18px 24px;
}
.linkbtn {
  appearance: none; border: 0; background: none; padding: 0;
  color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer;
}

.startbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.startbar > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.startbar__hint { text-align: center; color: var(--muted); font-size: 13px; margin: 8px auto 0; min-height: 1em; }

/* ---------- playlist ---------- */
.progress { color: var(--prep); font-weight: 600; margin: 4px 0 0; }
.progress::after { content: ''; display: inline-block; width: 1ch; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.summary { margin: 16px 0 10px; padding: 14px; border-radius: 12px; background: var(--panel-2); line-height: 1.5; }
.summary strong { color: #fff; }
.summary a { display: inline-block; margin-top: 6px; }

.tracks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.track {
  display: grid;
  grid-template-columns: 34px 48px 1fr auto;
  gap: 12px; align-items: center;
  padding: 8px 10px 8px 6px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid transparent;
}
.track--new { border-color: var(--accent); background: rgba(255, 90, 54, 0.08); }
.track__min { font-family: var(--font-display); font-size: 24px; color: var(--muted); text-align: center; }
.track--new .track__min { color: var(--accent); }
.track__art { width: 48px; height: 48px; border-radius: 8px; background: var(--panel-2); object-fit: cover; }
.track__text { min-width: 0; }
.track__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track__artist { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track__exercise { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.badge {
  display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; vertical-align: middle;
}

/* ---------- devices ---------- */
.devices { display: grid; gap: 8px; margin-bottom: 10px; }
.device {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); cursor: pointer;
}
.device input { accent-color: var(--accent); width: 18px; height: 18px; }
.device__name { font-weight: 600; }
.device__type { color: var(--muted); font-size: 13px; }
.device--active .device__type::after { content: ' · playing now'; color: var(--spotify); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(110px + env(safe-area-inset-bottom));
  max-width: min(92vw, 560px);
  background: #fff; color: #111;
  padding: 12px 16px; border-radius: 12px;
  font-weight: 600; font-size: 15px; line-height: 1.4;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 50;
}
.toast--error { background: #ffe1dd; color: #6a0f05; }
body[data-screen="workout"] .toast { bottom: 24px; }

/* ================= WORKOUT SCREEN ================= */
.screen--workout {
  max-width: none;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  min-height: 100dvh;
  transition: background 0.35s ease;
  background: var(--bg);
  color: #fff;
}
body[data-phase="prep"] .screen--workout { background: #141018; }
body[data-phase="work"] .screen--workout { background: radial-gradient(120% 90% at 50% 0%, var(--work) 0%, var(--work-deep) 100%); }
body[data-phase="rest"] .screen--workout { background: radial-gradient(120% 90% at 50% 0%, var(--rest) 0%, var(--rest-deep) 100%); }
body[data-phase="paused"] .screen--workout { background: #1b1b22; }
body[data-phase="done"] .screen--workout { background: var(--bg); }

.wk-top { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-display); letter-spacing: 0.04em; }
.wk-top .label { font-size: 18px; opacity: 0.75; }
.wk-top strong { font-size: 40px; font-weight: 400; }
.wk-top .of { font-size: 22px; opacity: 0.6; margin-left: 2px; }
.wk-progress { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.2); overflow: hidden; margin: 8px 0 0; }
#wk-bar { height: 100%; width: 0; background: #fff; transition: width 0.25s linear; }

.wk-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 12px 0; }
.wk-phase { font-family: var(--font-display); font-size: clamp(28px, 6vw, 44px); letter-spacing: 0.18em; opacity: 0.85; }
.wk-count {
  font-family: var(--font-display);
  font-size: clamp(160px, 42vw, 300px);
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
body[data-phase="prep"] .wk-count { color: var(--prep); }
.wk-exercise { font-family: var(--font-display); font-size: clamp(36px, 9vw, 64px); letter-spacing: 0.04em; margin-top: 8px; line-height: 1; }
.wk-next { margin-top: 10px; font-size: 16px; opacity: 0.8; }

.wk-now {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.28); border-radius: 14px; padding: 10px 12px;
  margin-bottom: 12px;
}
.wk-now img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; }
.np-text { min-width: 0; }
.np-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.7; }
.np-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 14px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist .badge { background: #fff; color: var(--work-deep); }

.embed-wrap {
  background: rgba(0,0,0,0.28); border-radius: 14px; padding: 10px 12px 4px;
  margin-bottom: 12px;
}
.embed-wrap .np-label { margin-bottom: 6px; }
#embed-container iframe { border-radius: 10px; display: block; }

.wk-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.wk-controls .btn { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); color: #fff; }
.wk-controls .btn--danger { color: #fff; }

/* ================= DONE ================= */
.screen--done .wordmark span { color: var(--spotify); }
