:root {
  --bg: #111418; --card: #1b2027; --card2: #232a33; --line: #2e3640;
  --text: #eef1f4; --muted: #96a1ad; --accent: #4cc38a; --accent-ink: #06210f;
  --warn: #f0b429; --danger: #ef6461; --stretch: #6aa9ff;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f7; --card: #ffffff; --card2: #eef1f4; --line: #dde2e7;
    --text: #15191e; --muted: #5d6874; --accent: #1f9d63; --accent-ink: #ffffff;
    --warn: #b7791f; --danger: #c53d3a; --stretch: #2f6fd1;
    color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 96px);
  -webkit-text-size-adjust: 100%;
}
main { max-width: 560px; margin: 0 auto; padding: 12px 16px; }
h1 { font-size: 26px; margin: 8px 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 24px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.spread { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }

button { font: inherit; color: inherit; border: 0; background: var(--card2); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 18px; width: 100%; padding: 16px; border-radius: 12px; }
.btn-ghost { background: transparent; color: var(--muted); padding: 6px 8px; font-size: 14px; }
.btn-danger { color: var(--danger); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { white-space: nowrap; font-size: 14px; padding: 8px 12px; border: 1px solid var(--line); background: var(--card); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

input, textarea {
  font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; width: 100%; font-size: 17px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Week dots */
.week { display: flex; gap: 6px; align-items: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); }
.dot.stretch { border-color: var(--stretch); border-style: dashed; }
.dot.on { background: var(--accent); }
.dot.stretch.on { background: var(--stretch); border-style: solid; }

.coach { border-left: 3px solid var(--accent); font-size: 14px; color: var(--muted); }
.next h3 { margin: 0; font-size: 22px; }
.next .ex-list { font-size: 14px; color: var(--muted); margin: 8px 0 14px; }
.hist { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.hist:last-child { border-bottom: 0; }

/* Workout */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; margin: -12px 0 0; padding-top: calc(env(safe-area-inset-top) + 8px); }
.block-label { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: 0.06em; margin: 22px 0 -2px; }
.ex.skipped { opacity: 0.45; }
.ex.skipped .sets, .ex.skipped .tools .hide-skip { display: none; }
.ex-name { font-size: 18px; font-weight: 650; margin: 0; }
.ex-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-note { font-size: 13px; color: var(--muted); margin-top: 6px; font-style: italic; }
.last { font-size: 13px; margin-top: 6px; }
.bump { color: var(--warn); font-weight: 650; }
.sets { margin-top: 10px; }
.set { display: grid; grid-template-columns: 22px 1fr 14px 1fr 56px; gap: 8px; align-items: center; margin: 6px 0; }
.set.timed { grid-template-columns: 22px 1fr 34px 56px; }
.set .n { color: var(--muted); font-size: 14px; text-align: center; }
.set input { text-align: center; padding: 10px 4px; }
.set .x { color: var(--muted); text-align: center; }
.check { height: 46px; font-size: 22px; font-weight: 700; background: var(--card2); border: 2px solid var(--line); }
.set.done .check { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.set.done input { border-color: transparent; background: transparent; font-weight: 650; }
.tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.optional-toggle { width: 100%; margin-top: 8px; color: var(--muted); border: 1px dashed var(--line); background: transparent; }

/* Rest timer */
#timer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
}
#timer .inner { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
#timer .time { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; min-width: 84px; }
#timer .label { flex: 1; font-size: 14px; color: var(--muted); }
#timer .bar { position: absolute; top: 0; left: 0; height: 3px; background: var(--accent); }
#timer.go { background: var(--accent); color: var(--accent-ink); }
#timer.go .label { color: var(--accent-ink); }

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

/* Bottom sheet */
#sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; }
#sheet .panel {
  background: var(--card); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); max-height: 85vh; overflow-y: auto;
}
#sheet .opt { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 14px; font-size: 17px; }
#sheet .opt.on { outline: 2px solid var(--accent); }

.login { margin-top: 30vh; }
.sync { font-size: 12px; color: var(--muted); text-align: center; margin-top: 24px; }
.sync.pending { color: var(--warn); }

/* Weight stepper (dumbbell/bar), bodyweight label */
.set { grid-template-columns: 22px minmax(0, 1.6fr) 12px minmax(0, 1fr) 52px; gap: 6px; }
.wt { display: flex; align-items: stretch; min-width: 0; }
.wt input { border-radius: 0; border-left: 0; border-right: 0; min-width: 0; padding-left: 0; padding-right: 0; }
.stp { flex: 0 0 34px; padding: 0; font-size: 20px; font-weight: 700; border: 1px solid var(--line); color: var(--muted); }
.stp:first-child { border-radius: 10px 0 0 10px; }
.stp:last-child { border-radius: 0 10px 10px 0; }
.set.done .stp { visibility: hidden; }
.bwlabel { text-align: center; color: var(--muted); font-weight: 650; font-size: 15px; }
.guides a, .tools a.guide { color: var(--accent); text-decoration: none; }
.tools a.guide { display: inline-flex; align-items: center; }
.load { color: var(--text); }

/* Progress */
.progress-link { width: 100%; display: flex; justify-content: space-between; align-items: center; text-align: left; }
.progress-link .chev, .back { font-size: 15px; }
.progress-link .chev { font-size: 26px; color: var(--muted); }
.back { padding-left: 0; }
.prog { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; }
.prog .pinfo { min-width: 0; }
.prog.empty { opacity: 0.6; }
.spark { flex: 0 0 auto; overflow: visible; }
.up { color: var(--accent); font-weight: 650; }
.down { color: var(--warn); font-weight: 650; }
.bigchart { margin: 8px 0 12px; }
.bigchart .spark { display: block; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.ptable td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ptable td:last-child, .ptable th:last-child { text-align: right; }

/* Split workouts: welcome-back card, done superset labels */
.resume { border-left: 3px solid var(--accent); }
.resume strong { display: block; margin: 4px 0; }
.resume .warm { color: var(--warn); margin: 6px 0 12px; }
.resume .btn-primary { font-size: 16px; padding: 12px; }
.block-label { scroll-margin-top: 90px; }
.block-label.done { color: var(--accent); }
