:root {
  --bg: #0b0b0f;
  --fg: #f4f4f7;
  --muted: #8a8a9a;
  --accent: #f5a623;
  --accent-deep: #c97f0a;
  --card: #16161d;
  --card-hover: #1f1f29;
  --border: #2a2a36;
  --done: #4ade80;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

#app {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 1rem env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}

/* --- routine picker --- */
.picker {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 0;
}
.picker h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.picker .sub { color: var(--muted); margin-bottom: 1.5rem; }
.routine-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.routine-card:active { background: var(--card-hover); }
.routine-card .title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.routine-card .meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}
.routine-card .count {
  color: var(--accent);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* --- step view --- */
.runner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.runner:active {
  background: rgba(255, 255, 255, 0.02);
}
.runner .no-advance {
  cursor: default;
}
.runner .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 0.5rem;
  margin-left: -0.5rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.back:active { color: var(--fg); }
.dots {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  padding: 0.5rem;
  margin-right: -0.5rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { color: var(--fg); }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.dot.active { background: var(--accent); }
.dot.done { background: var(--done); }

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.5rem 0.5rem;
}
.step .index {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.step .clip {
  width: auto;
  max-width: 100%;
  height: 45vh;
  max-height: 22rem;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 16px;
  background: var(--card);
  margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: block;
}
.step .name {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 1rem;
}
.step .reps {
  font-size: 2.75rem;
  font-weight: 300;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}
.step .note {
  color: var(--muted);
  font-size: 1rem;
  max-width: 22rem;
  line-height: 1.4;
}

.timer {
  font-size: 4rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.04em;
  margin-bottom: 0.75rem;
}
.timer-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.timer-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.6rem 1.25rem;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.timer-btn:active { background: var(--card-hover); }

.bottom {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}
.next-peek {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.5em;
}
.source {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  opacity: 0.6;
  padding: 0.25rem;
}
.source:active { opacity: 1; color: var(--fg); }
.next-peek .label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 0.5em;
  opacity: 0.7;
}
.advance {
  background: var(--accent);
  color: #1a1308;
  border: none;
  border-radius: 14px;
  padding: 1.25rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.advance:active { background: var(--accent-deep); }
.advance.done { background: var(--done); color: #082014; }

/* --- complete screen --- */
.complete {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
}
.complete .check {
  font-size: 4rem;
  color: var(--done);
}
.complete h2 {
  font-size: 1.75rem;
  margin: 0;
  letter-spacing: -0.02em;
}
.complete p { color: var(--muted); margin: 0; }
.complete .advance { margin-top: 2rem; width: 100%; max-width: 22rem; }
