:root {
    --bg: #f6f7f9;
    --flaeche: #fff;
    --rand: #e2e5ea;
    --text: #1c2024;
    --gedimmt: #61676e;
    --akzent: #2f5bd7;
    --akzent-weich: #eaefff;
    --gut: #1a7f4b;
    --gut-weich: #e6f5ec;
    --schlecht: #b3261e;
    --schlecht-weich: #fdecea;
    --radius: 10px;
    --schatten: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);
}

/* Dunkles Schema: einmal als Systemvorgabe, einmal per Schalter erzwungen. */
@media (prefers-color-scheme: dark) {
    :root:not([data-thema="hell"]) {
        --bg: #16181c;
        --flaeche: #1e2126;
        --rand: #31353c;
        --text: #e6e8eb;
        --gedimmt: #9ba1a9;
        --akzent: #7f9cf5;
        --akzent-weich: #22283a;
        --gut: #4ade80;
        --gut-weich: #16281d;
        --schlecht: #f87171;
        --schlecht-weich: #2a1a1a;
        --schatten: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 12px rgb(0 0 0 / 20%);
    }
}

:root[data-thema="dunkel"] {
    --bg: #16181c;
    --flaeche: #1e2126;
    --rand: #31353c;
    --text: #e6e8eb;
    --gedimmt: #9ba1a9;
    --akzent: #7f9cf5;
    --akzent-weich: #22283a;
    --gut: #4ade80;
    --gut-weich: #16281d;
    --schlecht: #f87171;
    --schlecht-weich: #2a1a1a;
    --schatten: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 12px rgb(0 0 0 / 20%);
}

:root[data-thema="hell"] { color-scheme: light; }
:root[data-thema="dunkel"] { color-scheme: dark; }

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    background: var(--flaeche);
    border-bottom: 1px solid var(--rand);
    position: sticky;
    top: 0;
    z-index: 10;
}

.marke { font-weight: 650; font-size: 1.05rem; text-decoration: none; color: var(--text); }
.kopf nav { display: flex; align-items: center; gap: 1rem; }
.kopf nav a { color: var(--gedimmt); text-decoration: none; font-size: 0.92rem; }
.kopf nav a:hover { color: var(--akzent); }

.thema-schalter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    background: var(--flaeche);
    color: var(--gedimmt);
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.thema-schalter:hover { border-color: var(--akzent); color: var(--akzent); }
.thema-schalter:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

main { max-width: 62rem; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.fuss { text-align: center; color: var(--gedimmt); font-size: 0.82rem; padding: 0 1rem 2.5rem; }

a { color: var(--akzent); }

h1 { font-size: 1.65rem; line-height: 1.25; margin: 0 0 0.35rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.08rem; margin: 1.5rem 0 0.4rem; }
p { margin: 0 0 0.9rem; }

.lead { color: var(--gedimmt); margin-bottom: 1.75rem; }
.zurueck { display: inline-block; color: var(--gedimmt); text-decoration: none; font-size: 0.88rem; margin-bottom: 1rem; }
.zurueck:hover { color: var(--akzent); }

/* Karten-Raster */
.raster { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }

.karte-flaeche {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--schatten);
}

a.karte-flaeche { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.karte-flaeche:hover { border-color: var(--akzent); transform: translateY(-2px); }

.karte-flaeche h2 { margin: 0 0 0.3rem; font-size: 1.12rem; }
.meta { color: var(--gedimmt); font-size: 0.85rem; }

/* Fortschrittsbalken */
.balken { height: 6px; background: var(--rand); border-radius: 99px; overflow: hidden; margin: 0.8rem 0 0.45rem; }
.balken > span { display: block; height: 100%; background: var(--akzent); border-radius: 99px; transition: width .3s; }

/* Modus-Buttons */
.modi { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0 2rem; }

.knopf {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    background: var(--flaeche);
    color: var(--text);
    text-decoration: none;
    font: inherit;
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.knopf:hover { border-color: var(--akzent); }
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.knopf.primaer:hover { filter: brightness(1.08); }
.knopf.gut { background: var(--gut-weich); border-color: var(--gut); color: var(--gut); }
.knopf.schlecht { background: var(--schlecht-weich); border-color: var(--schlecht); color: var(--schlecht); }
.knopf[disabled] { opacity: .5; cursor: default; }

.abzeichen {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 99px;
    font-size: 0.75rem;
    background: var(--akzent-weich);
    color: var(--akzent);
}

.abzeichen.fertig { background: var(--gut-weich); color: var(--gut); }

/* Kapitelliste */
.kapitelliste { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }

.kapitelliste a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
}

.kapitelliste a:hover { border-color: var(--akzent); }
.kapitelliste .nr { color: var(--gedimmt); font-variant-numeric: tabular-nums; font-size: 0.85rem; min-width: 1.6rem; }
.kapitelliste .wachs { flex: 1; }

/* Lesetext */
.lesetext { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 1.5rem 1.75rem; box-shadow: var(--schatten); }
.lesetext img { max-width: 100%; height: auto; border-radius: 6px; }
.lesetext figure { margin: 1.25rem 0; }
.lesetext figcaption { color: var(--gedimmt); font-size: 0.85rem; margin-top: 0.4rem; }
.lesetext blockquote { margin: 1rem 0; padding: 0.4rem 0 0.4rem 1rem; border-left: 3px solid var(--akzent); color: var(--gedimmt); }
.lesetext pre { background: var(--bg); padding: 0.9rem 1rem; border-radius: 6px; overflow-x: auto; border: 1px solid var(--rand); }
.lesetext code { font-size: 0.9em; background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; }
.lesetext pre code { background: none; padding: 0; }

.tabelle-wrap { overflow-x: auto; margin: 1.15rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { border: 1px solid var(--rand); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
th { background: var(--bg); font-weight: 600; }

/* Blättern */
.blaettern { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* Lernkarte */
.lernkarte {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 2.25rem 1.75rem;
    box-shadow: var(--schatten);
    min-height: 14rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.lernkarte .frage { font-size: 1.2rem; font-weight: 550; }
.lernkarte .antwort { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rand); text-align: left; }
.lernkarte .antwort table, .lernkarte .antwort ul, .lernkarte .antwort ol { text-align: left; }
[hidden] { display: none !important; }

.bewertung { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 1.25rem; }

/* Quiz */
.optionen { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 0.55rem; }

.optionen label {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.75rem 1rem;
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    cursor: pointer;
}

.optionen label:hover { border-color: var(--akzent); }
.optionen label.richtig { background: var(--gut-weich); border-color: var(--gut); }
.optionen label.falsch { background: var(--schlecht-weich); border-color: var(--schlecht); }
.optionen input { margin-top: 0.35rem; }

.rueckmeldung { margin: 1.25rem 0; padding: 0.9rem 1.15rem; border-radius: var(--radius); border: 1px solid var(--rand); background: var(--flaeche); }
.rueckmeldung.richtig { background: var(--gut-weich); border-color: var(--gut); }
.rueckmeldung.falsch { background: var(--schlecht-weich); border-color: var(--schlecht); }
.rueckmeldung strong { display: block; margin-bottom: 0.3rem; }

.leer { text-align: center; color: var(--gedimmt); padding: 3rem 1rem; }

/* Anmeldung */
.anmeldung { max-width: 22rem; margin: 3rem auto; }
.anmeldung h1 { text-align: center; }
.anmeldung .lead { text-align: center; }

.formular {
    display: grid;
    gap: 0.35rem;
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--schatten);
}

.formular label { font-size: 0.85rem; color: var(--gedimmt); }
.formular label + input { margin-bottom: 0.9rem; }

.formular input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.formular input:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; border-color: var(--akzent); }
.formular .knopf { justify-content: center; margin-top: 0.35rem; }

.kopf .benutzer { color: var(--gedimmt); font-size: 0.92rem; }
.kopf .abmelden { margin: 0; display: flex; }

.verweis-knopf {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 0.92rem;
    color: var(--gedimmt);
    cursor: pointer;
}

.verweis-knopf:hover { color: var(--akzent); }
.verweis-knopf:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; border-radius: 4px; }

.kennzahlen { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.kennzahlen li { font-size: 0.85rem; color: var(--gedimmt); }
.kennzahlen b { display: block; font-size: 1.35rem; color: var(--text); font-weight: 600; }
