:root {
  --bg: #0b0e14; --panel: #131825; --panel-2: #1a2030; --panel-3: #222a3d; --line: #232938;
  --text: #e6eaf2; --muted: #8a95ad; --dim: #5d6885;
  --green: #16d186; --red: #ef4f6b; --blue: #6c8eff; --amber: #f5a623; --purple: #a06fff;
  --font: 'Inter', -apple-system, system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; line-height: 1.45; min-height: 100vh; overscroll-behavior-y: none; }
button { font-family: var(--font); cursor: pointer; }
input, select { font-family: var(--font); }
a { color: var(--blue); }

.app { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--sat)) 16px calc(92px + var(--sab)); }
header.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.brand .sub { font-size: 12px; color: var(--muted); }
.icon-btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); width: 38px; height: 38px; border-radius: 10px; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:active { transform: scale(.96); }

h2 { font-size: 17px; font-weight: 700; margin: 22px 0 10px; letter-spacing: -0.01em; }
h2:first-child { margin-top: 0; }
h3 { font-size: 14px; font-weight: 700; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
p.note { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.card.tap { cursor: pointer; }
.card.tap:active { border-color: var(--dim); }
.card.done { opacity: .75; }
.card.accent { border-color: rgba(108,142,255,.45); }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .title { font-weight: 700; font-size: 15px; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.chip.green { background: rgba(22,209,134,.16); color: var(--green); }
.chip.blue { background: rgba(108,142,255,.16); color: var(--blue); }
.chip.amber { background: rgba(245,166,35,.16); color: var(--amber); }
.chip.red { background: rgba(239,79,107,.16); color: var(--red); }
.chip.purple { background: rgba(160,111,255,.16); color: var(--purple); }

.btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 11px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--green); color: #06281b; border-color: var(--green); }
.btn.blue { background: var(--blue); color: #0b1330; border-color: var(--blue); }
.btn.danger { color: var(--red); border-color: rgba(239,79,107,.4); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; text-align: center; padding: 14px; font-size: 15px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btnrow .btn { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px; }
.stat .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .d.up { color: var(--green); }

.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width .3s; }
.progress i.green { background: var(--green); }

/* week strip */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.strip .day { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 0 7px; text-align: center; font-size: 11px; color: var(--muted); }
.strip .day.today { border-color: var(--blue); color: var(--text); }
.strip .day b { display: block; font-size: 13px; color: var(--text); margin-bottom: 4px; }
.strip .dots { display: flex; gap: 3px; justify-content: center; height: 6px; }
.strip .dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }

/* pain chips */
.painrow { display: flex; gap: 5px; margin-top: 8px; }
.painrow button { flex: 1; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-weight: 700; font-size: 13px; }
.painrow button.on { background: var(--blue); border-color: var(--blue); color: #0b1330; }
.painrow button.on.warn { background: var(--amber); border-color: var(--amber); }
.painrow button.on.bad { background: var(--red); border-color: var(--red); color: #fff; }

/* tabs */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(11,14,20,.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 8px calc(8px + var(--sab)); z-index: 50; }
nav.tabs .inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
nav.tabs button { background: none; border: none; color: var(--dim); font-size: 11px; font-weight: 600; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; border-radius: 10px; }
nav.tabs button .em { font-size: 20px; line-height: 1; }
nav.tabs button.on { color: var(--text); }
nav.tabs button.on .em { filter: drop-shadow(0 0 6px rgba(108,142,255,.6)); }

/* session list rows */
.sess { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.sess:first-of-type { border-top: none; }
.sess .k { font-family: var(--mono); font-weight: 700; font-size: 12px; width: 30px; color: var(--muted); }
.sess .k.done { color: var(--green); }
.sess .n { flex: 1; min-width: 0; }
.sess .n .name { font-weight: 600; font-size: 14px; }
.sess .n .rx { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess .st { font-size: 12px; color: var(--muted); }
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.weeknav .wk { display: flex; gap: 4px; flex: 1; justify-content: center; }
.weeknav .wk button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 700; }
.weeknav .wk button.on { background: var(--blue); border-color: var(--blue); color: #0b1330; }
.weeknav .wk button.full { color: var(--green); }
.adapt { font-size: 12px; color: var(--amber); margin-top: 4px; }
.adapt::before { content: '↻ '; }

/* runner */
.runner-head { position: sticky; top: 0; background: var(--bg); padding: calc(8px + var(--sat)) 0 10px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.runner-head .t { font-weight: 800; font-size: 16px; }
.runner-head .s { font-size: 12px; color: var(--muted); }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px; margin-bottom: 10px; }
.item.complete { border-color: rgba(22,209,134,.4); }
.item .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.item .mv { font-weight: 700; font-size: 15px; }
.item .rx { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.item .hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.item .adapt { margin-bottom: 8px; }
.setrow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.setrow:first-of-type { border-top: none; }
.setrow .lbl { width: 62px; font-size: 12px; color: var(--muted); }
.setrow .lbl b { color: var(--text); font-family: var(--mono); }
.stepper { display: flex; align-items: center; gap: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.stepper button { width: 38px; height: 36px; background: transparent; border: none; color: var(--text); font-size: 18px; font-weight: 700; }
.stepper input { width: 52px; height: 36px; text-align: center; background: transparent; border: none; color: var(--text); font-family: var(--mono); font-size: 15px; font-weight: 700; }
.stepper input:focus { outline: none; }
.setrow .unit { font-size: 12px; color: var(--muted); width: 28px; }
.tick { width: 40px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--dim); font-size: 17px; margin-left: auto; }
.tick.on { background: var(--green); border-color: var(--green); color: #06281b; }
.wbox { display: flex; align-items: center; gap: 6px; }
.wbox input { width: 64px; height: 36px; text-align: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-family: var(--mono); font-size: 14px; font-weight: 700; }

.timer { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.timer .digits { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: -0.02em; min-width: 108px; font-variant-numeric: tabular-nums; }
.timer .digits.big { font-size: 56px; min-width: 0; text-align: center; width: 100%; }
.timer .digits.warn { color: var(--amber); }
.timer .digits.done { color: var(--green); }
.timer .sub { font-size: 12px; color: var(--muted); flex: 1; }
.timer .sub b { color: var(--text); font-family: var(--mono); }
.roundbar { display: flex; gap: 3px; margin: 6px 0 8px; }
.roundbar i { flex: 1; height: 5px; border-radius: 2px; background: var(--panel-3); }
.roundbar i.on { background: var(--blue); }
.roundbar i.cur { background: var(--green); }
.amrap-big { text-align: center; padding: 6px 0 8px; }
.amrap-big .rounds { font-size: 64px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.amrap-big .rounds small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.amrap-big .split { font-size: 13px; color: var(--muted); margin-top: 6px; }
.amrap-big .split b { font-family: var(--mono); color: var(--text); }
.splits { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.splits span { font-family: var(--mono); font-size: 11px; background: var(--panel-2); border-radius: 6px; padding: 2px 7px; color: var(--muted); }
.roundbtn { width: 100%; padding: 22px; font-size: 20px; font-weight: 800; border-radius: 14px; margin-top: 8px; }
.restbtns { display: flex; gap: 6px; margin-top: 8px; }
.restbtns .btn { flex: 1; }
.ladder { display: grid; gap: 6px; }
.ladder .lrow { display: flex; align-items: center; gap: 6px; }
.ladder .lrow .lbl { width: 62px; font-size: 12px; color: var(--muted); }
.ladder .rung { flex: 1; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-family: var(--mono); font-weight: 700; font-size: 15px; }
.ladder .rung.on { background: var(--green); border-color: var(--green); color: #06281b; }
.ladder .rung.miss { background: rgba(239,79,107,.18); border-color: var(--red); color: var(--red); }

.finish { margin-top: 18px; }
.rpe { display: flex; gap: 6px; margin: 8px 0; }
.rpe button { flex: 1; padding: 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-weight: 600; }
.rpe button.on { background: var(--blue); border-color: var(--blue); color: #0b1330; }
.rpe button.on.warn { background: var(--amber); border-color: var(--amber); }
label.field { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
input.text, select.text, textarea.text { width: 100%; font-family: var(--font); padding: 11px 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-size: 15px; }
input.text:focus, textarea.text:focus { outline: 1px solid var(--blue); border-color: var(--blue); }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .refline { stroke: var(--dim); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .tick { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .endlabel { fill: var(--text); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart .markband { fill: rgba(245,166,35,.08); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-table { margin-top: 6px; font-size: 12px; color: var(--muted); }
.chart-table summary { cursor: pointer; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { text-align: left; padding: 3px 6px; border-top: 1px solid var(--line); }
#charttip { position: fixed; display: none; background: var(--panel-3); border: 1px solid var(--dim); color: var(--text); font-size: 12px; padding: 5px 9px; border-radius: 7px; pointer-events: none; z-index: 100; white-space: nowrap; }
.heat { margin: 6px 0; }
.heat-head, .heat-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.heat-head span { font-size: 10px; color: var(--dim); text-align: center; }
.heat-cell { height: 26px; background: var(--panel-2); border-radius: 6px; display: flex; gap: 3px; align-items: center; justify-content: center; }
.heat-cell.today { outline: 1px solid var(--blue); }
.heat-cell.future { opacity: .35; }
.heat-cell i { width: 6px; height: 6px; border-radius: 50%; display: block; }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--sab)); transform: translateX(-50%); background: var(--panel-3); border: 1px solid var(--dim); color: var(--text); padding: 11px 16px; border-radius: 10px; font-size: 13px; z-index: 200; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.empty { text-align: center; color: var(--dim); padding: 30px 12px; font-size: 13px; }
.tech li { font-size: 13px; color: var(--muted); margin-left: 16px; margin-bottom: 4px; }
details.card summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.list-log { font-size: 13px; }
.list-log .r { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.list-log .r:first-child { border-top: none; }
.list-log .r .d { color: var(--muted); font-size: 12px; white-space: nowrap; }
.modal { position: fixed; inset: 0; background: rgba(5,7,12,.7); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; padding: 18px 18px calc(18px + var(--sab)); max-height: 88vh; overflow: auto; }

/* plan card */
.card.plan { border-left: 3px solid var(--blue); }
.card.plan.green { border-left-color: var(--green); }
.card.plan.amber { border-left-color: var(--amber); }
.card.plan.red { border-left-color: var(--red); background: rgba(239,79,107,.07); }
.planmsg { font-size: 15px; font-weight: 600; margin-top: 6px; line-height: 1.4; }
details.rules { margin-top: 8px; }
details.rules summary { font-size: 12px; color: var(--muted); cursor: pointer; font-weight: 600; }
details.rules ul { margin-top: 6px; }

/* uitleg */
details.uitleg { margin: 2px 0 10px; font-size: 13px; }
details.uitleg summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: 12px; }
details.uitleg .doel { color: var(--text); margin: 6px 0; }
details.uitleg ol, details.uitleg ul { margin: 4px 0 6px 18px; color: var(--muted); }
details.uitleg li { margin-bottom: 3px; }
details.uitleg ul.letop li { color: var(--amber); }
details.uitleg a.video { display: inline-block; margin-top: 4px; font-weight: 600; text-decoration: none; background: var(--panel-2); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; font-size: 12px; }

/* notes */
.note-in { width: 100%; margin-top: 8px; padding: 9px 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 13px; }
.note-in:focus { outline: 1px solid var(--blue); border-color: var(--blue); }
.notebtn { background: none; border: none; color: var(--dim); font-size: 12px; font-weight: 600; padding: 6px 0 0; }
textarea.notes { resize: vertical; min-height: 64px; line-height: 1.4; }
.prevnote { background: var(--panel); border: 1px dashed var(--dim); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.prevnote .eyebrow { display: block; margin-bottom: 4px; }
/* run/walk */
.phase { text-align: center; font-weight: 800; letter-spacing: .06em; font-size: 14px; color: var(--muted); margin-top: 6px; }
.phase.run { color: var(--green); } .phase.walk { color: var(--blue); } .phase.done { color: var(--green); }
/* gate checklist */
.gate { margin-top: 10px; display: grid; gap: 6px; }
.gitem { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.gitem.tap { cursor: pointer; }
.gitem .mark { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--dim); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: var(--dim); flex: none; }
.gitem.ok { border-color: rgba(22,209,134,.4); }
.gitem.ok .mark { background: var(--green); border-color: var(--green); color: #06281b; }
/* install */
.card.install { border-color: rgba(22,209,134,.4); }
