/* ============================================================
   einfach34a – Grund-Stylesheet (Gerüst aus Industriemeister BQ übernommen)
   Design: Dark Dashboard (DESIGN-SPEC.md)
   ============================================================ */

/* ── Reset & Basis ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Hintergrundfarben */
  --bg-primary:    #0f1119;
  --bg-secondary:  #0a0b12;
  --bg-tertiary:   #1a1c2e;
  --bg-card:       #131520;
  --bg-card-hover: #1a1c2e;

  /* Borders */
  --border-default: #1e2030;
  --border-subtle:  #2a2d42;

  /* Textfarben */
  --text-primary:   #ffffff;
  --text-secondary: #e2e4ea;
  --text-muted:     #8b8fa6;
  --text-dim:       #6b6f82;
  --text-label:     #4a4e63;

  /* Akzentfarben */
  --accent-red:    #e85d4a;
  --accent-orange: #f0a03c;
  --accent-blue:   #3b82f6;
  --accent-purple: #a78bfa;
  --accent-green:  #4ade80;
  --accent-yellow: #f59e0b;

  /* Border-Radien */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;

  /* Rückwärtskompatible Aliasse für Views/Quiz-Styles */
  /* --bg wird weiter unten vom Redesign-Token gesetzt (war ungenutzt) */
  --bg2:        var(--bg-card);
  --bg3:        var(--bg-card-hover);
  --border:     var(--border-default);
  --text:       var(--text-secondary);
  --accent:     var(--accent-red);
  --accent2:    var(--accent-orange);
  --success:    var(--accent-green);
  --danger:     var(--accent-red);

  /* ── Fach-Akzentfarben (dynamisch per JS gesetzt) ─────────── */
  --fach-color:        #e85d4a;
  --fach-color-dim:    rgba(232,93,74,0.15);
  --fach-color-border: rgba(232,93,74,0.4);
  --warning:    var(--accent-yellow);
  --radius:     var(--radius-lg);
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --transition: 0.15s ease;

  /* ── Redesign-Tokens (design-referenz.html) ──────────────────
     Neue, verbindliche Palette für Dashboard und Navigation.
     Farbregel: Orange nur für Fortschritt und Primäraktionen,
     Grün nur für Erfolg, Rot nur für Fehler und Schwachstellen.
     Die älteren Tokens darüber bleiben bestehen, solange die
     übrigen Seiten sie noch nutzen. */
  --bg:         #0c0e12;
  --surface:    #14171d;
  --surface-hi: #1a1e26;
  --line:       rgba(255,255,255,.07);
  --line-hi:    rgba(255,255,255,.14);
  --tx:         #e8eaee;
  --tx-2:       #9aa1ad;
  --tx-3:       #6b7280;
  --orange:     #e8742a;
  --orange-hi:  #f0a03c;
  --orange-dim: rgba(232,116,42,.14);
  --ok:         #3ec27a;
  --warn:       #f0a03c;
  --r:          12px;
  --nav-w:      236px;
}

html { font-size: 16px; scroll-behavior: smooth; background-color: #0f1119; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-secondary);
  min-height: 100vh;
  display: flex;
  line-height: 1.6;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--nav-w);
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  /* Kein overflow hier! Der Einklapp-Knopf ragt mit right:-14px bewusst über
     den Rand hinaus und würde sonst abgeschnitten. Gescrollt wird in
     .sidebar-nav. */
  transition: width 0.2s ease;
}

.sidebar-logo {
  padding: 0 8px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-red), var(--accent-orange));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--tx);
}

.sidebar-logo-sub {
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--tx-3);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10.5px;
  color: var(--tx-3);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  padding: 18px 10px 7px;
  margin: 0;
}

.sidebar-section-label:first-of-type {
  padding-top: 10px;
}

/* Nav-Items: Klasse .nav-btn bleibt für app.js-Kompatibilität */
.nav-item,
.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  color: var(--tx-2);
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover,
.nav-btn:hover {
  background: var(--surface);
  color: var(--tx);
}

.nav-item.active,
.nav-btn.active {
  background: var(--orange-dim);
  color: var(--orange-hi);
  font-weight: 500;
}

.nav-item.active svg,
.nav-btn.active svg {
  stroke: currentColor;
}

/* Hardcore-Hervorhebung in der Sidebar */
/* Hardcore war früher rot umrandet und rot hinterlegt. Entfernt — der Punkt
   sieht jetzt aus wie jeder andere, gekennzeichnet nur durch die Badges.
   Die Klasse .sb-hardcore-link bleibt als Ansatzpunkt bestehen. */
.sb-neu-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 0.3px;
  background: #e85d4a; color: #fff;
  padding: 1px 5px; border-radius: 4px;
  vertical-align: middle; margin-left: 4px; display: inline-block;
  line-height: 1.4;
}
.sb-beta-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.3px;
  color: #a78bfa; vertical-align: middle; margin-left: 2px;
}

.nav-item svg,
.nav-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: #2a1a1a;
  color: var(--accent-red);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
}

/* A5-Fix: Profil-Bereich in der Sidebar */
#sidebar-user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px;
}

/* Einstellungen-Button im Sidebar-Footer (jetzt aktiv) */
.sidebar-footer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 6px 8px;
  transition: background 0.15s;
}

/* ==================== MAIN CONTENT ==================== */
.main,
.app-main {
  flex: 1;
  margin-left: var(--nav-w);
  padding: 28px 32px;
  overflow-y: auto;
  min-height: 100vh;
}

/* C1-Fix: padding-bottom damit untere Kästen bei 100% Zoom vollständig sichtbar */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.15s;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-primary {
  background: var(--accent-red);
  color: var(--tx);
  font-weight: 500;
}

.btn-primary:hover { opacity: 0.9; }

/* ==================== STAT CARDS ==================== */

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

/* ==================== BOTTOM SECTION ==================== */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  /* C1-Fix: Kein festes height — Panel wächst mit Inhalt */
  overflow: visible;
}

/* ==================== UEBEN / QUIZ ==================== */

.chip {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border-default);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  font-family: inherit;
}

.chip:hover {
  border-color: var(--fach-color);
  color: var(--text-secondary);
}

.chip.active {
  background: var(--fach-color);
  border-color: var(--fach-color);
  color: #fff;
  font-weight: 600;
}

/* ── Quiz Panel ────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Fortschrittsbalken im Quiz (eigene Klasse, damit kein Konflikt mit Dashboard) */

.quiz-frage {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

/* ==================== MODAL ==================== */

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }

  .sidebar-logo-text,
  .sidebar-logo-sub,
  .nav-item span,
  .nav-btn span,
  .sidebar-section-label,
  .nav-badge,
  .sidebar-footer-text {
    display: none;
  }

  .sidebar-logo { justify-content: center; padding: 16px 0; }

  .nav-item,
  .nav-btn {
    justify-content: center;
    padding: 10px;
  }

  .main,
  .app-main {
    margin-left: 60px;
    padding: 20px 16px;
  }

}

@media (max-width: 600px) {
  .main,
  .app-main { padding: 16px 12px; }
}

/* M8 – Mobiler Breakpoint: Sidebar ausblenden, Bottom Nav einblenden */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main, .app-main { margin-left: 0; padding: 16px 16px 80px; }
}

/* ==================== KI-HILFE PANEL ==================== */
.ki-hilfe-panel {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.08), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: var(--radius-md, 8px);
  padding: 14px 16px;
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease;
}

.ki-hilfe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.ki-hilfe-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-purple, #a78bfa);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ki-hilfe-title svg {
  width: 14px;
  height: 14px;
  stroke: var(--accent-purple, #a78bfa);
  stroke-width: 2;
  fill: none;
}

.ki-hilfe-close {
  background: none;
  border: none;
  color: var(--text-dim, #6b6f82);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1;
}

.ki-hilfe-close:hover {
  background: var(--border-default, #1e2030);
  color: var(--text-secondary, #e2e4ea);
}

.ki-hilfe-content {
  font-size: 13px;
  color: var(--text-secondary, #e2e4ea);
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
}

/* Sidebar-Footer: Hover-Effekt für den Einstellungen-Button */
.sidebar-footer-item:hover {
  background: var(--bg-card-hover);
}

/* ── KI Chat Panel ───────────────────────────────────────────── */
.ki-chat-panel {
  margin-top: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
}

.ki-chat-panel.hidden {
  display: none;
}

.ki-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-default);
}

.ki-chat-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-blue);
}

.ki-chat-title svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.ki-chat-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.ki-chat-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.ki-chat-verlauf {
  min-height: 100px;
  max-height: 260px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ki-chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.ki-chat-msg-ki {
  background: var(--bg-card);
  color: var(--text-secondary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ki-chat-msg-user {
  background: var(--accent-blue);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ki-chat-loading {
  opacity: 0.55;
  font-style: italic;
}

.ki-chat-eingabe {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border-default);
  background: var(--bg-card);
  align-items: flex-end;
}

.ki-chat-textarea {
  flex: 1;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
}

.ki-chat-textarea:focus {
  border-color: var(--accent-blue);
}

.ki-chat-senden-btn {
  padding: 0.5rem 0.75rem;
  flex-shrink: 0;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ki-chat-senden-btn svg {
  width: 15px;
  height: 15px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

/* ============================================================
   KI-CHAT WIDGET (Zusammenfassungsseite)
   ============================================================ */
:root { --ki-fach-color: #e85d4a; }

.ki-widget { position: fixed; bottom: 24px; right: 24px; z-index: 1000; }

/* G3-Fix: Auffälliger Pill-Button mit Text, orange Hintergrund, Pulsier-Animation */
.ki-fab {
  /* Kein festes width/height mehr — wächst mit dem Text */
  min-height: 48px;
  border-radius: 28px;
  background: #f0a03c;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  box-shadow: 0 4px 16px rgba(240, 160, 60, 0.5);
  transition: transform 0.2s, opacity 0.25s, box-shadow 0.2s;
  /* Pulsier-Animation alle 30 Sekunden */
  animation: ki-fab-puls 30s ease-in-out infinite;
}
.ki-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 22px rgba(240, 160, 60, 0.65);
}
.ki-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.7); }
.ki-fab svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; flex-shrink: 0; }
.ki-fab-text { white-space: nowrap; }

@keyframes ki-fab-puls {
  /* Puls-Effekt bei 0% und kurz danach, danach 30 Sekunden Pause */
  0%   { transform: scale(1); box-shadow: 0 4px 16px rgba(240,160,60,0.5); }
  1.5% { transform: scale(1.05); box-shadow: 0 6px 24px rgba(240,160,60,0.7); }
  3%   { transform: scale(1); box-shadow: 0 4px 16px rgba(240,160,60,0.5); }
  100% { transform: scale(1); box-shadow: 0 4px 16px rgba(240,160,60,0.5); }
}

.ki-panel {
  position: absolute; bottom: 70px; right: 0;
  width: 380px; height: 480px;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(16px) scale(0.96); pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease; overflow: hidden;
}
.ki-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.ki-panel-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary); flex-shrink: 0;
}
.ki-panel-title { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.ki-panel-title svg { stroke: var(--ki-fach-color); }
.ki-panel-kontext { flex: 1; font-size: 0.75rem; color: var(--text-muted); }
.ki-close-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 0.25rem; line-height: 1; transition: color 0.15s; }
.ki-close-btn:hover { color: var(--text-primary); }

.ki-verlauf { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.ki-willkommen p { font-size: 0.83rem; color: var(--text-muted); text-align: center; line-height: 1.5; }

.ki-nachricht { font-size: 0.85rem; line-height: 1.55; padding: 0.6rem 0.875rem; border-radius: 10px; max-width: 90%; }
.ki-nachricht-user { background: var(--ki-fach-color); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.ki-nachricht-assistant { background: var(--bg-tertiary); color: var(--text-secondary); align-self: flex-start; border-bottom-left-radius: 3px; border: 1px solid var(--border); }
.ki-nachricht-fehler { color: var(--accent-red) !important; border-color: rgba(229,62,62,0.3) !important; }

.ki-input-area { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.ki-textarea { flex: 1; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font-size: 0.85rem; font-family: inherit; padding: 0.5rem 0.75rem; resize: none; outline: none; line-height: 1.5; transition: border-color 0.15s; max-height: 100px; }
.ki-textarea:focus { border-color: var(--ki-fach-color); }
.ki-send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--ki-fach-color); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity 0.15s; }
.ki-send-btn:hover { opacity: 0.85; }
.ki-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ki-send-btn svg { stroke: #fff; }

@media (max-width: 480px) { .ki-panel { width: calc(100vw - 32px); right: -8px; } }

/* ── Prüfungs-Timer-Bar ──────────────────────────────────── */

@keyframes puls { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Filter-Select ───────────────────────────────────────── */

.btn-sm { font-size: 0.8rem; padding: 6px 12px; }

/* ── Prüfungstermine-Grid ────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Änderung 4: Buttons nach falscher Antwort ─────────────── */

/* ── Änderung 5: KI-Hinweis Glow + Puls ───────────────────── */
.ki-hint-glow {
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.3);
  border: 1px solid rgba(249, 115, 22, 0.4);
  transition: all 0.3s;
}

/* ── Lernplan Wochen-Akkordion ─────────────────────────────── */

.badge-soon {
  background: #3b82f6;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ── Onboarding Spotlight-System ── */

/* ── Rechner-Toggle ──────────────────────────────────────────── */

/* ── KI-Tipp / KI-Hilfe Buttons im Thema-Modal ───────────── */
/* Modal-Aktionsleiste: KI-Tipp + Lösung anzeigen */
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* KI-Button im Hilfe-Modus (nach Antwort) — gilt in Quiz + Modal */
.ki-hilfe-modus {
  border-color: rgba(240, 160, 60, 0.4) !important;
  color: #f0a03c !important;
  box-shadow: none !important;
  animation: none !important;
}

/* Sidebar und Main-Content nach unten schieben wenn Banner sichtbar */
body:has(.gast-banner) .sidebar {
  top: 42px;
}

body:has(.gast-banner) .main,
body:has(.gast-banner) .app-main {
  padding-top: 70px;
}

/* Bei minimiertem Banner nur minimalen Versatz */
body:has(.gast-banner.minimiert) .sidebar {
  top: 28px;
}

body:has(.gast-banner.minimiert) .main,
body:has(.gast-banner.minimiert) .app-main {
  padding-top: 56px;
}

/* ── Badge-Unlock-Popup ─────────────────────────────────────── */
.badge-unlock-popup {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: #1a1d27; border: 1px solid #e8742a; border-radius: 14px;
  padding: 16px 20px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 8px 32px rgba(232,116,42,0.25);
  animation: badge-slide-in 0.4s ease, badge-slide-out 0.4s ease 3.6s forwards;
  max-width: 320px;
}
.badge-unlock-icon { font-size: 2rem; }
.badge-unlock-titel { font-size: 11px; color: #e8742a; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.badge-unlock-name { font-size: 15px; font-weight: 700; color: #fff; }
@keyframes badge-slide-in { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }
@keyframes badge-slide-out { from { opacity:1; } to { opacity:0; transform: translateY(10px); } }

/* ── Toast-Benachrichtigungen ──────────────────────────────── */

/* ==================== MOBILE BOTTOM NAVIGATION ==================== */
.mobile-bottom-nav {
  display: none;
}

/* Leiste und Blatt gibt es nur am Handy. Ohne diese Regel staende das Blatt
   am Desktop sichtbar unten im Bild — dort greifen die Regeln aus der
   Media-Query darunter nicht, auch nicht die Verschiebung aus dem Bild. */
.mobil-mehr-blatt,
.mobil-mehr-schleier {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #0a0c10;
    border-top: 1px solid #1e2233;
    justify-content: space-between;
    align-items: stretch;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Platz unter dem Seiteninhalt, damit die feste Leiste nicht das Letzte
     verdeckt. Ohne das lag auf /lernplan der Knopf „Üben →" des untersten
     Eintrags hinter der Leiste und war nicht antippbar, auf /statistik und
     /schwachstellen die Fusszeile mit Impressum und Datenschutz.
     Der Abstand gehoert an den Inhaltsbereich, nicht an den body: auf Seiten
     mit Seitenleiste ist der body ein Flex-Container in Zeilenrichtung, dort
     bliebe ein body-Abstand wirkungslos. Die body-Regel faengt die wenigen
     Seiten ohne eigenes main ab. */
  body:has(.mobile-bottom-nav) > main,
  body:has(.mobile-bottom-nav) > .main {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  body:has(.mobile-bottom-nav):not(:has(> main)) {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  /* Alle Items einheitlich — auch .nav-btn-Elemente überschreiben */
  .mobile-bottom-nav .mobile-nav-item,
  .mobile-bottom-nav .nav-btn.mobile-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: auto !important;
    height: 100% !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    color: #5a6070 !important;
    font-size: 10px !important;
    font-family: inherit;
    text-decoration: none;
    padding: 6px 0 !important;
    margin-bottom: 0 !important;
    text-align: center !important;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    border-radius: 0 !important;
  }

  .mobile-bottom-nav .mobile-nav-item:hover,
  .mobile-bottom-nav .mobile-nav-item:focus,
  .mobile-bottom-nav .nav-btn.mobile-nav-item.active {
    color: #e8742a !important;
    background: none !important;
    outline: none;
  }

  /* Icons und Labels immer sichtbar — 900px-Breakpoint (.nav-btn span display:none) überschreiben */
  .mobile-bottom-nav .mobile-nav-icon {
    font-size: 22px;
    line-height: 1;
    display: block !important;
  }

  .mobile-bottom-nav .mobile-nav-label {
    display: block !important;
    font-size: 10px;
    line-height: 1.2;
  }

  /* Verstecken muss ueber eine Klasse laufen: die Regel oben setzt
     `display: flex !important`, ein Inline-`display:none` kam dagegen nie an.
     Deshalb war der Eintrag „Raum 2B" mobil auch dann sichtbar, wenn der
     Raum geschlossen war. */
  .mobile-bottom-nav .mobile-nav-item.nav-verborgen,
  .mobile-bottom-nav .nav-btn.mobile-nav-item.nav-verborgen {
    display: none !important;
  }

  /* Die Symbole sind jetzt dieselben SVGs wie in der Seitenleiste statt
     Emojis: gleiche Darstellung auf jedem Geraet und in der Akzentfarbe. */
  .mobile-bottom-nav .mobile-nav-icon svg {
    width: 22px;
    height: 22px;
    display: block;
  }

  /* Sammelpunkt am Knopf „Mehr" — zeigt, dass im Blatt ein Hinweis wartet
     (Lernplan-Erinnerung, neue Forumsbeitraege, MEP-Abzeichen). */
  .mobile-bottom-nav .mobile-nav-mehr { position: relative; }

  .mobile-nav-sammelpunkt {
    position: absolute;
    top: 7px;
    right: calc(50% - 17px);
    width: 8px;
    height: 8px;
    background: #f0a03c;
    border-radius: 50%;
  }

  /* ── Blatt hinter „Mehr" ─────────────────────────────────────────────
     Frueher standen hier 14 Eintraege in einer waagerecht scrollbaren
     Leiste; sichtbar waren sechs. Jetzt vier feste Plaetze, der Rest in
     einem Blatt, das von unten hereinfaehrt. */
  /* Sichtbarkeit über `visibility`, nicht über das hidden-Attribut: ein
     Element, das gerade aus `display: none` kommt, faehrt nicht herein —
     der Browser hat dafuer noch kein Layout und ueberspringt den Uebergang. */
  .mobil-mehr-schleier {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .mobil-mehr-schleier.offen {
    opacity: 1;
    pointer-events: auto;
  }

  .mobil-mehr-blatt {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1002;
    max-height: 72vh;
    overflow-y: auto;
    background: #0f1119;
    border-top: 1px solid #1e2233;
    border-radius: 18px 18px 0 0;
    padding: 8px 12px calc(84px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    pointer-events: none;
    /* Geschlossen unsichtbar auch für Tastatur/Screenreader (kein Fokus auf versteckte Links) */
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55);
  }

  .mobil-mehr-blatt.offen {
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition: transform 0.22s ease, visibility 0s;
  }

  .mobil-blatt-griff {
    width: 38px;
    height: 4px;
    background: #2a2f45;
    border-radius: 2px;
    margin: 4px auto 10px;
  }

  .mobil-blatt-kopf {
    font-size: 13px;
    font-weight: 700;
    color: #e8e8f0;
    padding: 0 8px 6px;
  }

  .mobil-blatt-gruppe {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5a6070;
    padding: 12px 8px 4px;
  }

  .mobil-blatt-punkt {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 10px;
    border: none;
    background: none;
    color: #c7ccd8;
    font-size: 15px;
    font-family: inherit;
    text-align: left;
    text-decoration: none;
    border-radius: 10px;
    cursor: pointer;
  }

  .mobil-blatt-punkt svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .mobil-blatt-punkt.active {
    color: #e8742a;
    background: rgba(232, 116, 42, 0.10);
  }

  .mobil-blatt-punkt:active { background: rgba(255, 255, 255, 0.06); }

  /* Gast-Banner auf Mobile ausblenden */
  body:has(.gast-banner) .sidebar { top: 0 !important; }
  body:has(.gast-banner) .main,
  body:has(.gast-banner) .app-main { padding-top: 0 !important; }

  /* ── KI-Chat Panel: Mobile Bottom Sheet ── */
  .ki-chat-panel {
    position: fixed !important;
    bottom: 70px !important;
    left: 0 !important;
    right: 0 !important;
    height: 60vh !important;
    max-height: 60vh !important;
    background: #12161f !important;
    border-radius: 16px 16px 0 0 !important;
    border-top: 2px solid #e8742a !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    margin: 0 !important;
    z-index: 1200 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .ki-chat-panel.hidden {
    display: none !important;
  }

  .ki-chat-header {
    flex-shrink: 0;
    border-radius: 16px 16px 0 0;
  }

  .ki-chat-verlauf {
    flex: 1 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .ki-chat-eingabe {
    flex-shrink: 0 !important;
    position: sticky;
    bottom: 0;
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px) !important;
  }

  /* ── Zusammenfassungen: Grid auf Mobile → 1 Spalte ── */
  .zs-grid,
  .zs-karten-grid,
  .zs-card-grid,
  .zs-schema,
  .zs-pyramid,
  .zs-diagram,
  [class*="zs-"][class*="grid"],
  [class*="zs-"][class*="cols"] {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  /* Hinweistext per Wrapper-Klasse .zs-table-wrapper (kein direktes table::after — browserinkompatibel) */
  /* Verwendung: <div class="zs-table-wrapper"><table ...>...</table></div> */

  /* ── Mobile Bottom Nav: scrollbar mit 10 Items ── */
  .mobile-bottom-nav {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 0;
    padding: 0 8px;
    scrollbar-width: none;
    height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    justify-content: flex-start;
    align-items: stretch;
  }

  .mobile-bottom-nav::-webkit-scrollbar {
    display: none;
  }

  /* Nav-Items teilen sich die Breite. Früher standen hier feste 64 px mit
     `flex: 0 0` und Scroll-Einrastung — das gehörte zur scrollbaren Leiste
     mit 14 Einträgen. Mit fünf festen Plätzen wäre die Leiste sonst rechts
     angeschnitten: die Einträge endeten bei 328 px, egal wie breit das
     Gerät ist. */
  .mobile-bottom-nav .mobile-nav-item,
  .mobile-bottom-nav .nav-btn.mobile-nav-item {
    min-width: 0 !important;
    flex: 1 1 0 !important;
    width: auto !important;
  }

  /* Aktive Seite: oranger Punkt unter Icon */
  .mobile-bottom-nav .mobile-nav-item.active .mobile-nav-icon::after,
  .mobile-bottom-nav .nav-btn.mobile-nav-item.active .mobile-nav-icon::after {
    content: "";
    display: block;
    width: 4px;
    height: 4px;
    background: #e8742a;
    border-radius: 50%;
    margin: 2px auto 0;
  }

  /* ── Fix 1: KI-Knopf kollidiert mit der Leiste unten (60 px hoch) ── */
  .ki-widget { bottom: 76px; right: 16px; }
  .ki-panel {
    height: min(480px, calc(100dvh - 170px));
    width: min(380px, calc(100vw - 32px));
  }

  /* ── Fix 4: iOS zoomt bei Eingabefeldern unter 16 px automatisch ── */
  .ki-textarea, .ki-chat-textarea, .quiz-ki-textarea,
  .formel-suche-input, .lp-field input, .lp-field select,
  .frage-melden-body textarea {
    font-size: 16px !important;
  }

  /* ── Nachtrag (Redesign): Inhalt darf nicht unter der Leiste liegen ── */
  .main, .app-main {
    padding-bottom: calc(60px + env(safe-area-inset-bottom) + 16px);
  }

  /* ── Nachtrag: aktiver Punkt war nur für <button> hervorgehoben.
     Auf allen Unterseiten sind es <a>-Elemente — die blieben grau. ── */
  .mobile-bottom-nav .mobile-nav-item.active {
    color: #e8742a !important;
  }

}

/* ==================== SIDEBAR COLLAPSE (manuell) ==================== */

.sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  right: -14px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: var(--bg-card, #1e2233);
  border: 1px solid var(--border-default, #2a2d45);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  color: var(--text-muted, #8b8fa6);
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.sidebar-collapse-btn:hover {
  background: var(--bg-card-hover, #252840);
  color: var(--text-primary, #e8eaf0);
}
.sidebar-collapse-btn .sb-icon-expand { display: none; }

html.sb-collapsed .sidebar,
body.sb-collapsed .sidebar {
  width: 60px;
  overflow: visible;
  /* Seitliches Padding zurücknehmen, sonst bleiben von 60px nur 32px Inhalt */
  padding-left: 8px;
  padding-right: 8px;
}
html.sb-collapsed .sidebar-logo-text,
html.sb-collapsed .sidebar-logo-sub,
html.sb-collapsed .sidebar-section-label,
html.sb-collapsed .nav-btn > span,
html.sb-collapsed .nav-item > span,
html.sb-collapsed .nav-badge,
html.sb-collapsed .sidebar-footer > div:last-child,
html.sb-collapsed .sidebar-footer-item .sidebar-footer-text,
html.sb-collapsed .sidebar-footer-item span:last-child,
body.sb-collapsed .sidebar-logo-text,
body.sb-collapsed .sidebar-logo-sub,
body.sb-collapsed .sidebar-section-label,
body.sb-collapsed .nav-btn > span,
body.sb-collapsed .nav-item > span,
body.sb-collapsed .nav-badge,
body.sb-collapsed .sidebar-footer > div:last-child,
body.sb-collapsed .sidebar-footer-item .sidebar-footer-text,
body.sb-collapsed .sidebar-footer-item span:last-child {
  display: none !important;
}
html.sb-collapsed .sidebar-logo,
body.sb-collapsed .sidebar-logo {
  justify-content: center;
  padding: 16px 0;
}
html.sb-collapsed .nav-btn,
html.sb-collapsed .nav-item,
body.sb-collapsed .nav-btn,
body.sb-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}
html.sb-collapsed .sidebar-collapse-btn .sb-icon-collapse,
body.sb-collapsed .sidebar-collapse-btn .sb-icon-collapse { display: none; }
html.sb-collapsed .sidebar-collapse-btn .sb-icon-expand,
body.sb-collapsed .sidebar-collapse-btn .sb-icon-expand { display: flex; }
html.sb-collapsed .main,
html.sb-collapsed .app-main,
html.sb-collapsed .zs-content,
html.sb-collapsed .profil-main,
html.sb-collapsed .ach-main,
body.sb-collapsed .main,
body.sb-collapsed .app-main,
body.sb-collapsed .zs-content,
body.sb-collapsed .profil-main,
body.sb-collapsed .ach-main {
  margin-left: 60px !important;
}

/* Tooltip für eingeklappte Sidebar-Symbole — via JS positioniert (#sb-tooltip) */
#sb-tooltip {
  position: fixed;
  background: #1e2233;
  border: 1px solid #2a2d45;
  border-radius: 6px;
  padding: 5px 12px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: #e8eaf0;
  z-index: 99999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  pointer-events: none;
  display: none;
}

@media (max-width: 900px) {
  .sidebar-collapse-btn { display: none; }
}

/* ============================================================
   DASHBOARD-REDESIGN (Phase 2) — Layout nach design-referenz.html
   Alle Klassen mit Praefix "db-", damit sie nicht mit den
   bestehenden Klassen (.stat, .chip, .video …) kollidieren.
   ============================================================ */

/* ── Tastaturbedienung ─────────────────────────────────────────
   Sichtbarer Fokusring für alle interaktiven Elemente. :focus-visible
   greift nur bei Tastatursteuerung, Mausklicks bleiben unverändert. */
:focus-visible {
  outline: 2px solid var(--orange-hi);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Skeleton beim Laden ───────────────────────────────────── */

/* ============================================================
   MOBILE-FIXES (Fix 2, 3, 5, 6)
   Bewusst gebündelt statt an vier Stellen verstreut — funktional
   identisch, weil es reine Ergänzungen mit eigener Spezifität sind.
   ============================================================ */

/* ── Fix 2: KaTeX läuft auf schmalen Displays seitlich aus dem Bild ── */
.quiz-loesung-text, .ml-schritt, .quiz-frage, .frage-text {
  overflow-x: auto;
  max-width: 100%;
}

/* ── Leiste scrollt nicht mehr ────────────────────────────────────────────
   Mit fünf festen Plätzen gibt es nichts mehr zu wischen. Bliebe das
   Scrollen erlaubt, entstünde auf 320-px-Geräten (iPhone SE) ein
   Teufelskreis: der Scrollbalken nimmt Platz, dadurch passen die Einträge
   nicht mehr, dadurch erscheint der Scrollbalken. */
@media (max-width: 768px) {
  .mobile-bottom-nav {
    overflow-x: hidden;
  }
}

@media (max-width: 360px) {
  .mobile-bottom-nav {
    padding-left: 0;
    padding-right: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Zusammenfassungen am Handy: Platz, Raster, KI-Knopf
   Bewusst am Dateiende, damit keine spaetere Regel sie wieder aushebelt.
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* 3. Der KI-Knopf nahm mit 270 x 48 px siebzig Prozent der Bildbreite ein
     und schwebte quer ueber dem Text. Am Handy nur noch das Symbol. */
  .ki-fab {
    width: 52px !important;
    height: 52px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    justify-content: center !important;
  }

  .ki-fab-text {
    display: none !important;
  }

}

/* ==================== LOGO BQ + HQ (Seitenleiste, Entwurf A, 26.09.2026) ====================
   BQ-Icon vorne unten links, HQ-Icon versetzt dahinter oben rechts. Steht bewusst am Dateiende,
   damit es die Einklapp-Regeln (max-width 900px, sb-collapsed) sicher überschreibt. */
.sidebar-logo-stapel {
  position: relative;
  width: 52px;
  height: 42px;
  flex-shrink: 0;
  display: block;
}
.sidebar-logo-stapel img {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: block;
}
.sidebar-logo-stapel .sidebar-logo-bq { left: 0; bottom: 0; box-shadow: 0 0 0 2.5px var(--bg); }

/* Schrift links (etwas größer), Icons rechts (Walied 26.09.) */
.sidebar .sidebar-logo { justify-content: space-between; }
.sidebar .sidebar-logo-text { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.sidebar .sidebar-logo-sub { margin-top: 1px; }
html.sb-collapsed .sidebar .sidebar-logo,
body.sb-collapsed .sidebar .sidebar-logo { justify-content: center; }
html.sb-collapsed .sidebar-logo-schrift,
body.sb-collapsed .sidebar-logo-schrift { display: none; }

/* Eingeklappt bleiben 44 px Innenbreite → Stapel etwas kleiner */
@media (max-width: 900px) {
  .sidebar .sidebar-logo { justify-content: center; }
  .sidebar-logo-schrift { display: none; }
  .sidebar-logo-stapel { width: 44px; height: 38px; }
  .sidebar-logo-stapel img { width: 25px; height: 25px; border-radius: 7px; }
}
html.sb-collapsed .sidebar-logo-stapel,
body.sb-collapsed .sidebar-logo-stapel { width: 44px; height: 38px; }
html.sb-collapsed .sidebar-logo-stapel img,
body.sb-collapsed .sidebar-logo-stapel img { width: 25px; height: 25px; border-radius: 7px; }

/* Nur für Screenreader/Suchmaschinen sichtbar (z. B. Seitenüberschrift auf Login-Seiten) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
