@font-face { font-family: "Bricolage"; src: url(fonts/bricolage.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url(fonts/dmmono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url(fonts/dmmono-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #f3efe6;
  --surface: #fbf9f4;
  --sunk: #e9e4d8;
  --ink: #1c1b19;
  --ink-2: #57544d;
  --ink-3: #8c887e;
  --line: #ddd7ca;
  --accent: #d9542b;
  --accent-ink: #fff8f2;
  --good: #2f7a4f;
  --bad: #b8352a;
  --key: #e6e1d4;
  --key-hi: #f6f3ec;
  --key-shadow: #c9c2b2;
  --heat-0: #e6e1d4; --heat-1: #f1c3ad; --heat-2: #e8906b; --heat-3: #d9542b; --heat-4: #9e3517;
  --m1: #d9542b; --m2: #2f6fb0; --m3: #9a7a12; --m4: #8a4e8c; --m5: #2f8a55;
  --r: 18px;
  --font: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1d1b; --surface: #282725; --sunk: #171615; --ink: #f1ede4; --ink-2: #b6b1a6; --ink-3: #7f7b72; --line: #3a3835;
    --accent: #e5693d; --accent-ink: #1e1d1b; --good: #4fae76; --bad: #e0675b;
    --key: #32302d; --key-hi: #3b3936; --key-shadow: #121110;
    --heat-0: #2e2c29; --heat-1: #5b3324; --heat-2: #8e4527; --heat-3: #c9572d; --heat-4: #f08a5d;
    --m1: #db6236; --m2: #5b95d8; --m3: #ad8b22; --m4: #b07ab3; --m5: #3f9e66;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1d1b; --surface: #282725; --sunk: #171615; --ink: #f1ede4; --ink-2: #b6b1a6; --ink-3: #7f7b72; --line: #3a3835;
  --accent: #e5693d; --accent-ink: #1e1d1b; --good: #4fae76; --bad: #e0675b;
  --key: #32302d; --key-hi: #3b3936; --key-shadow: #121110;
  --heat-0: #2e2c29; --heat-1: #5b3324; --heat-2: #8e4527; --heat-3: #c9572d; --heat-4: #f08a5d;
  --m1: #db6236; --m2: #5b95d8; --m3: #ad8b22; --m4: #b07ab3; --m5: #3f9e66;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  font-variation-settings: "opsz" 14;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; }
.screen { flex: 1; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 92px); gap: 14px; }
.screen.bare { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }

/* ---------- typografie ---------- */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
h1 { font-size: 34px; line-height: 1.02; font-weight: 800; letter-spacing: -0.03em; font-variation-settings: "opsz" 96; }
h2 { font-size: 22px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; font-variation-settings: "opsz" 48; }
h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); vertical-align: 0.35em; margin-left: 2px; }

/* ---------- kaarten en knoppen ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 16px; border: 1px solid var(--line); }
.card.flat { background: transparent; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 54px; border-radius: 16px; font-weight: 650; font-size: 17px; width: 100%; transition: transform 0.08s; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 0 color-mix(in oklab, var(--accent) 60%, black); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.ghost { background: var(--key); color: var(--ink); }
.btn.line { border: 1.5px solid var(--line); }
.btn.sm { height: 40px; font-size: 15px; border-radius: 12px; width: auto; padding: 0 14px; }
.link { color: var(--accent); font-weight: 600; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--ink-2); }
.iconbtn:active { background: var(--key); }

.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .v { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.04em; line-height: 1.1; }
.tile .l { font-size: 12px; color: var(--ink-3); font-weight: 550; }
.tile .d { font-size: 12px; font-family: var(--mono); }
.up { color: var(--good); }
.down { color: var(--bad); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; color: #fff; font-size: 17px; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--key); font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.chip.acc { background: color-mix(in oklab, var(--accent) 14%, var(--surface)); color: var(--accent); }
.chip.good { background: color-mix(in oklab, var(--good) 14%, var(--surface)); color: var(--good); }

.bar { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--ink); }
.bar.acc > i { background: var(--accent); }

/* ---------- tabbalk ---------- */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center; background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs nav { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 520px; }
.tabs button { height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.tabs button.on { color: var(--ink); }
.tabs button.on svg { color: var(--accent); }

/* ---------- vandaag ---------- */
.today-card { background: var(--ink); color: var(--bg); border: 0; padding: 20px; display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden; }
.today-card .eyebrow { color: color-mix(in oklab, var(--bg) 55%, var(--ink)); }
.today-card h2 { font-size: 26px; }
.blocks { display: flex; gap: 6px; }
.blocks span { flex: 1; border-radius: 10px; padding: 8px 10px; background: color-mix(in oklab, var(--bg) 10%, var(--ink)); font-size: 12px; line-height: 1.2; }
.blocks span b { display: block; font-family: var(--mono); font-weight: 500; font-size: 15px; }
.blocks span.done { opacity: 0.45; }
.today-card .btn.primary { box-shadow: none; }
.ring { position: absolute; right: -28px; top: -28px; opacity: 0.9; }

.tipcard .ex { font-family: var(--mono); background: var(--sunk); border-radius: 12px; padding: 12px 14px; font-size: 16px; line-height: 1.6; }
.tipcard .ex div:first-child { color: var(--ink); font-weight: 500; }
.tipcard .ex div { color: var(--ink-2); }

.rank { display: flex; flex-direction: column; }
.rank .r { display: grid; grid-template-columns: 22px 28px 1fr auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.rank .r:first-child { border-top: 0; }
.rank .pos { font-family: var(--mono); color: var(--ink-3); font-size: 13px; }
.rank .v { font-family: var(--mono); font-weight: 500; }
.rank .me { font-weight: 700; }
.check { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--good); color: var(--surface); vertical-align: -3px; margin-left: 6px; }

/* ---------- oefenscherm ---------- */
.practice { height: 100dvh; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 10px); gap: 8px; max-width: 520px; margin: 0 auto; width: 100%; }
.p-top { display: flex; align-items: center; gap: 10px; }
.segs { flex: 1; display: flex; gap: 3px; }
.segs i { flex: 1; height: 4px; border-radius: 2px; background: var(--sunk); }
.segs i.ok { background: var(--ink); }
.segs i.bad { background: var(--bad); }
.segs i.cur { background: var(--ink-3); }
.p-block { font-size: 13px; font-weight: 650; color: var(--ink-2); display: flex; justify-content: space-between; padding: 0 4px; }
.p-block .num { color: var(--ink); }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; min-height: 0; padding: 0 4px; position: relative; }
.q { font-family: var(--mono); font-weight: 500; font-size: clamp(40px, 12.5vw, 62px); letter-spacing: -0.04em; line-height: 1; text-align: center; white-space: nowrap; }
.q.long { font-size: clamp(32px, 9.5vw, 48px); }
.ans { font-family: var(--mono); font-weight: 500; font-size: clamp(40px, 12.5vw, 62px); letter-spacing: -0.04em; min-width: 2.4ch; text-align: center; border-bottom: 3px solid var(--ink); line-height: 1.15; padding: 0 6px; min-height: 1.2em; position: relative; }
.ans.empty::after { content: ""; position: absolute; left: 50%; top: 14%; height: 70%; width: 3px; background: var(--accent); animation: blink 1s steps(2) infinite; }
.ans.good { color: var(--good); border-color: var(--good); }
.ans.bad { color: var(--bad); border-color: var(--bad); }
@keyframes blink { 50% { opacity: 0; } }
.again { position: absolute; top: 8px; font-size: 12px; }
.timer { width: 60%; height: 3px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.timer i { display: block; height: 100%; width: 0; background: var(--ink-3); border-radius: 2px; }
.timer.over i { background: var(--line); }
.flash { position: absolute; bottom: 4px; font-family: var(--mono); font-size: 15px; color: var(--good); font-weight: 500; opacity: 0; transition: opacity 0.15s; }
.flash.on { opacity: 1; }
.shake { animation: shake 0.32s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.solve { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.solve .steps { font-family: var(--mono); font-size: 17px; line-height: 1.65; }
.solve .steps div:first-child { font-weight: 500; }
.solve .steps div:not(:first-child) { color: var(--ink-2); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px 2px 0; }
.key { height: clamp(52px, 8.2dvh, 68px); border-radius: 20px; background: var(--key); font-family: var(--mono); font-size: 28px; font-weight: 500; box-shadow: inset 0 1px 0 var(--key-hi), 0 2px 0 var(--key-shadow); display: grid; place-items: center; user-select: none; -webkit-user-select: none; transition: transform 0.05s, background 0.05s; }
.key:active, .key.down { transform: translateY(2px); box-shadow: inset 0 1px 0 var(--key-hi), 0 0 0 var(--key-shadow); background: var(--key-hi); }
.key.fn { font-family: var(--font); font-size: 15px; font-weight: 650; color: var(--ink-2); }
.key.go { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 0 color-mix(in oklab, var(--accent) 55%, black); font-family: var(--font); font-size: 17px; font-weight: 700; }
.key:disabled { opacity: 0.35; }

/* sprint */
.clock { font-family: var(--mono); font-size: 15px; font-weight: 500; width: 46px; text-align: right; }
.clock.low { color: var(--accent); }
.sprintbar { flex: 1; height: 4px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.sprintbar i { display: block; height: 100%; background: var(--accent); transform-origin: left; }

/* ---------- uitleg / tipblad ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; border-radius: 24px 24px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px); max-height: 92dvh; overflow: auto; animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); display: flex; flex-direction: column; gap: 14px; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0.4; } }

/* ---------- samenvatting ---------- */
.big { font-family: var(--mono); font-size: 76px; font-weight: 500; letter-spacing: -0.06em; line-height: 0.95; }
.big small { font-size: 30px; letter-spacing: -0.03em; }
.event { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }
.event .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--key); color: var(--ink); }
.event .ic.acc { background: var(--accent); color: var(--accent-ink); }
.lvchange { font-family: var(--mono); font-size: 14px; color: var(--ink-2); }

/* ---------- technieken ---------- */
.skill { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); text-align: left; width: 100%; }
.skill:first-child { border-top: 0; }
.skill .n { font-family: var(--mono); font-size: 13px; color: var(--ink-3); width: 34px; height: 34px; border-radius: 10px; background: var(--key); display: grid; place-items: center; }
.skill.locked { opacity: 0.45; }
.skill .meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.skill .meta .bar { height: 4px; }
.groupname { margin-top: 6px; }

/* ---------- grafieken ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-family: var(--mono); font-size: 10px; }
.chart .lbl { font-family: var(--font); font-size: 11.5px; font-weight: 650; fill: var(--ink-2); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 7px 10px; font-size: 12px; line-height: 1.35; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity 0.1s; z-index: 3; }
.tip.on { opacity: 1; }
.tip b { font-family: var(--mono); font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: 3px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 2px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--heat-0); }
.heat i.t { outline: 1.5px solid var(--ink); outline-offset: -1.5px; }
.seg { display: flex; background: var(--key); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 34px; border-radius: 9px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data td, table.data th { padding: 6px 4px; border-top: 1px solid var(--line); text-align: right; }
table.data th { color: var(--ink-3); font-weight: 600; }
table.data td:first-child, table.data th:first-child { text-align: left; }

/* ---------- formulieren ---------- */
.field { width: 100%; height: 56px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 18px; outline: none; }
.field:focus { border-color: var(--ink); }
.field.code { font-family: var(--mono); letter-spacing: 0.2em; text-transform: uppercase; text-align: center; font-size: 22px; }
.swatches { display: flex; gap: 12px; }
.swatches button { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; outline: 2px solid transparent; }
.swatches button.on { border-color: var(--bg); outline-color: var(--ink); }
.codebox { font-family: var(--mono); font-size: 30px; letter-spacing: 0.18em; text-align: center; padding: 14px; background: var(--sunk); border-radius: 14px; font-weight: 500; }
.principle { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.principle .k { font-family: var(--mono); font-size: 13px; color: var(--accent); padding-top: 2px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 30; animation: fade 0.2s; }
.hero-wordmark { font-size: 46px; font-weight: 800; letter-spacing: -0.045em; line-height: 0.95; font-variation-settings: "opsz" 96; }
