:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #dddad3;
  --accent: #c2410c;
  --accent-soft: #fde9dc;
  --accent-ink: #ffffff;
  --good: #2f7d3b;
  --good-soft: #dff1e1;
  --good-ink: #ffffff;
  --danger: #b42318;
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --surface: #1c1d20;
    --surface-2: #26272b;
    --ink: #f1f1f3;
    --muted: #a0a0a8;
    --line: #34353a;
    --accent: #ff8a4c;
    --accent-soft: #3a2519;
    --accent-ink: #1a0d05;
    --good: #6cc97a;
    --good-soft: #1d3322;
  --good-ink: #0c1f10;
    --danger: #ff6b5e;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111214;
  --surface: #1c1d20;
  --surface-2: #26272b;
  --ink: #f1f1f3;
  --muted: #a0a0a8;
  --line: #34353a;
  --accent: #ff8a4c;
  --accent-soft: #3a2519;
  --accent-ink: #1a0d05;
  --good: #6cc97a;
  --good-soft: #1d3322;
  --good-ink: #0c1f10;
  --danger: #ff6b5e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 90px);
}

h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 0 0 6px; }
p { margin: 6px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { text-transform: uppercase; font-size: 12px; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 2px; font-weight: 600; }

.page-head { padding-top: 4px; }
.back { display: inline-block; margin-top: 4px; text-decoration: none; font-weight: 600; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 12px;
  box-shadow: 0 1px 0 var(--line);
}

.accent-card { background: var(--accent-soft); box-shadow: none; }

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

.big-num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 18px; color: var(--muted); font-weight: 600; }

/* ---------- Knoppen ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; margin-top: 12px; font-size: 17px; min-height: 52px; }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: 14px; }
.btn.link { background: none; border: none; color: var(--accent); width: 100%; margin-top: 4px; }
.btn.danger { color: var(--danger); }
.card .btn + .btn, .card label.btn { margin-top: 8px; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 99px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ---------- Plan ---------- */
.plan-list { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: plan; }
.plan-list li {
  counter-increment: plan;
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.plan-list li::before {
  content: counter(plan);
  grid-row: span 2;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.plan-name { font-weight: 600; }
.plan-line { color: var(--muted); font-size: 14px; }

/* ---------- Weekstrook ---------- */
.week-strip { display: flex; gap: 6px; align-items: flex-end; margin: 10px 0 6px; }
.wk { flex: 1; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wk-bar { height: 44px; background: var(--surface-2); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.wk-bar div { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.wk.hit .wk-bar div { background: var(--good); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-num { display: block; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------- Training ---------- */
body.in-workout .tabbar { display: none; }
body.in-workout .view { padding-bottom: calc(env(safe-area-inset-bottom) + 180px); }

.workout-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 8px; }
.workout-head .center { text-align: center; }

.stepper { display: flex; gap: 4px; margin-bottom: 12px; }
.step { flex: 1; height: 8px; border-radius: 4px; border: none; background: var(--line); padding: 0; cursor: pointer; }
.step.done { background: var(--good); }
.step.current { background: var(--accent); }
.step::after { content: ""; display: block; height: 28px; margin-top: -10px; } /* grotere tikzone */

.exercise h1 { margin-top: 4px; font-size: 24px; }
.fig-wrap { background: var(--surface-2); border-radius: 12px; margin: -4px -4px 8px; }
.figure { width: 100%; height: auto; display: block; max-height: 240px; }
.fig-limb, .fig-torso { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; fill: none; }
.fig-far { stroke: var(--muted); opacity: 0.55; }
.fig-head { fill: var(--ink); }
.fig-floor, .fig-prop { stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round; }
.fig-bar { fill: var(--muted); }
.fig-bench { fill: var(--line); stroke: var(--muted); stroke-width: 1.5; }
.fig-weight { fill: var(--accent); }
.fig-weight.fig-far { fill: var(--accent); stroke: none; }
.fig-plate { fill: none; stroke: var(--accent); stroke-width: 4; }
.fig-chain { stroke: var(--muted); stroke-width: 1.5; }

.ladder { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.ladder-btns { display: flex; gap: 6px; }
.target { font-size: 20px; font-weight: 700; margin: 10px 0 2px; }
.suggest { background: var(--accent-soft); padding: 8px 12px; border-radius: 10px; }
.note { background: var(--surface-2); padding: 8px 12px; border-radius: 10px; font-size: 14px; }

.howto { margin: 10px 0; }
.howto summary { font-weight: 600; cursor: pointer; padding: 6px 0; color: var(--accent); }
.howto ul { padding-left: 20px; margin: 4px 0 8px; }
.howto li { margin: 4px 0; }

.swap { display: block; font-size: 14px; color: var(--muted); margin: 6px 0 10px; }
.swap select, .field select {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  font-size: 16px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.sets { margin-top: 12px; }
.set-row {
  display: grid;
  grid-template-columns: 24px repeat(var(--cols, 1), minmax(0, 1fr)) 52px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}
.set-row.head { font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 0; }
.set-n { font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.set-input {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.set-input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.with-btn { display: flex; gap: 6px; }
.sw.running { background: var(--accent); color: var(--accent-ink); }
.check {
  width: 52px;
  height: 46px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}
.check.on { background: var(--good); border-color: var(--good); color: var(--good-ink); }
.set-row.done .set-input { background: var(--good-soft); border-color: transparent; }
.set-actions { display: flex; gap: 8px; margin-top: 6px; }

.checklist { list-style: none; padding: 0; margin: 8px 0 0; }
.checklist li { border-top: 1px solid var(--line); }
.checklist label { display: flex; gap: 12px; align-items: center; padding: 12px 0; }
.checklist input { width: 24px; height: 24px; accent-color: var(--good); flex: none; }

.workout-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.workout-nav .btn { flex: 1; min-height: 52px; }

/* ---------- Rusttimer ---------- */
.rest {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 82px);
  max-width: 536px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 16px;
  z-index: 10;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}
.rest[hidden] { display: none; }
.rest-label { font-size: 13px; opacity: 0.7; }
.rest-time { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; flex: 1; }
.rest .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.rest.finished { background: var(--good); color: var(--good-ink); }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 12px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 20;
  font-size: 15px;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }

/* ---------- Tabbalk ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  min-height: var(--tabbar-h);
  justify-content: center;
}
.tabbar a span { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: 0.7; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active span { filter: none; opacity: 1; }

/* ---------- Lijsten, tabellen, grafiek ---------- */
.plain { list-style: none; padding: 0; margin: 8px 0; }
.plain li { padding: 8px 0; border-top: 1px solid var(--line); }

.ex-list { list-style: none; padding: 0; margin: 8px 0 0; }
.ex-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.ex-cur { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; }
.table td { border-top: 1px solid var(--line); padding: 8px 4px; vertical-align: top; }
.table td:first-child { white-space: nowrap; color: var(--muted); }

.chart { margin: 8px 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-tip { font-size: 14px; color: var(--muted); min-height: 20px; margin-bottom: 4px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-hit { fill: transparent; cursor: pointer; }

.hist summary { list-style: none; cursor: pointer; }
.hist summary::-webkit-details-marker { display: none; }

.field { display: block; margin: 10px 0; font-weight: 600; }
.field.row { display: flex; gap: 10px; align-items: center; }
.field.row input { width: 22px; height: 22px; accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
