/* =============================================================================
   Mathi V2 – style.css
   Aufbaut auf lmb-app.css (Design-Tokens via --lmb-* Variablen).
   ============================================================================= */

/* =============================================================================
   DESIGN-TOKENS (ergänzend zu lmb-app.css)
   ============================================================================= */
:root {
  /* Semantische Aliase */
  --blau:        var(--lmb-primary);
  --blau-hell:   var(--lmb-accent);
  --blau-bg:     rgba(99, 102, 241, 0.1);
  --gruen:       var(--lmb-secondary);
  --gruen-hell:  rgba(16, 185, 129, 0.1);
  --rot:         #ef4444;
  --rot-hell:    rgba(239, 68, 68, 0.1);
  --gelb:        #f59e0b;
  --gelb-hell:   rgba(245, 158, 11, 0.1);
  --orange:      #f97316;

  --bg:          var(--lmb-bg-dark);
  --surface:     var(--lmb-bg-surface);
  --surface-hover: var(--lmb-bg-surface-hover);
  --text:        var(--lmb-text-main);
  --muted:       var(--lmb-text-muted);
  --border:      rgba(255, 255, 255, 0.08);

  --radius:      var(--lmb-radius-md);      /* 12px */
  --radius-sm:   8px;
  --radius-lg:   var(--lmb-radius-lg);      /* 24px */
  --radius-full: var(--lmb-radius-full);    /* 100px */

  --shadow:      0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.5);
  --glow:        var(--lmb-shadow-glow);

  --trans:       var(--lmb-trans-smooth);
  --trans-fast:  var(--lmb-trans-fast);

  --schrift:     'Outfit', system-ui, sans-serif;
  --mono:        'Menlo', 'Consolas', monospace;
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--schrift);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
a { color: var(--blau); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Hilfklasse */
.versteckt { display: none !important; }

/* =============================================================================
   ANIMATIONEN
   ============================================================================= */
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(40px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes benFloat {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-15px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.85); }
  70%  { transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

/* =============================================================================
   APP LAYOUT
   ============================================================================= */
.app-main {
  flex: 1;
  position: relative;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: calc(100vh - 60px);
  width: 100%;
}

.screen.aktiv {
  display: block;
}

/* =============================================================================
   HEADER
   ============================================================================= */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  transition: opacity var(--trans-fast);
}
.header-logo:hover { opacity: 0.8; }

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  background: var(--lmb-grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.logo-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  line-height: 1;
}

/* Level-Badge (Mitte) */
.header-center { flex: 1; display: flex; justify-content: center; }

.level-badge {
  background: var(--blau-bg);
  color: var(--blau);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-full);
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--trans-fast);
}
.level-badge:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: translateY(-1px);
}
.level-badge-label { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.level-badge-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  min-width: 1.2em;
  text-align: center;
}
.level-badge-icon { font-size: 0.9rem; }
.level-badge-label--mobile { display: none; }

/* Nav-Buttons */
.header-nav {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
}

.header-nav button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  transition: var(--trans-fast);
}

.header-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 40px;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
}

.header-nav-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border);
  transform: translateY(-1px);
}

.header-nav-icon {
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-nav-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-nav-label {
  color: inherit;
}

.badge {
  display: inline-block;
  background: var(--rot);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 0 0.35rem;
  margin-left: 0.15rem;
  min-width: 1.2em;
  text-align: center;
  vertical-align: middle;
}

.header-nav-btn .badge {
  margin-left: 0;
}

.badge:empty { display: none; }

/* =============================================================================
   BEN SIDEBAR (gemeinsam für Start + Aufgabe)
   ============================================================================= */
.ben-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.ben-char-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
  transition: var(--trans);
}

.ben-speech-wrap {
  background: var(--blau-bg);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: relative;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
  width: 100%;
  box-shadow: var(--shadow);
}
.ben-speech-wrap::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: rgba(99, 102, 241, 0.25);
}

/* =============================================================================
   START-SCREEN
   ============================================================================= */
.start-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 60px);
  position: relative;
}

#screen-start {
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 30%),
    radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 28%),
    var(--bg);
}

#screen-start .ben-sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  width: 260px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  justify-content: flex-start;
  padding: 2.25rem 1.5rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    var(--surface);
  z-index: 850;
}

#screen-start .ben-char-img {
  width: 200px;
  height: 200px;
}

#screen-start .ben-speech-wrap {
  max-width: 220px;
  text-align: center;
}

.start-content {
  grid-column: 2;
  padding: 2.5rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  overflow: visible;
}

.start-shell {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.start-hero-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(255, 255, 255, 0.02) 36%, rgba(16, 185, 129, 0.08)),
    var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.start-hero-card::after {
  content: '';
  position: absolute;
  inset: auto -5% -40% auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.22), transparent 68%);
  pointer-events: none;
}

.start-hero-copy {
  position: relative;
  z-index: 1;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.start-eyebrow {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--blau-hell);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.start-title {
  font-size: clamp(1.9rem, 3.1vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  max-width: 14ch;
}

.start-lead {
  font-size: 1rem;
  color: var(--muted);
  max-width: 62ch;
}

/* Modus-Bereich */
.start-modus-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.start-section-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Modus-Kacheln */
.kachel-grid.kachel-grid-modi {
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.kachel-grid-modi .kachel {
  padding: 1.15rem 1rem;
  min-height: 136px;
  border-radius: 18px;
  border-width: 2px;
  gap: 0.55rem;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.kachel-grid-modi .kachel-icon { font-size: 2rem; }
.kachel-grid-modi .kachel-name { font-size: 0.94rem; color: var(--text); }
.kachel-grid-modi .kachel-desc { font-size: 0.8rem; opacity: 0.82; text-align: left; }

/* Mode-Farbakzente */
.kachel-grid-modi [data-modus="allgemein"] { border-top: 3px solid var(--blau); }
.kachel-grid-modi [data-modus="spezifisch"] { border-top: 3px solid var(--gruen); }
.kachel-grid-modi [data-modus="selbsttest"] { border-top: 3px solid var(--orange); }

.kachel-grid-modi [data-modus="allgemein"].aktiv { box-shadow: 0 0 0 1px var(--blau), var(--glow); }
.kachel-grid-modi [data-modus="spezifisch"].aktiv { border-color: var(--gruen); box-shadow: 0 0 0 1px var(--gruen); background: rgba(16, 185, 129, 0.08); }
.kachel-grid-modi [data-modus="spezifisch"].aktiv .kachel-name { color: var(--gruen); }
.kachel-grid-modi [data-modus="selbsttest"].aktiv { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); background: rgba(249, 115, 22, 0.08); }
.kachel-grid-modi [data-modus="selbsttest"].aktiv .kachel-name { color: var(--orange); }

.start-tool-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

/* =============================================================================
   KATEGORIE-BLÖCKE (Start-Screen)
   ============================================================================= */
.start-kategorien {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.75rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(8, 12, 22, 0.45);
  box-shadow: var(--shadow);
}

.start-kategorien-header {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 720px;
}

.start-kategorien-subtext {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.kat-block {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)), var(--surface);
  border-radius: 20px;
  padding: 1.35rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
}

.kat-titel {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
}

/* =============================================================================
   KACHELN (Aufgabentypen + Modi)
   ============================================================================= */
.kachel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.75rem;
}

.kachel {
  background: var(--surface-hover);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 0.95rem 0.65rem;
  text-align: center;
  cursor: pointer;
  transition: var(--trans);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  position: relative;
  user-select: none;
}

.kachel:hover {
  background: var(--blau-bg);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.kachel.aktiv {
  background: var(--blau-bg);
  border-color: var(--blau);
  box-shadow: 0 0 0 1px var(--blau), var(--glow);
}
.kachel.aktiv .kachel-name { color: var(--blau); }

.kachel-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.kachel-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
  transition: color var(--trans-fast);
}

.kachel-desc {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.7;
}

/* Lock-Zustand */
.kachel.locked {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.kachel.locked:hover {
  background: var(--surface-hover);
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

.lock-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.5);
  color: #ccc;
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  line-height: 1.4;
}

/* Wenn Level hoch genug → locked entfernen (via JS-Klasse) */
.kachel.freigeschaltet {
  opacity: 1;
  cursor: pointer;
  pointer-events: auto;
}
.kachel.freigeschaltet .lock-badge { display: none; }

/* =============================================================================
   SELBSTTEST-OPTIONEN
   ============================================================================= */
.selftest-optionen {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--blau-bg);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 1.5rem;
  animation: fadeDown 0.25s ease;
}

.selftest-optionen label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.selftest-optionen input[type="number"] {
  width: 60px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  font-weight: 700;
}

.selftest-optionen input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blau);
  cursor: pointer;
}

/* =============================================================================
   START-AKTION (Loslegen-Button)
   ============================================================================= */
.start-aktion {
  display: flex;
  justify-content: flex-end;
  padding: 0;
}

.btn-start-loslegen {
  background: var(--lmb-grad-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 1rem 2.4rem;
  min-width: 220px;
  font-size: 1.08rem;
  font-weight: 800;
  box-shadow: var(--glow);
  transition: var(--trans);
  letter-spacing: -0.02em;
}
.btn-start-loslegen:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.45);
}
.btn-start-loslegen:active {
  transform: translateY(0) scale(0.98);
}

/* =============================================================================
   AUFGABE-SCREEN
   ============================================================================= */
.aufgabe-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 60px);
  position: relative;
}

/* Aufgaben-Ben-Sidebar */
#screen-aufgabe .ben-sidebar {
  padding: 1.5rem 1.25rem;
}
#screen-aufgabe .ben-char-img {
  width: 140px;
  height: 140px;
}

/* Timer */
.timer-display {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-hover);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  text-align: center;
  width: 100%;
}

/* Fortschritt */
.fortschritt-anzeige {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

/* Formel-Button (Sidebar) */
.btn-sekundaer.formel-trigger {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: auto;
  line-height: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.formel-trigger-icon {
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.formel-trigger-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-sekundaer.formel-trigger:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.formel-trigger-mobile { display: none; }

/* Aufgaben-Hauptbereich */
.aufgabe-haupt {
  display: flex;
  flex-direction: column;
  padding: 2.5rem 4rem;
  gap: 1.75rem;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  justify-content: center;
}

/* Aufgabentext */
.task-display { text-align: center; }

.aufgabe-text {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 1rem;
}

/* Einheiten-Check-Hinweis */
.unit-check-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gelb-hell);
  color: var(--gelb);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.75rem;
}

/* Eingabe-Bereich */
.answer-area {
  background: var(--surface);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

#eingabe-zahl {
  flex: 1;
  font-size: 1.75rem;
  font-family: var(--mono);
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
  color: var(--text);
  text-align: center;
  transition: border-color var(--trans-fast);
}
#eingabe-zahl:focus {
  outline: none;
  border-color: var(--blau);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
#eingabe-zahl.korrekt  { border-color: var(--gruen); background: rgba(16,185,129,0.08); }
#eingabe-zahl.falsch   { border-color: var(--rot);   background: rgba(239,68,68,0.08); }

.einheit-select {
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--trans-fast);
  min-width: 80px;
}
.einheit-select:focus {
  outline: none;
  border-color: var(--blau);
}

/* Buttons */
.action-buttons {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.btn-pruefen {
  flex: 1;
  background: var(--lmb-grad-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: var(--glow);
  transition: var(--trans);
}
.btn-pruefen:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}
.btn-pruefen:active { transform: translateY(0); }

.secondary-actions { margin-top: -0.5rem; }

.btn-sekundaer {
  flex: 1;
  background: var(--surface-hover);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--trans-fast);
}
.btn-sekundaer:hover {
  background: var(--surface);
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

/* Feedback-Box */
.feedback-box {
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  animation: popIn 0.3s ease;
}
.feedback-box.richtig {
  background: var(--gruen-hell);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}
.feedback-box.falsch {
  background: var(--rot-hell);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Lösungsweg-Panel */
.loesung-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  animation: fadeDown 0.3s ease;
}

.loesung-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.loesung-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--blau);
}

.btn-sm {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: var(--trans-fast);
}
.btn-sm:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }

/* Lösungsschritte */
.loesung-schritte {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.loesung-schritt {
  background: var(--surface-hover);
  border-left: 3px solid var(--blau);
  border-radius: 4px;
  padding: 0.65rem 0.85rem;
  animation: slideInLeft 0.3s ease-out both;
}

.schritt-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.schritt-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Nächste-Aufgabe-Button */
.next-btn-wrap {
  animation: fadeDown 0.3s ease;
}

.btn-naechste {
  width: 100%;
  background: var(--gruen);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  transition: var(--trans);
}
.btn-naechste:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

/* =============================================================================
   FORMELBLATT DRAWER (Slide-in von rechts)
   ============================================================================= */
.formel-drawer {
  position: fixed;
  right: -340px;
  top: 60px;
  width: 340px;
  height: calc(100vh - 60px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.4);
  transition: right var(--trans);
  z-index: 900;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.formel-drawer.offen { right: 0; }

.formel-tab {
  position: absolute;
  left: -46px;
  top: 24px;
  background: var(--blau);
  color: #fff;
  padding: 0.9rem 0.45rem;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  box-shadow: -3px 0 10px rgba(0,0,0,0.3);
  user-select: none;
}

.formel-close-btn {
  display: none;
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--trans-fast);
}
.formel-close-btn:hover { color: var(--text); }

/* Formelblatt-Inhalt-Styles */
.fb-titel {
  font-size: 1rem;
  font-weight: 800;
  color: var(--blau);
  margin-bottom: 0.5rem;
}

.formel-gruppe {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}

.formel-gruppe h4 {
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.formel-gruppe ul {
  margin-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.formel-gruppe li {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Brüche im Formelblatt */
.fb-frac, .fraction {
  display: inline-flex;
  flex-direction: column;
  text-align: center;
  vertical-align: middle;
  line-height: 1;
  font-size: 0.88em;
}
.fb-frac > span:first-child,
.frac-top {
  border-bottom: 1px solid var(--text);
  padding: 0 0.2em 0.05em;
}
.fb-frac > span:last-child,
.frac-bot {
  padding: 0.05em 0.2em 0;
}

/* =============================================================================
   ERGEBNIS-SCREEN
   ============================================================================= */
.screen-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.screen-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.ergebnis-wrap {
  max-width: 700px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.ergebnis-score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-lg);
}

.ergebnis-ben {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
  animation: benFloat 2.5s ease-in-out infinite;
}

.ergebnis-score {
  font-size: 3rem;
  font-weight: 800;
  background: var(--lmb-grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.ergebnis-kommentar {
  font-size: 1rem;
  color: var(--muted);
  max-width: 400px;
}

.ergebnis-balken-wrap {
  width: 100%;
  background: var(--surface-hover);
  border-radius: var(--radius-full);
  height: 12px;
  overflow: hidden;
}

.ergebnis-balken {
  height: 100%;
  background: var(--lmb-grad-primary);
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.ergebnis-liste {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ergebnis-eintrag {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.5rem;
  align-items: start;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.ergebnis-eintrag.richtig {
  background: var(--gruen-hell);
  border-left: 3px solid var(--gruen);
}
.ergebnis-eintrag.falsch {
  background: var(--rot-hell);
  border-left: 3px solid var(--rot);
}
.ergebnis-eintrag-nr { font-weight: 700; color: var(--muted); }
.ergebnis-eintrag-antwort { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }

.ergebnis-aktionen {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* =============================================================================
   STATISTIK-SCREEN
   ============================================================================= */
.statistik-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.stat-header-card {
  background: var(--lmb-grad-primary);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-lg);
}
.stat-header-left h2 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.stat-subtitle { font-size: 0.88rem; opacity: 0.85; }

.stat-header-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.stat-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 3px solid rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-ring-value { font-size: 1.35rem; font-weight: 800; }
.stat-ring-label { font-size: 0.75rem; opacity: 0.8; }

.stat-sektionen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.stat-leer {
  color: var(--muted);
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

.stat-kat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: transform var(--trans-fast), box-shadow var(--trans-fast);
}
.stat-kat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-kat-card.stat-gut    { border-left: 4px solid var(--gruen); }
.stat-kat-card.stat-mittel { border-left: 4px solid var(--gelb); }
.stat-kat-card.stat-schwach{ border-left: 4px solid var(--rot); }
.stat-kat-card.stat-leer   { border-left: 4px solid var(--border); opacity: 0.5; }

.stat-kat-header { display: flex; justify-content: space-between; align-items: center; }
.stat-kat-name { font-weight: 700; font-size: 0.92rem; }
.stat-kat-quote { font-size: 1.2rem; font-weight: 800; color: var(--blau); }

.stat-balken-wrap {
  background: var(--surface-hover);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
}
.stat-balken {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}
.stat-gut    .stat-balken { background: var(--gruen); }
.stat-mittel .stat-balken { background: var(--gelb); }
.stat-schwach .stat-balken { background: var(--rot); }

.stat-fehlertypen h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.fehlertypen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.fehlertyp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fehlertyp-anzahl {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--rot);
}

/* =============================================================================
   MERKLISTE-SCREEN
   ============================================================================= */
.merkliste-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

.merkliste-header { margin-bottom: 1rem; }
.merkliste-count { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

.merkliste-liste {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.merkliste-eintrag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--trans-fast);
}
.merkliste-eintrag:hover { box-shadow: var(--shadow-lg); }

/* Kategorie-Akzentfarben */
.kat-einheiten { border-left-color: var(--blau); }
.kat-bewegung  { border-left-color: var(--orange); }
.kat-kraft     { border-left-color: var(--gruen); }
.kat-farbe     { border-left-color: var(--rot); }
.kat-papier    { border-left-color: #a78bfa; }
.kat-nutzen    { border-left-color: var(--gelb); }

.merkliste-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.merkliste-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-hover);
  border-radius: 4px;
  padding: 0.12rem 0.45rem;
  color: var(--muted);
}

.merkliste-datum { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

.merkliste-text {
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.merkliste-aktionen { display: flex; gap: 0.5rem; }

.btn-wieder {
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--blau-bg);
  color: var(--blau);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: var(--trans-fast);
}
.btn-wieder:hover { background: rgba(99,102,241,0.2); }

.merkliste-leer {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}
.merkliste-leer-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  opacity: 0.3;
}
.merkliste-leer p { margin: 0.25rem 0; }
.merkliste-leer-hint { font-size: 0.82rem; opacity: 0.7; margin-top: 0.5rem; }

/* =============================================================================
   MODALS
   ============================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.aktiv {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  position: relative;
  animation: slideInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-ben {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-top: -70px;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.modal-content h2 { font-size: 1.4rem; margin-bottom: 0.75rem; }
.modal-content > p { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.75rem; }
.modal-hint { font-size: 0.82rem; color: var(--muted); margin-top: 1.5rem; font-style: italic; }

/* Level-Wahl-Grid */
.level-wahl-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.level-btn {
  background: var(--surface-hover);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  grid-template-rows: auto auto;
  gap: 0 0.75rem;
  align-items: center;
  transition: var(--trans);
}
.level-btn:hover {
  border-color: var(--blau);
  background: var(--blau-bg);
  transform: scale(1.01);
}
.level-btn.aktiv {
  border-color: var(--blau);
  background: var(--blau-bg);
  box-shadow: var(--glow);
}

/* «Dein Level»-Badge auf dem aktuell gewählten Level-Button */
.level-btn.aktiv::after {
  content: '✓ Aktuell';
  position: absolute;
  top: 0.45rem;
  right: 0.7rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--blau);
  background: var(--blau-bg);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.level-btn { position: relative; }

.level-btn-nr {
  grid-row: 1 / 3;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--blau);
  text-align: center;
}
.level-btn-titel {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.level-btn-desc {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-sekundaer-modal {
  flex: none;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-full);
}

/* =============================================================================
   PAPER-MODAL (Papierrechnen)
   ============================================================================= */
.paper-modal-content {
  max-width: 500px;
}

.paper-modal-ben {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin-top: -90px;
  margin-bottom: 1.25rem;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.5));
  animation: benFloat 2.5s ease-in-out infinite;
}

.paper-modal-text {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 1.75rem;
}

.paper-modal-btn {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.05rem;
}

/* =============================================================================
   UPGRADE-MODAL
   ============================================================================= */
.upgrade-modal .modal-content { }

/* =============================================================================
   RECHENWEG-PANEL (ui/rechenweg.js)
   ============================================================================= */
.rechenweg-panel {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 0.75rem;
  margin-bottom: 1rem;
}

.rw-titel {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--blau);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.rw-schritt {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background var(--trans-fast), border-color var(--trans-fast);
}

.rw-schritt-info {
  background: transparent;
  border-color: transparent;
  padding: 0.2rem 0.4rem;
}

.rw-schritt.rw-richtig {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

@keyframes rw-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

.rw-schritt.rw-falsch {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  animation: rw-shake 0.4s ease;
}

.rw-schritt-nr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  background: var(--blau-bg);
  color: var(--blau);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 0.1rem;
}

.rw-schritt.rw-richtig .rw-schritt-nr {
  background: rgba(16, 185, 129, 0.15);
  color: var(--gruen);
}

.rw-schritt-text {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.5;
  padding-top: 0.1rem;
}

.rw-info-text {
  color: var(--muted);
  font-style: italic;
}

.rw-eingabe-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.rw-eingabe {
  width: 7rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  text-align: right;
  transition: border-color var(--trans-fast);
}

.rw-eingabe:focus {
  outline: none;
  border-color: var(--blau);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.rw-eingabe:disabled {
  opacity: 0.5;
  cursor: default;
  background: var(--surface);
}

.rw-einheit {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 1.5rem;
}

.rw-feedback {
  font-size: 1rem;
  font-weight: 700;
  width: 1.2rem;
  text-align: center;
  transition: color var(--trans-fast);
}

.rw-feedback.rw-ok  { color: var(--gruen); }
.rw-feedback.rw-nein { color: var(--rot); }

/* Rechenweg-Toggle (Expertenoption – dezent) */
.rechenweg-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  cursor: pointer;
  width: fit-content;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.03);
  transition: opacity var(--trans-fast), border-color var(--trans-fast), background var(--trans-fast);
}
.rechenweg-toggle-row:hover {
  opacity: 1;
  border-color: rgba(99, 102, 241, 0.22);
  background: rgba(99, 102, 241, 0.08);
}

.rechenweg-toggle-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
  accent-color: var(--blau);
}

.rechenweg-toggle-row .rw-toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.rechenweg-toggle-row .rw-toggle-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 0.2rem;
}

/* Export-Modal */
.export-modal .export-optionen {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0 0.75rem;
}

.export-modal .btn-export-loe {
  background: var(--gruen-hell);
  color: var(--gruen);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.export-modal .btn-export-loe:hover {
  background: var(--gruen);
  color: #fff;
}

.export-leer-hinweis {
  background: var(--gelb-hell);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: var(--gelb);
  margin: 1rem 0;
  text-align: left;
}

/* =============================================================================
   WAKE-LOCK BUTTON
   ============================================================================= */
.wake-lock-btn {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  min-width: 44px;
  height: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  cursor: pointer;
  z-index: 800;
  transition: var(--trans);
  box-shadow: var(--shadow);
}
.wake-lock-btn:hover { background: var(--surface-hover); color: var(--text); }
.wake-lock-btn[aria-pressed="true"] {
  background: var(--blau-bg);
  border-color: var(--blau);
  color: var(--blau);
}

/* =============================================================================
   RESPONSIVE – Breakpoint 800px
   ============================================================================= */
@media (max-width: 800px) {

  /* Start */
  .start-layout {
    grid-template-columns: 1fr;
  }
  #screen-start .ben-sidebar { display: none; }

  .start-content { padding: 1.25rem; gap: 1.25rem; }
  .start-shell { gap: 1.25rem; }
  .start-hero-card { padding: 1.4rem; border-radius: 22px; }
  .start-title { max-width: none; }
  .start-tool-row { flex-direction: column; align-items: stretch; }
  .start-aktion { width: 100%; justify-content: stretch; }
  .btn-start-loslegen { width: 100%; }
  .rechenweg-toggle-row { width: 100%; justify-content: center; flex-wrap: wrap; border-radius: 18px; }
  .start-kategorien { padding: 1.1rem; border-radius: 22px; }
  .kachel-grid.kachel-grid-modi { grid-template-columns: 1fr; }
  .kachel-grid-modi .kachel { min-height: 96px; padding: 1rem 0.85rem; }
  .kachel-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .selftest-optionen { flex-direction: column; gap: 0.75rem; }
  .start-section-label { font-size: 1rem; }

  /* Aufgabe */
  .aufgabe-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  #screen-aufgabe .ben-sidebar { display: none; }
  .aufgabe-haupt {
    padding: 1rem 0.75rem;
    gap: 1rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
  }
  .task-display { overflow-x: hidden; }
  .aufgabe-text { font-size: 1.1rem; overflow-wrap: break-word; word-break: break-word; }
  .answer-area { padding: 0.85rem; gap: 0.85rem; }
  #eingabe-zahl { font-size: 1.3rem; padding: 0.6rem 0.6rem; min-width: 0; }
  .einheit-select { min-width: 70px; font-size: 0.9rem; }
  .action-buttons { flex-wrap: wrap; }
  .btn-pruefen { min-width: 0; }
  .btn-sekundaer { min-width: 0; font-size: 0.82rem; padding: 0.6rem 0.75rem; }

  /* Status-Bar (Timer + Fortschritt) auf Mobile */
  .aufgabe-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.25rem 0 0.5rem;
  }

  .formel-trigger-desktop { display: none; }
  .formel-trigger-mobile  { display: block; margin-top: 0.75rem; }

  /* Formelblatt als Bottom Sheet */
  .formel-drawer {
    width: 100%;
    left: 0;
    right: 0;
    bottom: -72vh;
    top: auto;
    height: 72vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    transition: bottom 0.3s ease;
    padding-top: 0.5rem;
  }
  .formel-drawer.offen { bottom: 0; }
  .formel-tab { display: none; }
  .formel-close-btn { display: flex; }

  /* Drag-Handle */
  .formel-handle {
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 0.75rem;
    flex-shrink: 0;
  }

  /* Ben-Bubble */
  body.screen-aufgabe-aktiv .ben-bubble {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 850;
  }
  .ben-bubble-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    padding: 0;
    cursor: pointer;
    overflow: hidden;
  }
  #screen-aufgabe .ben-bubble .ben-char-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
  }
  .ben-bubble-speech-wrap {
    max-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: none;
  }
  .ben-bubble-speech-wrap.sichtbar { display: block; }

  /* Header */
  .header-logo .logo-sub { display: none; }
  .header-nav-btn { padding: 0.45rem 0.7rem; font-size: 0.82rem; }
  .header-nav-label { display: none; }
  .level-badge-icon { display: none; }
  .level-badge-label--desktop { display: none; }
  .level-badge-label--mobile { display: inline; }
  #btn-export { display: none; }

  /* Modals */
  .modal-ben { margin-top: -50px; width: 90px; height: 90px; }
  .level-wahl-grid { gap: 0.5rem; }

  /* Statistik */
  .stat-header-card { flex-direction: column; gap: 1rem; text-align: center; }
  .stat-sektionen { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .start-hero-card { padding: 1.15rem; }
  .start-title { font-size: 1.6rem; }
  .start-lead, .start-kategorien-subtext { font-size: 0.9rem; }
  .aufgabe-text { font-size: 1.1rem; }
  #eingabe-zahl { font-size: 1.4rem; }
  .btn-start-loslegen { padding: 0.9rem 2rem; font-size: 1rem; }
  .kachel-icon { font-size: 1.3rem; }
  .kachel-name { font-size: 0.72rem; }
}

/* Mobil 390px (iPhone-Klasse) – feinere Anpassungen */
@media (max-width: 400px) {
  /* Header: Export-Button-Text ausblenden */
  #btn-export { font-size: 1rem; padding: 0.35rem 0.45rem; }

  /* Eingabezeile auf sehr kleinen Screens */
  .input-row { flex-wrap: wrap; }
  .einheit-select { flex: 1 0 auto; }

  /* Rechenweg: kompaktere Schritte */
  .rw-schritt { flex-wrap: wrap; gap: 0.35rem; }
  .rw-eingabe-wrap { width: 100%; justify-content: flex-end; }
  .rw-eingabe { width: 100%; text-align: left; }

  /* Merkliste-Aktionen stapeln */
  .merkliste-aktionen { flex-wrap: wrap; }
  .merkliste-aktionen .btn-wieder { flex: 1; }

  /* Stat-Cards ein bisschen kleiner */
  .stat-kat-quote { font-size: 1rem; }

  /* Modal-Buttons untereinander */
  .export-modal .export-optionen { gap: 0.5rem; }
}

/* =============================================================================
   MOBILE-ONLY ELEMENTE (auf Desktop immer versteckt)
   ============================================================================= */
.ben-bubble       { display: none; }
.aufgabe-status-bar { display: none; }
.formel-handle    { display: none; }

/* =============================================================================
   FOOTER
   ============================================================================= */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  margin-top: 2rem;
}

.app-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.app-footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: color var(--trans-fast);
}
.app-footer-brand:hover { color: var(--text); }
.app-footer-brand img  { width: 24px; height: 24px; border-radius: 50%; opacity: 0.7; }

.app-footer-copy {
  font-size: 0.78rem;
  color: var(--muted);
}
.app-footer-copy a { color: var(--muted); text-decoration: none; }
.app-footer-copy a:hover { color: var(--text); }

.app-footer-nav {
  display: flex;
  gap: 1rem;
}
.app-footer-nav a {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--trans-fast);
}

/* =============================================================================
   ONBOARDING-SCREEN
   ============================================================================= */
.onboarding-layout {
  display: block;
  min-height: calc(100vh - 60px);
}

#screen-onboarding {
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.14), transparent 30%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.1), transparent 28%),
    var(--bg);
}

.onboarding-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.5rem;
  padding: 2.5rem 2rem 3rem;
}

.onboarding-shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(620px, 1.06fr);
  align-items: start;
  gap: 1.5rem;
}

.onboarding-hero-card,
.onboarding-form-card {
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
}

.onboarding-hero-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(255, 255, 255, 0.02) 36%, rgba(16, 185, 129, 0.08)),
    var(--surface);
}

.onboarding-hero-card::after {
  content: '';
  position: absolute;
  inset: auto auto -36% 72%;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2), transparent 68%);
  pointer-events: none;
}

.onboarding-hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.onboarding-hero-main {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(220px, 320px);
  align-items: center;
  gap: 1.5rem;
}

.onboarding-title {
  font-size: clamp(1.9rem, 3vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  max-width: 14ch;
}

.onboarding-lead {
  font-size: 1rem;
  color: var(--muted);
  max-width: 62ch;
}

.onboarding-ben-speech {
  margin-top: 0.35rem;
  max-width: 460px;
}

.onboarding-ben-speech::before {
  left: 2rem;
  transform: none;
}

.onboarding-ben-panel {
  position: relative;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-ben-orbit {
  position: absolute;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.06) 42%, transparent 72%);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.onboarding-ben-img {
  position: relative;
  z-index: 1;
  width: min(100%, 250px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.35));
}

.onboarding-info-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.onboarding-info-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.onboarding-info-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.onboarding-info-card strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}

.onboarding-info-card p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.onboarding-form-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.75rem;
  background: rgba(8, 12, 22, 0.45);
  min-height: 100%;
}

.onboarding-form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.onboarding-section-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.onboarding-section-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.onboarding-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

.onboarding-input {
  width: 100%;
  padding: 1rem 1.15rem;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)), var(--surface);
  color: var(--text);
  transition: border-color var(--trans), box-shadow var(--trans-fast), background var(--trans-fast);
  box-sizing: border-box;
}

.onboarding-input:focus {
  outline: none;
  border-color: var(--blau);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.onboarding-level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.9rem;
}

.onboarding-level-grid .level-btn {
  min-width: 0;
  padding: 1.15rem 1rem 1rem;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: var(--trans);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.onboarding-level-grid .level-btn:hover {
  border-color: rgba(99, 102, 241, 0.28);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-2px);
}

.onboarding-level-grid .level-btn.aktiv {
  border-color: var(--blau);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 1px var(--blau), var(--glow);
}

.onboarding-level-grid .level-btn.aktiv::after {
  content: 'Empfohlen';
  position: absolute;
  top: -0.55rem;
  right: 0.9rem;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff;
  background: var(--lmb-grad-primary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  padding: 0.22rem 0.55rem;
  box-shadow: 0 8px 18px rgba(99, 102, 241, 0.28);
  z-index: 1;
}

.onboarding-level-grid .level-btn-nr {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--blau);
}

.onboarding-level-grid .level-btn-titel {
  font-weight: 700;
  font-size: 0.96rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.onboarding-level-grid .level-btn-desc {
  font-size: 0.79rem;
  color: var(--muted);
  text-align: left;
  overflow-wrap: anywhere;
}

.onboarding-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-top: 0.25rem;
}

.btn-onboarding-start {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-full);
  background: var(--lmb-grad-primary);
  color: #fff;
  cursor: pointer;
  transition: var(--trans);
  box-shadow: var(--glow);
}

.btn-onboarding-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.35);
}

.onboarding-fehler {
  color: #fca5a5;
  font-size: 0.88rem;
  display: none;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
}

/* =============================================================================
   EXPORT TYP-LISTE (Aufgabenblatt-Generator)
   ============================================================================= */
.export-typ-liste {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
  text-align: left;
}
.export-kat-gruppe { margin-bottom: 1rem; }
.export-kat-titel {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0.5rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.export-typ-zeile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.25rem;
  border-radius: 4px;
  cursor: pointer;
}
.export-typ-zeile:hover { background: var(--hover, rgba(255,255,255,0.05)); }
.export-typ-cb { flex-shrink: 0; cursor: pointer; }
.export-typ-name { flex: 1; font-size: 0.9rem; }
.export-typ-anzahl {
  width: 3.5rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.25rem;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

@media (max-width: 680px) {
  .onboarding-layout {
    min-height: auto;
  }
  .onboarding-content {
    padding: 1.25rem;
  }
  .onboarding-shell {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .onboarding-hero-card,
  .onboarding-form-card {
    border-radius: 22px;
  }
  .onboarding-hero-card {
    padding: 1.4rem;
  }
  .onboarding-title {
    max-width: none;
  }
  .onboarding-hero-main {
    grid-template-columns: 1fr;
  }
  .onboarding-ben-panel {
    order: -1;
    min-height: 200px;
  }
  .onboarding-ben-img {
    width: min(100%, 200px);
  }
  .onboarding-ben-speech {
    max-width: none;
  }
  .onboarding-ben-speech::before {
    left: 50%;
    transform: translateX(-50%);
  }
  .onboarding-info-row,
  .onboarding-level-grid {
    grid-template-columns: 1fr;
  }
}
.app-footer-nav a:hover { color: var(--text); text-decoration: underline; }
