:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --border: #dcd8cf;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --accent-soft: #e3efe8;
  --ok: #1f7a3d;
  --ok-soft: #e1f3e6;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --warn-soft: #fff4d6;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1e2227;
    --text: #e8eaed;
    --muted: #a1a8b0;
    --border: #353b42;
    --accent: #5cb98a;
    --accent-text: #0d1a13;
    --accent-soft: #1f3329;
    --ok: #6fd28f;
    --ok-soft: #173123;
    --bad: #ff8a80;
    --bad-soft: #3a1d1b;
    --warn-soft: #3a3218;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--text);
}
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 8px 0 12px; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
}
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.mode-card h2 { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-row.spread { justify-content: space-between; }

label.field { display: block; margin: 12px 0 4px; font-weight: 600; }
select, input[type=number] {
  width: 100%; min-height: 44px; padding: 8px 10px; font: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.check input { width: 20px; height: 20px; }

.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 6px 0 2px; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: .9rem; color: var(--muted); }

.q-chapter { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.q-text { font-size: 1.15rem; font-weight: 600; margin: 6px 0 4px; white-space: pre-line; }
.q-hint { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.q-image { display: block; max-width: 100%; height: auto; margin: 10px auto; border-radius: 8px; border: 1px solid var(--border); background: #fff; }

.options { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; user-select: none;
}
.opt input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.opt .letter { font-weight: 700; flex: none; width: 1.3em; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.missed { border-color: var(--ok); border-style: dashed; }
.opt.locked { cursor: default; }
.opt .tag { margin-left: auto; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.opt.correct .tag, .opt.missed .tag { color: var(--ok); }
.opt.wrong .tag { color: var(--bad); }

.feedback { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }

.navgrid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.navgrid button {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.navgrid button.answered { background: var(--accent-soft); border-color: var(--accent); }
.navgrid button.current { outline: 2px solid var(--accent); outline-offset: 1px; font-weight: 700; }
.navgrid button.ok { background: var(--ok-soft); border-color: var(--ok); }
.navgrid button.bad { background: var(--bad-soft); border-color: var(--bad); }

.result-big { font-size: 2.2rem; font-weight: 800; margin: 4px 0; }
.result-big.ok { color: var(--ok); }
.result-big.bad { color: var(--bad); }

table.stats { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.stats th, table.stats td { text-align: left; padding: 8px 4px; overflow-wrap: anywhere; border-bottom: 1px solid var(--border); }
table.stats td.num, table.stats th.num { text-align: right; white-space: nowrap; width: 1%; }

.notice { background: var(--warn-soft); border-radius: 10px; padding: 12px 14px; }

.footer { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; font-size: .85rem; color: var(--muted); }

/* Impressum und Datenschutz */
.legal h2 { font-size: 1.1rem; margin: 18px 0 6px; }
.legal .card h2:first-child { margin-top: 0; }
.legal p { line-height: 1.55; }
