:root {
  --bg: #0f1117;
  --bg-karte: #171a23;
  --bg-hover: #1e2230;
  --rand: #2a2f3e;
  --text: #e6e8ee;
  --text-dunkel: #9aa3b5;
  --akzent: #4fc3f7;
  --akzent-2: #ffb74d;
  --gruen: #66bb6a;
  --rot: #ef5350;
  --gelb: #ffee58;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

header {
  background: linear-gradient(180deg, #141824, var(--bg));
  border-bottom: 1px solid var(--rand);
  padding: 1.2rem 1.5rem;
  text-align: center;
}

header h1 { font-size: 1.5rem; }

.subtitle { color: var(--text-dunkel); font-size: 0.95rem; }

nav { margin-top: 0.8rem; display: flex; gap: 1.1rem; justify-content: center; align-items: flex-start; flex-wrap: wrap; }

/* Reiter-Gruppen (Lernen | KI & Tools | Konto) */
.nav-gruppe { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.nav-gruppe + .nav-gruppe { border-left: 1px solid var(--rand); padding-left: 1.1rem; }
.nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dunkel);
  opacity: 0.85;
}
.nav-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.nav-btn {
  background: var(--bg-karte);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.nav-btn:hover { background: var(--bg-hover); }
.nav-btn.active { background: var(--akzent); color: #0b0e14; font-weight: 600; border-color: var(--akzent); }
/* KI-Assistent (LLM): noch nicht freigeschaltet → ausgegraut & gesperrt */
.nav-btn:disabled { opacity: 0.45; cursor: not-allowed; }

main { flex: 1; max-width: 860px; width: 100%; margin: 1.5rem auto; padding: 0 1rem; }

.karte {
  background: var(--bg-karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
}

.karte h2 { margin-bottom: 0.6rem; color: var(--akzent); }
.karte h3 { margin: 1rem 0 0.4rem; color: var(--akzent-2); }

.button-reihe { display: flex; gap: 0.7rem; margin-top: 1rem; flex-wrap: wrap; }

button.primary, button.secondary {
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  font-size: 0.95rem;
}
button.primary { background: var(--akzent); color: #0b0e14; font-weight: 600; }
button.primary:hover { filter: brightness(1.15); }
button.secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--rand); }
button.secondary:hover { background: #262c3d; }

.lf-eintrag {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin: 0.45rem 0;
  cursor: pointer;
  transition: background 0.15s;
}
.lf-eintrag:hover { background: var(--bg-hover); }
.lf-eintrag .lf-status { color: var(--gruen); font-weight: 700; min-width: 3.2rem; }
.lf-eintrag .lf-status.offen { color: var(--text-dunkel); }
.lf-eintrag .lf-titel { flex: 1; }

.stufen label { display: block; margin: 0.3rem 0; cursor: pointer; }

/* IHK-Notenschlüssel-Tabelle */
.noten-details {
  margin: 0.8rem 0;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
}
.noten-details summary { cursor: pointer; color: var(--akzent); font-weight: 600; }
.noten-tabelle {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-size: 0.92rem;
}
.noten-tabelle th, .noten-tabelle td {
  border: 1px solid var(--rand);
  padding: 0.35rem 0.7rem;
  text-align: left;
}
.noten-tabelle th { background: var(--bg-hover); color: var(--text-dunkel); }
.noten-tabelle .bestanden-zeile { background: rgba(102, 187, 106, 0.12); }
.noten-tabelle .bestanden-zeile td { border-color: var(--gruen); }

/* Ziel & Mission Seite */
.ziel-hero { border-left: 4px solid var(--akzent); }
.ziel-leitsatz {
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text);
  border-left: 3px solid var(--akzent-2);
  padding: 0.4rem 0.9rem;
  margin: 0.6rem 0;
  background: rgba(255, 183, 77, 0.08);
  border-radius: 0 6px 6px 0;
}
.vergleich-tabelle {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.95rem;
}
.vergleich-tabelle th, .vergleich-tabelle td {
  border: 1px solid var(--rand);
  padding: 0.5rem 0.8rem;
  text-align: left;
}
.vergleich-tabelle th { background: var(--bg-hover); color: var(--akzent); }

.phase-eintrag {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  margin: 0.7rem 0;
  padding: 0.7rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
}
.phase-nr {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--akzent);
  color: #0b0e14;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.phase-meilenstein { color: var(--akzent-2); font-size: 0.9rem; }
.phase-dauer {
  display: inline-block;
  background: rgba(79, 195, 247, 0.15);
  border: 1px solid var(--akzent);
  color: var(--akzent);
  border-radius: 999px;
  padding: 0.05rem 0.6rem;
  font-size: 0.8rem;
  margin-left: 0.5rem;
  white-space: nowrap;
}
.phase-gesamt {
  margin-top: 0.8rem;
  padding: 0.7rem 0.9rem;
  background: rgba(102, 187, 106, 0.1);
  border: 1px solid var(--gruen);
  border-radius: 8px;
  font-size: 0.95rem;
}
.roadmap-pre {
  max-height: 24rem;
  overflow-y: auto;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.ziel-schritte { margin: 0.6rem 0 0.6rem 1.2rem; }
.ziel-schritte li { margin: 0.45rem 0; }

.quiz-kopf {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  color: var(--text-dunkel);
  font-size: 0.9rem;
}

#frage-bereich { font-size: 1.05rem; margin-bottom: 0.8rem; white-space: pre-wrap; }

.option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin: 0.45rem 0;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.option:hover { background: var(--bg-hover); }
.option.richtig { background: rgba(102, 187, 106, 0.15); border-color: var(--gruen); }
.option.falsch { background: rgba(239, 83, 80, 0.15); border-color: var(--rot); }
.option:disabled { cursor: default; }

.feedback { margin-top: 0.8rem; padding: 0.7rem 1rem; border-radius: 8px; font-size: 0.95rem; }
.feedback.richtig { background: rgba(102, 187, 106, 0.12); border: 1px solid var(--gruen); }
.feedback.falsch { background: rgba(239, 83, 80, 0.12); border: 1px solid var(--rot); }

#quiz-fortschritt { color: var(--akzent-2); font-weight: 600; }

#ergebnis-details { font-size: 1.05rem; }
#ergebnis-details .note-gross { font-size: 2.2rem; font-weight: 800; margin: 0.4rem 0; }
.note-1, .note-2 { color: var(--gruen); }
.note-3, .note-4 { color: var(--gelb); }
.note-5, .note-6 { color: var(--rot); }
.bestanden { color: var(--gruen); font-weight: 700; }
.nicht-bestanden { color: var(--rot); font-weight: 700; }

.kurs-eintrag {
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin: 0.45rem 0;
  cursor: pointer;
  transition: background 0.15s;
}
.kurs-eintrag:hover { background: var(--bg-hover); }
.kurs-eintrag.gelesen::after { content: " ✓ gelesen"; color: var(--gruen); font-weight: 600; }

.abschnitt {
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.abschnitt h3 { color: var(--akzent); margin-bottom: 0.5rem; }
.sprache-titel { font-weight: 700; margin-top: 0.8rem; }
.sprache-titel.python { color: #ffd94a; }
.sprache-titel.cpp { color: #659ad2; }
.abschnitt p { margin: 0.4rem 0; white-space: pre-wrap; }
pre.code {
  background: #0b0e14;
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 0.5rem 0;
  overflow-x: auto;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.88rem;
  color: #c8d3e8;
  white-space: pre-wrap;
}
.vergleich { margin-top: 0.8rem; padding: 0.6rem 0.9rem; background: rgba(255, 183, 77, 0.08); border-left: 3px solid var(--akzent-2); border-radius: 0 6px 6px 0; }
.merk { margin-top: 0.6rem; padding: 0.6rem 0.9rem; background: rgba(76, 175, 80, 0.08); border-left: 3px solid var(--gruen); border-radius: 0 6px 6px 0; font-weight: 600; }

footer {
  text-align: center;
  color: var(--text-dunkel);
  font-size: 0.85rem;
  padding: 1rem;
  border-top: 1px solid var(--rand);
}

/* Toast-Meldungen (statt Browser-alert) */
#toast-container {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast {
  background: var(--bg-karte);
  border: 1px solid var(--rand);
  border-left: 4px solid var(--akzent);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: toast-ein 0.25s ease-out;
}

.toast.erfolg { border-left-color: var(--gruen); }
.toast.fehler { border-left-color: var(--rot); }

.toast.ausblenden { animation: toast-aus 0.3s ease-in forwards; }

@keyframes toast-ein {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes toast-aus {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(12px); opacity: 0; }
}

@media (max-width: 600px) {
  header h1 { font-size: 1.2rem; }
  .quiz-kopf { flex-direction: column; gap: 0.3rem; }
  /* Gruppen gestapelt: keine senkrechte Trenner-Linie mehr, nur Label-Abstand */
  .nav-gruppe + .nav-gruppe { border-left: none; padding-left: 0; margin-top: 0.35rem; }
}

/* ===== Glossar ===== */
.glossar-suche {
  margin: 0.8rem 0 0.6rem;
}

.glossar-suche input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 8px;
  outline: none;
}

.glossar-suche input:focus { border-color: var(--akzent); }

.glossar-filter {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.filter-btn:hover { background: var(--bg-hover); }

.filter-btn.active {
  background: var(--akzent);
  color: #0b0e14;
  font-weight: 600;
  border-color: var(--akzent);
}

.glossar-eintrag {
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}

.glossar-kopf {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.glossar-begriff {
  font-size: 1.05rem;
  color: var(--akzent);
}

.glossar-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--rand);
}

.badge-python { color: #ffd94a; border-color: #ffd94a55; background: #ffd94a12; }
.badge-cpp { color: #659ad2; border-color: #659ad255; background: #659ad212; }
.badge-beide { color: var(--gruen); border-color: var(--gruen); background: rgba(76, 175, 80, 0.1); }

.glossar-erklaerung { margin: 0.3rem 0; }

.glossar-beispiel {
  margin: 0.4rem 0;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
}

.glossar-kapitel {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-dunkel);
  margin-top: 0.3rem;
}

.glossar-zaehler {
  margin-top: 0.8rem;
  text-align: right;
}

/* ===== Fortschritt-Sync ===== */
.sync-code-input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 8px;
  outline: none;
  margin: 0.4rem 0 0.8rem;
  box-sizing: border-box;
}

.sync-code-input:focus { border-color: var(--akzent); }

/* ===== KI-Assistent ===== */
.ki-verlauf {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.8rem 0;
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.2rem;
}
.ki-msg {
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  max-width: 88%;
  white-space: pre-wrap;
  line-height: 1.5;
}
.ki-msg.user {
  align-self: flex-end;
  background: var(--akzent);
  color: #0f1117;
}
.ki-msg.assistent {
  align-self: flex-start;
  background: var(--bg-hover);
  border: 1px solid var(--rand);
  color: var(--text);
}
.ki-msg.fehler {
  align-self: flex-start;
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid var(--rot);
  color: var(--rot);
}
.ki-denken {
  align-self: flex-start;
  color: var(--text-dunkel);
  font-style: italic;
}
.ki-eingabe {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.ki-eingabe input { flex: 1; margin-bottom: 0; }

/* Karteikarten (Server-Speicherung, dedupliziert) */
.karten-eintrag {
  position: relative;
  border: 1px solid var(--rand);
  border-radius: 0.6rem;
  padding: 0.9rem 2.6rem 0.9rem 0.9rem;
  margin-top: 0.8rem;
  background: var(--bg-hover);
}
.karten-kopf {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.karten-thema { font-weight: 600; color: var(--akzent); font-size: 0.85rem; }
.karten-datum { color: var(--text-dunkel); font-size: 0.8rem; white-space: nowrap; }
.karten-frage { font-weight: 600; margin-bottom: 0.3rem; }
.karten-antwort { color: var(--text-dunkel); white-space: pre-wrap; }
.karten-loeschen {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
}
.karten-loeschen:hover { opacity: 1; }
.karten-eintrag.neu {
  box-shadow: 0 0 0 2px var(--akzent);
  transition: box-shadow 0.8s ease;
}

/* KI-Bewertung offener Antworten */
.ki-bewertung {
  border: 1px solid var(--rand);
  border-radius: 0.6rem;
  padding: 0.8rem 1rem;
  margin-top: 0.8rem;
  background: var(--bg-karte);
}
.kw-gefunden { color: var(--gruen); margin: 0.2rem 0; }
.kw-fehlt { color: var(--rot); margin: 0.2rem 0; }
