/* baimaisai — Design-Token
   Stand 19.11.2026. Abgeleitet aus 07_Company/02_Brand/baimaisai.md (Farbstand 06.08.2026)
   und den Werten der Kurs-App. Maßgeblich ist DESIGN.md im selben Ordner.
   Hell ist Standard. Dunkel greift über das System oder über data-theme="dark";
   data-theme="light" erzwingt Hell.
   Alle Text-Paare sind nachgemessen (WCAG 2.2, Stufe AA): Text mindestens 4,5:1,
   Ränder von Eingabefeldern und Fokusring mindestens 3:1. Werte in DESIGN.md. */

:root {
  color-scheme: light;

  /* Flächen */
  --bg: #FBF8F1;        /* Seitengrund, warm getönt, nie reinweiß */
  --flaeche: #F5EFE3;   /* ruhige Fläche, Sektionswechsel */
  --karte: #FFFFFF;     /* Karte, Eingabefeld */

  /* Linien */
  --linie: #EAE1CE;     /* Trennlinie, nur Schmuck */
  --rand: #948771;      /* Rand von Eingabefeldern, 3,1:1 und mehr */

  /* Text */
  --text: #171310;
  --text2: #4A4238;
  --leise: #72685B;     /* 4,6:1 auf --gold-bg, mehr auf den übrigen hellen Flächen. Nicht auf Statusflächen. */

  /* Gold: Akzent, nie Fläche */
  --gold: #89621D;        /* Gold als Text und Fokusring auf Hell */
  --gold-hell: #CE9F4A;   /* Füllfarbe: Hauptknopf, Akzentlinie */
  --gold-heller: #E0BE72; /* Hauptknopf beim Überfahren */
  --gold-tief: #B8893A;   /* Hauptknopf beim Drücken */
  --gold-bg: #F6EBD3;     /* goldene Tönung für Hervorhebungen */
  --auf-gold: #171310;    /* Text auf goldener Füllung */
  --fokus: var(--gold);

  /* Status, jeweils Text auf eigener Tönung */
  --gruen: #2C6E49; --gruen-bg: #E3F1E8;
  --gelb: #8A6100;  --gelb-bg: #FBF0CC;
  --rot: #9E3322;   --rot-bg: #F8E3DE;

  /* Tiefe: geschichtet und warm getönt */
  --schatten: 0 1px 2px rgba(23, 19, 16, .08), 0 8px 24px rgba(138, 106, 31, .10);

  /* Schrift */
  --kopf: "Fraunces", Georgia, "Times New Roman", serif;
  --lauf: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Abstände im 4er-Raster */
  --a1: 4px; --a2: 8px; --a3: 12px; --a4: 16px; --a5: 24px; --a6: 32px; --a7: 48px; --a8: 64px;

  /* Rundungen */
  --r1: 6px; --r2: 10px; --r3: 12px; --r-rund: 999px;

  /* Maße */
  --spalte: 42rem;   /* Lesespalte: rund 75 bis 80 Zeichen je Zeile bei 17 px Inter */
  --tippe: 44px;     /* Mindesthöhe für Tippflächen */

  /* Bewegung: nur transform und opacity */
  --dauer-kurz: 120ms;
  --dauer: 200ms;
  --kurve: cubic-bezier(.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12100D; --flaeche: #1B1813; --karte: #211C16;
    --linie: #3A3226; --rand: #77674E;
    --text: #F5EFE3; --text2: #D8CFBE; --leise: #A89E8C;
    --gold: #E0BE72; --gold-hell: #CE9F4A; --gold-heller: #E0BE72; --gold-tief: #B8893A;
    --gold-bg: #2E2616; --auf-gold: #171310; --fokus: var(--gold-hell);
    --gruen: #8FD0A6; --gruen-bg: #17301F;
    --gelb: #EBCB6B;  --gelb-bg: #332A0E;
    --rot: #F0A493;   --rot-bg: #3A1A14;
    --schatten: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12100D; --flaeche: #1B1813; --karte: #211C16;
  --linie: #3A3226; --rand: #77674E;
  --text: #F5EFE3; --text2: #D8CFBE; --leise: #A89E8C;
  --gold: #E0BE72; --gold-hell: #CE9F4A; --gold-heller: #E0BE72; --gold-tief: #B8893A;
  --gold-bg: #2E2616; --auf-gold: #171310; --fokus: var(--gold-hell);
  --gruen: #8FD0A6; --gruen-bg: #17301F;
  --gelb: #EBCB6B;  --gelb-bg: #332A0E;
  --rot: #F0A493;   --rot-bg: #3A1A14;
  --schatten: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}
/* baimaisai — Bausteine für Einzeldatei-Apps (Kurs-App, Demos, Mandats-Oberflächen)
   Stand 19.11.2026. Braucht tokens.css davor. Klassen heißen wie in der Kurs-App.
   Regeln: Abstände nur aus dem 4er-Raster · jedes Bedienelement hat Überfahren,
   Drücken und sichtbaren Fokus · bewegt werden nur transform und opacity ·
   Farben nur über Token. */

/* ---- Grund ---- */
*, *::before, *::after { box-sizing: border-box }
html { scroll-behavior: smooth; overflow-x: clip }
body { margin: 0; overflow-x: clip; background: var(--bg); color: var(--text); font-family: var(--lauf); font-size: 17px; line-height: 1.65; -webkit-text-size-adjust: 100% }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg) }
img { max-width: 100% }
[hidden] { display: none !important }
h1, h2, h3 { font-family: var(--kopf); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0 }
h1 { font-size: clamp(1.7rem, 4.6vw, 2.4rem); letter-spacing: -0.02em }
h2 { font-size: 1.3rem; letter-spacing: -0.015em }
h3 { font-size: 1.08rem; font-family: var(--lauf); letter-spacing: 0 }
p { margin: 0; text-wrap: pretty }
a { color: var(--gold) }
button { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; border-radius: var(--r1) }

/* ---- Rahmen: Leiste, Lesespalte, Fuß ---- */
.leiste { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 1px solid var(--linie) }
.leiste-innen, .seite, .fuss-innen { max-width: var(--spalte); margin-inline: auto; padding-left: max(var(--a4), env(safe-area-inset-left, 0px)); padding-right: max(var(--a4), env(safe-area-inset-right, 0px)) }
.leiste-innen { display: flex; align-items: center; gap: var(--a3); padding-block: var(--a2); flex-wrap: wrap }
.marke { font-family: var(--kopf); font-weight: 600; font-size: 1.02rem; text-decoration: none; color: var(--text); margin-right: auto; min-width: 0; padding-block: var(--a2) }
.nav { display: flex; gap: var(--a1); flex-wrap: wrap }
.nav a { display: inline-flex; align-items: center; min-height: 40px; text-decoration: none; color: var(--text2); font-size: .9rem; font-weight: 500; padding: var(--a2) var(--a3); border-radius: var(--r-rund) }
.nav a:hover { background: var(--flaeche); color: var(--text) }
.nav a:active { background: var(--gold-bg) }
.nav a[aria-current] { background: var(--gold-bg); color: var(--gold) }
.seite { padding-block: var(--a5) 56px; display: flex; flex-direction: column; gap: var(--a5) }
.fuss { border-top: 1px solid var(--linie); color: var(--leise); font-size: .85rem }
.fuss-innen { padding-block: var(--a4) var(--a6); display: flex; flex-direction: column; gap: var(--a2) }

/* ---- Text-Bausteine ---- */
.kicker { font-size: .78rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--gold) }
.leise { color: var(--leise); font-size: .92rem; max-width: 35rem }   /* kleinere Schrift, schmalere Zeile: rund 75 Zeichen */
.stapel { display: flex; flex-direction: column; gap: var(--a3) }
.stapel-eng { display: flex; flex-direction: column; gap: var(--a2) }
.reihe { display: flex; flex-wrap: wrap; gap: var(--a2); align-items: center }
.marken span { font-size: .82rem; font-weight: 500; color: var(--text2); background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r-rund); padding: var(--a1) var(--a3) }
ul.punkte { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: var(--a2) }
/* Merksatz: goldene Linie oben wie bei Modul und Schaubild, kein Randstreifen */
.merksatz { border-top: 2px solid var(--gold-hell); padding-top: var(--a3); font-family: var(--kopf); font-size: 1.25rem; line-height: 1.35 }

/* ---- Knöpfe und Wahlflächen ---- */
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: var(--a2); border: 1px solid var(--gold-hell); background: var(--gold-hell); color: var(--auf-gold); font-weight: 600; border-radius: var(--r2); padding: var(--a3) var(--a4); cursor: pointer; text-decoration: none; min-height: var(--tippe); transition: transform var(--dauer-kurz) var(--kurve) }
.knopf:hover { background: var(--gold-heller); border-color: var(--gold-heller); transform: translateY(-1px) }
.knopf:active { background: var(--gold-tief); border-color: var(--gold-tief); transform: translateY(0) }
.knopf.zweit { background: transparent; color: var(--gold); border-color: var(--linie) }
.knopf.zweit:hover { background: transparent; border-color: var(--gold) }
.knopf.zweit:active { background: var(--gold-bg); border-color: var(--gold) }
.knopf.klein { padding: var(--a2) var(--a3); min-height: 40px; font-size: .9rem }
.knopf[disabled], .knopf[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none }
.wahl { border: 1px solid var(--rand); background: var(--bg); color: var(--text); border-radius: var(--r-rund); padding: var(--a2) var(--a4); font: inherit; cursor: pointer; min-height: 40px }
.wahl:hover { border-color: var(--gold) }
.wahl:active { background: var(--gold-bg) }
.wahl.richtig { background: var(--gruen-bg); color: var(--gruen); border-color: var(--gruen) }
.wahl.falsch { background: var(--rot-bg); color: var(--rot); border-color: var(--rot) }

/* ---- Fortschritt ---- */
.fortschritt { height: 8px; background: var(--flaeche); border-radius: var(--r-rund); overflow: hidden; border: 1px solid var(--linie) }
.fortschritt i { display: block; height: 100%; background: var(--gold); width: 0 }

/* ---- Listen und Module ---- */
.modul { display: flex; flex-direction: column; gap: var(--a2) }
.modul > header { display: flex; flex-direction: column; gap: var(--a1); padding-top: var(--a2); border-top: 2px solid var(--gold-hell) }
.lektionsliste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column }
.lektionsliste a { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: var(--a3); align-items: baseline; padding: var(--a3) var(--a1); text-decoration: none; color: var(--text); border-bottom: 1px solid var(--linie) }
.lektionsliste a:hover { background: var(--flaeche) }
.lektionsliste a:active { background: var(--gold-bg) }
.lektionsliste .nr { font-family: var(--kopf); color: var(--gold); font-variant-numeric: tabular-nums }
.lektionsliste .zeit { color: var(--leise); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums }
.lektionsliste .titel { min-width: 0 }
.lektionsliste .titel small { display: block; color: var(--leise); font-size: .88rem; line-height: 1.4 }
.haken { color: var(--gruen); font-weight: 600 }
ol.schritte { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: var(--a3) }
ol.schritte > li { counter-increment: s; display: grid; grid-template-columns: 2rem 1fr; gap: var(--a2) }
ol.schritte > li::before { content: counter(s); font-family: var(--kopf); font-weight: 600; color: var(--gold); border: 1px solid var(--linie); border-radius: var(--r-rund); width: 2rem; height: 2rem; display: grid; place-items: center; font-size: .95rem; background: var(--bg) }
ol.schritte .sehen { color: var(--text2); font-size: .95rem }

/* ---- Kästen und Karten ---- */
.block { display: flex; flex-direction: column; gap: var(--a3) }
.block > .kopf { display: flex; align-items: baseline; gap: var(--a2); flex-wrap: wrap }
.kasten { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--r3); padding: var(--a4); display: flex; flex-direction: column; gap: var(--a3); box-shadow: var(--schatten) }
.ziel { background: var(--gold-bg); border-radius: var(--r3); padding: var(--a4); display: flex; flex-direction: column; gap: var(--a2) }
.woerter { display: grid; gap: var(--a2) }
.woerter div { display: flex; flex-direction: column; gap: var(--a1); padding: var(--a2) var(--a3); background: var(--flaeche); border-radius: var(--r2) }
.woerter b { font-weight: 600 }
.woerter b .fach { font-weight: 400; color: var(--text2); font-size: .92em }
.woerter span { color: var(--text2); font-size: .95rem }
.auftrag { background: var(--flaeche); border: 1px dashed var(--gold-hell); border-radius: var(--r2); padding: var(--a3); display: flex; flex-direction: column; gap: var(--a2) }
.auftrag pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--lauf); font-size: .98rem; line-height: 1.55 }
.auftrag .kopfzeile { display: flex; justify-content: space-between; align-items: center; gap: var(--a2); flex-wrap: wrap }
.karten { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: var(--a3) }
/* Drei Karten: in breiter Spalte drei nebeneinander, schmaler nimmt die dritte die ganze Reihe.
   So steht keine Karte allein neben einer Lücke. */
.karten:has(> :nth-child(3):last-child) > :last-child { grid-column: 1 / -1 }
@media (min-width: 44rem) {
  .karten:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)) }
  .karten:has(> :nth-child(3):last-child) > :last-child { grid-column: auto }
}
.karte { display: flex; flex-direction: column; gap: var(--a1); padding: var(--a4); border: 1px solid var(--linie); border-radius: var(--r3); background: var(--flaeche); color: inherit; text-decoration: none; transition: transform var(--dauer-kurz) var(--kurve) }
a.karte:hover { border-color: var(--gold); transform: translateY(-1px) }
a.karte:active { background: var(--gold-bg); transform: translateY(0) }
.karte b { font-family: var(--kopf); font-size: 1.05rem }
.karte span { color: var(--text2); font-size: .93rem }
.karte.schmal { padding: var(--a3) var(--a4); margin-top: var(--a2) }
.zkarte { border: 1px solid var(--linie); border-radius: var(--r3); padding: var(--a3) var(--a4); display: flex; flex-direction: column; gap: var(--a2); background: var(--karte) }
.klickweg { border: 1px dashed var(--linie); border-radius: var(--r3); padding: var(--a4); display: flex; flex-direction: column; gap: var(--a2); background: var(--flaeche) }
.klickweg i { font-style: normal; font-weight: 600; font-size: .92rem; color: var(--text2) }
.klemmt { display: grid; gap: var(--a2) }
.klemmt div { background: var(--flaeche); border-radius: var(--r2); padding: var(--a3); display: flex; flex-direction: column; gap: var(--a1); font-size: .96rem }
.klemmt i { font-style: normal; color: var(--leise); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600 }
details { border: 1px solid var(--linie); border-radius: var(--r2); background: var(--karte) }
details > summary { cursor: pointer; padding: var(--a3) var(--a4); font-weight: 600; list-style-position: inside; border-radius: var(--r2) }
details > summary:hover { background: var(--flaeche) }
details > div { padding: 0 var(--a4) var(--a4); display: flex; flex-direction: column; gap: var(--a3) }

/* ---- Dateien ---- */
.dateien { display: flex; flex-wrap: wrap; gap: var(--a2) }
.datei { display: inline-flex; align-items: center; gap: var(--a2); border: 1px solid var(--linie); background: var(--karte); border-radius: var(--r2); padding: var(--a2) var(--a3); text-decoration: none; color: var(--text); font-size: .93rem; min-height: var(--tippe); cursor: pointer; max-width: 100% }
.datei:hover { border-color: var(--gold) }
.datei:active { background: var(--gold-bg) }
.datei b { font-weight: 600; overflow-wrap: anywhere }
.datei .art { font-size: .78rem; font-weight: 600; letter-spacing: .06em; color: var(--gold); border: 1px solid var(--gold-hell); border-radius: var(--r1); padding: 0 var(--a1); text-transform: uppercase }

/* ---- Formular und Quiz ---- */
.feld { display: flex; flex-direction: column; gap: var(--a2) }
.feld label { font-weight: 600 }
.eingabe { font: inherit; color: var(--text); background: var(--karte); border: 1px solid var(--rand); border-radius: var(--r2); padding: var(--a3); width: 100%; min-height: var(--tippe) }
.eingabe:hover { border-color: var(--gold) }
.eingabe:focus { outline: 2px solid var(--fokus); outline-offset: 1px }
textarea.eingabe { resize: vertical; min-height: 5.5rem }
.quiz fieldset { border: 1px solid var(--linie); border-radius: var(--r3); padding: var(--a3) var(--a4); margin: 0; display: flex; flex-direction: column; gap: var(--a2); min-width: 0 }
.quiz legend { font-weight: 600; padding: 0 var(--a2) }
.quiz label { display: grid; grid-template-columns: 1.4rem 1fr; gap: var(--a2); align-items: start; padding: var(--a2); border-radius: var(--r1); cursor: pointer }
.quiz label:hover { background: var(--flaeche) }
.quiz label.richtig { background: var(--gruen-bg); color: var(--gruen) }
.quiz label.falsch { background: var(--rot-bg); color: var(--rot) }
.quiz .erkl, .zkarte .erkl { font-size: .95rem; color: var(--text2) }

/* ---- Hinweise und Ampel ---- */
.hinweis { border-radius: var(--r2); padding: var(--a3) var(--a4); font-size: .96rem; display: flex; flex-direction: column; gap: var(--a1) }
.hinweis.gruen { background: var(--gruen-bg) }
.hinweis.gelb { background: var(--gelb-bg) }
.hinweis.rot { background: var(--rot-bg) }
.hinweis.neutral { background: var(--flaeche) }
.hinweis b { font-size: .8rem; letter-spacing: .07em; text-transform: uppercase }
.ampel { display: grid; gap: var(--a2) }
.ampel div { display: grid; grid-template-columns: 5.2rem 1fr; gap: var(--a3); padding: var(--a3); border-radius: var(--r2); align-items: start }
.ampel b { font-weight: 600 }
.ampel .gruen { background: var(--gruen-bg); color: var(--gruen) }
.ampel .gelb { background: var(--gelb-bg); color: var(--gelb) }
.ampel .rot { background: var(--rot-bg); color: var(--rot) }
.ampel div span { color: var(--text) }

/* ---- Schaubilder: Stationskarten, unvollständige Reihe mittig ---- */
.schaubild { display: flex; flex-direction: column; gap: var(--a2) }
.schaubild .teile { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--a2) }
/* Ablauf: gleich breite Karten, vier je Reihe; bei 3, 5 oder 6 Stationen drei je Reihe,
   damit nie eine einzelne Karte übrig bleibt (5 = 3 + 2, 6 = 3 + 3, 7 = 4 + 3).
   Am Handy stehen die Stationen untereinander wie eine nummerierte Liste. */
.schaubild.ablauf .teil { flex: 0 1 100% }
@media (min-width: 30.01rem) {
  .schaubild.ablauf .teil { flex-basis: calc((100% - 3 * var(--a2)) / 4) }
  .schaubild.ablauf .teile:has(> .teil:nth-child(3):last-child) > .teil,
  .schaubild.ablauf .teile:has(> .teil:nth-child(5):last-child) > .teil,
  .schaubild.ablauf .teile:has(> .teil:nth-child(6):last-child) > .teil { flex-basis: calc((100% - 2 * var(--a2)) / 3) }
  .schaubild.ablauf .teile:has(> .teil:nth-child(2):last-child) > .teil { flex-basis: calc((100% - var(--a2)) / 2) }
}
.schaubild.vergleich .teil { flex: 1 1 13rem }
/* Vergleich: vier Felder stehen zwei und zwei; drei Felder stehen nebeneinander oder,
   wenn die Spalte dafür zu schmal ist, untereinander. Nie drei und eins, nie zwei und eins. */
@media (min-width: 30.01rem) {
  .schaubild.vergleich .teile:has(> .teil:nth-child(4):last-child) > .teil { flex-basis: calc((100% - var(--a2)) / 2) }
}
@media (max-width: 43.99rem) {
  .schaubild.vergleich .teile:has(> .teil:nth-child(3):last-child) > .teil { flex-basis: 100% }
}
.schaubild .teil { border: 1px solid var(--linie); border-radius: var(--r2); padding: var(--a3); background: var(--karte); display: flex; flex-direction: column; gap: var(--a1); min-width: 0 }
.schaubild.ablauf .teil { border-top: 3px solid var(--gold-hell) }
.schaubild .teil b { font-weight: 600 }
.schaubild .teil span { font-size: .93rem; color: var(--text2) }
.schaubild .schritt-nr { font-family: var(--kopf); color: var(--gold); font-size: .9rem }

/* ---- Tabellen ---- */
.tabelle { overflow-x: auto }
table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums }
th, td { text-align: left; padding: var(--a2) var(--a3); border-bottom: 1px solid var(--linie); vertical-align: top }
th { color: var(--leise); font-weight: 600; font-size: .82rem; letter-spacing: .05em; text-transform: uppercase }

/* ---- Blättern und Meldung ---- */
.blaettern { display: flex; justify-content: space-between; gap: var(--a3); flex-wrap: wrap; border-top: 1px solid var(--linie); padding-top: var(--a4) }
.meldung { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--a4) + env(safe-area-inset-bottom, 0px)); background: var(--text); color: var(--bg); padding: var(--a3) var(--a4); border-radius: var(--r-rund); font-size: .92rem; z-index: 20; max-width: calc(100% - 32px) }

/* ---- Bedienung mit dem Finger: volle Tipphöhe ---- */
@media (pointer: coarse) {
  .nav a, .knopf.klein, .wahl { min-height: var(--tippe) }
}

/* ---- Wenig Bewegung gewünscht ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto }
  .knopf, .karte { transition: none }
  .knopf:hover, a.karte:hover { transform: none }
}

/* ---- Schmale Geräte ---- */
@media (max-width: 30rem) {
  .leiste { position: static }
  .nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: var(--a1); scrollbar-width: none }
  .nav::-webkit-scrollbar { display: none }
  .nav a { white-space: nowrap }
  .ampel div { grid-template-columns: 1fr }
  .lektionsliste a { grid-template-columns: 1.9rem 1fr }
  .lektionsliste .zeit { grid-column: 2 }
}
