:root {
  --bg: #151310;
  --surface: #1e1a15;
  --surface-2: #262119;
  --line: #332c22;
  --gold: #c9a45c;
  --gold-dim: #8a7345;
  --bone: #ede7d8;
  --muted: #8a8577;
  --danger: #b5563e;
  --radius: 14px;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--bone);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;   /* a stray downward swipe shouldn't reload mid-workout */
}

.mono { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 10px;
  border-bottom: 1px solid var(--line);
}
.top h1 {
  font-family: "Marcellus", serif;
  font-size: 22px; letter-spacing: 0.35em; color: var(--gold); font-weight: 400;
}
.top-date { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

main { padding: 18px 16px; max-width: 560px; margin: 0 auto; }

/* ---------- Cards & buttons ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 { font-family: "Marcellus", serif; font-weight: 400; font-size: 20px; margin-bottom: 8px; }
.eyebrow { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; }

.btn {
  display: block; width: 100%;
  background: var(--gold); color: #1a150d;
  border: none; border-radius: var(--radius);
  font-size: 17px; font-weight: 600;
  padding: 16px; margin-top: 14px;
  font-family: inherit; cursor: pointer;
}
.btn:active { background: var(--gold-dim); }
.btn.secondary { background: var(--surface-2); color: var(--bone); border: 1px solid var(--line); }
.btn.small { padding: 10px 14px; font-size: 14px; width: auto; display: inline-block; margin-top: 8px; }
.ghost-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 13px 26px; font-size: 14px; font-family: inherit; margin-top: 14px;
  min-height: 44px;   /* Skip gets tapped mid-set with one hand — keep it thumb-sized */
}
.danger-text { color: var(--danger); background: none; border: none; font-size: 13px; padding: 6px; }

/* ---------- Guided workout ---------- */
.session-progress {
  display: flex; gap: 4px; margin-bottom: 16px;
}
.session-progress span { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.session-progress span.done { background: var(--gold); }
.session-progress span.current { background: var(--gold-dim); }

.ex-title { font-family: "Marcellus", serif; font-size: 26px; font-weight: 400; line-height: 1.15; }
.set-label { color: var(--gold); font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; margin: 10px 0 4px; }
.target { color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.set-strip { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.set-chip {
  flex: 1; min-width: 62px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.set-chip b { font-size: 10px; letter-spacing: 0.12em; color: var(--muted); font-weight: 400; }
.set-chip em { font-style: normal; font-size: 18px; color: var(--bone); }
.set-chip i { font-style: normal; font-size: 10px; color: var(--muted); }
.set-chip.current { border-color: var(--gold); background: var(--surface); }
.set-chip.current em { color: var(--gold); }
.set-chip.done { opacity: 0.55; }
.set-chip.done em { color: var(--gold-dim); }

.cues {
  border-left: 2px solid var(--gold-dim);
  padding: 6px 0 6px 12px; margin: 12px 0;
  font-size: 14px; color: var(--bone); line-height: 1.5; white-space: pre-wrap;
}

.video-embed { margin: 12px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.video-embed iframe { display: block; width: 100%; aspect-ratio: 16/9; border: 0; }

.log-row { display: flex; gap: 10px; margin-top: 8px; }
.log-field { flex: 1; }
.log-field label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.log-field input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--bone); font-family: "IBM Plex Mono", monospace; font-size: 28px; text-align: center;
  padding: 12px 4px;
}
.log-field input:focus { outline: none; border-color: var(--gold); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 44px; height: 58px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--gold); font-size: 22px; flex: none;
}

/* ---------- Timer / stretch overlay: the signature ---------- */
.timer-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  /* Ring + cues + a 16:9 stretch video are taller than a short phone. A scroll
     container with justify-content:center makes the overflow unreachable at both
     ends, so centring is done with auto margins instead — they collapse to a plain
     scroll once the content outgrows the viewport. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
}
.timer-overlay > .timer-dial { margin-top: auto; }
.timer-overlay > :last-child { margin-bottom: auto; }
.timer-overlay[hidden] { display: none; }

.timer-dial { position: relative; flex: none; display: flex; justify-content: center; }
.timer-ring { width: min(64vw, 260px); height: auto; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 6; }
.ring-fill {
  fill: none; stroke: var(--gold); stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 553; stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear;
}
.timer-center { position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.timer-center button { pointer-events: auto; }
.timer-label { font-size: 12px; letter-spacing: 0.24em; color: var(--gold); text-transform: uppercase; }
.timer-value { font-family: "IBM Plex Mono", monospace; font-size: 56px; font-weight: 600; margin: 2px 0; }
.stretch-panel { margin-top: 24px; padding-top: 20px; width: 100%; max-width: 460px; }
.stretch-panel .eyebrow { margin-bottom: 2px; }
.stretch-panel h3 { font-family: "Marcellus", serif; font-weight: 400; font-size: 22px; }

/* ---------- Tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 16px 0; font-family: inherit;
}
.tab.active { color: var(--gold); }

/* ---------- Program editor ---------- */
.editor-field { margin-bottom: 12px; }
.editor-field label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
/* 16px is the threshold below which iOS auto-zooms the page on focus — never go under it. */
.editor-field input, .editor-field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--bone); font-family: inherit; font-size: 16px; padding: 10px 12px;
}
.editor-field textarea { min-height: 70px; resize: vertical; }
.ex-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.ex-list-item:last-child { border-bottom: none; }
.chart-wrap { margin-top: 10px; }
canvas.chart { width: 100%; height: 180px; }
select.plain {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--bone); font-size: 16px; padding: 12px; font-family: inherit;
  -webkit-appearance: none; appearance: none;
}

.done-check { color: var(--gold); font-family: "IBM Plex Mono", monospace; }
.summary-num { font-family: "IBM Plex Mono", monospace; font-size: 34px; color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  .ring-fill { transition: none; }
}

/* ---------- Lock screen ---------- */
.card.lock { margin-top: 18vh; text-align: center; }
.lock-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--bone); font-family: "IBM Plex Mono", monospace;
  font-size: 24px; letter-spacing: 0.3em; text-align: center; padding: 14px 12px;
  margin: 16px 0 10px;
}
.lock-input:focus { outline: none; border-color: var(--gold-dim); }
.card.lock .muted { min-height: 18px; margin-bottom: 12px; }
body.locked nav.tabs, body.locked .top-date { display: none; }
