:root {
  --bg: #101418;
  --surface: #181e24;
  --surface-2: #212932;
  --line: #2c3540;
  --text: #e8edf2;
  --muted: #8d99a6;
  --accent: #4fd1a5;
  --accent-ink: #062a1e;
  --main: #ffb454;
  --warn: #ffcf6e;
  --bad: #ff7a7a;
  --hard: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.up { color: var(--accent); }
.down { color: var(--bad); }

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card.compact { padding: 12px 14px; margin-bottom: 8px; }
.stack > * + * { margin-top: 12px; }

.hero { padding: 16px 0 8px; }
.hero p { color: var(--muted); }

.block-banner {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface));
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.block-banner.deload { background: linear-gradient(135deg, color-mix(in srgb, var(--warn) 18%, var(--surface)), var(--surface)); }
.block-banner p { margin: 0; }

.pill {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  vertical-align: middle;
}

button, .button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
button.ghost, .button.ghost { background: transparent; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); width: 100%; }
button.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
button.small { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; }
.card > button.ghost { width: 100%; margin-top: 8px; }
.linklike { display: block; text-align: center; color: var(--muted); text-decoration: underline; cursor: pointer; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; }
label.check input { width: 22px; height: 22px; }
input, select {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 44px;
  width: 100%;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.lift-input { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.lift-input .lift-name { grid-column: 1 / -1; font-weight: 600; }

.note { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.92rem; }
.note.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); }
.note.cap { background: color-mix(in srgb, var(--main) 16%, var(--surface)); margin: 8px 0; }
.ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.exercise.finisher { border-left: 4px solid var(--accent); }
.note.coach { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); margin: 8px 0; }

.preview { list-style: none; padding: 0; margin: 8px 0 14px; }
.preview li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.preview li:last-child { border-bottom: 0; }
.preview li span:first-child { flex-shrink: 0; max-width: 55%; }
.preview li span:last-child { color: var(--muted); text-align: right; }
.preview .main { font-weight: 700; color: var(--main); }

.week { padding-left: 20px; margin: 4px 0 8px; }
.week li { padding: 3px 0; }
.week li.done { color: var(--muted); text-decoration: line-through; }
.week li.current { font-weight: 700; color: var(--accent); }

.readiness-q .chips { margin-top: 6px; }
.scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { flex: 1 0 auto; min-width: 44px; padding: 8px 6px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.chips.rpe .chip { min-width: 48px; }

.active-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }

.exercise.main { border-left: 4px solid var(--main); }
.ex-head h3 { margin-bottom: 2px; }
.warmup { margin: 8px 0; font-size: 0.9rem; color: var(--muted); }
.warmup summary { cursor: pointer; }
.warmup ul { margin: 6px 0 0; padding-left: 20px; }

.sets { list-style: none; padding: 0; margin: 10px 0 0; }
.set {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 6px;
  background: var(--surface-2);
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}
.set .tag { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); min-width: 72px; }
.set .val { flex: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.set .go { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
.set.next { border-color: var(--accent); }
.set.logged .val { color: var(--accent); }
.set.logged.miss .val { color: var(--warn); }
.set.optional { opacity: 0.55; }
.set.editing { display: block; cursor: default; border-color: var(--accent); }

.editor > * + * { margin-top: 10px; }
.stepper { display: grid; grid-template-columns: 1fr 52px 90px 52px; gap: 6px; align-items: center; }
.stepper .lbl, .editor .lbl { font-size: 0.85rem; color: var(--muted); }
.stepper input { text-align: center; font-weight: 700; font-size: 1.15rem; padding: 8px 4px; }
.stepper button { font-size: 1.4rem; padding: 0; }
.editor .row .primary { flex: 1; }

.rest-bar {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 10px 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
  z-index: 5;
}
.rest-bar span { flex: 1; }
.rest-bar[hidden] { display: none; }

.timer { text-align: center; padding: 18px 0; border-radius: 12px; background: var(--surface-2); }
.timer .phase { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.timer .phase.hard { color: var(--hard); }
.timer .clock { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }

.intro { margin-bottom: 8px; }
.week-head { margin: 18px 0 8px; font-size: 0.95rem; color: var(--muted); }
.plan-title { display: flex; justify-content: space-between; align-items: center; }
.card.compact .preview { margin-bottom: 0; }

.lift-stat { padding: 10px 0; border-bottom: 1px solid var(--line); }
.lift-stat:last-child { border-bottom: 0; }
.spark { width: 100%; height: 48px; color: var(--accent); margin-top: 6px; display: block; }

.kv { list-style: none; padding: 0; margin: 0; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv li:last-child { border-bottom: 0; }
.kv li span:last-child { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { border-bottom: 1px solid var(--line); }
.history summary { display: flex; gap: 12px; padding: 10px 0; cursor: pointer; }
.history summary span:first-child { color: var(--muted); min-width: 56px; }
.notes { padding-left: 18px; margin: 6px 0; }
.notes li { margin-bottom: 6px; }

.how p { font-size: 0.93rem; }

nav#nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
nav#nav[hidden] { display: none; }
nav#nav button { border: 0; border-radius: 0; background: transparent; color: var(--muted); min-height: 58px; font-weight: 600; }
nav#nav button.on { color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  max-width: calc(100% - 32px);
  z-index: 20;
  font-size: 0.93rem;
}

@media (max-width: 380px) {
  .grid2 { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: 1fr 44px 76px 44px; }
}
