/* KI-Kurs: gemeinsames Stylesheet. Zuerst für 390 px gebaut, hell und dunkel über prefers-color-scheme. */
:root {
  --papier: #f7f5f0;
  --flaeche: #ffffff;
  --flaeche-2: #efece4;
  --linie: #d9d4c7;
  --text: #1f2328;
  --text-2: #565d66;
  --akzent: #0d6b6e;
  --akzent-2: #9a5a12;
  --akzent-weich: #e1efee;
  --warn: #a2341f;
  --warn-weich: #f6e4df;
  --gut: #2f6b2a;
  --gut-weich: #e3efdf;
  --mac: #3d4f8a;
  --mac-weich: #e5e8f3;
  --spark: #48730f; /* 4,8:1 auf --spark-weich (vorher #4d7a12 mit 4,36:1) */
  --spark-weich: #e8f0dc;
  --code-bg: #1d2126;
  --code-text: #e6e1d6;
  --sv-fill: #ffffff;
  --sv-fill-2: #efece4;
  --schrift-text: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --schrift-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --schrift-code: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --breite: 44rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --papier: #121417;
    --flaeche: #1a1d21;
    --flaeche-2: #23272c;
    --linie: #343a41;
    --text: #e4e2dc;
    --text-2: #a3a8ae;
    --akzent: #5cc2bd;
    --akzent-2: #e3a65a;
    --akzent-weich: #183433;
    --warn: #f08a72;
    --warn-weich: #3a221d;
    --gut: #8fcf86;
    --gut-weich: #1f3320;
    --mac: #a9b8f0;
    --mac-weich: #23283d;
    --spark: #a8d66a;
    --spark-weich: #26301a;
    --code-bg: #0b0d0f;
    --code-text: #e6e1d6;
    --sv-fill: #1a1d21;
    --sv-fill-2: #23272c;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--text);
  font: 1.0625rem/1.65 var(--schrift-text);
  overflow-wrap: break-word;
  hyphens: auto;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--akzent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; border-radius: 3px; }

/* Kopfleiste */
.kopf {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--papier) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--linie);
  font-family: var(--schrift-ui);
}
.kopf-innen {
  max-width: 60rem; margin: 0 auto; padding: 0.55rem 1rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.kopf .marke { font-weight: 650; color: var(--text); text-decoration: none; font-size: 0.95rem; white-space: nowrap; }
.kopf .marke span { color: var(--akzent); }
.kopf .fortschritt { flex: 1; min-width: 3rem; height: 4px; background: var(--flaeche-2); border-radius: 2px; overflow: hidden; }
.kopf .fortschritt i { display: block; height: 100%; width: 0; background: var(--akzent); }
.kopf .fortschritt-text { font-size: 0.8rem; color: var(--text-2); white-space: nowrap; }
.inhalt-menue { position: relative; }
.inhalt-menue > summary {
  list-style: none; cursor: pointer; font-size: 0.9rem; padding: 0.3rem 0.65rem;
  border: 1px solid var(--linie); border-radius: 999px; background: var(--flaeche); white-space: nowrap;
}
.inhalt-menue > summary::-webkit-details-marker { display: none; }
.inhalt-menue[open] > summary { border-color: var(--akzent); }
.inhalt-menue nav {
  position: absolute; right: 0; top: calc(100% + 0.5rem);
  width: min(22rem, calc(100vw - 2rem)); max-height: 75vh; overflow-y: auto;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px;
  padding: 0.6rem 0.4rem; box-shadow: 0 12px 32px rgb(0 0 0 / 0.16);
}
.inhalt-menue nav p { margin: 0.6rem 0.7rem 0.2rem; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.inhalt-menue nav a { display: flex; gap: 0.5rem; padding: 0.3rem 0.7rem; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 0.9rem; line-height: 1.35; }
.inhalt-menue nav a:hover { background: var(--flaeche-2); }
.inhalt-menue nav a[aria-current] { background: var(--akzent-weich); }
.inhalt-menue nav a .nr { color: var(--text-2); min-width: 1.6rem; font-variant-numeric: tabular-nums; }
.gelesen-mark { margin-left: auto; color: var(--gut); visibility: hidden; }
.ist-gelesen .gelesen-mark { visibility: visible; }

/* Seite */
main { max-width: var(--breite); margin: 0 auto; padding: 1.5rem 1.1rem 3rem; }
.kapitel-kopf { margin: 1rem 0 2rem; }
.kapitel-kopf .teil { font-family: var(--schrift-ui); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--akzent-2); margin: 0; }
h1, h2, h3, h4 { font-family: var(--schrift-ui); line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 6vw, 2.4rem); margin: 0.3rem 0 0.6rem; font-weight: 720; }
h2 { font-size: 1.4rem; margin: 2.8rem 0 0.8rem; font-weight: 680; padding-top: 0.4rem; border-top: 1px solid var(--linie); }
h3 { font-size: 1.12rem; margin: 2rem 0 0.5rem; font-weight: 650; }
h4 { font-size: 1rem; margin: 1.4rem 0 0.4rem; }
.kapitel-kopf .unterzeile { font-size: 1.1rem; color: var(--text-2); margin: 0 0 0.8rem; }
.kapitel-kopf .meta { font-family: var(--schrift-ui); font-size: 0.85rem; color: var(--text-2); margin: 0; }
p, ul, ol, dl { margin: 0 0 1rem; }
li { margin: 0.25rem 0; }
li > ul, li > ol { margin: 0.25rem 0 0.25rem; }
strong { font-weight: 680; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: help; }
hr { border: 0; border-top: 1px solid var(--linie); margin: 2rem 0; }
.klein { font-size: 0.9rem; color: var(--text-2); }

/* Kapitel-Inhaltsübersicht */
.auf-dieser-seite { font-family: var(--schrift-ui); background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 0.8rem 1rem; margin: 0 0 2rem; }
.auf-dieser-seite summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.auf-dieser-seite ol { margin: 0.6rem 0 0; padding-left: 1.3rem; font-size: 0.92rem; }

/* Kästen: Farbe trägt die Überschrift, kein farbiger Seitenbalken */
.kasten, .lernziele, .einstieg {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px;
  padding: 0.95rem 1.1rem 0.3rem; margin: 1.5rem 0;
}
.kasten-titel {
  font-family: var(--schrift-ui); font-weight: 680; font-size: 0.82rem; letter-spacing: 0.05em;
  text-transform: uppercase; margin: 0 0 0.5rem; color: var(--akzent);
}
.einstieg { background: var(--flaeche-2); border-color: transparent; }
.einstieg .kasten-titel { color: var(--akzent-2); }
.lernziele .kasten-titel { color: var(--akzent); }
.kasten.merke { background: var(--akzent-weich); border-color: transparent; }
.kasten.merke .kasten-titel { color: var(--akzent); }
.kasten.warnung { background: var(--warn-weich); border-color: transparent; }
.kasten.warnung .kasten-titel { color: var(--warn); }
.kasten.uebung .kasten-titel { color: var(--gut); }
.kasten.beispiel .kasten-titel { color: var(--akzent-2); }
.kasten.video .kasten-titel { color: var(--akzent-2); }
.kasten.tybo .kasten-titel { color: var(--mac); }
.fassung { border-radius: 10px; padding: 0.75rem 0.9rem 0.2rem; margin: 0.9rem 0; }
.fassung-titel { font-family: var(--schrift-ui); font-weight: 680; font-size: 0.9rem; margin: 0 0 0.4rem; }
.fassung.mac { background: var(--mac-weich); }
.fassung.mac .fassung-titel { color: var(--mac); }
.fassung.spark { background: var(--spark-weich); }
.fassung.spark .fassung-titel { color: var(--spark); }
.marke-gemessen, .marke-doku, .marke-unbestaetigt {
  display: inline-block; font-family: var(--schrift-ui); font-size: 0.74rem; line-height: 1.3;
  padding: 0.12rem 0.5rem; border-radius: 999px; vertical-align: 0.1em; white-space: normal;
}
.marke-gemessen { background: var(--gut-weich); color: var(--gut); }
.marke-doku { background: var(--flaeche-2); color: var(--text-2); }
.marke-unbestaetigt { background: var(--warn-weich); color: var(--warn); }

/* Rechenweg */
.rechenweg { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 0.9rem 1.1rem 0.4rem; margin: 1.5rem 0; }
.rechenweg ol { padding-left: 1.3rem; }
.rechenweg li { margin: 0.5rem 0; }
.formel { font-family: var(--schrift-code); font-size: 0.92rem; background: var(--flaeche-2); padding: 0.1rem 0.35rem; border-radius: 5px; }
.formel-block { font-family: var(--schrift-code); font-size: 0.92rem; background: var(--flaeche-2); padding: 0.7rem 0.9rem; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; margin: 0 0 1rem; }

/* Irrtümer */
dl.irrtuemer dt { font-family: var(--schrift-ui); font-weight: 650; margin-top: 1rem; }
dl.irrtuemer dt::before { content: "Misconception: "; color: var(--warn); }
dl.irrtuemer dd { margin: 0.3rem 0 0 0; }
dl.irrtuemer dd::before { content: "Actually: "; font-family: var(--schrift-ui); font-weight: 650; color: var(--gut); }

/* Verständnisfragen */
details.frage { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; margin: 0.8rem 0; }
details.frage > summary { cursor: pointer; padding: 0.8rem 1rem; font-weight: 600; font-family: var(--schrift-ui); font-size: 0.98rem; line-height: 1.4; list-style-position: outside; }
details.frage > summary::marker { color: var(--akzent); }
details.frage[open] > summary { border-bottom: 1px solid var(--linie); }
details.frage > div { padding: 0.8rem 1rem 0.2rem; }

/* Tabellen */
table { border-collapse: collapse; width: 100%; margin: 1.2rem 0 1.5rem; font-family: var(--schrift-ui); font-size: 0.9rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--linie); }
th { font-weight: 650; background: var(--flaeche-2); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
caption { caption-side: bottom; text-align: left; font-size: 0.82rem; color: var(--text-2); padding-top: 0.4rem; }
@media (max-width: 720px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  th, td { min-width: 5.5rem; padding: 0.45rem 0.45rem; }
  th:first-child, td:first-child { min-width: 3.5rem; }
  th { hyphens: manual; }
  td code { overflow-wrap: anywhere; }
}

/* Code */
code { font-family: var(--schrift-code); font-size: 0.88em; background: var(--flaeche-2); padding: 0.08rem 0.3rem; border-radius: 4px; overflow-wrap: anywhere; hyphens: none; }
pre { background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: 0.85rem 1rem; overflow-x: auto; margin: 0 0 1.2rem; font-size: 0.85rem; line-height: 1.5; max-width: 100%; }
pre code { background: none; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; white-space: pre; }
pre .kommentar { color: #9aa39a; }
pre .ausgabe { color: #b9c7d6; }

/* Schaubilder */
figure.schaubild { margin: 1.8rem 0; }
figure.schaubild .flaeche-svg { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 0.8rem; overflow-x: auto; }
figure.schaubild svg { display: block; width: 100%; height: auto; min-width: 0; font-family: var(--schrift-ui); }
/* Ab Breite 560 px nicht beliebig groß werden lassen; schmale Bilder (viewBox 340) sonst mit riesiger Schrift */
figure.schaubild svg { max-width: 30rem; margin-inline: auto; }
@media (max-width: 720px) { figure.schaubild .flaeche-svg { padding: 0.6rem 0.5rem; } }
figcaption { font-family: var(--schrift-ui); font-size: 0.85rem; color: var(--text-2); margin-top: 0.5rem; line-height: 1.45; }
/* SVG-Klassen: Farben folgen dem Farbschema */
.sv-text { fill: var(--text); font-size: 15px; }
.sv-text-2 { fill: var(--text-2); font-size: 13px; }
.sv-titel { fill: var(--text); font-size: 16px; font-weight: 650; }
.sv-akzent-text { fill: var(--akzent); font-weight: 650; }
.sv-akzent2-text { fill: var(--akzent-2); font-weight: 650; }
.sv-warn-text { fill: var(--warn); font-weight: 650; }
.sv-box { fill: var(--sv-fill); stroke: var(--linie); stroke-width: 1.5; }
.sv-box-2 { fill: var(--sv-fill-2); stroke: var(--linie); stroke-width: 1.5; }
.sv-box-akzent { fill: var(--akzent-weich); stroke: var(--akzent); stroke-width: 1.5; }
.sv-box-akzent2 { fill: var(--flaeche-2); stroke: var(--akzent-2); stroke-width: 1.5; }
.sv-box-warn { fill: var(--warn-weich); stroke: var(--warn); stroke-width: 1.5; }
.sv-box-mac { fill: var(--mac-weich); stroke: var(--mac); stroke-width: 1.5; }
.sv-box-spark { fill: var(--spark-weich); stroke: var(--spark); stroke-width: 1.5; }
.sv-fuell-akzent { fill: var(--akzent); }
.sv-fuell-akzent2 { fill: var(--akzent-2); }
.sv-fuell-warn { fill: var(--warn); }
.sv-fuell-gut { fill: var(--gut); }
.sv-fuell-mac { fill: var(--mac); }
.sv-fuell-spark { fill: var(--spark); }
.sv-fuell-leise { fill: var(--flaeche-2); }
.sv-fuell-grau { fill: var(--text-2); }
.sv-linie { stroke: var(--text-2); stroke-width: 1.5; fill: none; }
.sv-linie-akzent { stroke: var(--akzent); stroke-width: 2; fill: none; }
.sv-linie-akzent2 { stroke: var(--akzent-2); stroke-width: 2; fill: none; }
.sv-linie-warn { stroke: var(--warn); stroke-width: 2; fill: none; }
.sv-gestrichelt { stroke-dasharray: 5 4; }
.sv-pfeilspitze { fill: var(--text-2); }
.sv-pfeilspitze-akzent { fill: var(--akzent); }
.sv-pfeilspitze-warn { fill: var(--warn); }
.sv-pfeilspitze-gut { fill: var(--gut); }
.sv-box-gut { fill: var(--gut-weich); stroke: var(--gut); stroke-width: 1.5; }
.sv-gut-text { fill: var(--gut); font-weight: 650; }
.sv-linie-gut { stroke: var(--gut); stroke-width: 2; fill: none; }
.sv-mac-text { fill: var(--mac); font-weight: 650; }
.sv-spark-text { fill: var(--spark); font-weight: 650; }
.sv-invers { fill: var(--flaeche); font-weight: 700; }
.sv-mono { font-family: var(--schrift-code); font-size: 13px; }
.sv-linie-duenn { stroke: var(--linie); stroke-width: 1; fill: none; }
.sv-leer { fill: none; stroke: var(--text-2); stroke-width: 1.2; stroke-dasharray: 4 3; }

/* Werkzeuge (Speicherrechner, Quiz) */
.werkzeug { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 1rem 1.1rem; margin: 1.5rem 0; font-family: var(--schrift-ui); }
.werkzeug label { display: block; font-size: 0.9rem; font-weight: 600; margin: 0.7rem 0 0.25rem; }
.werkzeug input, .werkzeug select {
  width: 100%; font: inherit; font-size: 1rem; padding: 0.5rem 0.6rem; border-radius: 8px;
  border: 1px solid var(--linie); background: var(--papier); color: var(--text);
}
.werkzeug .zeile { display: grid; grid-template-columns: 1fr; gap: 0 0.8rem; }
@media (min-width: 560px) { .werkzeug .zeile { grid-template-columns: 1fr 1fr; } }
.werkzeug output { display: block; margin-top: 1rem; padding: 0.8rem 0.9rem; border-radius: 10px; background: var(--akzent-weich); font-size: 0.95rem; line-height: 1.55; }
.werkzeug output strong { font-size: 1.1rem; }
.balken { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--flaeche-2); margin: 0.6rem 0 0.3rem; }
.balken span { display: block; height: 100%; }
.knopf {
  font-family: var(--schrift-ui); font-size: 0.95rem; font-weight: 600; cursor: pointer;
  padding: 0.55rem 1rem; border-radius: 999px; border: 1px solid var(--akzent);
  background: var(--akzent); color: var(--papier);
}
.knopf.leise { background: transparent; color: var(--akzent); }
.quiz-frage { border-top: 1px solid var(--linie); padding-top: 1rem; margin-top: 1rem; }
.quiz-frage fieldset { border: 0; padding: 0; margin: 0; }
.quiz-frage legend { font-weight: 650; margin-bottom: 0.4rem; font-family: var(--schrift-ui); }
.quiz-frage label { display: flex; gap: 0.55rem; align-items: flex-start; font-weight: 400; font-size: 0.98rem; margin: 0.35rem 0; cursor: pointer; }
.quiz-frage input[type=radio] { width: auto; margin-top: 0.3rem; flex: none; }
.quiz-frage .rueckmeldung { display: none; margin-top: 0.4rem; font-size: 0.92rem; }
.quiz-frage.richtig .rueckmeldung, .quiz-frage.falsch .rueckmeldung { display: block; }
.quiz-frage.richtig legend::after { content: "  correct"; color: var(--gut); font-size: 0.85rem; }
.quiz-frage.falsch legend::after { content: "  not yet"; color: var(--warn); font-size: 0.85rem; }

/* Fuß des Kapitels */
.gelesen-box { font-family: var(--schrift-ui); display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin: 2.5rem 0 1rem; padding: 1rem; border-radius: 12px; background: var(--flaeche-2); }
.gelesen-box p { margin: 0; flex: 1 1 14rem; font-size: 0.92rem; color: var(--text-2); }
.blaettern { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 1.5rem 0 0; font-family: var(--schrift-ui); }
.blaettern a { display: block; padding: 0.75rem 0.9rem; border: 1px solid var(--linie); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--flaeche); line-height: 1.35; font-size: 0.92rem; }
.blaettern a:hover { border-color: var(--akzent); }
.blaettern small { display: block; color: var(--text-2); font-size: 0.78rem; margin-bottom: 0.15rem; }
.blaettern .weiter { text-align: right; grid-column: 2; }
footer.fuss { max-width: var(--breite); margin: 0 auto; padding: 1.5rem 1.1rem 3rem; font-family: var(--schrift-ui); font-size: 0.8rem; color: var(--text-2); border-top: 1px solid var(--linie); }

/* Karten (Anhang A5) */
.karten { display: grid; grid-template-columns: 1fr; gap: 0.8rem; margin: 1rem 0 1.5rem; }
@media (min-width: 720px) { .karten { grid-template-columns: 1fr 1fr; } }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 0.8rem 1rem 0.2rem; font-size: 0.95rem; line-height: 1.5; }
.karte p { margin: 0 0 0.6rem; }
.karte-titel { font-family: var(--schrift-ui); font-weight: 650; }
.karte-label { display: block; font-family: var(--schrift-ui); font-size: 0.75rem; font-weight: 680; letter-spacing: 0.05em; text-transform: uppercase; }
.karte-label.spark { color: var(--spark); }
.karte-label.mac { color: var(--mac); }

/* Startseite */
.start-kopf { padding: 1.5rem 0 0.5rem; }
.vorzeile { font-family: var(--schrift-ui); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--akzent-2); margin: 0; }
a.knopf { text-decoration: none; display: inline-block; }
.start-kopf h1 { font-size: clamp(2rem, 8vw, 3rem); line-height: 1.1; }
.start-kopf .unterzeile { font-size: 1.15rem; color: var(--text-2); max-width: 36rem; }
.pfade { display: grid; grid-template-columns: 1fr; gap: 0.8rem; margin: 1.2rem 0 2rem; }
@media (min-width: 640px) { .pfade { grid-template-columns: repeat(3, 1fr); } }
.pfad { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 0.9rem 1rem 0.3rem; font-family: var(--schrift-ui); font-size: 0.9rem; line-height: 1.5; }
.pfad h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.teil-liste { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.teil-liste li { margin: 0; }
.teil-liste a { display: grid; grid-template-columns: 2.3rem 1fr auto; gap: 0.2rem 0.6rem; align-items: baseline; padding: 0.75rem 0.4rem; border-bottom: 1px solid var(--linie); text-decoration: none; color: var(--text); }
.teil-liste a:hover { background: var(--flaeche); }
.teil-liste .nr { font-family: var(--schrift-ui); font-weight: 700; color: var(--akzent); font-variant-numeric: tabular-nums; }
.teil-liste .titel { font-family: var(--schrift-ui); font-weight: 620; }
.teil-liste .kurz { grid-column: 2 / 4; font-size: 0.92rem; color: var(--text-2); line-height: 1.45; }
.teil-liste .gelesen-mark { font-family: var(--schrift-ui); font-size: 0.8rem; }
.teil-ueberschrift { font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--akzent-2); border-top: 0; margin: 2.2rem 0 0.3rem; padding: 0; }

@media print {
  .kopf, .blaettern, .gelesen-box, .inhalt-menue { display: none; }
  details.frage { break-inside: avoid; }
  body { background: #fff; color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
