/*
 * Gemeinsame Tokens und Komponenten aller Lern-Apps — mobile-first (360 px), Systemschriften, keine externen Ressourcen.
 * Einmal im Monorepo, einmal ausgeliefert (/kern/css/stil.css). Die Fachfarbe (--farbe-primaer, --farbe-primaer-dunkel)
 * setzt das Layout aus der Tabelle lib/fachfarben.js; App-spezifische Regeln gehören in src/<app>/css/<app>.css.
 */
:root {
  --farbe-text: #1a1a1a;
  --farbe-hintergrund: #ffffff;
  --farbe-flaeche: #f3f4f6;
  --farbe-rand: #d1d5db;
  --farbe-akzent: #b45309;
  --farbe-richtig: #166534;
  --farbe-richtig-hell: #dcfce7;
  --farbe-falsch: #b91c1c;
  --farbe-falsch-hell: #fee2e2;
  --farbe-hinweis-hell: #fef3c7;
  --farbe-fokus: #f59e0b;
  --abstand: 1rem;
  --radius: 0.5rem;
}

* { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--farbe-text);
  background: var(--farbe-hintergrund);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--farbe-primaer);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

header.kopf {
  background: var(--farbe-primaer-dunkel);
  color: #fff;
  padding: 0.75rem var(--abstand);
}
header.kopf a { color: #fff; }
header.kopf .marke {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0.4rem;
}
nav.themen ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  font-size: 0.9rem;
}
nav.themen a { text-decoration: none; padding: 0.15rem 0.35rem; border-radius: 0.25rem; }
nav.themen a:hover, nav.themen a:focus { text-decoration: underline; }
nav.themen a[aria-current="page"] { background: #fff; color: var(--farbe-primaer-dunkel); font-weight: 600; }
/* Nummer als Plakette: trennt die Ziffer sichtbar vom Menütext (Formeln wie (a+b)²); Screenreader lesen "2 (a+b)²". */
nav.themen .nummer {
  display: inline-block;
  min-width: 1.45em;
  padding: 0 0.3em;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  vertical-align: middle;
  margin-right: 0.1em;
}
nav.themen a[aria-current="page"] .nummer {
  background: var(--farbe-primaer-dunkel);
  border-color: var(--farbe-primaer-dunkel);
  color: #fff;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: var(--abstand);
}

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0.5rem 0 0.75rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 0.5rem; padding-top: 0.25rem; border-top: 2px solid var(--farbe-flaeche); }
h3 { font-size: 1.1rem; margin: 1.25rem 0 0.4rem; }
p { margin: 0 0 0.9rem; }
a { color: var(--farbe-primaer); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--farbe-fokus);
  outline-offset: 2px;
}

.formel {
  background: var(--farbe-flaeche);
  border-left: 4px solid var(--farbe-primaer);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 1.15rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.formel code, .rechenweg code, code {
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  font-size: 0.95em;
}
.merke { background: var(--farbe-hinweis-hell); padding: 0.6rem 0.9rem; border-radius: var(--radius); }

table { border-collapse: collapse; width: 100%; margin: 0.75rem 0; }
/* Breite Tabellen scrollen in ihrem Rahmen seitlich, die Seite selbst bleibt 360 px breit (L-015). */
.tabelle-rahmen { overflow-x: auto; max-width: 100%; }
.tabelle-rahmen > table { margin: 0.75rem 0; }
th, td { border: 1px solid var(--farbe-rand); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
th { background: var(--farbe-flaeche); }
td.zahl, th.zahl { text-align: right; white-space: nowrap; }

svg.vis { width: 100%; height: auto; max-width: 30rem; display: block; margin: 0.5rem 0; }
.vis-beschriftung { font-size: 0.9rem; color: #374151; }
.aufgabe-bild { margin: 0.5rem 0 1rem; }
.bild-status { margin: 0.25rem 0; font-weight: 600; }
.bild-status:empty { margin: 0; }
.erklaerung > summary { cursor: pointer; font-weight: 600; padding: 0.5rem 0; color: var(--farbe-primaer); }
/* Deep Link mit #uebung: die zugeklappte Erklärung bleibt über der Übung sichtbar, auch wenn der Browser zum Anker springt. */
.erklaerung:not([open]) + #uebung { scroll-margin-top: 5rem; }

/* Übung */
.trainer { border: 1px solid var(--farbe-rand); border-radius: var(--radius); padding: var(--abstand); margin-top: 0.75rem; }
.aufgabe-text { font-size: 1.1rem; font-weight: 500; }
.felder { display: grid; gap: 0.75rem; margin-bottom: 0.75rem; }
.feld label { display: block; font-weight: 600; margin-bottom: 0.2rem; }
.feld input[type="text"], .feld select {
  font: inherit;
  width: 100%;
  max-width: 16rem;
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--farbe-rand);
  border-radius: var(--radius);
  background: #fff;
  color: var(--farbe-text);
}
.feld .eingabe { display: flex; align-items: center; gap: 0.4rem; }
.feld.richtig input, .feld.richtig select { border-color: var(--farbe-richtig); }
.feld.falsch input, .feld.falsch select { border-color: var(--farbe-falsch); }
.feld.hinweis input { border-color: var(--farbe-akzent); }
fieldset.feld { border: 1px solid var(--farbe-rand); border-radius: var(--radius); padding: 0.5rem 0.75rem; margin: 0; }
fieldset.feld legend { font-weight: 600; padding: 0 0.3rem; }
fieldset.feld label { font-weight: 400; display: flex; gap: 0.5rem; align-items: baseline; margin: 0.35rem 0; }
table.feldtabelle td input { max-width: 9rem; }
.eingabe-hinweis { display: block; font-size: 0.85rem; color: #4b5563; margin-top: 0.2rem; }
.eingabe-vorschau { display: block; font-size: 0.9rem; color: var(--farbe-primaer-dunkel); font-weight: 600; margin-top: 0.2rem; }
.eingabe-vorschau:empty { display: none; }

.aktionen { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
button, .knopf {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--farbe-primaer);
  background: #fff;
  color: var(--farbe-primaer);
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button:disabled { opacity: 0.5; cursor: default; }
button.primaer, .knopf.primaer { background: var(--farbe-primaer); color: #fff; }
button:hover, .knopf:hover { background: var(--farbe-primaer-dunkel); color: #fff; border-color: var(--farbe-primaer-dunkel); }

.feedback { min-height: 1.5rem; padding: 0.6rem 0.9rem; border-radius: var(--radius); font-weight: 500; }
.feedback:empty { padding: 0; }
.feedback.richtig { background: var(--farbe-richtig-hell); color: var(--farbe-richtig); }
.feedback.falsch { background: var(--farbe-falsch-hell); color: var(--farbe-falsch); }
.feedback.hinweis { background: var(--farbe-hinweis-hell); color: #78350f; }
.tipp-text { background: var(--farbe-hinweis-hell); padding: 0.6rem 0.9rem; border-radius: var(--radius); margin-top: 0.5rem; }
.loesung-text { background: var(--farbe-flaeche); padding: 0.6rem 0.9rem; border-radius: var(--radius); margin-top: 0.5rem; }
.loesung-text ol { margin: 0.25rem 0 0 1.25rem; padding: 0; }
.zaehler { margin-top: 0.75rem; font-size: 0.95rem; }
.aufgabenlink { font-size: 0.85rem; color: #4b5563; margin: 0.25rem 0 0; word-break: break-all; }
.aufgabenlink button { font-size: 0.8rem; padding: 0.15rem 0.6rem; margin-left: 0.5rem; }
[hidden] { display: none !important; }
.nur-vorlesen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
noscript p { background: var(--farbe-hinweis-hell); padding: 0.6rem 0.9rem; border-radius: var(--radius); }

/* Test und Schnelltest */
.test-stand { font-weight: 600; color: #4b5563; margin: -0.25rem 0 0.75rem; }
.test-stand:empty { margin: 0; }
table.ergebnis td:last-child { white-space: nowrap; width: 6.5rem; font-weight: 600; }
.stufe-S { color: var(--farbe-richtig); }
.stufe-Ü { color: var(--farbe-falsch); }
.stufe-T { color: var(--farbe-akzent); }
.ergebniszeile { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ergebniszeile input { flex: 1 1 14rem; font: inherit; padding: 0.5rem 0.6rem; border: 2px solid var(--farbe-rand); border-radius: var(--radius); background: var(--farbe-flaeche); color: var(--farbe-text); min-width: 0; }

/* Startseite */
#checkliste table.checkliste th, #checkliste table.checkliste td { padding: 0.45rem 0.4rem; }
#checkliste table.checkliste th:not(:first-child), #checkliste table.checkliste td:not(:first-child) { text-align: center; width: 2.9rem; font-size: 0.85rem; vertical-align: middle; line-height: 1.2; }
#checkliste table.checkliste th:last-child, #checkliste table.checkliste td:last-child { width: 2.2rem; padding: 0.45rem 0.15rem; font-weight: 700; }
#checkliste table.checkliste td:first-child { word-break: normal; overflow-wrap: anywhere; }
#checkliste table.checkliste input[type="radio"] { width: 1.25rem; height: 1.25rem; margin: 0; vertical-align: middle; cursor: pointer; }
.legende { font-size: 0.9rem; color: #4b5563; margin: 0.25rem 0 0; }
.legende:empty { margin: 0; }
.uebersicht { font-size: 0.95rem; }
.tutor { margin: 1.25rem 0; padding: 1rem; background: var(--farbe-flaeche); border-radius: var(--radius); }
.tutor h2 { margin-top: 0; border-top: 0; padding-top: 0; }
.tutor .fallback { font-size: 0.9rem; margin: 0.75rem 0 0; }

footer.fuss {
  margin-top: 2rem;
  padding: 1rem var(--abstand) 2rem;
  border-top: 1px solid var(--farbe-rand);
  font-size: 0.9rem;
  color: #374151;
  text-align: center;
}
footer.fuss .melden { margin: 0.5rem 0 0; font-size: 0.85rem; color: #4b5563; }
footer.fuss .melden a { color: inherit; }

@media (min-width: 40rem) {
  body { font-size: 1.125rem; }
  header.kopf { display: flex; align-items: baseline; gap: 1.5rem; }
  header.kopf .marke { margin-bottom: 0; }
  #checkliste table.checkliste th:not(:first-child), #checkliste table.checkliste td:not(:first-child) { width: 5.5rem; }
  #checkliste table.checkliste th:last-child, #checkliste table.checkliste td:last-child { width: 3.5rem; }
  .felder.nebeneinander { grid-template-columns: 1fr 1fr; }
}

/* Video-Karte (Zwei-Klick-Einbettung) */
.video-karte .video-platzhalter { border: 1px solid var(--farbe-rand); border-radius: var(--radius); padding: 0.75rem; max-width: 36rem; }
.video-bild { aspect-ratio: 16 / 9; background: #111827; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.video-play { width: 3.5rem; height: auto; }
.video-titel { font-weight: 600; margin: 0.6rem 0 0.2rem; }
.video-kanal { color: #4b5563; font-size: 0.95rem; margin: 0 0 0.4rem; }
.serlo-link p { margin: 0.5rem 0 0; }
.video-hinweis { font-size: 0.9rem; color: #4b5563; }
.video-merken { font-size: 0.95rem; margin: 0.25rem 0 0; }
.video-merken label { cursor: pointer; }
.video-rahmen { aspect-ratio: 16 / 9; max-width: 36rem; border-radius: var(--radius); overflow: hidden; background: #111827; }
.video-rahmen iframe { width: 100%; height: 100%; border: 0; display: block; }
button.video-link { border: 0; background: none; padding: 0; min-height: 0; font-weight: 500; text-decoration: underline; color: var(--farbe-primaer); }
button.video-link:hover { background: none; color: var(--farbe-primaer-dunkel); }
.video-notiz { font-size: 0.9rem; }
div.video-karte h3 { margin: 0.75rem 0 0.4rem; font-size: 1.05rem; }
div.video-karte + div.video-karte { margin-top: 1rem; }

/* Übersicht aller Apps (Wurzel des Monorepos) */
.app-liste { list-style: none; padding: 0; display: grid; gap: var(--abstand); }
.app-liste li { border: 1px solid var(--farbe-rand); border-left: 0.5rem solid var(--farbe-fach, var(--farbe-primaer)); border-radius: var(--radius); padding: 0.75rem 1rem; }
.app-liste h3 { margin: 0 0 0.25rem; }
.app-liste p { margin: 0.25rem 0; }

/* "Zurück zu Claude" (nur mit ?von=tutor, ADR-021) */
.zurueck { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.75rem 0 0; }
.zurueck-zeile { flex: 1 1 14rem; font: inherit; padding: 0.5rem 0.6rem; border: 2px solid var(--farbe-rand); border-radius: var(--radius); background: var(--farbe-flaeche); color: var(--farbe-text); min-width: 0; }
.zurueck-meldung { flex-basis: 100%; margin: 0.25rem 0 0; font-weight: 500; }
.zurueck-meldung:empty { margin: 0; }
