/* ============================================================
   Azure Lernen – Basis-Styles
   Design-Ziele: ruhig, klar, vorhersehbar, barrierefrei.
   - Kein Blocksatz, keine Animationen ohne Not
   - Große Klickflächen, deutliche Fokus-Ringe
   - Wenige, konsistente Farben
   ============================================================ */

:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --card-border: #dbe4ee;
  --text: #1f2933;
  --text-soft: #52606d;
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --primary-soft: #e6f2fc;
  --accent: #ffb900;
  --accent-soft: #fff4d6;
  --success: #107c10;
  --success-soft: #e6f4e6;
  --error: #c50f1f;
  --error-soft: #fdecee;
  --warn: #9a6700;
  --warn-soft: #fdf6e3;
  --code-bg: #17263a;
  --code-text: #e8f1fb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(16, 42, 67, 0.08);
  --font-size: 17px;
  --line-height: 1.65;
  --space: 1.1;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0.01em;
  word-spacing: var(--space) * 0.01em;
}

/* ---------- Fokus & Skip-Link ---------- */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 8px 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 2px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15em;
}
.brand-mascot { border-radius: 50%; }

.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}
.main-nav a {
  color: var(--text-soft);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.main-nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }
.main-nav a[aria-current="page"] {
  background: var(--primary);
  color: #fff;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92em;
}
.status-streak { font-weight: 700; color: #b45309; white-space: nowrap; }
.status-level {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-xpbar {
  width: 110px;
  height: 10px;
  background: #e4eaf1;
  border-radius: 999px;
  overflow: hidden;
}
.status-xpbar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #50b3ff);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.status-xptext { color: var(--text-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Layout ---------- */
#app {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 20px 60px;
  min-height: 60vh;
}

.page h1 {
  font-size: 1.75em;
  margin: 0 0 6px;
}
.page .page-sub {
  color: var(--text-soft);
  margin: 0 0 24px;
  max-width: 70ch;
}

.breadcrumb {
  color: var(--text-soft);
  font-size: 0.92em;
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--primary-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--primary-soft);
  color: var(--primary-dark);
  min-height: 46px;
  text-decoration: none;
}
.btn:hover { background: #d8ecfb; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0b5f0b; }
.btn-ghost { background: transparent; border-color: var(--card-border); color: var(--text-soft); }
.btn-ghost:hover { background: #eef3f8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 8px 14px; min-height: 38px; font-size: 0.95em; }

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

/* ---------- Modul-Karten ---------- */
.module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.module-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.module-card .mc-top { display: flex; align-items: center; gap: 10px; }
.module-card .mc-emoji { font-size: 1.9em; line-height: 1; }
.module-card .mc-level {
  margin-left: auto;
  font-size: 0.8em;
  color: var(--text-soft);
  background: #eef3f8;
  padding: 3px 9px;
  border-radius: 999px;
}
.module-card h2 { font-size: 1.2em; margin: 0; }
.module-card .mc-summary { color: var(--text-soft); font-size: 0.95em; margin: 0; flex: 1; }
.progress {
  height: 10px;
  background: #e4eaf1;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #3fa93f);
  border-radius: 999px;
  width: 0%;
}
.module-card .mc-progress-label {
  font-size: 0.85em;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
}

/* ---------- Section-Ansicht ---------- */
.section-view .section-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.section-view .section-progress .progress { flex: 1; }
.section-view .section-progress-label { color: var(--text-soft); font-size: 0.92em; white-space: nowrap; }

.section-body { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
.section-body h2 { margin: 0 0 14px; font-size: 1.45em; }
.section-body > p:first-of-type { margin-top: 0; }
.section-body p { margin: 0 0 14px; }

.section-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ---------- Merk-/Wichtig-Boxen ---------- */
.keypoints {
  background: var(--primary-soft);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 18px 0;
}
.keypoints h3 { margin: 0 0 10px; font-size: 1.05em; color: var(--primary-dark); }
.keypoints ul { margin: 0; padding-left: 22px; }
.keypoints li { margin-bottom: 6px; }

.wichtig {
  background: var(--accent-soft);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 16px 0;
  font-weight: 500;
}

/* ---------- Code ---------- */
.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 16px 0;
  position: relative;
  overflow-x: auto;
}
.code-block pre {
  margin: 0;
  font-family: "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
  font-size: 0.92em;
  line-height: 1.55;
  white-space: pre;
}
.code-block .code-title {
  display: block;
  color: #9fc3e8;
  font-size: 0.85em;
  margin-bottom: 8px;
  font-weight: 600;
}
.code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85em;
}
.code-copy:hover { background: rgba(255,255,255,0.25); }

.inline-code {
  background: #eef3f8;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
  color: #0b3550;
}

/* ---------- Quiz ---------- */
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  font-size: 1em;
  background: #f7fafc;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  min-height: 50px;
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-soft); }
.quiz-option .q-letter {
  flex: 0 0 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e4eaf1;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9em;
  color: var(--text-soft);
}
.quiz-option.correct { border-color: var(--success); background: var(--success-soft); }
.quiz-option.correct .q-letter { background: var(--success); color: #fff; }
.quiz-option.wrong { border-color: var(--error); background: var(--error-soft); }
.quiz-option.wrong .q-letter { background: var(--error); color: #fff; }
.quiz-option:disabled { cursor: default; }

.quiz-feedback {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 12px 0;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.good { background: var(--success-soft); border-left: 6px solid var(--success); }
.quiz-feedback.bad { background: var(--error-soft); border-left: 6px solid var(--error); }

.task-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.hint-box {
  margin-top: 12px;
  background: var(--warn-soft);
  border-left: 6px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.hint-box[hidden] { display: none; }

/* ---------- Sortier-Aufgabe ---------- */
.order-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; padding: 0; list-style: none; }
.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f7fafc;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  min-height: 48px;
}
.order-item:hover { border-color: var(--primary); }
.order-item .o-num {
  flex: 0 0 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e4eaf1;
  border-radius: 50%;
  font-weight: 700;
  color: var(--text-soft);
}
.order-item.chosen .o-num { background: var(--primary); color: #fff; }
.order-item.chosen { border-color: var(--primary); background: var(--primary-soft); }
.order-item.solved-correct { border-color: var(--success); background: var(--success-soft); }
.order-item.solved-correct .o-num { background: var(--success); color: #fff; }
.order-item.solved-wrong { border-color: var(--error); background: var(--error-soft); }

/* ---------- Befehls-Bastler ---------- */
.cb-goal {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.cb-goal strong { color: var(--primary-dark); }

.cb-terminal {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 60px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1em;
  line-height: 1.7;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.cb-token {
  background: rgba(255,255,255,0.14);
  border-radius: 6px;
  padding: 3px 8px;
  border: none;
  color: var(--code-text);
  font: inherit;
  cursor: pointer;
}
.cb-token:hover { background: rgba(255,255,255,0.3); }
.cb-token.cb-param { background: #123b63; color: #a8d8ff; }
.cb-cursor { width: 9px; height: 1.2em; background: #7fd1ff; animation: blink 1.1s steps(2) infinite; border-radius: 2px; }
.cb-empty { color: #8fb0cf; }

.cb-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.cb-chip {
  font: inherit;
  font-size: 0.95em;
  border: 2px solid var(--card-border);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
}
.cb-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.cb-chip .chip-kind { color: var(--text-soft); font-size: 0.85em; margin-right: 6px; }
.cb-chip.used { opacity: 0.45; }
.cb-freeinput {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  align-items: center;
}
.cb-freeinput input {
  flex: 1;
  font: inherit;
  font-family: Consolas, "Courier New", monospace;
  padding: 10px 12px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  min-height: 46px;
}
.cb-freeinput input:focus { border-color: var(--primary); }

.cb-feedback { list-style: none; padding: 0; margin: 12px 0; }
.cb-feedback li {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  align-items: flex-start;
}
.cb-feedback .fb-icon { flex: 0 0 22px; font-weight: 700; }
.cb-fb-ok { background: var(--success-soft); color: #0b5f0b; }
.cb-fb-missing { background: var(--error-soft); color: #9c0e1c; }
.cb-fb-extra { background: var(--warn-soft); color: var(--warn); }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 90;
  max-width: 340px;
}
.toast {
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  animation: toast-in 0.25s ease;
  font-size: 0.98em;
}
.toast.xp { background: var(--primary-dark); }
.toast.streak { background: #b45309; }
.toast.badge { background: var(--success); }
.toast.error { background: var(--error); }

/* ---------- Level-Up ---------- */
.levelup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.levelup-overlay[hidden] { display: none; }
.levelup-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  position: relative;
  z-index: 2;
}
.levelup-card h2 { margin: 10px 0 6px; font-size: 1.6em; }
.levelup-card p { color: var(--text-soft); margin: 0 0 18px; }
#confetti-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

/* ---------- TTS ---------- */
.tts-fab {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 80;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tts-fab:hover { background: var(--primary-dark); }
.tts-fab.speaking { background: #b45309; animation: pulse 1.6s ease infinite; }
.tts-fab.speaking .tts-fab-label { display: none; }
@media (max-width: 640px) { .tts-fab-label { display: none; } }

/* ---------- Badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.badge-card {
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
}
.badge-card .b-emoji { font-size: 2.2em; display: block; margin-bottom: 6px; }
.badge-card.locked { opacity: 0.45; filter: grayscale(0.9); }
.badge-card h3 { margin: 4px 0; font-size: 1em; }
.badge-card p { margin: 0; font-size: 0.82em; color: var(--text-soft); }
.badge-card .b-count { font-size: 0.8em; color: var(--text-soft); margin-top: 6px; }

/* ---------- Glossar / Listen ---------- */
.glossar-list { display: flex; flex-direction: column; gap: 10px; }
.glossar-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.glossar-item dt { font-weight: 700; }
.glossar-item dd { margin: 4px 0 0; color: var(--text-soft); }
.glossar-filter { margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.glossar-filter input {
  font: inherit;
  padding: 10px 14px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  min-width: 240px;
}

/* ---------- Cheatsheet ---------- */
.cs-group { margin-bottom: 22px; }
.cs-group h2 { font-size: 1.2em; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.cs-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius-sm); overflow: hidden; }
.cs-table th, .cs-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: top;
}
.cs-table th { background: #eef3f8; font-size: 0.9em; }
.cs-table td code { background: #eef3f8; border-radius: 4px; padding: 1px 6px; font-size: 0.9em; }

/* ---------- Startseite ---------- */
.hero {
  display: flex;
  gap: 26px;
  align-items: center;
  background: linear-gradient(135deg, #e6f2fc, #d6eeff);
  border-radius: var(--radius);
  padding: 30px;
  margin-bottom: 26px;
}
.hero img { width: 130px; height: 130px; flex-shrink: 0; }
.hero h1 { margin: 0 0 8px; font-size: 1.8em; }
.hero p { margin: 0 0 14px; color: var(--text-soft); max-width: 62ch; }
.hero .btn { margin-right: 10px; }

.daily-quest {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 26px;
}
.daily-quest h2 { margin: 0 0 6px; font-size: 1.15em; display: flex; align-items: center; gap: 8px; }
.daily-quest .dq-items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.daily-quest .dq-item { display: flex; align-items: center; gap: 10px; }
.daily-quest .dq-item .dq-state { width: 24px; text-align: center; }
.daily-quest .dq-item.done { color: var(--text-soft); }
.daily-quest .dq-item.done .dq-text { text-decoration: line-through; }

/* ---------- Einstellungen ---------- */
.settings-group { margin-bottom: 24px; }
.settings-group h2 { font-size: 1.15em; margin: 0 0 10px; }
.setting-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.setting-row .setting-info { flex: 1; min-width: 220px; }
.setting-row .setting-info strong { display: block; }
.setting-row .setting-info span { color: var(--text-soft); font-size: 0.92em; }

/* Toggle-Switch */
.switch { position: relative; display: inline-block; width: 54px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #c4cfdb;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(24px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--primary); outline-offset: 2px; }

.range-row input[type="range"] { width: 200px; }

/* ---------- Hilfe ---------- */
.help-section { margin-bottom: 20px; }
.help-section h2 { font-size: 1.2em; }
.help-section ul { padding-left: 22px; }
.help-section li { margin-bottom: 6px; }

/* ---------- Animationen (Respektiert prefers-reduced-motion) ---------- */
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 4px 14px rgba(0,0,0,0.25); } 50% { box-shadow: 0 4px 22px rgba(255,185,0,0.55); } }

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

/* ---------- KI-Lern-Assistent (Wolki KI) ---------- */
.ai-fab {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 80;
  background: linear-gradient(135deg, #0078d4, #005a9e);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-fab:hover { transform: translateY(-2px); }
.ai-fab.active { background: #b45309; }
@media (max-width: 640px) { .ai-fab-label { display: none; } }

.ai-panel {
  position: fixed;
  bottom: 78px;
  right: 18px;
  width: min(430px, calc(100vw - 36px));
  height: min(620px, calc(100vh - 110px));
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  z-index: 90;
  overflow: hidden;
}
.ai-panel[hidden] { display: none; }

.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--primary-soft);
  border-bottom: 1px solid var(--card-border);
}
.ai-header-mascot { border-radius: 50%; }
.ai-header strong { display: block; }
.ai-subline { font-size: 0.8em; color: var(--text-soft); }
.ai-close {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 1.1em;
  cursor: pointer;
  padding: 8px;
  color: var(--text-soft);
  border-radius: 8px;
}
.ai-close:hover { background: rgba(0,0,0,0.08); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg { display: flex; flex-direction: column; max-width: 92%; }
.ai-user { align-self: flex-end; align-items: flex-end; }
.ai-bot { align-self: flex-start; }
.ai-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.96em;
  line-height: 1.55;
}
.ai-user .ai-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-bot .ai-bubble {
  background: #eef3f8;
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 6px 0; padding-left: 20px; }
.ai-bubble li { margin-bottom: 4px; }
.ai-tts {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 0.82em;
  min-height: 30px;
  padding: 4px 10px;
}

.ai-typing { display: flex; gap: 4px; padding: 14px 16px; }
.ai-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: ai-bounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 10px;
}
.ai-chip {
  font: inherit;
  font-size: 0.85em;
  border: 2px solid var(--primary);
  color: var(--primary-dark);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
}
.ai-chip:hover { background: var(--primary-soft); }

.ai-inputrow {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--card-border);
  align-items: center;
}
.ai-inputrow input {
  flex: 1;
  font: inherit;
  padding: 10px 12px;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  min-height: 44px;
}
.ai-inputrow input:focus { border-color: var(--primary); outline: none; }
.ai-inputrow .btn { min-height: 44px; }

.ai-notice {
  padding: 8px 14px;
  background: #f7fafc;
  border-top: 1px solid var(--card-border);
  font-size: 0.78em;
  color: var(--text-soft);
}
.ai-notice p { margin: 4px 0; }

body.ai-open { overflow: hidden; }

@media (max-width: 640px) {
  .ai-panel { inset: 0; width: 100%; height: 100%; border: none; border-radius: 0; bottom: 0; right: 0; }
  .ai-fab { bottom: 16px; right: 16px; }
}


/* ---------- Responsiv ---------- */
@media (max-width: 760px) {
  .header-inner { gap: 10px; }
  .header-status { order: 3; width: 100%; justify-content: flex-end; }
  .hero { flex-direction: column; text-align: center; padding: 24px 18px; }
  .hero .btn { margin: 4px; }
  .section-body { padding: 18px 14px; }
  .cs-table { font-size: 0.9em; }
}


/* ============================================================
   Upgrade: Animationen, Pfad-Karte, Combo, Kisten, Rekorde
   Alle Animationen respektieren theme-nomotion und
   prefers-reduced-motion (siehe Motion-Gate unten).
   ============================================================ */

/* ---------- Header: Combo-Anzeige ---------- */
.status-combo {
  background: linear-gradient(135deg, #ffb900, #ff8c00);
  color: #fff;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  animation: combo-pulse 1.1s ease infinite;
  box-shadow: 0 0 10px rgba(255, 140, 0, 0.45);
  white-space: nowrap;
}
.status-combo.combo-hot {
  background: linear-gradient(135deg, #ff5722, #ffb900);
  animation-duration: 0.7s;
}
@keyframes combo-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---------- Fortschritts-Ring (Modul-Ansicht) ---------- */
.progress-ring {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: #e4eaf1; stroke-width: 4; }
.ring-arc {
  fill: none;
  stroke: url(#ring-grad);
  stroke: var(--primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 119.38;
  stroke-dashoffset: 119.38;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95em;
  color: var(--primary-dark);
}

/* ---------- Section-Übergänge ---------- */
.section-out { opacity: 0; transform: translateX(-18px); transition: opacity 0.18s ease, transform 0.18s ease; }
.section-in { animation: section-in 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes section-in {
  from { opacity: 0; transform: translateX(22px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Tages-Bonus-Kiste ---------- */
.daily-bonus {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #fff4d6, #ffe9b3);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.daily-bonus:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(255, 185, 0, 0.35); }
.daily-bonus .db-chest { font-size: 2em; animation: chest-wiggle 2.2s ease infinite; }
@keyframes chest-wiggle {
  0%, 86%, 100% { transform: rotate(0); }
  88% { transform: rotate(-8deg); }
  92% { transform: rotate(8deg); }
  96% { transform: rotate(-4deg); }
}
.daily-bonus strong { display: block; }
.daily-bonus span:not(.db-chest):not(.db-arrow) { color: var(--text-soft); font-size: 0.9em; }
.daily-bonus .db-arrow { margin-left: auto; font-size: 1.2em; color: var(--warn); }
.daily-bonus.opened { opacity: 0.75; border-style: dashed; }
.daily-bonus.opened .db-chest { animation: none; }

/* ---------- Session-Ziel ---------- */
.session-goal {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.session-goal .sg-info strong { display: block; font-size: 0.95em; }
.session-goal .sg-info span { color: var(--text-soft); font-size: 0.85em; }
.sg-fill { transition: width 0.5s ease; }

/* ---------- Rekorde ---------- */
.records-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}
.record-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.record-chip .rc-emoji { font-size: 1.5em; }
.record-chip strong { display: block; font-size: 1.1em; line-height: 1.2; }
.record-chip span:last-child { color: var(--text-soft); font-size: 0.78em; }

/* ---------- Pfad-Karte (Module) ---------- */
.path-map {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 14px 0;
}
.path-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.path-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 1;
}
.path-node.left { flex-direction: row; }
.path-node.right { flex-direction: row-reverse; }
.path-node-link {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e6f2fc, #d6eeff);
  border: 3px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7em;
  text-decoration: none;
  flex-shrink: 0;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(16, 42, 67, 0.1);
}
.path-node-link:hover { transform: scale(1.1); border-color: var(--primary); box-shadow: 0 4px 16px rgba(0, 120, 212, 0.3); }
.path-node.done .path-node-link {
  background: linear-gradient(135deg, #d9f2d9, #a9e0a9);
  border-color: var(--success);
}
.path-node.started .path-node-link { border-color: var(--primary); box-shadow: 0 0 14px rgba(0, 120, 212, 0.4); animation: node-glow 2.4s ease infinite; }
@keyframes node-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 120, 212, 0.3); }
  50% { box-shadow: 0 0 18px rgba(0, 120, 212, 0.55); }
}
.path-node .pn-status {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--text);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7em;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}
.path-node.done .pn-status { background: var(--success); }
.path-node.started .pn-status { background: var(--primary); }
.path-card {
  flex: 1;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.path-node:hover .path-card { border-color: var(--primary); transform: translateY(-2px); }
.path-card h3 { margin: 0 0 4px; font-size: 1.05em; }
.path-card .mc-summary { margin: 0 0 10px; font-size: 0.85em; }
.path-node.right .path-card { text-align: right; }

/* ---------- Badges-Übersicht ---------- */
.badge-overview {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 22px;
}
.badge-ring-wrap { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.badge-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.badge-ring-arc { stroke-dasharray: 119.38; }
.badge-ring-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1em;
  color: var(--success);
}
.badge-overview-text strong { font-size: 1.6em; display: block; line-height: 1.1; }
.badge-overview-text span { color: var(--text-soft); }

/* ---------- Modul-Abschluss ---------- */
.module-done-stats {
  color: var(--text-soft);
  font-size: 0.95em;
  margin: -8px 0 16px;
}

/* ---------- FX: Orbs ---------- */
.fx-orb-host { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
.fx-orb {
  position: fixed;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #50e6ff, #0078d4);
  box-shadow: 0 0 8px rgba(0, 120, 212, 0.6);
  animation: orb-fly 0.9s cubic-bezier(0.3, 0.7, 0.4, 1) forwards;
  transform: translate(var(--start-x), var(--start-y));
  opacity: 0;
}
@keyframes orb-fly {
  0% { opacity: 0; transform: translate(var(--start-x), var(--start-y)) scale(0.6); }
  20% { opacity: 1; }
  100% { opacity: 0.2; transform: translate(var(--tx), var(--ty)) scale(0.3); }
}
.fx-xp-flash { animation: xp-flash 0.5s ease; }
@keyframes xp-flash {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.8); }
  100% { filter: brightness(1); }
}

/* ---------- FX: Konfetti-Partikel ---------- */
.fx-confetti-host { position: fixed; pointer-events: none; z-index: 210; }
.fx-confetti-bit {
  position: absolute;
  border-radius: 2px;
  animation: confetti-fly 1.2s ease-out forwards;
  opacity: 0;
}
@keyframes confetti-fly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

/* ---------- FX: Pop / Shake / Float ---------- */
.fx-pop { animation: fx-pop 0.28s ease; }
@keyframes fx-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.fx-shake { animation: fx-shake 0.4s ease; }
@keyframes fx-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}
.fx-float {
  position: fixed;
  pointer-events: none;
  z-index: 220;
  font-weight: 800;
  animation: float-up 1.3s ease-out forwards;
  transform: translate(-50%, 0);
}
.fx-float-xp { color: var(--primary-dark); font-size: 1.1em; text-shadow: 0 1px 0 #fff; }
@keyframes float-up {
  0% { opacity: 0; translate: 0 8px; }
  15% { opacity: 1; }
  100% { opacity: 0; translate: 0 -46px; }
}

/* ---------- FX: Belohnungs-Kiste ---------- */
.fx-chest-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 55, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.fx-chest-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 34px 40px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: chest-card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes chest-card-in {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.fx-chest-box { position: relative; width: 120px; height: 96px; margin: 0 auto 18px; }
.fx-chest-lid {
  position: absolute;
  top: 0; left: 8px; right: 8px;
  height: 34px;
  background: linear-gradient(180deg, #ffc94d, #ffb900);
  border-radius: 8px 8px 0 0;
  border: 2px solid #b8860b;
  transform-origin: bottom center;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.fx-chest-base {
  position: absolute;
  bottom: 0; left: 6px; right: 6px;
  height: 52px;
  background: linear-gradient(180deg, #ffb900, #e6a200);
  border-radius: 0 0 8px 8px;
  border: 2px solid #b8860b;
}
.fx-chest-base::before {
  content: "";
  position: absolute;
  top: -14px; left: 22px; right: 22px;
  height: 16px;
  background: #ffd25e;
  border-radius: 4px;
  border: 2px solid #b8860b;
}
.fx-chest-box.open .fx-chest-lid { transform: rotateX(-120deg) translateY(-8px); }
.fx-chest-box .fx-chest-glow {
  position: absolute;
  inset: -14px;
  border-radius: 24px;
  background: radial-gradient(circle, rgba(255, 200, 60, 0.65), transparent 70%);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.fx-chest-box.open .fx-chest-glow { opacity: 1; }
.fx-chest-title { margin: 0 0 6px; font-size: 1.35em; }
.fx-chest-text { color: var(--text-soft); margin: 0 0 20px; }
.fx-chest-btn { min-width: 150px; }

/* ---------- FX: Sterne (Level-Up) ---------- */
.fx-star-host { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.fx-star {
  position: absolute;
  top: -40px;
  animation: star-fall 3.2s linear infinite;
  opacity: 0.9;
}
@keyframes star-fall {
  0% { transform: translateY(-40px) rotate(0); opacity: 0; }
  8% { opacity: 0.95; }
  100% { transform: translateY(110vh) rotate(200deg); opacity: 0.6; }
}

/* ---------- Level-Up-Zahl ---------- */
.levelup-number-wrap { display: flex; flex-direction: column; align-items: center; margin: 6px 0 2px; }
.levelup-number {
  font-size: 3.4em;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #0078d4, #50e6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 120, 212, 0.35));
}
.levelup-levelword {
  font-size: 0.75em;
  letter-spacing: 0.35em;
  color: var(--text-soft);
  margin-top: 2px;
}

/* ---------- Befehls-Bastler: Erfolgs-Glow ---------- */
.cb-success {
  box-shadow: 0 0 0 3px rgba(16, 124, 16, 0.55), 0 0 22px rgba(16, 124, 16, 0.4);
  transition: box-shadow 0.3s ease;
}
.cb-token { transition: transform 0.15s ease, background 0.15s ease; }
.cb-token:hover { transform: translateY(-1px); }

/* ---------- Stil-Update: Karten & Buttons mit mehr Tiefe ---------- */
.btn-primary {
  background: linear-gradient(135deg, #0078d4, #005a9e);
  box-shadow: 0 3px 10px rgba(0, 120, 212, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 120, 212, 0.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-success {
  background: linear-gradient(135deg, #107c10, #0b5f0b);
  box-shadow: 0 3px 10px rgba(16, 124, 16, 0.3);
}
.module-card, .card, .path-card, .daily-bonus, .session-goal, .records-row .record-chip, .badge-overview {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.status-xpbar-fill {
  background: linear-gradient(90deg, #0078d4, #50e6ff);
  background-size: 200% 100%;
  animation: bar-shimmer 3s linear infinite;
}
@keyframes bar-shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: -200% 0; }
}
.hero {
  background: linear-gradient(135deg, #e6f2fc 0%, #d6eeff 55%, #cde6ff 100%);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 200px at 85% 20%, rgba(80, 230, 255, 0.35), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero img { animation: wolki-float 4s ease-in-out infinite; }
@keyframes wolki-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* ---------- Motion-Gate: alles abschaltbar ---------- */
body.theme-nomotion .fx-orb-host,
body.theme-nomotion .fx-confetti-host,
body.theme-nomotion .fx-float,
body.theme-nomotion .fx-chest-overlay,
body.theme-nomotion .fx-star,
body.theme-nomotion .section-in,
body.theme-nomotion .status-combo,
body.theme-nomotion .daily-bonus .db-chest,
body.theme-nomotion .path-node.started .path-node-link,
body.theme-nomotion .hero img,
body.theme-nomotion .status-xpbar-fill {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .fx-orb-host, .fx-confetti-host, .fx-float, .fx-chest-overlay, .fx-star,
  .section-in, .status-combo, .daily-bonus .db-chest,
  .path-node.started .path-node-link, .hero img, .status-xpbar-fill {
    animation: none !important;
    transition: none !important;
  }
}


/* ---------- So lernst du (Schritte-Box auf der Startseite) ---------- */
.howto {
  background: linear-gradient(135deg, #f0f7ff, #e6f2fc);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.howto-head strong {
  display: block;
  font-size: 1.1em;
  color: var(--primary-dark);
}
.howto-head span {
  color: var(--text-soft);
  font-size: 0.9em;
}
.howto-steps {
  list-style: none;
  margin: 12px 0 10px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.howto-steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.howto-steps .hs-num {
  flex: 0 0 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85em;
  margin-top: 2px;
}
.howto-steps strong { display: block; font-size: 0.95em; }
.howto-steps span:last-child { color: var(--text-soft); font-size: 0.82em; }
.howto-note {
  margin: 4px 0 0;
  font-size: 0.85em;
  color: var(--text-soft);
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
