:root {
  --bg: #121411;
  --surface: #1c1f1a;
  --surface-2: #262a23;
  --line: #333830;
  --text: #ecefe8;
  --muted: #9aa393;
  --accent: #8fb36a;
  --accent-ink: #12160e;
  --warn: #e0b04f;
  --danger: #e06a5a;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f1; --surface: #ffffff; --surface-2: #eceee7; --line: #d9ddd2;
    --text: #1b1e18; --muted: #626b5b; --accent: #4b6b2e; --accent-ink: #ffffff; --warn: #9a6a00; --danger: #b8392a;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; }

header.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
header.top .row { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
header.top h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .sub { color: var(--muted); font-size: 12px; font-weight: 500; display: block; }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a {
  flex: 1; text-align: center; padding: 10px 4px 12px; color: var(--muted); text-decoration: none; font-size: 12px;
}
nav.tabs a .ic { display: block; font-size: 20px; line-height: 1.2; }
nav.tabs a.on { color: var(--accent); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 9px 14px; cursor: pointer;
  text-decoration: none; color: var(--text); min-height: 40px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.iconbtn { background: none; border: 0; padding: 6px; font-size: 20px; cursor: pointer; color: var(--text); }

/* week grid */
.weeks { display: grid; gap: 8px; }
.week { display: grid; grid-template-columns: 54px repeat(var(--days, 5), 1fr); gap: 6px; align-items: center; }
.week .wl { font-size: 13px; color: var(--muted); }
.daydot {
  display: flex; align-items: center; justify-content: center; text-decoration: none; height: 40px; border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 12px; border: 1px solid var(--line);
}
.daydot.done { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.daydot.started { border-color: var(--accent); color: var(--accent); }
.daydot.next { outline: 2px solid var(--warn); outline-offset: 1px; }
/* program list */
a.card.prog { display: block; text-decoration: none; color: var(--text); }
.prog-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.prog-ic { font-size: 24px; }
.prog-title { flex: 1; font-weight: 700; font-size: 16px; line-height: 1.3; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.blocklabel { font-size: 12px; color: var(--accent); margin: 10px 0 2px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* exercise card */
.ex h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.ex h3 a { color: var(--text); text-decoration: none; }
.ex h3 a::after { content: " ▶"; font-size: 11px; color: var(--accent); vertical-align: 2px; }
.ex .idx { color: var(--muted); font-size: 12px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; white-space: nowrap; }
.chip b { font-weight: 600; }
.chip.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); white-space: normal; }
details.notes { margin: 6px 0 10px; }
details.notes summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.notes p { margin: 6px 0 0; font-size: 13.5px; }
.subs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.subs button { font-size: 12.5px; }
.subs button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.last { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.last b { color: var(--text); font-weight: 600; }

.sets { display: grid; gap: 6px; }
.setrow { display: grid; grid-template-columns: 62px 1fr 1fr 40px; gap: 8px; align-items: center; }
.setrow .lbl { font-size: 12.5px; color: var(--muted); line-height: 1.15; }
.setrow .lbl b { color: var(--text); display: block; font-size: 14px; }
.setrow input {
  width: 100%; min-width: 0; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  font-size: 17px; text-align: center; -moz-appearance: textfield;
}
.setrow input::-webkit-outer-spin-button, .setrow input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.setrow input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.setrow .ok { text-align: center; font-size: 18px; color: var(--accent); }
.setrow.saved input { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.setrow.pending input { border-color: var(--warn); }
.sethead { display: grid; grid-template-columns: 62px 1fr 1fr 40px; gap: 8px; font-size: 11.5px; color: var(--muted); text-align: center; }
.exactions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 10px; min-height: 64px; resize: vertical;
}
.warmup { margin-top: 10px; font-size: 13.5px; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.warmup table { width: 100%; border-collapse: collapse; }
.warmup td { padding: 3px 0; }
.warmup td:last-child { text-align: right; }

.daynav { display: flex; gap: 8px; margin-top: 16px; }
.daynav .btn { flex: 1; }

/* timer */
.timer {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 11;
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 8px 8px 8px 18px; display: flex; gap: 10px;
  align-items: center; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.timer.over { background: var(--warn); }
.timer button { background: rgba(0,0,0,.15); border: 0; border-radius: 999px; padding: 6px 10px; color: inherit; cursor: pointer; font-weight: 600; }

/* lists & forms */
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a, .list .item { display: flex; justify-content: space-between; gap: 10px; padding: 12px 2px; color: var(--text); text-decoration: none; }
.form { display: flex; gap: 8px; flex-wrap: wrap; }
.form input { flex: 1 1 120px; min-width: 0; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; }
.stat { display: flex; gap: 10px; flex-wrap: wrap; }
.stat div { flex: 1 1 90px; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

table.hist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.hist th, table.hist td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.hist th { color: var(--muted); font-weight: 500; font-size: 12px; }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot { fill: var(--accent); }

.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { font-size: 22px; }
.err { color: var(--danger); font-size: 14px; }
.offline { background: var(--warn); color: #1b1300; text-align: center; font-size: 13px; padding: 4px; }
.prose p, .prose li { font-size: 14px; }
.prose ol, .prose ul { padding-left: 20px; }
.prose code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.mono { word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 4px 0 6px; }
[hidden] { display: none !important; }

.setrow .prev { grid-column: 2 / -1; font-size: 12px; color: var(--muted); margin: -2px 0 4px; }
.setrow .prev:empty { display: none; }
.setrow .prev b { color: var(--text); font-weight: 600; }
.up { color: var(--accent); font-weight: 600; }
.down { color: var(--danger); font-weight: 600; }
.stat .up, .stat .down { font-size: inherit; }
.stat .up { color: var(--accent); }
.stat .down { color: var(--danger); }
