:root {
  --grund: #fbf6ef;
  --flaeche: #ffffff;
  --text: #2a211c;
  --leise: #7a6a5f;
  --linie: #e8ddd0;
  --akzent: #9c3b22;
  --akzent-text: #ffffff;
  --gold: #c99a2e;
  --ja: #2e7d4f;
  --ja-grund: #e3f3e8;
  --nein: #b3261e;
  --nein-grund: #fbe5e3;
  --schatten: 0 1px 3px rgba(60, 30, 10, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #1b1714;
    --flaeche: #26201c;
    --text: #f2ebe4;
    --leise: #b3a497;
    --linie: #3a312a;
    --akzent: #d9643f;
    --gold: #e0b44e;
    --ja: #6fcf97;
    --ja-grund: #1f3528;
    --nein: #ff8a80;
    --nein-grund: #3d2220;
    --schatten: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--grund);
  color: var(--text);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; color: var(--leise); }

/* Kopf und Leiste */
.kopf {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .4rem;
  min-height: 52px; padding: .3rem 16px; padding-top: calc(.3rem + env(safe-area-inset-top));
  background: var(--akzent); color: var(--akzent-text);
}
.kopf h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-knopf {
  border: 0; background: none; color: inherit; font-size: 2rem; line-height: 1;
  padding: 0 .5rem 0 0; cursor: pointer;
}
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }
.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--flaeche); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.leiste a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 2px 10px; font-size: .72rem; color: var(--leise);
}
.leiste a span { font-size: 1.35rem; }
.leiste a.aktiv { color: var(--akzent); font-weight: 600; }

/* Texte */
.lt { font-weight: 600; }
.de { color: var(--leise); }
.km { display: block; font-family: "Noto Sans Khmer", "Khmer OS", "Khmer UI", "Leelawadee UI", sans-serif; font-size: 1.15rem; line-height: 1.9; }
.gross { font-size: 1.5rem; }
.km.gross { font-size: 1.9rem; }
.riesig-text { font-size: 1.9rem; line-height: 1.25; }
.hinweis { color: var(--leise); font-size: .92rem; }
.leer { color: var(--leise); text-align: center; padding: 2rem 0; }
.rolle { font-size: .8rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .03em; }
.version { color: var(--leise); font-size: .8rem; text-align: center; margin-top: 2rem; }

/* Knöpfe */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 48px; padding: .55rem 1rem;
  border: 1px solid var(--linie); border-radius: 12px;
  background: var(--flaeche); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; box-shadow: var(--schatten);
  text-align: center;
}
.knopf:active { transform: scale(.98); }
.knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf.klein { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }
.knopf.breit { width: 100%; margin-top: .6rem; }
.knopf.gross { font-size: 1.2rem; min-height: 60px; }
.knopf.riesig { font-size: 1.6rem; min-height: 72px; min-width: 72px; }
.knopf.ja { background: var(--ja-grund); border-color: var(--ja); color: var(--ja); }
.knopf.nein { background: var(--nein-grund); border-color: var(--nein); color: var(--nein); }
.knopf:disabled { cursor: default; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.knopfreihe > * { flex: 1 1 auto; }
.knopfreihe.mitte { justify-content: center; }
.hoer {
  flex: none; width: 48px; height: 48px; min-height: 0; padding: 0;
  border-radius: 50%; font-size: 1.2rem;
}

/* Kacheln und Kapitel */
.kacheln { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: .4rem; }
.kachel {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: 1rem .5rem; border-radius: 16px; background: var(--flaeche);
  border: 1px solid var(--linie); box-shadow: var(--schatten); text-align: center;
}
.kachel-icon { font-size: 2rem; }
.kachel small { color: var(--leise); }
.karte-link {
  display: block; padding: .9rem 1rem; margin-bottom: .6rem;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; box-shadow: var(--schatten);
}
.karte-link-titel { font-weight: 700; }
.karte-link .typ { font-size: .8rem; color: var(--leise); }
.balken { height: 6px; border-radius: 3px; background: var(--linie); margin-top: .5rem; overflow: hidden; }
.balken-fuell { height: 100%; background: var(--ja); }
.balken-text { font-size: .78rem; color: var(--leise); margin-top: .2rem; }

/* Listen */
.liste { display: flex; flex-direction: column; gap: .5rem; }
.zeile {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .65rem .8rem; background: var(--flaeche);
  border: 1px solid var(--linie); border-radius: 12px; cursor: pointer;
}
.zeile-text { flex: 1 1 0; min-width: 0; }
.zeile.spielt { border-color: var(--akzent); box-shadow: 0 0 0 2px var(--akzent); }
.zeile.du { border-style: dashed; cursor: default; }
.zeile.quiz { cursor: default; }
.zeile.quiz .knopfreihe { flex-basis: 100%; margin: .2rem 0 0; }
.punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--linie); flex: none; }
.punkt.an { background: var(--ja); }
.rueckmeldung { flex-basis: 100%; font-size: .92rem; }
.rueckmeldung:empty { display: none; }

/* Lernkarten */
.sitzung-kopf { display: flex; justify-content: space-between; align-items: center; color: var(--leise); margin-bottom: .6rem; }
.lernkarte {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 18px;
  padding: 1.6rem 1rem; text-align: center; box-shadow: var(--schatten); min-height: 200px;
  display: flex; flex-direction: column; justify-content: center; gap: .4rem;
}
.lernkarte hr { width: 60%; border: 0; border-top: 1px solid var(--linie); margin: .8rem auto; }
.bewertung > * { flex: 1 1 0; min-height: 60px; font-size: 1.1rem; }
.frage { text-align: center; font-weight: 600; margin: 1rem 0 .4rem; }
.optionen { display: flex; flex-direction: column; gap: .5rem; }
.option { justify-content: flex-start; text-align: left; }
.fertig { text-align: center; padding: 2rem 0; }

/* Zuordnen */
.stapel { display: flex; flex-direction: column; gap: .5rem; }
.zuordnen { flex-direction: column; align-items: flex-start; text-align: left; }
.zuordnen small { display: block; font-weight: 400; }
.zuordnen.gewaehlt { border-color: var(--akzent); box-shadow: 0 0 0 2px var(--akzent); }
.wackeln { animation: wackeln .4s; border-color: var(--nein); }
@keyframes wackeln {
  25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); }
}

/* Formular */
.formular { display: flex; flex-direction: column; gap: .8rem; }
.schalter, .regler, .feld {
  display: flex; gap: .6rem; padding: .7rem .9rem;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px;
}
.schalter { justify-content: space-between; align-items: center; }
.schalter input { width: 24px; height: 24px; accent-color: var(--akzent); }
.regler, .feld { flex-direction: column; }
.regler input { width: 100%; accent-color: var(--akzent); }
select {
  font: inherit; padding: .55rem; border-radius: 10px; width: 100%;
  border: 1px solid var(--linie); background: var(--grund); color: var(--text);
}
.box {
  padding: .8rem 1rem; border-radius: 12px; margin: .6rem 0;
  background: var(--nein-grund); border: 1px solid var(--nein); font-size: .93rem;
}
.box ol { padding-left: 1.2rem; margin: .4rem 0; }
details { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: .6rem .9rem; margin: .6rem 0; }
summary { font-weight: 600; cursor: pointer; }

/* Auto-Modus */
.auto-anzeige { margin-top: 1rem; }
.auto-status { text-align: center; font-size: 1.25rem; font-weight: 700; color: var(--akzent); min-height: 1.8rem; }
.auto-karte {
  text-align: center; padding: 1.4rem 1rem; margin: .6rem 0;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 18px;
}
.auto-zaehler { text-align: center; color: var(--leise); font-size: .85rem; }
.auto-steuer { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .8rem; }

.fehler {
  position: fixed; left: 8px; right: 8px; top: 8px; z-index: 20;
  padding: .8rem 1rem; border-radius: 12px; background: var(--nein); color: #fff; font-size: .9rem;
}
