:root {
  --bg: #0d1117;
  --panel: #151a23;
  --panel2: #1c2330;
  --line: #273041;
  --text: #e8edf4;
  --muted: #8b97a8;
  --accent: #f5a524;
  --gym: #f5a524;
  --run: #2dd4bf;
  --kb: #fb7185;
  --other: #94a3b8;
  --weight: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 14px;
  --tabh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabh) + var(--safe-b) + 24px);
  -webkit-tap-highlight-color: transparent;
}
body.resting { padding-bottom: calc(var(--tabh) + var(--safe-b) + 80px); }
body.noscroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.6rem; margin: 6px 0 4px; letter-spacing: -0.01em; }
h1 small { font-size: 1rem; color: var(--muted); font-weight: 500; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 26px 2px 10px; font-weight: 650; }
h3 { margin: 0; font-size: 1.05rem; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
ul.bul { margin: 0; padding-left: 18px; }
ul.bul li { margin: 6px 0; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 10px;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 750; letter-spacing: -0.01em; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--muted); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync.busy i { background: var(--warn); animation: pulse 1s infinite; }
.sync.off i { background: var(--muted); }
.sync.ok span { display: none; }
@keyframes pulse { 50% { opacity: 0.3; } }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px; }
.loading { text-align: center; padding: 40px; }

.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

/* hero */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 10px 0 4px; }
.hero .date { margin: 0; color: var(--muted); }
.hero .date::first-letter, .day-head b::first-letter { text-transform: uppercase; }
.hero .status { margin: 2px 0 0; font-size: 1.05rem; }
.race { text-align: right; display: flex; flex-direction: column; align-items: flex-end; font-size: 0.75rem; color: var(--muted); max-width: 130px; line-height: 1.2; }
.race .big { font-size: 2rem; font-weight: 800; color: var(--run); line-height: 1; }

.chip { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); font-weight: 600; vertical-align: middle; }
.chip.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.1); }
.chip.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.1); }
.chip.miss { color: var(--bad); border-color: rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.08); }

/* sessiekaarten */
.session { position: relative; overflow: hidden; padding-left: 20px; transition: transform 0.08s; }
.session::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
a.session:active { transform: scale(0.985); }
.session-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kind { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.session-title { font-weight: 650; font-size: 1.08rem; margin-top: 2px; }
.session-sub { color: var(--muted); font-size: 0.88rem; margin-top: 3px; }
.session.done { opacity: 0.8; }
.session.done .session-title { color: var(--muted); }
.session.compact { padding-top: 10px; padding-bottom: 10px; }
.session.compact .session-title { font-size: 0.98rem; }
.session.rest { opacity: 0.55; }
.restday .session-title { color: var(--muted); }

.stats { display: flex; justify-content: space-around; align-items: center; text-align: center; gap: 8px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.78rem; color: var(--muted); min-width: 80px; }
.stat .big { font-size: 1.5rem; font-weight: 750; color: var(--text); line-height: 1.2; }
.stat.link .big { color: var(--accent); }
.ring { width: 64px; height: 64px; }
.ring-bg { fill: none; stroke: var(--panel2); stroke-width: 6; }
.ring-fg { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dasharray 0.4s; }
.ring-txt { fill: var(--text); font-size: 13px; font-weight: 700; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .btn { border-color: color-mix(in srgb, var(--c) 40%, var(--line)); color: var(--c); }

.list .row, .row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 1.3rem; }

/* knoppen & formulieren */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:active { filter: brightness(1.2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1205; }
.btn.danger { color: var(--bad); background: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.88rem; }
.btn.wide { width: 100%; }
.btn.icon { width: 44px; padding: 0; font-size: 1.5rem; }
.btn[aria-disabled="true"] { opacity: 0.3; pointer-events: none; }
.btn.big { min-height: 58px; font-size: 1.15rem; flex: 1; }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }

.form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
  font-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; border-color: transparent; }
label.inline input, label.inline select { max-width: 60%; }
.unit { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.unit input { width: 90px; text-align: right; }
.pace-in { width: 74px !important; text-align: center; }
textarea { resize: vertical; }
.error { color: var(--bad); margin: 0; }
.warnline { color: var(--warn); font-size: 0.88rem; display: block; margin-top: 4px; }
.okline { color: var(--ok); font-size: 0.88rem; display: block; margin-top: 4px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 40px; min-width: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; padding: 0 10px; }
.seg button.on { background: var(--accent); color: #1a1205; border-color: var(--accent); }
.feel { display: flex; flex-direction: column; gap: 6px; }
.feel > span { font-size: 0.9rem; color: var(--muted); }

/* login */
.login { max-width: 360px; margin: 10vh auto 0; text-align: center; }
.login form { text-align: left; display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.logo svg { border-radius: 16px; }

/* week */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 12px; text-align: center; }
.weeknav h1 { margin: 0; }
.weeknav p { margin: 0; font-size: 0.85rem; }
.blocknote p { font-size: 0.9rem; }
.day { margin: 14px 0; }
.day-head { margin: 0 2px 6px; }
.day-head b { display: inline-block; }
.day.today .day-head b { color: var(--accent); }
.day.today .day-head b::after { content: " · vandaag"; font-weight: 500; text-transform: none; }
.rest-line { padding: 4px 2px 6px; }

/* schema */
.weekpattern { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 12px 0 6px; }
.weekpattern > div { display: flex; flex-direction: column; gap: 2px; background: var(--panel2); border-radius: 8px; padding: 6px 4px; font-size: 0.68rem; text-align: center; min-height: 64px; line-height: 1.2; }
.weekpattern b { font-size: 0.78rem; text-transform: uppercase; margin-bottom: 2px; }
.zones { display: grid; gap: 8px; }
.zone { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel2); border-left: 4px solid var(--zc); }
.zone b { text-transform: capitalize; }
.zone .pace { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--zc); }
.zone small { grid-column: 1 / -1; color: var(--muted); }
.z-easy { --zc: #2dd4bf; }
.z-stevig { --zc: #f97316; }
.z-race { --zc: #e879f9; }
.zones.mini { margin: 10px 0; }
.weeks { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.wk { display: block; padding: 10px 12px; border-radius: 10px; background: var(--panel2); border: 1px solid transparent; }
.wk.current { border-color: var(--accent); }
.wk.recovery { background: color-mix(in srgb, var(--panel2) 70%, #1e3a5f); }
.wk-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.wk-head .muted { font-size: 0.8rem; flex: 1; }
.wk-line { font-size: 0.9rem; padding-left: 10px; border-left: 3px solid var(--c); margin: 3px 0; }
.wk-line.small { font-size: 0.78rem; color: var(--muted); }
.exlist { margin: 4px 0 12px; padding-left: 18px; }
.exlist li { margin: 3px 0; }

/* sessie */
.sesshead { padding: 6px 0 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.sesshead h1 { border-left: 5px solid var(--c); padding-left: 10px; }
.sesshead .detail { color: var(--text); opacity: 0.9; }
.sesshead label.inline { margin: 10px 0; }
.back { color: var(--muted); font-size: 0.95rem; display: inline-block; padding: 6px 0; }
.hint { font-size: 0.85rem; color: var(--warn); }
.hint.up { color: var(--ok); margin-top: 6px; }
.timerbtn { margin: 6px 0 4px; border-color: var(--run); color: var(--run); }
.paceout { font-size: 1rem; min-height: 1.4em; }
.paceout b { font-size: 1.25rem; }

.ex.main { border-color: color-mix(in srgb, var(--gym) 45%, var(--line)); }
.ex-head { display: flex; flex-direction: column; gap: 2px; }
.target { font-weight: 650; color: var(--gym); }
.target .muted { font-weight: 500; }
.prev { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.exnote { font-size: 0.82rem; color: var(--muted); margin-top: 4px; font-style: italic; }
.plates { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 8px; }
.plate { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 26px; padding: 0 6px; border-radius: 5px; font-size: 0.75rem; font-weight: 700; color: #fff; background: #475569; }
.plate.p25 { background: #dc2626; }
.plate.p20 { background: #2563eb; }
.plate.p15 { background: #ca8a04; }
.plate.p10 { background: #16a34a; }
.plate.p5 { background: #e5e7eb; color: #111; }
.plate.p2_5 { background: #111827; border: 1px solid #4b5563; }
.plate.p1_25 { background: #9ca3af; color: #111; }
.sets { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.set { display: grid; grid-template-columns: 34px 1fr 1fr 52px; gap: 8px; align-items: center; }
.set.head { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.set .n { text-align: center; color: var(--muted); font-weight: 700; }
.set input { width: 100%; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; padding: 8px 6px; }
.set input::placeholder { color: #4b5768; font-weight: 500; }
.tick { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.set.done .tick { background: var(--ok); border-color: var(--ok); color: #052e1c; }
.set.done input { border-color: rgba(52, 211, 153, 0.4); color: var(--ok); }
.ex-actions { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.ex-actions .memo { flex: 1; min-height: 36px; padding: 6px 10px; font-size: 0.9rem; min-width: 0; }

/* rusttimer */
.restbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--tabh) + var(--safe-b) + 8px); z-index: 30;
  max-width: 620px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 14px; height: 54px;
  background: #0b2a24; border: 1px solid var(--run); border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.rest-fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(45, 212, 191, 0.18); transition: width 0.25s linear; }
.rest-label { flex: 1; position: relative; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest-time { position: relative; font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--run); }
.restbar button { position: relative; height: 38px; min-width: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(16, 21, 29, 0.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 0.68rem; color: var(--muted); }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

/* intervaltimer */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); }
.itimer {
  --zc: #2dd4bf;
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 22px calc(var(--safe-b) + 20px); text-align: center;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--zc) 22%, transparent), transparent 70%);
  transition: background 0.4s;
}
.itimer[data-zone="stevig"] { --zc: #f97316; }
.itimer[data-zone="race"] { --zc: #e879f9; }
.itimer[data-zone="done"] { --zc: #34d399; }
.itimer .close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 1.1rem; }
.istep { font-size: 1.7rem; font-weight: 800; color: var(--zc); }
.itime { font-size: clamp(4.5rem, 24vw, 8rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.ipace { color: var(--muted); font-size: 1.05rem; }
.inext { font-size: 1rem; }
.ibar { width: 100%; max-width: 420px; height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; }
.ibar i { display: block; height: 100%; background: var(--zc); width: 0; }
.itotal { color: var(--muted); font-variant-numeric: tabular-nums; }
.ibtns { display: flex; gap: 10px; width: 100%; max-width: 420px; }

/* voortgang */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke-dasharray: 4 4; stroke-width: 1.4; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .bar-target { fill: #2a3444; }
.chart .bar-current { stroke: #fff; stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.legend i, table.tm i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
table.tm { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
table.tm th { text-align: right; color: var(--muted); font-weight: 600; font-size: 0.75rem; padding: 4px; }
table.tm td { text-align: right; padding: 6px 4px; border-top: 1px solid var(--line); }
table.tm td:first-child, table.tm th:first-child { text-align: left; }
.grid17 { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.grid17 .cell { aspect-ratio: 1; border-radius: 8px; background: var(--panel2); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; }
.grid17 .cell::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--f) * 100%); background: var(--ok); opacity: 0.75; }
.grid17 .cell span { position: relative; }
.grid17 .cell.future { opacity: 0.45; }
.grid17 .cell.current { outline: 2px solid var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 76px); transform: translate(-50%, 20px);
  background: #e8edf4; color: #0d1117; padding: 10px 18px; border-radius: 999px; font-weight: 650; font-size: 0.92rem;
  opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 60; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  main { padding-top: 16px; }
  .grid17 { grid-template-columns: repeat(17, 1fr); }
}
