/* Ein Farbton je Kurs (--h, aus data.course.hue), Töne nur über L und C abgeleitet wie in den
   Büchern: Marke oklch(0.52 0.12 H), heller Grund oklch(0.95 0.03 H), Akzent dunkel oklch(0.75 0.12 H).
   Rot und Grün sind hier Signalfarben für richtig/falsch, nie Marke.
   Im Stil des Logos (web/logo.svg): flach, kräftige Formen, Lila wie der Esel, Aprikose wie die Brücke.
   Planken (Antwortknöpfe, Karten, Fortschritt) haben eine dicke Unterkante wie die Brüstung. */
:root {
  --h: 295;
  --brand: oklch(0.52 0.12 var(--h));
  --brand-ink: #fff;
  --tint: oklch(0.95 0.03 var(--h));
  --tint-strong: oklch(0.9 0.05 var(--h));
  --bg: oklch(0.985 0.005 var(--h));
  --panel: #fff;
  --ink: oklch(0.25 0.02 var(--h));
  --muted: oklch(0.5 0.02 var(--h));
  --line: oklch(0.9 0.01 var(--h));
  --right: oklch(0.52 0.12 150);
  --right-tint: oklch(0.95 0.03 150);
  --wrong: oklch(0.52 0.15 25);
  --wrong-tint: oklch(0.95 0.03 25);
  --apricot: oklch(0.74 0.13 52);
  --apricot-ink: oklch(0.3 0.06 52);
  --apricot-tint: oklch(0.95 0.035 60);
  --apricot-mark: oklch(0.62 0.14 50); /* Schwierigkeitspunkte: mindestens 3:1 auf Weiß, --apricot hat nur 2,4:1 */
  /* Rand der Planken: mindestens 3:1 gegen Weiß, Grund und den getönten Kartengrund (WCAG 1.4.11); bis
     0.12.0 waren es 30 % Marke, also 2:1 */
  --plank: color-mix(in oklch, var(--brand) 70%, var(--line));
  --radius: 1.1rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: oklch(0.75 0.12 var(--h));
    --brand-ink: oklch(0.2 0.03 var(--h));
    --tint: oklch(0.28 0.04 var(--h));
    --tint-strong: oklch(0.34 0.06 var(--h));
    --bg: oklch(0.18 0.015 var(--h));
    --panel: oklch(0.23 0.02 var(--h));
    --ink: oklch(0.93 0.01 var(--h));
    --muted: oklch(0.72 0.02 var(--h));
    --line: oklch(0.32 0.02 var(--h));
    --right: oklch(0.75 0.12 150);
    --right-tint: oklch(0.28 0.04 150);
    --wrong: oklch(0.75 0.12 25);
    --wrong-tint: oklch(0.28 0.04 25);
    --apricot: oklch(0.8 0.11 55);
    --apricot-ink: oklch(0.22 0.04 52);
    --apricot-tint: oklch(0.3 0.04 55);
    --apricot-mark: var(--apricot);
    --plank: color-mix(in oklch, var(--brand) 55%, var(--line));
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 100%/1.5 var(--font); /* 100 %: die im Browser eingestellte Schriftgröße gilt */
}
a { color: var(--brand); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 4px solid var(--apricot-tint);
}
/* Die Unterkante der Kopfzeile ist die Brücke: je Antwort eine Planke, richtig in Aprikose, falsch rot,
   die aktuelle Frage lila. */
.planks { position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; display: flex; gap: 2px; }
.planks[hidden] { display: none; }
.planks span { flex: 1; background: transparent; transition: background-color 0.25s; }
.planks span.r { background: var(--apricot); }
.planks span.w { background: var(--wrong); }
.planks span.cur { background: var(--brand); }
.topbar .home { display: inline-flex; align-items: center; gap: 0.4rem; flex: none; font-weight: 800; text-decoration: none; letter-spacing: 0.01em; }
.topbar .home img { display: block; width: 2.1rem; height: auto; margin-block: -0.35rem; }
/* Am Telefon trägt das Logo allein den Namen; der Platz gehört dem Kapitel. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 30rem) { .topbar .home span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
/* Ein h1 (die Seite braucht genau eine Überschrift erster Ordnung), das aussieht wie die Zeile davor. */
.topbar .title { flex: 1; min-width: 0; margin: 0; font: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { color: var(--muted); }
/* Auf Kapitelseiten ist das Kürzel der Weg zurück zur Kursseite, als Pfad vor dem h1; sieht aus wie ein Wort davor. */
.topbar .pfad { flex: none; }
.topbar .pfad ol { display: flex; margin: 0; padding: 0; list-style: none; }
.topbar .pfad + .title { margin-inline-start: -0.45rem; }
.topbar .pfad a { color: inherit; text-decoration: none; }
.topbar .pfad a:hover, .topbar .pfad a:focus-visible { text-decoration: underline; }
.topbar .progress { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.topbar button, .choices .choice, .linkbutton {
  font: inherit;
  cursor: pointer;
}
.topbar button {
  border: 2px solid var(--brand);
  background: transparent;
  color: var(--brand);
  border-radius: 999px;
  padding: 0.2rem 0.85rem;
  font-weight: 650;
}
.topbar button:hover { background: var(--tint); }
/* Karte der Inhalte: nur ein Symbol, gedämpft, damit es neben der Runde nicht stört. */
.topbar .karte-icon { flex: none; display: inline-flex; padding: 0.3rem; margin: -0.3rem -0.2rem; border-radius: 0.5rem; color: var(--muted); }
.topbar .karte-icon:hover, .topbar .karte-icon:focus-visible { color: var(--brand); background: var(--tint); }
.topbar .karte-icon svg { display: block; }

.staging {
  background: var(--apricot-tint);
  color: var(--ink);
  text-align: center;
  font-size: 0.85rem;
  padding: 0.35rem 1rem;
}

/* Chat: Kopf, Verlauf und Antworten teilen sich genau die Fensterhöhe. Nur der Verlauf scrollt, die
   Antworten stehen darunter und verdecken nie eine Frage. */
body.chat { height: 100dvh; min-height: 0; overflow: hidden; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
main#log {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.msg { display: flex; scroll-margin-top: 0.75rem; }
.msg.bot { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: min(36rem, 92%);
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.msg.bot .bubble { border-bottom-left-radius: 0.3rem; }
/* Die Frage ist eine Planke: kräftiger Rand, dicke Unterkante. */
.msg.bot .bubble:has(> .question) { border: 2px solid var(--plank); border-bottom-width: 4px; }
.msg.user .bubble {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: transparent;
  border-bottom-right-radius: 0.3rem;
}
.msg.user.right .bubble { box-shadow: inset 0 -3px 0 var(--right); }
.msg.user.wrong .bubble { box-shadow: inset 0 -3px 0 var(--wrong); }
.msg.aside .bubble { background: transparent; border-style: dashed; color: var(--muted); }
.msg.right .feedback .verdict { color: var(--right); }
.msg.wrong .feedback .verdict { color: var(--wrong); }
.msg.bot.right .bubble { background: var(--right-tint); border-color: transparent; }
.msg.bot.wrong .bubble { background: var(--wrong-tint); border-color: transparent; }
.msg.wide .bubble { max-width: 100%; width: 100%; }
.msg.error .bubble { border-color: var(--wrong); }
.bubble p { margin: 0.35rem 0; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul.topics { margin: 0.35rem 0 0; padding-inline-start: 1.25rem; }
.bubble ul.topics li { margin: 0.1rem 0; }
/* Kapitelwahl auf der Kursseite: zugeklappt, damit der Chat vorne bleibt; die Links stehen trotzdem im HTML. */
.kapitelwahl > summary { cursor: pointer; }
.kapitelwahl[open] > summary { margin-bottom: 0.35rem; }
.verdict { font-weight: 750; }
.verdict .inline, .verdict .inline p { display: inline; }
.feedback .explain { margin: 0.35rem 0; }
a.skript { display: inline-block; margin-top: 0.25rem; font-size: 0.9rem; }
/* Fundstelle ohne Link (Werk ohne HTML-Fassung) */
p.skript.quelle { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--muted); }

.question .meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.question .chapter { min-width: 0; }
.question .side { flex: none; display: inline-flex; align-items: center; gap: 0.5rem; }
.question .dots { flex: none; white-space: nowrap; color: var(--apricot-mark); letter-spacing: 0.1em; }
.question .chapter { font-weight: 600; }
/* Probleme melden: klein und leise, erst beim Zeigen deutlich (leise durch die Größe, nicht durch Blässe:
   mit opacity hatte das ? nur 2,6:1). */
a.report {
  flex: none; display: inline-grid; place-items: center;
  width: 1rem; height: 1rem; border: 1px solid currentColor; border-radius: 50%;
  font-size: 0.68rem; font-weight: 650; line-height: 1; text-decoration: none;
  color: var(--muted);
}
a.report:hover, a.report:focus-visible { color: var(--brand); }
.feedback .foot { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.feedback .foot a.report { align-self: center; margin-top: 0.25rem; }
.question .lead { font-weight: 650; margin: 0 0 0.15rem; }
.question .q { font-size: 1.04rem; }

pre {
  margin: 0.5rem 0;
  padding: 0.6rem 0.75rem;
  background: var(--tint);
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.4;
}
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }
/* Codezeilen brechen um, statt aus der Blase zu laufen; die Fortsetzung hängt 6 Zeichen tiefer als der
   Zeilenanfang (--i = Einzug der Zeile, aus tools/render.mjs), damit sie nicht wie ein Block aussieht. */
pre .ln {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-inline-start: calc((var(--i, 0) + 6) * 1ch);
  text-indent: calc((var(--i, 0) + 6) * -1ch);
}
pre .ln:empty::before { content: "\200b"; }
@media (max-width: 30rem) { pre { font-size: 0.8rem; padding: 0.5rem 0.6rem; } }
/* Was nicht umbrechen soll: kurze Formeln, kurzer Code (tools/render.mjs). .pt ist Text, der an einer
   Formel klebt (Satzzeichen, Klammer) und deshalb in ihr steht, aber wie der Text daneben aussieht. */
.nb { white-space: nowrap; }
.katex .pt { font-family: var(--font); font-size: calc(1em / 1.21); }
.msg.user .bubble code, .msg.user .bubble pre { background: color-mix(in oklch, var(--brand-ink) 18%, transparent); }
.katex-display { margin: 0.5rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.1rem 0; }

.choices {
  flex: none;
  max-height: 60dvh;
  overflow-y: auto;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 0.5rem;
  display: grid;
  gap: 0.45rem;
  border-top: 1px solid var(--line);
}
.choices:empty { border-top: 0; padding: 0; }
.choices:focus { outline: none; } /* nur Platzhalter des Fokus zwischen zwei Fragen (app.js, offer) */
.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  width: 100%;
  text-align: start;
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--plank);
  border-bottom-width: 4px;
  border-radius: 0.9rem;
  background: var(--panel);
  color: var(--ink);
  transition: transform 0.08s, border-color 0.08s, background-color 0.08s;
}
.choice:hover, .choice:focus-visible { background: var(--tint); border-color: var(--brand); outline: 2px solid transparent; transform: translateY(-1px); }
.choice:active { transform: translateY(1px); }
.choice:focus-visible { box-shadow: 0 0 0 3px var(--tint-strong); }
@media (prefers-reduced-motion: reduce) { .choice, .planks span { transition: none; } .choice:hover, .choice:active { transform: none; } }
.choice .key {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--apricot);
  color: var(--apricot-ink);
  font-weight: 750;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
  margin-top: 0.05rem;
}
.choice .label { flex: 1; min-width: 0; }
.choice .label p { margin: 0; }
.choice .label strong { display: block; }
.choice .label small { display: block; color: var(--muted); }
@media (hover: none) { .choice .key { display: none; } }

.summary h2 { margin: 0 0 0.25rem; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }
.summary .score { font-size: 1.05rem; }
.summary section { margin-top: 1rem; }
.summary h3 { margin: 0 0 0.35rem; font-size: 1rem; font-weight: 750; }
.summary h3 small { font-weight: 400; color: var(--muted); }
ul.concepts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
ul.concepts li { background: var(--tint); border-radius: 0.6rem; padding: 0.2rem 0.55rem; font-size: 0.94rem; }
ul.concepts li small, ul.concepts li .small { display: block; color: var(--muted); font-size: 0.82rem; }
.inline { display: inline; }
ul.concepts li small.tag { display: inline; margin-inline-start: 0.35rem; }
ul.concepts li .goal { font-weight: 600; }
.summary details > summary { cursor: pointer; }
.summary details > summary h3 { display: inline; }
.summary details[open] > summary { margin-bottom: 0.35rem; }
ul.concepts:has(a) { flex-direction: column; }
ul.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
ul.bars li { display: grid; grid-template-columns: 1fr auto 3.5rem; gap: 0.6rem; align-items: center; font-size: 0.88rem; line-height: 1.3; }
ul.bars .count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { display: flex; height: 0.55rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter .m { background: var(--right); }
.meter .l { background: color-mix(in oklch, var(--right) 45%, var(--line)); }
.meter .g { background: var(--wrong); margin-inline-start: auto; }

footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.5rem 1rem 1rem;
}
footer a { color: var(--muted); margin: 0 0.4rem; }
/* Im Chat steht die Zeile fest unter den Antworten und nimmt dem Verlauf keinen Platz. */
body.chat footer { flex: none; font-size: 0.72rem; line-height: 1.3; padding: 0.1rem 1rem calc(0.35rem + env(safe-area-inset-bottom)); }

/* Startseite und Textseiten */
.page { max-width: 42rem; margin: 0 auto; padding: 1.5rem 1rem 2rem; flex: 1; width: 100%; }
.page h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.015em; line-height: 1.2; margin: 0.5rem 0 1rem; }
.page h2 { font-size: 1.2rem; font-weight: 750; margin: 1.75rem 0 0.5rem; }
/* Unter jeder Zwischenüberschrift eine kleine Planke. */
.page h2::after { content: ""; display: block; width: 2.5rem; height: 4px; margin-top: 0.3rem; border-radius: 2px; background: var(--apricot); }
.hero { display: flex; align-items: center; gap: 1.25rem; margin: 0.5rem 0 1rem; }
.hero img { flex: none; width: 7.5rem; height: auto; }
.hero h1 { margin: 0; }
.hero .unterzeile { margin: 0.25rem 0 0; font-size: 1.15rem; color: var(--muted); }
@media (max-width: 30rem) { .hero { flex-direction: column; align-items: flex-start; gap: 0.5rem; } .hero img { width: 6rem; } }
.cards { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.cards a {
  display: block;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 2px solid var(--plank);
  border-bottom: 5px solid var(--apricot);
  background: var(--panel);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.08s, border-color 0.08s;
}
.cards a:hover, .cards a:focus-visible { border-color: var(--brand); border-bottom-color: var(--apricot); transform: translateY(-1px); }
.cards a strong { color: var(--brand); font-weight: 800; }
.cards a span { display: block; color: var(--muted); font-size: 0.92rem; }
.cards li { display: grid; gap: 0.4rem; }
.cards a.karte-link { padding: 0.55rem 1.1rem; border-bottom-width: 3px; border-bottom-color: var(--plank); font-size: 0.95rem; }
.cards a.karte-link strong { font-weight: 700; }
.cards a.karte-link strong::after { content: " →"; content: " →" / ""; } /* Pfeil nur Schmuck, wird nicht vorgelesen */
