/* ==========================================================================
   LingoFlow — Stylesheet
   --------------------------------------------------------------------------
   Aufbau
     1  Design Tokens + die drei Design-Richtungen
     2  Grundlagen / Reset
     3  Bühne und Smartphone-Rahmen
     4  Bausteine: Buttons, Karten, Chips, Fortschritt
     5  Onboarding
     6  Topbar und Bottom Navigation
     7  Lernpfad
     8  Lektion und Übungen
     9  Schrift: Alphabet, Detailansicht, Schreibtraining
    10  Üben
    11  Profil
    12  Overlay, Modal, Toast, Konfetti
    13  Accessibility und Reduced Motion

   Die Design-Richtungen sind reine Token-Sets (Kapitel 57). Umschalten über
   data-theme am <html>-Element — kein Bauteil kennt eine feste Farbe.
   ========================================================================== */

/* ------------------------------------------------------------------ 1 ----- */

:root {
  /* Richtung 1 — "Indigo": die Farbrichtung aus Kapitel 7 der Quelle */
  --c-primary:        #5b4cf0;
  --c-primary-strong: #4536c9;
  --c-primary-soft:   #eeebfe;
  --c-on-primary:     #ffffff;

  --c-stage:          #e7e8f0;
  --c-bg:             #f4f5f9;
  --c-surface:        #ffffff;
  --c-surface-2:      #fafaff;
  --c-border:         #e3e4ee;

  --c-text:           #1b1b2a;
  --c-text-muted:     #676a80;

  --c-success:        #17914f;
  --c-success-soft:   #e6f5ec;
  --c-danger:         #cf4d4d;
  --c-danger-soft:    #fceded;
  --c-streak:         #ec7a13;
  --c-accent:         #e0ab21;

  /* Maße */
  --radius-card:   20px;
  --radius-btn:    14px;
  --radius-pill:   999px;
  --space-xs:      4px;
  --space-sm:      8px;
  --space-md:      12px;
  --space-lg:      16px;
  --space-xl:      24px;
  --space-2xl:     32px;
  --shadow-card:   0 1px 2px rgba(20, 20, 45, .05), 0 6px 18px rgba(20, 20, 45, .06);
  --shadow-raised: 0 6px 20px rgba(20, 20, 45, .14);
  --app-max:       430px;

  /* Schrift */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-fa: Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", Arial, sans-serif;

  --dur-fast: 150ms;
  --dur-mid:  240ms;
  --dur-slow: 340ms;
}

/* Richtung 2 — "Saffran": Petrol mit Safran-Akzent auf warmem Papierweiß */
html[data-theme="saffran"] {
  --c-primary:        #0e6e6e;
  --c-primary-strong: #095151;
  --c-primary-soft:   #dcecea;
  --c-on-primary:     #ffffff;

  --c-stage:          #efe6d7;
  --c-bg:             #fbf7f0;
  --c-surface:        #ffffff;
  --c-surface-2:      #fffdf8;
  --c-border:         #ece1d0;

  --c-text:           #241f18;
  --c-text-muted:     #6d6558;

  --c-success:        #2c7a4b;
  --c-success-soft:   #e5f2e8;
  --c-danger:         #bf4f43;
  --c-danger-soft:    #fbeae7;
  --c-streak:         #c8641c;
  --c-accent:         #c98c11;
}

/* Richtung 3 — "Mitternacht": dunkle Oberfläche mit leuchtendem Violett */
html[data-theme="mitternacht"] {
  --c-primary:        #9c8dff;
  --c-primary-strong: #b3a7ff;
  --c-primary-soft:   #2b2845;
  --c-on-primary:     #14131f;

  --c-stage:          #0c0b13;
  --c-bg:             #14131f;
  --c-surface:        #1f1e2e;
  --c-surface-2:      #262539;
  --c-border:         #33314a;

  --c-text:           #f2f1f8;
  --c-text-muted:     #a7a4c0;

  --c-success:        #56d68b;
  --c-success-soft:   #17301f;
  --c-danger:         #f38585;
  --c-danger-soft:    #33191c;
  --c-streak:         #f7a941;
  --c-accent:         #ffd569;

  --shadow-card:   0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  --shadow-raised: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ------------------------------------------------------------------ 2 ----- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  color: var(--c-text);
  background: var(--c-stage);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

button { font: inherit; color: inherit; }

.noscript {
  max-width: 30rem;
  margin: 3rem auto;
  padding: var(--space-lg);
  background: var(--c-surface);
  border-radius: var(--radius-card);
}

/* Persische Textbereiche — nur diese sind RTL (Kapitel 9).
   Nie über transform: scaleX(-1), sondern über dir="rtl" im Markup.        */
.fa {
  font-family: var(--font-fa);
  direction: rtl;
  unicode-bidi: isolate;
  line-height: 1.7;
}

.muted { color: var(--c-text-muted); }
.center { text-align: center; }
.tr { color: var(--c-text-muted); font-size: .95rem; }

/* ------------------------------------------------------------------ 3 ----- */

/* Die Bühne ist genau so hoch wie der Bildschirm. Nur dadurch bekommen die
   inneren Flex-Kinder eine feste Höhe — sonst wächst die App über den
   Bildschirm hinaus und Bottom Navigation und Fußzeilen rutschen darunter. */
.stage {
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.phone {
  position: relative;
  width: 100%;
  max-width: var(--app-max);
  height: 100%;
  background: var(--c-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Desktop: App mittig als Smartphone, neutraler Hintergrund außen (Kap. 53) */
@media (min-width: 700px) {
  .stage { align-items: center; padding: var(--space-xl) 0; }
  .phone {
    height: 844px;
    max-height: 100%;
    border-radius: 34px;
    box-shadow: var(--shadow-raised), 0 0 0 8px rgba(0, 0, 0, .16);
  }
}

.app { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-lg) var(--space-lg) calc(var(--space-2xl) + 8px);
  scroll-behavior: smooth;
}
.view:focus { outline: none; }

/* ------------------------------------------------------------------ 4 ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 48px;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: var(--c-surface);
  font-weight: 650;
  cursor: pointer;
  transition: transform var(--dur-fast) ease, background var(--dur-fast) ease,
              box-shadow var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn-primary {
  width: 100%;
  background: var(--c-primary);
  color: var(--c-on-primary);
  box-shadow: 0 4px 0 0 var(--c-primary-strong);
}
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 0 var(--c-primary-strong); transform: translateY(3px) scale(1); }
.btn-primary:disabled { box-shadow: 0 4px 0 0 var(--c-border); background: var(--c-border); color: var(--c-text-muted); }

.btn-ghost { background: transparent; border-color: var(--c-border); }
.btn-quiet  { background: var(--c-primary-soft); color: var(--c-primary-strong); border-color: transparent; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-block  { width: 100%; }
.btn-sm     { min-height: 40px; padding: var(--space-sm) var(--space-md); font-size: .92rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  font-size: 1.25rem;
}
.icon-btn:active { transform: scale(.92); }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}

.stack   { display: flex; flex-direction: column; gap: var(--space-md); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-lg); }
.row     { display: flex; align-items: center; gap: var(--space-sm); }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--c-primary-soft);
  color: var(--c-primary-strong);
  font-size: .82rem;
  font-weight: 650;
}
.chip-plain { background: var(--c-bg); color: var(--c-text-muted); }

.progress {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--c-border);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--c-primary);
  transition: width var(--dur-mid) ease;
}
.progress-success > span { background: var(--c-success); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.section-title h3 { font-size: .82rem; letter-spacing: .07em; text-transform: uppercase; color: var(--c-text-muted); }

/* ------------------------------------------------------------------ 5 ----- */

.onboarding {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + var(--space-xl)) var(--space-lg)
           calc(env(safe-area-inset-bottom) + var(--space-lg));
  overflow-y: auto;
}
.onboarding[hidden] { display: none; }

.ob-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: var(--space-xl); }
.ob-dots i {
  width: 24px; height: 4px; border-radius: var(--radius-pill);
  background: var(--c-border);
}
.ob-dots i.on { background: var(--c-primary); }

.ob-body { flex: 1; display: flex; flex-direction: column; gap: var(--space-lg); }
.ob-foot { padding-top: var(--space-lg); }

.wordmark {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.03em;
  background: linear-gradient(100deg, var(--c-primary), var(--c-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark-sub { color: var(--c-text-muted); }

.ob-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  text-align: center;
}
.ob-hero .glyph {
  font-size: 4.6rem;
  font-family: var(--font-fa);
  color: var(--c-primary);
  direction: rtl;
}

/* Auswahlkacheln (Sprache, Motivation, Tagesziel) */
.choice {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  text-align: left;
  padding: var(--space-md) var(--space-lg);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius-card);
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease, transform var(--dur-fast) ease;
}
.choice:active { transform: scale(.99); }
.choice[aria-pressed="true"] { border-color: var(--c-primary); background: var(--c-primary-soft); }
.choice[aria-pressed="true"] .choice-mark { opacity: 1; }
.choice:disabled { cursor: default; opacity: .6; }
.choice-emoji { font-size: 1.5rem; line-height: 1; }
.choice-main { flex: 1; min-width: 0; }
.choice-title { display: block; font-weight: 650; }
.choice-sub { display: block; font-size: .88rem; color: var(--c-text-muted); }
.choice-mark { opacity: 0; color: var(--c-primary); font-weight: 800; }
.choice-soon {
  font-size: .74rem; font-weight: 700; letter-spacing: .04em;
  padding: 3px 8px; border-radius: var(--radius-pill);
  background: var(--c-bg); color: var(--c-text-muted);
}
.choice .fa { font-size: 1.15rem; }

/* ------------------------------------------------------------------ 6 ----- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: calc(env(safe-area-inset-top) + var(--space-md)) var(--space-lg) var(--space-md);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.topbar-stats { display: flex; align-items: center; gap: var(--space-md); font-weight: 650; font-size: .95rem; }
.topbar-lang { font-family: var(--font-fa); font-size: 1.15rem; direction: rtl; color: var(--c-primary); }
.stat-streak { color: var(--c-streak); }
.stat-xp { color: var(--c-accent); }
.topbar-goal { font-size: .8rem; color: var(--c-text-muted); font-weight: 600; }

.bottomnav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.navbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 56px;
  padding: var(--space-sm) 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--c-text-muted);
  font-size: .72rem;
  font-weight: 650;
  position: relative;
  transition: color var(--dur-fast) ease;
}
.navbtn svg { width: 22px; height: 22px; }
.navbtn[aria-current="page"] { color: var(--c-primary); }
.navbtn[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  width: 26px; height: 3px;
  transform: translateX(-50%);
  border-radius: var(--radius-pill);
  background: var(--c-primary);
}

/* ------------------------------------------------------------------ 7 -----
   Lernpfad: Karten auf einer leicht versetzten vertikalen Route
   (eigene Interpretation, Kapitel 15).                                    */

.daily {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-card);
}
.daily-ring {
  --p: 0;
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 800;
  color: var(--c-primary-strong);
  background:
    conic-gradient(var(--c-primary) calc(var(--p) * 1%), var(--c-border) 0);
}
.daily-ring span {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--c-surface);
}

.chapter-head {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-xl) 0 var(--space-md);
}
.chapter-head .num {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-weight: 800;
  font-size: .95rem;
}
.chapter-head .lbl { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c-text-muted); font-weight: 700; }

.path { position: relative; padding: var(--space-sm) 0; }
.path::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 27px;
  width: 3px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    to bottom, var(--c-border) 0 7px, transparent 7px 14px);
}

.node {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: var(--space-md);
  width: 100%;
  text-align: left;
  padding: 0;
  margin-bottom: var(--space-md);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.node-dot {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  width: 56px; height: 56px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  color: var(--c-text-muted);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-fast) ease;
}
.node:active .node-dot { transform: scale(.94); }

.node-body {
  flex: 1;
  min-width: 0;
  align-self: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.node:nth-child(even) .node-body { margin-left: 20px; }
.node-title { display: block; font-weight: 650; }
.node-meta { display: block; font-size: .8rem; color: var(--c-text-muted); }

.node.is-completed .node-dot { background: var(--c-success); border-color: var(--c-success); color: #fff; }
.node.is-active .node-dot,
.node.is-available .node-dot { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.node.is-active .node-body { border-color: var(--c-primary); }
.node.is-active .node-dot { box-shadow: 0 0 0 5px var(--c-primary-soft); }
.node.is-locked { cursor: default; }
.node.is-locked .node-body { background: var(--c-surface-2); }
.node.is-locked .node-title,
.node.is-locked .node-meta { color: var(--c-text-muted); }

.unlock-pop { animation: unlockPop var(--dur-slow) ease both; }
@keyframes unlockPop {
  0%   { transform: scale(.7); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------------ 8 ----- */

.lesson {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
}
.lesson-head {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: calc(env(safe-area-inset-top) + var(--space-md)) var(--space-lg) var(--space-md);
}
.lesson-head .progress { flex: 1; }
.lesson-count { font-size: .82rem; font-weight: 700; color: var(--c-text-muted); min-width: 34px; text-align: right; }

.lesson-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.lesson-foot {
  padding: var(--space-md) var(--space-lg) calc(env(safe-area-inset-bottom) + var(--space-lg));
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}

.q-prompt { font-size: 1.18rem; font-weight: 700; }
.q-hint { font-size: .88rem; color: var(--c-text-muted); }

/* Persian Card (Kapitel 60): persisches Wort ist visuell das Wichtigste */
.pcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xl) var(--space-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
}
.pcard .word { font-family: var(--font-fa); direction: rtl; font-size: 2.6rem; font-weight: 700; line-height: 1.5; }
.pcard .word-lg { font-size: 3.4rem; }
.pcard .tr { font-size: 1rem; }
.pcard .de { font-size: 1.05rem; font-weight: 650; }

.answers { display: grid; gap: var(--space-md); }
.answers-2 { grid-template-columns: 1fr 1fr; }

.answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 56px;
  padding: var(--space-md);
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius-btn);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease, transform var(--dur-fast) ease;
}
.answer:active { transform: scale(.98); }
.answer[aria-pressed="true"] { border-color: var(--c-primary); background: var(--c-primary-soft); }
.answer.fa { font-size: 1.7rem; min-height: 76px; }
.answer.glyph { font-family: var(--font-fa); direction: rtl; font-size: 2.6rem; min-height: 96px; font-weight: 700; }

.answer.is-right { border-color: var(--c-success); background: var(--c-success-soft); }
.answer.is-wrong { border-color: var(--c-danger); background: var(--c-danger-soft); }
.answer .mark { font-size: 1rem; font-weight: 800; }

/* Wort bauen / Satz bauen */
.build-slot {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-btn);
  background: var(--c-surface-2);
}
.build-slot .built {
  font-family: var(--font-fa);
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.5;
}
.build-slot .placeholder { color: var(--c-text-muted); font-size: .9rem; }
.build-slot.is-right { border-style: solid; border-color: var(--c-success); background: var(--c-success-soft); }
.build-slot.is-wrong { border-style: solid; border-color: var(--c-danger); background: var(--c-danger-soft); }

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  direction: rtl;
  justify-content: center;
}
.tile {
  min-width: 56px;
  min-height: 56px;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-fa);
  direction: rtl;
  font-size: 1.7rem;
  font-weight: 700;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.tile:active { transform: scale(.94); }
.tile.used { opacity: .3; pointer-events: none; }
.tile-word { font-size: 1.35rem; }

/* Audio-Übung */
.audio-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}
.audio-circle {
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 0;
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-size: 2.6rem;
  cursor: pointer;
  box-shadow: var(--shadow-raised);
  transition: transform var(--dur-fast) ease;
}
.audio-circle:active { transform: scale(.94); }
.audio-circle.is-playing { animation: pulse 900ms ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow-raised); }
  50%      { box-shadow: 0 0 0 12px var(--c-primary-soft); }
}
.audio-row { display: flex; gap: var(--space-sm); }

/* Sprechübung */
.mic-circle {
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  font-size: 2.4rem;
  cursor: pointer;
  transition: transform var(--dur-fast) ease;
}
.mic-circle.is-recording { border-color: var(--c-danger); animation: pulse 900ms ease-in-out infinite; }

/* Feedback (Kapitel 41) — nie nur über Farbe, immer mit Zeichen und Text */
.feedback {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-btn);
  animation: riseIn var(--dur-mid) ease both;
}
.feedback .fb-icon { font-size: 1.3rem; line-height: 1.2; }
.feedback .fb-title { font-weight: 750; }
.feedback .fb-text { font-size: .92rem; }
.feedback.ok  { background: var(--c-success-soft); color: var(--c-success); }
.feedback.bad { background: var(--c-danger-soft);  color: var(--c-danger); }
.feedback .solution { color: var(--c-text); }
.feedback .solution .fa { font-family: var(--font-fa); direction: rtl; font-size: 1.35rem; font-weight: 700; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.xp-pop {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--c-accent);
  color: #26200a;
  font-weight: 800;
  font-size: .9rem;
  pointer-events: none;
  animation: xpFly 900ms ease-out both;
}
@keyframes xpFly {
  0%   { opacity: 0; transform: translate(-50%, 12px) scale(.8); }
  30%  { opacity: 1; transform: translate(-50%, -6px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* Ergebnisbildschirm (Kapitel 40) */
.result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-xl);
  background: var(--c-bg);
  text-align: center;
  overflow: hidden;
}
.result-badge { font-size: 3.4rem; }
.result-stats { display: flex; flex-direction: column; gap: var(--space-sm); }
.result-stat {
  display: flex; align-items: center; justify-content: center; gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-btn);
  font-weight: 650;
}

/* Konfetti, rein CSS (Kapitel 40) */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px; height: 14px;
  border-radius: 2px;
  opacity: .9;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0; }
}

/* ------------------------------------------------------------------ 9 ----- */

.alpha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--space-sm);
}
.letter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-sm) 4px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  cursor: pointer;
  transition: transform var(--dur-fast) ease, border-color var(--dur-fast) ease;
  min-height: 84px;
  justify-content: center;
}
.letter-card:active { transform: scale(.96); }
.letter-card .glyph { font-family: var(--font-fa); direction: rtl; font-size: 2rem; font-weight: 700; line-height: 1.2; }
.letter-card .name { font-size: .72rem; font-weight: 650; }
.letter-card .sound { font-size: .64rem; color: var(--c-text-muted); }
.letter-card .status {
  position: absolute; top: 5px; right: 6px;
  font-size: .66rem; font-weight: 800;
}
.letter-card.is-started { border-color: var(--c-accent); }
.letter-card.is-started .status { color: var(--c-accent); }
.letter-card.is-learned { border-color: var(--c-success); background: var(--c-success-soft); }
.letter-card.is-learned .status { color: var(--c-success); }

.now-learning { display: flex; gap: var(--space-sm); }
.now-learning .letter-card { flex: 0 0 76px; }

/* Buchstaben-Detailansicht (Kapitel 19) */
.detail-glyph {
  font-family: var(--font-fa);
  direction: rtl;
  font-size: 5.4rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: var(--c-primary);
}
.forms { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-sm); }
.forms-2 { grid-template-columns: repeat(2, 1fr); }
.form-box {
  padding: var(--space-sm) 4px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  text-align: center;
}
.form-box .glyph { font-family: var(--font-fa); direction: rtl; font-size: 1.9rem; font-weight: 700; line-height: 1.4; }
.form-box .lbl { font-size: .64rem; color: var(--c-text-muted); }

/* Schreibtraining (Kapitel 20) */
.canvas-wrap {
  position: relative;
  border: 2px dashed var(--c-border);
  border-radius: var(--radius-card);
  background: var(--c-surface);
  overflow: hidden;
}
.canvas-wrap canvas { display: block; width: 100%; height: 300px; touch-action: none; cursor: crosshair; }
.write-done {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: var(--space-sm);
  background: var(--c-success-soft);
  animation: riseIn var(--dur-mid) ease both;
  text-align: center;
  padding: var(--space-lg);
}
.write-done .tick { font-size: 2.6rem; color: var(--c-success); }

/* ----------------------------------------------------------------- 10 ----- */

.practice-grid { display: grid; gap: var(--space-md); }
.practice-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  text-align: left;
  padding: var(--space-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform var(--dur-fast) ease;
}
.practice-card:active { transform: scale(.99); }
.practice-card .emoji { font-size: 1.7rem; }
.practice-card .arrow { color: var(--c-text-muted); font-weight: 800; }

/* ----------------------------------------------------------------- 11 ----- */

.avatar {
  width: 76px; height: 76px;
  border-radius: 26px;
  display: grid; place-items: center;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--c-on-primary);
  background: linear-gradient(140deg, var(--c-primary), var(--c-accent));
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
.stat-box {
  padding: var(--space-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 16px;
}
.stat-box .val { font-size: 1.25rem; font-weight: 800; }
.stat-box .lbl { font-size: .78rem; color: var(--c-text-muted); }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--c-border);
}
.setting:last-child { border-bottom: 0; }
.setting-label { display: block; font-weight: 600; }
.setting-sub { font-size: .8rem; color: var(--c-text-muted); }

.switch {
  flex: 0 0 auto;
  width: 52px; height: 30px;
  border-radius: var(--radius-pill);
  border: 0;
  background: var(--c-border);
  position: relative;
  cursor: pointer;
  transition: background var(--dur-fast) ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform var(--dur-fast) ease;
}
.switch[aria-checked="true"] { background: var(--c-primary); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); }
.badge {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-md);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  background: var(--c-surface);
}
.badge .emoji { font-size: 1.5rem; }
.badge > span:last-child { min-width: 0; }
.badge .t { display: block; font-weight: 650; font-size: .9rem; }
.badge .r { display: block; font-size: .72rem; color: var(--c-text-muted); }
.badge.locked { opacity: .5; }
.badge.locked .emoji { filter: grayscale(1); }

.demo-box {
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  background: transparent;
}
.theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); }
.theme-btn {
  padding: var(--space-sm);
  border: 2px solid var(--c-border);
  border-radius: 14px;
  background: var(--c-surface);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 650;
}
.theme-btn[aria-pressed="true"] { border-color: var(--c-primary); background: var(--c-primary-soft); }
.theme-swatch { display: flex; gap: 3px; justify-content: center; margin-bottom: 5px; }
.theme-swatch i { width: 12px; height: 12px; border-radius: 4px; }

.disclaimer {
  font-size: .78rem;
  color: var(--c-text-muted);
  padding: var(--space-md);
  border-left: 3px solid var(--c-border);
}

/* ----------------------------------------------------------------- 12 ----- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--c-bg);
  animation: slideUp var(--dur-mid) ease both;
}
.overlay[hidden] { display: none; }
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: calc(env(safe-area-inset-top) + var(--space-md)) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.sheet-head h2 { flex: 1; font-size: 1.05rem; }
.sheet-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-lg);
}
.sheet-foot {
  padding: var(--space-md) var(--space-lg) calc(env(safe-area-inset-bottom) + var(--space-lg));
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  display: flex; flex-direction: column; gap: var(--space-sm);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--space-lg);
  background: rgba(12, 12, 24, .5);
  animation: fadeIn var(--dur-fast) ease both;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 340px;
  background: var(--c-surface);
  border-radius: var(--radius-card);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  animation: riseIn var(--dur-mid) ease both;
}

.toast {
  position: absolute;
  left: var(--space-lg);
  right: var(--space-lg);
  bottom: calc(env(safe-area-inset-bottom) + 76px);
  z-index: 60;
  margin: 0;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-btn);
  background: var(--c-text);
  color: var(--c-bg);
  font-size: .9rem;
  box-shadow: var(--shadow-raised);
  animation: riseIn var(--dur-mid) ease both;
}
.toast[hidden] { display: none; }

/* ----------------------------------------------------------------- 13 ----- */

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Wenn Animationen in den Einstellungen ausgeschaltet sind (Kapitel 35) */
html[data-anim="off"] *, html[data-anim="off"] *::before, html[data-anim="off"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
