:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #111722;
  --panel-2: #171f2d;
  --text: #f5f7fb;
  --muted: #9aa8bb;
  --line: #293447;
  --accent: #ff7a1a;
  --accent-2: #ffad66;
  --good: #43d17d;
  --danger: #ff5f62;
  --shadow: 0 16px 46px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 90% -20%, rgba(255, 122, 26, .18), transparent 38%),
    var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
}
.topbar, .section-heading, .run-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}
h1, h2, p { margin-top: 0; }
h1 { font-size: 1.15rem; margin-bottom: 0; }
h2 { font-size: clamp(1.65rem, 7vw, 2.5rem); line-height: 1.05; margin-bottom: 10px; }
.eyebrow, .kicker {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
  color: var(--accent-2);
  margin-bottom: 6px;
}
.muted, .microcopy { color: var(--muted); }
.microcopy { font-size: .82rem; min-height: 1.1rem; margin: 8px 0 0; }

.view { display: none; }
.view.active { display: block; animation: appear .2s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }

.hero-card, .finish-card, .timer-card, .sync-card, .rpe-card, .coach-card {
  background: rgba(17, 23, 34, .95);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.hero-card, .finish-card { padding: 24px; }
textarea {
  width: 100%;
  resize: vertical;
  min-height: 150px;
  background: #0b1018;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  line-height: 1.5;
  outline: none;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 26, .13); }

.input-actions, .review-actions, .controls, .finish-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
button {
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  font-weight: 750;
  color: var(--text);
}
.primary { background: var(--accent); color: #17100a; }
.secondary { background: var(--panel-2); border: 1px solid var(--line); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.danger { color: #ff999b; }
.big { flex: 1; min-height: 52px; }
.full { width: 100%; }
.text-button { background: none; color: var(--accent-2); padding: 8px 0; }
.hidden { display: none !important; }
.quick-card { text-align: center; padding: 12px; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.summary-strip > div {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.summary-strip span { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 5px; }
.summary-strip strong { font-size: .95rem; }

.interval-list { display: grid; gap: 9px; }
.interval-row {
  display: grid;
  grid-template-columns: 32px 1.3fr .75fr .68fr 34px;
  gap: 8px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
}
.interval-row label span { display: block; font-size: .68rem; color: var(--muted); margin: 0 0 5px 3px; }
.interval-row input, .interval-row select {
  width: 100%;
  min-height: 42px;
  background: #0b1018;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  outline: none;
}
.drag-index {
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-weight: 900;
}
.delete-row { background: transparent; color: var(--muted); font-size: 1.4rem; padding: 6px; }

.timer-card { padding: 26px 20px 20px; text-align: center; }
.phase-badge {
  display: inline-block;
  padding: 7px 10px;
  background: rgba(255, 122, 26, .13);
  color: var(--accent-2);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .09em;
}
.countdown {
  font-size: clamp(5rem, 25vw, 8.5rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
  font-weight: 800;
  margin: 20px 0 18px;
}
.progress-track { height: 8px; border-radius: 999px; overflow: hidden; background: #252e3c; }
.progress-bar { width: 0%; height: 100%; background: var(--accent); transition: width .2s linear; }
.timer-meta { display: flex; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: .8rem; }
.next-card {
  margin: 12px 0;
  padding: 15px 17px;
  border-radius: 16px;
  background: var(--panel-2);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.next-card span { color: var(--muted); }
.sync-card, .rpe-card, .coach-card { padding: 16px; margin-top: 12px; box-shadow: none; }
.sync-card p { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.sync-card p strong { color: var(--text); }
.rpe-title { margin-bottom: 10px; font-weight: 750; }
.rpe-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.rpe-buttons button { background: var(--panel-2); border: 1px solid var(--line); }
.rpe-buttons button.selected { border-color: var(--accent); background: rgba(255, 122, 26, .18); color: var(--accent-2); }
.controls { margin: 12px 0; }
.coach-card { display: flex; align-items: center; gap: 12px; opacity: .68; }
.coach-card p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.coach-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }

.session-summary { display: grid; gap: 8px; margin: 18px 0; }
.summary-row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.summary-row span { color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 580px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .hero-card, .finish-card { padding: 18px; }
  .interval-row {
    grid-template-columns: 28px 1fr .66fr 34px;
  }
  .interval-row .rpe-field { grid-column: 2 / 4; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip > div:last-child { grid-column: 1 / -1; }
  .input-actions { flex-direction: column; }
  .input-actions button { width: 100%; }
}
