:root {
  --bg: #f4f6f8;
  --flaeche: #ffffff;
  --rand: #d9dee4;
  --text: #1c2530;
  --text-leise: #5b6875;
  --primaer: #1f6feb;
  --primaer-dunkel: #1558bd;
  --richtig: #1a7f4b;
  --richtig-flaeche: #e6f5ec;
  --falsch: #c0392b;
  --falsch-flaeche: #fdecea;
  --warnung: #b7791f;
  --radius: 12px;
  --schatten: 0 1px 2px rgba(20, 30, 45, .06), 0 6px 20px rgba(20, 30, 45, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d;
    --flaeche: #1b222b;
    --rand: #2e3844;
    --text: #e8edf3;
    --text-leise: #9aa7b4;
    --primaer: #4c8dfb;
    --primaer-dunkel: #3b78e0;
    --richtig: #4ecb84;
    --richtig-flaeche: #16301f;
    --falsch: #f07b6d;
    --falsch-flaeche: #33191a;
    --warnung: #e0b357;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.5rem; line-height: 1.3; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--text-leise); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Kopfzeile ================= */
.kopf {
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
}

.kopf-inhalt {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--primaer);
  color: #fff;
  padding: .15rem .5rem;
  border-radius: 6px;
  font-size: .85rem;
}

.kopf-titel { font-weight: 600; }
.kopf-spacer { flex: 1; }
.kopf-status { color: var(--text-leise); font-size: .9rem; }

.inhalt {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.screen[hidden] { display: none; }

h1 { font-size: 1.5rem; }

.lead { color: var(--text-leise); max-width: 62ch; }
.lead-klein { color: var(--text-leise); font-size: .9rem; margin-top: .1rem; }

/* ---------- Karten ---------- */
.karten {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
  align-items: start;
}

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--schatten);
  margin-bottom: 1rem;
}

.karte h2 { margin-top: 0; }
.karte p { color: var(--text-leise); font-size: .93rem; }

.kennzahlen {
  margin: .8rem 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .25rem 1rem;
  font-size: .9rem;
}

.kennzahlen div { display: contents; }
.kennzahlen dt { color: var(--text-leise); }
.kennzahlen dd { margin: 0; font-weight: 600; text-align: right; }

.feld { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .8rem 0; font-size: .9rem; }

select {
  font: inherit;
  padding: .35rem .5rem;
  border-radius: 8px;
  border: 1px solid var(--rand);
  background: var(--flaeche);
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: .55rem 1rem;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}

.btn:focus-visible { outline: 3px solid var(--primaer); outline-offset: 2px; }
.btn-primaer { background: var(--primaer); color: #fff; }
.btn-primaer:hover { background: var(--primaer-dunkel); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--rand); }
.btn-ghost:hover { border-color: var(--primaer); color: var(--primaer); }
.btn-klein { padding: .35rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Filter ---------- */
.filter { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .4rem .9rem; margin: .6rem 0; }
.filter-aktionen { margin-bottom: .6rem; }

.check { display: flex; align-items: flex-start; gap: .5rem; font-size: .92rem; cursor: pointer; }
.check input { margin-top: .25rem; }

.optionen-schalter { border: 0; padding: 0; margin: .4rem 0 0; display: flex; flex-wrap: wrap; gap: 1rem; }
.optionen-schalter legend { padding: 0; }

.kapitel-label { display: flex; gap: .45rem; align-items: baseline; }
.kapitel-nr { font-weight: 700; color: var(--primaer); min-width: 1.2em; }
.kapitel-anzahl { color: var(--text-leise); font-size: .85rem; }

/* ---------- Lernzielfilter ---------- */
.lo-uebersicht { margin: .5rem 0 .8rem; }
.lo-uebersicht > summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.lo-filter { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.lo-kapitel { border: 1px solid var(--rand); border-radius: 8px; padding: .35rem .6rem; background: var(--bg); }
.lo-kapitel > summary { cursor: pointer; font-size: .88rem; font-weight: 600; }
.lo-boxen { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .15rem .8rem; margin-top: .4rem; font-size: .87rem; }
.feld-inline { display: flex; align-items: center; gap: .6rem; margin-top: .7rem; }
.feld-inline > span { font-weight: 600; }

/* ---------- Verlauf ---------- */
.verlauf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.verlauf-liste { list-style: none; margin: 0 0 .6rem; padding: 0; font-size: .9rem; }
.verlauf-liste li { display: flex; justify-content: space-between; gap: .75rem; padding: .3rem 0; border-bottom: 1px dashed var(--rand); }
.verlauf-leer { color: var(--text-leise); }

.bestanden { color: var(--richtig); font-weight: 700; }
.durchgefallen { color: var(--falsch); font-weight: 700; }

/* ---------- Quiz ---------- */
.quiz-kopf { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quiz-zaehler { color: var(--text-leise); font-size: .9rem; }

.badge {
  font-size: .78rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--rand);
  color: var(--text-leise);
}
.badge-modus { background: var(--primaer); border-color: var(--primaer); color: #fff; }
.badge-lo { background: transparent; border-color: var(--primaer); color: var(--primaer); }
.badge-herkunft { background: transparent; border-color: var(--rand); color: var(--text-leise); }
.badge-herkunft.entwurf { border-color: #b8912a; color: #8a6d1a; background: #fdf6e3; }

.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.knapp { color: var(--falsch); }

.frage-block {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--schatten);
}

.frage-text { font-size: 1.18rem; line-height: 1.45; margin: 0 0 .6rem; }
.frage-hinweis { color: var(--text-leise); font-size: .88rem; margin: 0 0 .9rem; }

.abbildung {
  background: var(--bg);
  border: 1px dashed var(--rand);
  border-radius: 8px;
  padding: .8rem .9rem;
  font-size: .88rem;
  color: var(--text-leise);
  margin: 0 0 1rem;
  white-space: pre-wrap;
}
.abbildung::before { content: "Abbildung: "; font-weight: 700; color: var(--text); }

.optionen { display: flex; flex-direction: column; gap: .5rem; }

.option {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  font: inherit;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 9px;
  padding: .6rem .75rem;
  cursor: pointer;
  color: var(--text);
}
.option:hover:not(:disabled) { border-color: var(--primaer); }
.option:focus-visible { outline: 3px solid var(--primaer); outline-offset: 2px; }
.option:disabled { cursor: default; }

.option-schluessel {
  font-weight: 700;
  min-width: 1.4em;
  color: var(--text-leise);
}

.option.gewaehlt { border-color: var(--primaer); background: color-mix(in srgb, var(--primaer) 10%, var(--flaeche)); }
.option.gewaehlt .option-schluessel { color: var(--primaer); }
.option.richtig { border-color: var(--richtig); background: var(--richtig-flaeche); }
.option.richtig .option-schluessel { color: var(--richtig); }
.option.falsch { border-color: var(--falsch); background: var(--falsch-flaeche); }
.option.falsch .option-schluessel { color: var(--falsch); }

.feedback { margin-top: 1rem; border-radius: 9px; padding: .8rem .9rem; font-size: .93rem; border: 1px solid var(--rand); }
.feedback.richtig { background: var(--richtig-flaeche); border-color: var(--richtig); }
.feedback.falsch { background: var(--falsch-flaeche); border-color: var(--falsch); }
.feedback h3 { margin: 0 0 .35rem; color: inherit; font-size: 1rem; }
.feedback p { margin: .25rem 0; }

.quiz-navigation { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; }

.navigator {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rand);
}

.navigator button {
  font: inherit;
  font-size: .82rem;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 7px;
  border: 1px solid var(--rand);
  background: var(--flaeche);
  color: var(--text);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.navigator button.aktuell { outline: 3px solid var(--primaer); outline-offset: 1px; }
.navigator button.beantwortet { background: color-mix(in srgb, var(--primaer) 18%, var(--flaeche)); border-color: var(--primaer); }
.navigator button.falsch { background: var(--falsch-flaeche); border-color: var(--falsch); }
.navigator button.richtig { background: var(--richtig-flaeche); border-color: var(--richtig); }

/* ---------- Ergebnis ---------- */
.ergebnis-kopf {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--schatten);
  margin-bottom: 1rem;
  text-align: center;
}
.ergebnis-kopf h1 { margin-bottom: .2rem; }
.ergebnis-prozent { font-size: 3rem; font-weight: 800; line-height: 1; margin: .3rem 0; font-variant-numeric: tabular-nums; }
.ergebnis-status { font-size: 1.1rem; font-weight: 700; }
.ergebnis-meta { color: var(--text-leise); font-size: .9rem; }

.themen-liste { list-style: none; margin: 0; padding: 0; }
.themen-liste li { padding: .45rem 0; border-bottom: 1px dashed var(--rand); }
.themen-kopf { display: flex; justify-content: space-between; gap: .5rem; font-size: .92rem; }
.balken { height: 7px; border-radius: 99px; background: var(--bg); border: 1px solid var(--rand); margin-top: .35rem; overflow: hidden; }
.balken span { display: block; height: 100%; background: var(--primaer); }
.balken.gut span { background: var(--richtig); }
.balken.schlecht span { background: var(--falsch); }

.fehler-liste { display: flex; flex-direction: column; gap: .9rem; }
.fehler-eintrag { border-left: 3px solid var(--falsch); padding-left: .8rem; }
.fehler-eintrag h3 { color: var(--text); font-size: .95rem; margin: 0 0 .3rem; }
.fehler-eintrag .zeile { font-size: .89rem; margin: .15rem 0; }
.marke-richtig { color: var(--richtig); font-weight: 700; }
.marke-falsch { color: var(--falsch); font-weight: 700; }
.begruendung { color: var(--text-leise); font-size: .87rem; margin-top: .35rem; }

.ergebnis-aktionen { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }

/* ---------- Fuß ---------- */
.kopf-status, .fuss { font-size: .85rem; }
.fuss { max-width: 900px; margin: 0 auto; padding: 0 1rem 2rem; color: var(--text-leise); }
