:root {
  --papier: #F6F5F2;
  --karte: #FFFFFF;
  --tinte: #1B1D22;
  --tinte-leise: #5E636E;
  --linie: #E2E0DB;
  --fach: #2F5BD7;
  --fach-weich: rgba(47, 91, 215, 0.10);
  --richtig: #1B7A4B;
  --falsch: #B3261E;
  --radius: 14px;
  --raum: 16px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #16181C;
    --karte: #1F2229;
    --tinte: #EDEDEA;
    --tinte-leise: #9AA0AC;
    --linie: #2E323B;
    --fach-weich: rgba(255, 255, 255, 0.07);
    --richtig: #54C48A;
    --falsch: #F2836F;
  }
}

:root[data-theme="dark"] {
  --papier: #16181C;
  --karte: #1F2229;
  --tinte: #EDEDEA;
  --tinte-leise: #9AA0AC;
  --linie: #2E323B;
  --fach-weich: rgba(255, 255, 255, 0.07);
  --richtig: #54C48A;
  --falsch: #F2836F;
}

*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .zahl {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 3px solid var(--fach); outline-offset: 2px; border-radius: 6px; }

/* Kopf */
#kopf {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: color-mix(in srgb, var(--papier) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--linie);
}

#titel { margin: 0; font-size: 19px; font-weight: 650; text-align: center; }

.ikon {
  width: 44px; height: 44px;
  background: none; border: 0;
  font-size: 22px; line-height: 1;
  color: var(--tinte-leise);
  border-radius: 12px;
}

/* Bühne */
#buehne { padding: var(--raum) var(--raum) 96px; max-width: 760px; margin: 0 auto; }

/* Navigationsleiste */
#leiste {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--papier) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--linie);
  z-index: 20;
}

#leiste button {
  flex: 1;
  background: none;
  border: 0;
  padding: 8px 2px;
  font-size: 12px;
  color: var(--tinte-leise);
  border-radius: 10px;
}

#leiste button.aktiv { color: var(--fach); font-weight: 650; }

/* Karten */
.karte {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: var(--raum);
  margin-bottom: 12px;
}

.karte h2, .karte h3 { margin: 0 0 6px; font-size: 17px; }

.leise-text { color: var(--tinte-leise); font-size: 15px; margin: 0; }

/* Stapel: der Blickfang auf „Heute“ */
.stapel {
  position: relative;
  border-radius: 20px;
  padding: 22px 20px 20px;
  background: var(--fach);
  color: #fff;
  margin-bottom: 18px;
  overflow: hidden;
}

.stapel::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.stapel .zahl { font-size: 46px; font-weight: 700; line-height: 1; }
.stapel p { margin: 6px 0 16px; opacity: 0.92; }
.stapel h2 { margin: 0 0 2px; font-size: 15px; font-weight: 600; opacity: 0.85; }

.stapel button {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: var(--fach);
  font-weight: 650;
}

/* Listen */
.liste { list-style: none; margin: 0; padding: 0; }

.zeile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
}

.zeile .punkt {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--fach-weich);
  color: var(--fach);
}

.zeile .inhalt { flex: 1 1 auto; min-width: 0; }
.zeile .inhalt strong { display: block; font-weight: 600; }
.zeile .inhalt span { display: block; font-size: 14px; color: var(--tinte-leise); }
.zeile .pfeil { color: var(--tinte-leise); }

.balken { height: 6px; border-radius: 3px; background: var(--linie); overflow: hidden; margin-top: 8px; }
.balken > i { display: block; height: 100%; background: var(--fach); }

/* Knöpfe */
.primaer, .zweit {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  margin-top: 10px;
}

.primaer { background: var(--fach); color: #fff; border-color: var(--fach); }
.zweit { background: transparent; color: var(--tinte); border-color: var(--linie); }
.leise { background: none; border: 0; color: var(--tinte-leise); text-decoration: underline; padding: 10px; width: 100%; }

.knopfreihe { display: flex; gap: 8px; }
.knopfreihe .primaer, .knopfreihe .zweit { margin-top: 10px; }

button[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Modi */
.modi { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0 4px; }
.modi button {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: left;
}
.modi strong { display: block; font-weight: 650; }
.modi span { font-size: 13px; color: var(--tinte-leise); }

/* Aufgaben */
.frage { font-size: 19px; line-height: 1.4; margin: 4px 0 16px; }

.option {
  display: block; width: 100%; text-align: left;
  background: var(--karte); border: 1px solid var(--linie);
  border-radius: 12px; padding: 13px 14px; margin-bottom: 8px;
}
.option.gewaehlt { border-color: var(--fach); background: var(--fach-weich); }
.option.richtig { border-color: var(--richtig); background: color-mix(in srgb, var(--richtig) 12%, transparent); }
.option.falsch { border-color: var(--falsch); background: color-mix(in srgb, var(--falsch) 12%, transparent); }

input[type="text"], input[type="date"], textarea, select {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid var(--linie);
  background: var(--karte);
  color: var(--tinte);
  font: inherit;
}

textarea { min-height: 120px; resize: vertical; }

label { display: block; font-size: 14px; color: var(--tinte-leise); margin: 12px 0 5px; }

.rueckmeldung { border-radius: 12px; padding: 14px; margin-top: 14px; border: 1px solid var(--linie); background: var(--karte); }
.rueckmeldung.gut { border-color: var(--richtig); }
.rueckmeldung.schief { border-color: var(--falsch); }
.rueckmeldung strong { display: block; margin-bottom: 4px; }
.rueckmeldung p { margin: 0 0 6px; }

.hinweisbox { border-left: 3px solid var(--fach); padding: 8px 0 8px 12px; margin: 10px 0; color: var(--tinte-leise); }

.fortschritt { display: flex; justify-content: space-between; font-size: 14px; color: var(--tinte-leise); margin-bottom: 8px; }

/* Tutor */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.blase { max-width: 85%; padding: 11px 14px; border-radius: 16px; white-space: pre-wrap; }
.blase.ich { align-self: flex-end; background: var(--fach); color: #fff; border-bottom-right-radius: 5px; }
.blase.tutor { align-self: flex-start; background: var(--karte); border: 1px solid var(--linie); border-bottom-left-radius: 5px; }

/* Vokabelkarte */
.vokabelkarte {
  min-height: 190px;
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 18px;
  padding: 24px;
  font-size: 26px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, sans-serif;
}
.vokabelkarte small { display: block; font-size: 14px; color: var(--tinte-leise); margin-top: 10px; font-family: inherit; }

/* Kopplung */
.kopplung { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--papier); z-index: 50; }
.kopplung-inner { width: 100%; max-width: 380px; }
.kopplung h2 { margin: 6px 0 8px; font-size: 24px; }
.marke { margin: 0; font-size: 14px; color: var(--fach); font-weight: 650; }
.hinweis { color: var(--tinte-leise); font-size: 15px; }
.fehler { color: var(--falsch); font-size: 15px; }

/* Lader */
.lader { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.25); z-index: 60; }
.lader span {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: dreh 0.9s linear infinite;
}

@keyframes dreh { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .lader span { animation-duration: 3s; }
  * { transition: none !important; }
}

.marker { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--fach-weich); color: var(--fach); margin-left: 6px; vertical-align: middle; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
td { padding: 7px 0; border-bottom: 1px solid var(--linie); }
td:last-child { text-align: right; color: var(--tinte-leise); }

.scrollbar { overflow-x: auto; }
