*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:      #111827;
  --bg2:     #1f2937;
  --bg3:     #374151;
  --text:    #f9fafb;
  --text2:   #9ca3af;
  --text3:   #6b7280;
  --run:     #f97316;
  --walk:    #22c55e;
  --warmup:  #60a5fa;
  --cooldown:#818cf8;
  --accent:  #8b5cf6;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: block;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.08s;
  text-align: center;
}

.btn:active { opacity: 0.75; transform: scale(0.98); }

.btn-primary  { background: var(--accent); color: #fff; width: 100%; }
.btn-secondary{ background: var(--bg3);   color: var(--text); width: 100%; }
.btn-ghost    { background: transparent;  color: var(--text2); width: 100%;
                border: 1px solid var(--bg3); }

.btn-link {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.btn-icon {
  background: var(--bg3);
  border: none;
  color: var(--text2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon:active { opacity: 0.7; }

/* ── Home Screen ─────────────────────────────────────────── */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--bg3);
}

.app-title {
  font-size: 20px;
  font-weight: 700;
}

.progress-text {
  font-size: 13px;
  color: var(--text2);
}

.home-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Session card */
.session-card {
  background: var(--bg2);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.week-chip {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(139,92,246,0.15);
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.run-chip {
  font-size: 13px;
  color: var(--text2);
}

.session-summary {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}

.session-meta {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  gap: 12px;
}

/* Progress section */
.progress-section h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 12px;
}

.progress-bar {
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s;
}

/* Dot grid: column-flow so each week is a column */
.dots-grid {
  display: grid;
  grid-template-rows: repeat(3, 10px);
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
  margin-bottom: 5px;
}

.dot {
  border-radius: 50%;
  background: var(--bg3);
}

.dot.done    { background: var(--accent); }
.dot.current { background: var(--run); box-shadow: 0 0 6px var(--run); }

.week-labels {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
}

.week-labels span {
  text-align: center;
  font-size: 10px;
  color: var(--text3);
}

.home-footer {
  padding: 10px 20px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  text-align: center;
  border-top: 1px solid var(--bg3);
}

/* Complete home card */
.all-done-card {
  background: var(--bg2);
  border-radius: 16px;
  padding: 32px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.all-done-card .trophy { font-size: 56px; }
.all-done-card h2 { font-size: 22px; font-weight: 700; }
.all-done-card p  { color: var(--text2); font-size: 15px; }

/* ── Workout Screen ──────────────────────────────────────── */

.workout-screen {
  position: relative;
  background: var(--bg);
}

.workout-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--bg3);
}

.workout-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.elapsed {
  font-size: 13px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
}

/* Current interval display */
.interval-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 12px;
  gap: 6px;
}

.interval-type-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.big-timer {
  font-size: 76px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -2px;
}

.next-up {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

/* Progress bars */
.interval-progress {
  height: 4px;
  background: var(--bg3);
  margin: 4px 20px 0;
  border-radius: 2px;
  overflow: hidden;
}

.interval-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.25s linear;
}

.total-progress {
  height: 2px;
  background: var(--bg3);
  margin: 6px 20px;
  border-radius: 1px;
  overflow: hidden;
}

.total-progress-fill {
  height: 100%;
  background: var(--text3);
  border-radius: 1px;
  transition: width 0.25s linear;
}

/* Interval list */
.interval-list-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.interval-list {
  display: flex;
  flex-direction: column;
  padding: 4px 0 8px;
}

.iv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 14px;
  color: var(--text2);
  transition: background 0.15s;
}

.iv-row.iv-done   { opacity: 0.35; }
.iv-row.iv-active { background: rgba(255,255,255,0.05); color: var(--text); }

.iv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.iv-label { flex: 1; }

.iv-dur {
  font-size: 13px;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

.iv-remaining {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  min-width: 36px;
  text-align: right;
}

/* Controls */
.workout-controls {
  padding: 10px 20px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--bg3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-nav {
  background: var(--bg3);
  border: none;
  color: var(--text);
  width: 56px;
  height: 38px;
  border-radius: 10px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.12s, transform 0.08s;
}

.btn-nav:active:not(:disabled) { opacity: 0.7; transform: scale(0.95); }

.btn-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

/* Paused overlay */
.paused-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.paused-text {
  font-size: 36px;
  font-weight: 800;
  color: rgba(255,255,255,0.85);
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* Wake lock warning */
.wakelock-warn {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  padding: 4px 20px 0;
}

/* ── Complete Screen ─────────────────────────────────────── */

.complete-screen {
  align-items: center;
  justify-content: center;
}

.complete-content {
  text-align: center;
  padding: 40px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.complete-icon { font-size: 72px; }

.complete-content h2 { font-size: 28px; font-weight: 800; }
.complete-content p  { font-size: 16px; color: var(--text2); }

.next-label { color: var(--accent) !important; font-weight: 600; }
.done-label { color: var(--walk) !important; font-weight: 600; }
