:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #17201d;
  --muted: #5d6b66;
  --border: #dbe1dd;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #d8efec;
  --on-accent: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcf3e3;
  --bad: #b42318;
  --bad-soft: #fbe2df;
  --warn: #a15c07;
  --warn-soft: #fbecd2;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .06);
  --radius: 14px;

  --c-lead: #2563eb;
  --c-boulder: #c2410c;
  --c-speed: #7c3aed;
  --c-teamspeed: #be185d;
  --c-allgemein: #0f766e;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e8eeeb;
    --muted: #9aa8a2;
    --border: #2c3833;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123a35;
    --on-accent: #06201d;
    --ok: #4ade80;
    --ok-soft: #12301d;
    --bad: #f87171;
    --bad-soft: #3a1513;
    --warn: #fbbf24;
    --warn-soft: #3a2a0c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --c-lead: #60a5fa;
    --c-boulder: #fb923c;
    --c-speed: #a78bfa;
    --c-teamspeed: #f472b6;
    --c-allgemein: #2dd4bf;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1412;
  --surface: #171e1b;
  --surface-2: #1f2824;
  --text: #e8eeeb;
  --muted: #9aa8a2;
  --border: #2c3833;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: #123a35;
  --on-accent: #06201d;
  --ok: #4ade80;
  --ok-soft: #12301d;
  --bad: #f87171;
  --bad-soft: #3a1513;
  --warn: #fbbf24;
  --warn-soft: #3a2a0c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --c-lead: #60a5fa;
  --c-boulder: #fb923c;
  --c-speed: #a78bfa;
  --c-teamspeed: #f472b6;
  --c-allgemein: #2dd4bf;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; outline: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
main:focus-visible, main:focus { outline: none; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 14px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; }
.logo svg { width: 36px; height: 36px; display: block; }
.logo rect { fill: var(--accent); }
.logo path { fill: var(--surface); }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: var(--muted); font-size: .8rem; }

/* Generic */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; border: 1px solid transparent; padding: 11px 18px; font-weight: 600;
  background: var(--accent); color: var(--on-accent); min-height: 44px; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.ghost { background: none; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; color: var(--muted); }
.ghost:hover { color: var(--text); background: var(--surface); }
.ghost.small { min-width: 40px; min-height: 40px; font-size: 1.1rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Home */
.hero { padding: 18px 0 6px; }
.hero p { color: var(--muted); max-width: 60ch; }
.modes { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .modes { grid-template-columns: repeat(3, 1fr); } }
.mode {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-height: 100%;
  transition: border-color .15s, transform .1s;
}
.mode:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.mode:disabled { opacity: .55; cursor: not-allowed; }
.mode .icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1.1rem; }
.mode strong { font-size: 1.02rem; }
.mode span.desc { color: var(--muted); font-size: .9rem; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 28px 0 10px; }
.section-title h2 { margin: 0; }

.progress-list { display: grid; gap: 12px; }
.prog-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.prog-row .label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.prog-row .nums { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.bar > i.ok { background: var(--ok); }
.bar > i.bad { background: var(--bad); opacity: .75; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.d-lead { --dc: var(--c-lead); }
.d-boulder { --dc: var(--c-boulder); }
.d-speed { --dc: var(--c-speed); }
.d-teamspeed { --dc: var(--c-teamspeed); }
.d-allgemein { --dc: var(--c-allgemein); }
.dot { background: var(--dc); }

/* Setup */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field > .flabel { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 99px; padding: 8px 14px; min-height: 40px; user-select: none; cursor: pointer;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { border-color: var(--dc, var(--accent)); background: color-mix(in srgb, var(--dc, var(--accent)) 12%, var(--surface)); }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip .cnt { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.chip.plain { --dc: var(--accent); }
.seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg label { padding: 8px 14px; cursor: pointer; border-right: 1px solid var(--border); min-height: 40px; display: inline-flex; align-items: center; }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--on-accent); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { min-width: 3.5ch; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.hint { font-size: .85rem; color: var(--muted); }

/* Quiz */
.quizbar { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; }
.quizbar .count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.quizbar .track { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.quizbar .track > i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.tag.disc { background: color-mix(in srgb, var(--dc) 14%, var(--surface)); color: var(--text); }
.tag.case { background: var(--warn-soft); color: var(--warn); }
.lvl { letter-spacing: 1px; }
.question { font-size: 1.12rem; font-weight: 600; margin-bottom: 6px; }
.multi-hint { font-size: .85rem; color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.options { display: grid; gap: 10px; margin-top: 12px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px; min-height: 52px;
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .mark {
  flex: none; width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: transparent;
}
.opt.multi .mark { border-radius: 6px; }
.opt .key { flex: none; font-size: .75rem; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.opt .txt { flex: 1; }
.opt[aria-pressed="true"], .opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt[aria-checked="true"] .mark { border-color: var(--accent); background: var(--accent); color: var(--surface); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .mark { border-color: var(--ok); background: var(--ok); color: var(--surface); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .mark { border-color: var(--bad); background: var(--bad); color: var(--surface); }
.opt.missed { border-color: var(--ok); border-style: dashed; }
.opt.missed .mark { border-color: var(--ok); color: var(--ok); }
.opt:disabled { cursor: default; }

.feedback { margin-top: 16px; border-radius: 12px; padding: 14px 16px; border: 1px solid var(--border); background: var(--surface-2); }
.feedback.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-soft); }
.feedback.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-soft); }
.feedback .verdict { font-weight: 800; margin-bottom: 4px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.feedback p { margin: 0 0 8px; }
.ref { display: inline-flex; gap: 6px; align-items: center; font-size: .85rem; font-weight: 600; color: var(--muted); }
.ref b { color: var(--text); }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 160px; }
.kbd-hint { font-size: .78rem; color: var(--muted); margin-top: 10px; text-align: center; }
@media (hover: none) { .kbd-hint, .opt .key { display: none; } }

.navdots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.navdots button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  font-size: .8rem; font-variant-numeric: tabular-nums;
}
.navdots button.answered { background: var(--accent-soft); border-color: var(--accent); }
.navdots button.current { outline: 2px solid var(--accent); outline-offset: 1px; font-weight: 800; }

/* Results */
.score { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center; }
.ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.verdict-badge { display: inline-block; font-weight: 800; padding: 4px 12px; border-radius: 99px; margin-bottom: 6px; }
.verdict-badge.pass { background: var(--ok-soft); color: var(--ok); }
.verdict-badge.fail { background: var(--bad-soft); color: var(--bad); }
.review { display: grid; gap: 10px; }
.review details { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px 14px; }
.review summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: flex-start; }
.review summary::-webkit-details-marker { display: none; }
.review summary .x { color: var(--bad); font-weight: 900; flex: none; }
.review .ans { margin: 10px 0 6px; padding-left: 0; list-style: none; display: grid; gap: 4px; font-size: .92rem; }
.review .ans li { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.review .ans li.c { background: var(--ok-soft); }
.review .ans li.y { outline: 2px solid var(--bad); outline-offset: -2px; }
.review .ans li.c.y { outline-color: var(--ok); }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

.footer { max-width: 760px; width: 100%; margin: 0 auto; padding: 18px 16px 28px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); }
.footer p { margin: 0 0 6px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; box-shadow: var(--shadow); z-index: 10; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Rechtsseiten */
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }
.footer-links { font-weight: 600; }
.legal { padding-top: 20px; }
.legal .back { display: inline-block; margin-bottom: 10px; font-weight: 600; color: var(--accent); text-decoration: none; }
.legal h2 { font-size: 1rem; margin: 22px 0 6px; }
.legal .card h2:first-child { margin-top: 0; }
.legal a { color: var(--accent); }

/* Regelwerk-Auswahl */
.rb-list { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .rb-list { grid-template-columns: repeat(3, 1fr); } }
.rb-card {
  position: relative; display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); transition: border-color .15s, background .15s;
}
.rb-card input { position: absolute; opacity: 0; pointer-events: none; }
.rb-card:hover { border-color: var(--accent); }
.rb-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rb-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.rb-check { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); margin-top: 1px; display: grid; place-items: center; background: var(--surface); }
.rb-card:has(input:checked) .rb-check { background: var(--accent); border-color: var(--accent); }
.rb-card:has(input:checked) .rb-check::after { content: "✓"; color: var(--on-accent); font-size: .8rem; font-weight: 900; }
.rb-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.rb-text small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.rb-card .cnt { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.rb-head { margin: 6px 0 -2px; font-size: .9rem; color: var(--muted); }
.rb-head:first-child { margin-top: 0; }
.rb-tag { background: var(--text); color: var(--bg); }

/* Sprachumschalter */
.top-actions { display: flex; align-items: center; gap: 8px; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.lang-switch button { background: none; border: 0; min-width: 40px; min-height: 40px; padding: 0 10px; font-size: .85rem; font-weight: 700; color: var(--muted); }
.lang-switch button + button { border-left: 1px solid var(--border); }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.lang-switch button:hover:not([aria-pressed="true"]) { color: var(--text); background: var(--surface); }
