/* =========================================================================
   Codaluna · app.css — Layout & Komponenten
   Tokens, Basis, Buttons und Editor-Farben stehen in design.css.
   Grundsätze: Flächen statt Karten-in-Karten, 1px-Linien statt Schatten,
   Farbe nur mit Bedeutung (Amber = Handlung/Position, Teal = Lumo/geschafft,
   Koralle = Fehler), Icons aus icons.js statt Emojis.
   Kopf, Werkzeugleiste und Konsole bleiben in beiden Themes dunkel
   (Variablen --chrome-*), der Lesebereich folgt dem Theme.
   ========================================================================= */

[hidden] { display: none !important; }  /* sonst überschreibt display:flex das hidden-Attribut */

#app {
  display: grid;
  grid-template-rows: calc(var(--header-h) + env(safe-area-inset-top, 0px)) 1fr;
  height: 100%;
  height: 100dvh;
}

/* =============================== Header ================================== */
.header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--chrome-line);
  background: var(--chrome);
  color: var(--chrome-text);
  position: relative;
  z-index: 30;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 17px;
  letter-spacing: -0.01em;
  flex: none;
  margin-right: 8px;
}
.brand .logo { width: 28px; height: 28px; display: block; }
.brand .name { color: var(--chrome-text); }
.brand .name b { color: inherit; font-weight: inherit; }
.header-spacer { flex: 1; min-width: 0; }

/* --- Wochenziel und Level als ein Knopf: öffnet Fortschritt & Abzeichen --- */
.stats-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--chrome-muted);
  font: inherit;
  cursor: pointer;
  margin-right: 6px;
  transition: background .12s ease;
}
.stats-btn:hover { background: var(--chrome-hover); }
.stat { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.stat .val { color: var(--chrome-text); font-weight: 700; }
.stat-label { font-size: 13px; font-weight: 500; color: var(--chrome-faint); }
@media (max-width: 1120px) { .stat[data-kind="week"] .stat-label { display: none; } }

.xp-wrap { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--chrome-line); height: 20px; }
.level-badge { color: var(--chrome-text); font-weight: 750; font-size: 14px; min-width: 1ch; }
.xp-bar {
  display: block;
  width: 112px;
  height: 4px;
  border-radius: 2px;
  background: #34312c;
  overflow: hidden;
}
.xp-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}

/* ---- Icon-Knöpfe in der Kopfzeile ---- */
.help-btn {
  width: 38px; height: 38px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  font: inherit; font-weight: 700; font-size: 15px;
  color: var(--chrome-muted);
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.help-btn:hover { color: var(--chrome-text); background: var(--chrome-hover); }
.help-btn[aria-expanded="true"] { color: var(--chrome-text); background: var(--chrome-hover); }
.help-btn.done { color: var(--teal); }

/* Sprach-Menü */
.lang-wrap { position: relative; display: inline-flex; }
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.lang-opt {
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}
.lang-opt:hover, .lang-opt:focus-visible { background: var(--surface-2); color: var(--text); }
.lang-opt.active { color: var(--text); font-weight: 700; box-shadow: inset 2px 0 0 var(--accent); }

/* ================================ Body ================================== */
.body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}
.body > *, .workspace > *, .editor-host { min-width: 0; }

/* ========================= Sidebar / Lernpfad =========================== */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-tint);
  overflow-y: auto;
  padding: 10px 10px calc(30px + env(safe-area-inset-bottom, 0px));
}
.chapter-title {
  padding: 22px 10px 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 1px 8px;
}
.chapter-title .ch-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
}
.chapter-title .ch-icon { display: inline-flex; color: var(--text-faint); }
.chapter-title .ch-count { grid-row: 1; grid-column: 2; align-self: center; font-size: 12.5px; font-weight: 600; color: var(--text-faint); }
.chapter-title .ch-name { grid-column: 1 / 3; font-size: 14.5px; font-weight: 750; color: var(--text); }

.lesson-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 38px;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--r-md);
  cursor: pointer;
  font: inherit;
  font-size: 14.5px;
  transition: background .12s ease, color .12s ease;
}
/* verbindende Linie des Lernpfads */
.lesson-item::before {
  content: "";
  position: absolute;
  left: 20.5px; top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}
.lesson-item.first::before { top: 50%; }
.lesson-item.last::before  { bottom: 50%; }
.lesson-item.done::before { background: var(--teal-line); }
.lesson-item.sandbox-item::before { display: none; }

.lesson-item:hover { background: var(--surface); color: var(--text); }
.lesson-item.active { background: var(--surface-2); color: var(--text); }
.lesson-item.locked { color: var(--text-faint); cursor: not-allowed; }
.lesson-item.locked:hover { background: transparent; }

.lesson-item .mark {
  position: relative;
  z-index: 1;
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  background: var(--bg-tint);
  color: var(--text-muted);
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 0 0 3px var(--bg-tint);
}
.lesson-item:hover .mark { box-shadow: 0 0 0 3px var(--surface); background: var(--surface); }
.lesson-item.active .mark { box-shadow: 0 0 0 3px var(--surface-2); }
.lesson-item .mark .icon { width: 12px; height: 12px; }
.lesson-item.boss .mark, .lesson-item.final .mark { border-radius: 5px; }
.lesson-item.done .mark { border-color: var(--teal-line); color: var(--teal-ink); }
.lesson-item.done .mark .icon { stroke-width: 2.2; }
.lesson-item.active .mark { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.lesson-item.locked .mark { border-style: dashed; border-color: var(--border); color: var(--text-faint); }
.lesson-item.locked .mark .icon { width: 11px; height: 11px; }
.lesson-item .title { font-weight: 500; flex: 1; min-width: 0; }
.lesson-item.active .title { font-weight: 700; }
.lesson-item .bonus-star { flex: none; display: inline-flex; color: var(--accent-ink); }

/* Spielplatz und Stationskarte oben im Lernpfad */
.lesson-item.sandbox-item .mark { border: none; background: transparent; box-shadow: none; color: var(--text-muted); width: 22px; }
.lesson-item.sandbox-item .mark .icon { width: 18px; height: 18px; }
.lesson-item.sandbox-item.active .mark { background: transparent; color: var(--accent-ink); }
.lesson-item.sandbox-item .title { font-weight: 600; }

/* ============================ Arbeitsbereich ============================ */
.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 42%) 1fr;
  min-height: 0;
}
.lesson-pane {
  overflow-y: auto;
  padding: 28px 36px 48px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.lesson-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lesson-kicker { font-size: 13.5px; font-weight: 650; color: var(--accent-ink); }
.lesson-kicker.sandbox { color: var(--teal-ink); }
.lesson-kicker.boss {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
}
.lesson-done { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; font-weight: 650; color: var(--teal-ink); }
.lesson-pane h1 { font-size: 30px; line-height: 1.15; margin: 6px 0 0; }
.lesson-body { font-size: 16px; line-height: 1.65; margin-top: 18px; }
.lesson-body p, .lesson-body li { color: var(--text); }
.lesson-body ul { padding-left: 1.3em; }
.lesson-body b, .lesson-body strong { font-weight: 700; }

.lesson-body pre {
  margin: 16px 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: #e6e1d6;
}

/* Aufgabe: der wichtigste Block der Spalte */
.lesson-body .task {
  margin-top: 26px;
  padding: 16px 18px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.lesson-body .task h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px;
  font-weight: 750;
  color: var(--accent-ink);
  margin: 0 0 4px;
}
.lesson-body .task > div > p:first-child { margin-top: 4px; }

/* Tipps (gestaffelt) */
.hint-box { margin-top: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.hint {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--warning-line);
  border-radius: var(--r-md);
  font-size: 15px;
  color: var(--text);
  animation: rise .2s ease;
}
.hint .hint-n { font-weight: 750; color: var(--warning-ink); margin-right: 4px; }
.hint-btn { padding-left: .7em; padding-right: .7em; color: var(--warning-ink); }
.hint-btn:hover { color: var(--warning-ink); }

/* Bonus-Aufgabe */
.expert {
  margin-top: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.expert-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.expert-toggle:hover { background: var(--surface); }
.expert-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.expert .label { display: inline-flex; align-items: center; gap: 7px; font-weight: 750; font-size: 15.5px; }
.expert .label .icon { color: var(--accent-ink); }
.expert .xp-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.expert.solved .xp-chip { color: var(--teal-ink); }
.expert .sub { grid-column: 1; font-size: 13.5px; color: var(--text-muted); }
.expert .chev { grid-row: 1 / 3; grid-column: 2; display: inline-flex; color: var(--text-muted); transition: transform .2s ease; }
.expert.open .chev { transform: rotate(180deg); }
.expert-body { padding: 2px 16px 16px; border-top: 1px solid var(--border-soft); }
.expert-note { font-size: 13.5px; color: var(--text-muted); margin: 12px 0; }

/* Navigation unter der Lektion */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* ============================ Editor-Spalte ============================= */
.editor-col {
  display: grid;
  grid-template-rows: 50px minmax(120px, 1fr) minmax(150px, 1fr);
  min-height: 0;
  background: var(--bg-deep);
}
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid var(--chrome-line);
  background: var(--chrome);
  min-width: 0;
}
.toolbar .spacer { flex: 1; }
.toolbar .btn-ghost { color: var(--chrome-muted); }
.toolbar .btn-ghost:hover { color: var(--chrome-text); background: var(--chrome-hover); }
.toolbar .btn-danger { color: #f2826f; }
.toolbar .btn-danger:hover { background: #f2826f1f; }
.toolbar .btn-danger:disabled { color: var(--chrome-faint); opacity: .5; }
#run-btn { min-width: 124px; margin-right: 2px; }
#run-btn .run-ico { display: inline-flex; }
#run-btn.loading .run-ico {
  width: 14px; height: 14px;
  border: 2px solid #1a130655;
  border-top-color: var(--on-accent);
  border-radius: 50%;
  overflow: hidden;
  animation: spin .8s linear infinite;
}
#run-btn.loading .run-ico .icon { display: none; }
#run-btn.loading:disabled { opacity: .8; }
.editor-host { min-height: 0; overflow: hidden; }
.editor-host .CodeMirror { height: 100%; }

/* =============================== Konsole ================================ */
.console {
  border-top: 1px solid var(--chrome-line);
  display: grid;
  grid-template-rows: 38px 1fr auto;
  min-height: 0;
  background: var(--bg-deep);
  color: var(--chrome-text);
}
.console-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 0 12px;
  font-size: 13px; font-weight: 650;
  color: var(--chrome-faint);
  border-bottom: 1px solid #201f1c;
  min-width: 0;
}
.console-head .spacer { flex: 1; }
.console-head .dot { display: none; }
.console-status {
  font-weight: 500;
  font-size: 13px;
  color: var(--chrome-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.console-status:not(:empty)::before { content: "·"; margin-right: 8px; color: var(--chrome-faint); }
.console-clear {
  width: 32px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-sm);
  background: transparent;
  color: var(--chrome-faint);
  cursor: pointer;
}
.console-clear:hover { color: var(--chrome-text); background: var(--chrome-hover); }
.console-out {
  overflow-y: auto;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e6e1d6;
}
.console-out .info { color: var(--chrome-faint); }
.console-out .err { color: #f5a596; }
.console-out .in { color: var(--teal); font-weight: 700; }
.console-out .placeholder { font-family: var(--font); font-size: 14px; color: var(--chrome-faint); }

/* ---- Karten in der Konsole (immer dunkel) ---- */
.err-card, .result-card, .stage-card {
  --card-bg: #1b1a17;
  --card-line: #2e2c28;
  margin: 10px 0 6px;
  border: 1px solid var(--card-line);
  border-radius: var(--r-lg);
  background: var(--card-bg);
  white-space: normal;
  font-family: var(--font);
  color: var(--chrome-text);
  animation: rise .2s ease;
}

/* Fehler-Karte */
.err-card { --card-bg: #1c1513; --card-line: #472923; overflow: hidden; }
.err-card .err-title {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 6px;
  font-weight: 750; font-size: 15px;
  color: #f5a596;
}
.err-card .err-title .ico { display: flex; }
.err-card .err-title .txt { flex: 1; }
.err-card .where {
  flex: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #e9c46a;
  background: transparent;
  border: 1px solid #4f4223;
  border-radius: var(--r-sm);
  padding: 3px 9px;
  cursor: pointer;
}
.err-card .where:hover { background: #e9c46a14; }
.err-card .err-msg { padding: 0 14px 10px 54px; font-size: 14.5px; line-height: 1.6; color: var(--chrome-text); }
.err-card .err-msg code, .result-card code { background: #2a2824; color: #f2b45a; }
.err-card .err-orig { padding: 0 14px 12px 54px; }
/* Betroffene Zeile mit markierter Stelle, darunter der Vorschlag */
.err-card .err-code {
  position: relative;
  margin: 0 14px 10px 54px;
  border: 1px solid #33201c;
  border-radius: var(--r-md);
  background: #14100e;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
}
.err-card .err-line { display: flex; align-items: baseline; min-width: max-content; padding: 2px 12px 2px 0; }
.err-card .err-line + .err-line { border-top: 1px solid #2a1c19; }
.err-card .err-line .ln {
  flex: none; display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px;
  min-width: 40px; padding-right: 10px;
  color: #8a6f68; font-size: 12px; user-select: none;
}
.err-card .err-line.fix .ln { color: #4fd6b8; }
.err-card .err-line code { background: none; padding: 0; color: #e6e1d6; white-space: pre; font-size: inherit; line-height: inherit; }
.err-card .err-line mark { background: #f2826f33; color: #ffd2c9; border-bottom: 2px solid #f2826f; border-radius: 2px; }
.err-card .err-line ins { text-decoration: none; background: #3ccfb026; color: #b7f2e3; border-bottom: 2px solid #3ccfb0; border-radius: 2px; }
.err-card .err-line .gap { display: inline-block; width: 2px; height: 1.2em; vertical-align: text-bottom; padding: 0; border: none; margin: 0 1px; }
.err-card .err-line mark.gap { background: #f2826f; }
.err-card .err-line ins.gap { background: #3ccfb0; }
.err-card .err-fix-bar { margin: -2px 14px 12px 54px; }
.err-card .btn-fix { min-height: 32px; padding: 0.3em 0.8em; font-size: 13.5px; background: #3ccfb0; border-color: #3ccfb0; color: #08251e; }
.err-card .btn-fix:hover { background: #4fd6b8; border-color: #4fd6b8; }
.err-card .btn-fix:disabled { opacity: 1; background: transparent; border-color: #24473f; color: #4fd6b8; }
.err-card .err-orig code { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: #2a1c19; color: #f5c2b6; }
.err-card .err-details { border-top: 1px solid #33201c; }
.err-card .err-details summary { cursor: pointer; padding: 9px 14px; color: var(--chrome-faint); font-size: 13px; }
.err-card .err-details summary:hover { color: var(--chrome-muted); }
.err-card .err-details pre { margin: 0; border: none; border-radius: 0; background: #14100e; color: #d8aaa0; font-size: 12px; padding: 12px 14px; }

/* Ergebnis-Karten: geschafft / fast / Bonus / Hinweis */
.result-card { padding: 12px 14px; }
.result-card .rc-title { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 15px; }
.result-card .rc-title .ico { display: flex; }
.result-card .rc-text { margin-top: 4px; padding-left: 28px; font-size: 14.5px; line-height: 1.6; color: #d9d5cc; }
.result-card .rc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-left: 28px; }
.result-card .rc-actions .btn-ghost { color: var(--chrome-muted); }
.result-card .rc-actions .btn-ghost:hover { color: var(--chrome-text); background: var(--chrome-hover); }
.result-card.ok { --card-bg: #131d19; --card-line: #24473f; }
.result-card.ok .rc-title { color: #4fd6b8; }
.result-card.hint { --card-line: #4f4223; }
.result-card.hint .rc-title { color: #e9c46a; }
.result-card.bonus { --card-bg: #131d19; --card-line: #24473f; }
.result-card.bonus .rc-title { color: #4fd6b8; }
.result-card.warn { --card-line: #5a4220; }
.result-card.warn .rc-title { color: #f2b45a; }
.result-card.reward { --card-bg: #1c1913; --card-line: #4a3a1d; padding: 10px 14px; }
.result-card.reward .rw { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #f2b45a; padding: 2px 0; }
.result-card .linkbtn { color: #4fd6b8; }
.result-card .rw-more { margin-top: 6px; font-size: 13.5px; }

/* Eingabezeile für input() */
.console-input {
  display: none;
  align-items: center; gap: 8px;
  padding: 6px 6px 6px 14px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--chrome-line);
  background: #161513;
}
.console-input.show { display: flex; animation: rise .2s ease; }
.console-input .prompt { color: var(--teal); font-family: var(--mono); font-weight: 700; }
.console-input input {
  flex: 1; min-width: 0;
  font: inherit;
  font-family: var(--mono); font-size: 14px;
  background: transparent; border: none; color: var(--chrome-text);
  padding: 6px 0;
}
.console-input input:focus { outline: none; }
.console-input:focus-within { box-shadow: inset 0 0 0 1px var(--teal); }
.console-input .input-send { color: var(--teal); min-height: 32px; }

/* ============================== Toasts =================================== */
.toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 10px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100vw - 32px);
  z-index: 250;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: 14.5px;
  box-shadow: var(--shadow);
  background: #24221f;
  color: #eeebe4;
  border: 1px solid #3a3732;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease;
  cursor: pointer;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast .toast-ico { display: inline-flex; }
.toast.ok .toast-ico { color: #4fd6b8; }
.toast.fail .toast-ico { color: #f2826f; }
.toast.badge .toast-ico { color: #f2b45a; }
.toast.lock .toast-ico { color: #bdb8ad; }
.toast code { background: #ffffff14; color: inherit; }

/* ============================= Startbild ================================ */
.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 300;
  transition: opacity .3s ease;
}
.boot.hide { opacity: 0; pointer-events: none; }
.boot .box { text-align: center; color: var(--text-muted); }
.boot .box .big { font-weight: 750; font-size: 20px; color: var(--text); }
.spinner {
  width: 32px; height: 32px; margin: 0 auto 14px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =============================== Responsiv ============================== */
#menu-btn { display: none; }
.mtabs { display: none; }
.scrim { display: none; }

@media (max-width: 960px) {
  #menu-btn { display: inline-flex; margin-left: -6px; }
  .body { grid-template-columns: 1fr; position: relative; }

  .sidebar {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); bottom: 0; left: 0;
    width: min(86vw, 330px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
    visibility: hidden;
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .scrim {
    position: fixed; inset: calc(var(--header-h) + env(safe-area-inset-top, 0px)) 0 0 0;
    background: rgba(10, 9, 8, .6);
    z-index: 35;
  }
  .sidebar.open ~ .scrim { display: block; }

  /* Aufgabe | Code als Segment-Schalter */
  .mtabs {
    display: flex;
    margin: 8px 12px;
    padding: 3px;
    gap: 3px;
    border-radius: var(--r-md);
    background: var(--surface-2);
  }
  .mtab {
    flex: 1;
    font: inherit; font-weight: 650; font-size: 14px;
    min-height: 36px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
  }
  .mtab.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
  :root[data-theme="light"] .mtab.active { background: var(--surface); }

  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .lesson-pane { border-right: none; }
  .workspace.show-code .lesson-pane { display: none; }
  .workspace:not(.show-code) .editor-col { display: none; }

  .header { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .xp-bar { width: 72px; }
}

@media (max-width: 600px) {
  .lesson-pane { padding: 18px 16px 32px; }
  .lesson-pane h1 { font-size: 25px; }
  .toolbar { gap: 2px; padding: 0 6px; }
  .toolbar .btxt { display: none; }
  .toolbar .btn { padding-left: .7em; padding-right: .7em; }
  #run-btn { min-width: 0; padding-left: 1em; padding-right: 1.1em; }
  #run-btn .btxt { display: inline; }  /* "Ausführen" bleibt lesbar */
  .brand { margin-right: 0; }
  .brand .name { display: none; }
  .header { gap: 2px; }
  .stats-btn { gap: 10px; padding: 0 8px; margin-right: 0; }
  .xp-bar { display: none; }
  .xp-wrap { padding-left: 10px; }
  .help-btn { width: 36px; height: 36px; }
}
@media (max-width: 380px) {
  #theme-btn { display: none; }  /* sehr schmal: Theme-Knopf weicht, alles andere bleibt erreichbar */
  .result-card .rc-text, .result-card .rc-actions { padding-left: 0; }
  .err-card .err-msg, .err-card .err-orig { padding-left: 14px; }
  .err-card .err-code, .err-card .err-fix-bar { margin-left: 14px; }
}

/* Touch-Geräte: 16px verhindert das automatische Hineinzoomen (iOS) */
@media (pointer: coarse) {
  .CodeMirror { font-size: 16px; }
  .console-input input, .auth-email input, .diploma-name-input { font-size: 16px; }
}

/* ===================== Dialoge, Willkommen, Tour ======================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 9, 8, .66);
  display: flex; flex-direction: column;  /* margin:auto zentriert, ohne oben abzuschneiden */
  z-index: 210; padding: 20px;
  overflow-y: auto;
}
.modal {
  position: relative;
  margin: auto;
  max-width: 460px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  animation: rise .18s ease;
}
:root:not([data-theme="light"]) .modal { background: var(--bg-tint); }
.modal:focus { outline: none; }
.modal-x {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-x ~ h2 { padding-right: 40px; }
.modal-logo { line-height: 1; margin-bottom: 12px; }
.modal h2 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.modal h2 .icon { color: var(--text-muted); }
.modal p { color: var(--text-muted); margin: 10px 0 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }
.confirm-modal { max-width: 420px; }
.confirm-modal h2 { font-size: 20px; }
.confirm-modal .modal-actions { flex-direction: row-reverse; justify-content: flex-start; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
:root:not([data-theme="light"]) .btn-danger-solid { color: #2a0b06; }
.btn-danger-solid:hover { filter: brightness(1.08); background: var(--danger); border-color: var(--danger); }

.tour { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.tour-spot {
  position: fixed;
  border-radius: var(--r-md);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(10, 9, 8, .66);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
  pointer-events: none;
}
.tour-card {
  position: fixed;
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.tour-step { font-size: 12.5px; color: var(--text-faint); font-weight: 600; }
.tour-card h3 { font-size: 17px; margin: 4px 0 6px; }
.tour-card p { margin: 0; color: var(--text-muted); font-size: 14.5px; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }

/* Fortschritt & Abzeichen */
.progress-modal { max-width: 720px; }
.progress-modal h3 { font-size: 15px; margin: 26px 0 8px; }
.pg-level { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.pg-badge {
  display: grid; place-items: center; flex: none;
  width: 54px; height: 60px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--accent);
  font-weight: 800; font-size: 24px; color: var(--on-accent);
}
.pg-xp { flex: 1; min-width: 0; }
.pg-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--text-muted); }
.pg-row b { color: var(--text); font-size: 15px; }
.xp-bar.big { width: 100%; height: 6px; margin: 8px 0 6px; background: var(--surface-3); border-radius: 3px; }
.pg-total { font-size: 13px; color: var(--text-faint); }
.pg-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 20px; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.pg-stats > div { padding: 12px 14px; }
.pg-stats > div + div { border-left: 1px solid var(--border-soft); }
.pg-stats .n { display: block; font-weight: 750; font-size: 22px; line-height: 1.2; }
.pg-stats .l { display: block; font-size: 13px; color: var(--text-muted); }
.badge-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }
.badge { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.badge .ico {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 42px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--surface-2);
  color: var(--text-faint);
}
.badge.earned .ico { background: var(--accent-weak); color: var(--accent-ink); }
.badge.secret.earned .ico { background: var(--teal-weak); color: var(--teal-ink); }
.badge .txt { display: flex; flex-direction: column; min-width: 0; padding-top: 1px; }
.badge .name { font-weight: 700; font-size: 14px; color: var(--text-muted); }
.badge.earned .name { color: var(--text); }
.badge .desc { font-size: 13px; color: var(--text-faint); line-height: 1.4; }
.badge.earned .desc { color: var(--text-muted); }
.pg-note { font-size: 13px; margin-top: 18px !important; }
@media (max-width: 480px) {
  .pg-stats { grid-template-columns: 1fr; }
  .pg-stats > div + div { border-left: none; border-top: 1px solid var(--border-soft); }
}

/* ============================== Offline-Toast =========================== */
.offline-toast {
  position: fixed;
  left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(16px);
  opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: var(--r-md);
  background: #24221f;
  border: 1px solid #3a3732;
  color: #eeebe4;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
}
.offline-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Fußbereich der Sidebar ---- */
.sidebar-footer {
  margin-top: 24px;
  padding: 12px 0 6px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.side-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  text-align: left;
  padding: 6px 10px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-action .icon { color: var(--text-faint); }
.side-action:hover { background: var(--surface); color: var(--text); }
.side-action:hover .icon { color: inherit; }
.side-action.danger:hover { background: var(--danger-weak); color: var(--danger); }
.side-account { padding: 2px 10px 6px; }
.acct-email {
  display: block;
  font-size: 13px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-legal {
  margin-top: 12px;
  padding: 10px 10px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-faint);
}
.side-legal a { color: var(--text-faint); }
.side-legal a:hover { color: var(--text); }

/* Anmelde-Dialog */
.auth-modal { max-width: 400px; }
.auth-email { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.auth-email input, .share-link, .diploma-name-input {
  font: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.auth-email input:focus, .share-link:focus, .diploma-name-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.auth-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-faint);
  font-size: 13px;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-providers { display: flex; flex-direction: column; gap: 8px; }
.auth-note { margin-top: 18px; font-size: 13px; color: var(--text-faint); }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.linkbtn {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal-ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }
.modal-overlay.gate { background: rgba(10, 9, 8, 0.92); }

/* Diplom */
.diploma-modal { max-width: 560px; }
.diploma-cert { width: 100%; margin-top: 14px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); }
.diploma-cert svg { display: block; width: 100%; height: auto; }
.diploma-name-input { width: 100%; margin-top: 14px; }

/* =========================================================================
   Spielend lernen · Paket 1: Lumo, Wochenziel, Klang, Effekte, Ausprobieren
   ========================================================================= */

/* ---- Lumo (Begleitdrohne, companion.js) ---- */
:root { --lumo-light: #3ccfb0; --lumo-hull: #2f2d29; --lumo-metal: #8a857b; }
.lumo { display: block; overflow: visible; flex: none; }
.lumo .lumo-shadow { fill: #00000040; }
.lumo .lumo-hull { fill: var(--lumo-hull); stroke: var(--lumo-light); stroke-width: 1.8; stroke-linejoin: round; }
.lumo .lumo-visor { fill: #100f0d; }
.lumo .lumo-rotor rect, .lumo .lumo-mast { fill: var(--lumo-metal); }
.lumo .lumo-led { fill: var(--accent); }
.lumo .lumo-eye { fill: var(--lumo-light); }
.lumo .lumo-line { fill: none; stroke: var(--lumo-light); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.lumo .lumo-glint { fill: #ffffffd9; }
.lumo .lumo-spark { fill: var(--accent-soft); }
.lumo .lumo-bits { fill: var(--lumo-light); }
.lumo .lumo-mark { fill: var(--accent-soft); font: 700 15px var(--font); }
:root[data-theme="light"] .lesson-pane .lumo, :root[data-theme="light"] .modal .lumo { --lumo-hull: #3a3732; }
.lumo .lumo-body, .lumo .lumo-rotor, .lumo .lumo-blink, .lumo .lumo-dots circle, .lumo .lumo-spark, .lumo .lumo-z {
  transform-box: fill-box; transform-origin: center;
}
.lumo .lumo-body { animation: lumo-hover 3.2s ease-in-out infinite; }
.lumo .lumo-rotor { animation: lumo-spin .16s linear infinite; }
.lumo .lumo-blink { animation: lumo-blink 5.5s ease-in-out infinite; }
.lumo-think .lumo-dots circle { animation: lumo-dot 1s ease-in-out infinite; }
.lumo-think .lumo-dots circle:nth-child(2) { animation-delay: .15s; }
.lumo-think .lumo-dots circle:nth-child(3) { animation-delay: .3s; }
.lumo-happy .lumo-body { animation: lumo-hop .5s ease 2, lumo-hover 3.2s 1s ease-in-out infinite; }
.lumo-proud .lumo-body { animation: lumo-hop .45s ease 3, lumo-hover 3.2s 1.4s ease-in-out infinite; }
.lumo-proud .lumo-spark { animation: lumo-twinkle 1.1s ease-in-out infinite; }
.lumo-curious .lumo-body { animation: lumo-tilt 2.4s ease-in-out infinite; }
.lumo-glitch .lumo-body { animation: lumo-jitter .1s steps(2) 6, lumo-hover 3.2s .6s ease-in-out infinite; }
.lumo-glitch .lumo-bits { animation: lumo-twinkle .5s steps(2) 4; }
.lumo-sleep .lumo-body { animation: lumo-hover 5s ease-in-out infinite; }
.lumo-sleep .lumo-rotor { animation: none; transform: scaleX(.85); }
.lumo-sleep .lumo-z { animation: lumo-float 2.4s ease-in-out infinite; }
.lumo-listen .lumo-body { animation: lumo-hover 1.6s ease-in-out infinite; }
@keyframes lumo-hover { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@keyframes lumo-spin { 50% { transform: scaleX(.3); } }
@keyframes lumo-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.12); } }
@keyframes lumo-dot { 0%, 100% { opacity: .35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@keyframes lumo-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-7px) scale(1.04); } }
@keyframes lumo-tilt { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(-3deg) translateY(-2px); } }
@keyframes lumo-jitter { 0% { transform: translate(-1.5px, .5px); } 100% { transform: translate(1.5px, -.5px); } }
@keyframes lumo-twinkle { 0%, 100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes lumo-float { 0% { opacity: 0; transform: translate(0, 4px); } 50% { opacity: 1; } 100% { opacity: 0; transform: translate(4px, -6px); } }

/* Lumo im Konsolenkopf (ersetzt den Status-Punkt) */
.console-head .buddy { display: flex; align-items: center; width: 28px; height: 28px; margin-left: -4px; flex: none; }

/* Lumo spricht die Karten */
.result-card .rc-title .buddy-ico, .err-card .err-title .buddy-ico { display: flex; font-size: 0; margin: -6px 0 -6px -4px; }
.result-card.talk .rc-text, .result-card.talk .rc-actions { padding-left: 40px; }
.result-card.pause { --card-bg: #131d19; --card-line: #24473f; }
.result-card.pause .rc-title { color: #4fd6b8; }
@media (max-width: 380px) {
  .result-card.talk .rc-text, .result-card.talk .rc-actions { padding-left: 0; }
  .err-card .err-msg, .err-card .err-orig { padding-left: 14px; }
  .err-card .err-code, .err-card .err-fix-bar { margin-left: 14px; }
}

/* ---- Wochenziel in der Kopfzeile ---- */
.week-dots { display: inline-flex; gap: 3px; align-items: center; }
.week-dots i { display: block; width: 6px; height: 6px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1.5px #4d4942; }
.week-dots i.on { background: var(--accent); box-shadow: none; }
.stat.met .week-dots i.on { background: var(--teal); }
.stat.met .val { color: var(--teal); }

/* Ton-Schalter: in der Kopfzeile nur auf breiten Schirmen, sonst im Lernpfad */
#sound-btn[aria-pressed="false"] { color: var(--chrome-faint); }
@media (max-width: 600px) { #sound-btn { display: none; } }

/* ---- „Ausprobieren“ an Codebeispielen: Leiste unter dem Code ---- */
.lesson-body pre.can-try { padding-bottom: 0; }
.try-btn {
  display: flex; align-items: center; gap: 7px;
  width: calc(100% + 32px);
  margin: 12px -16px 0;
  padding: 8px 16px;
  font: 650 13.5px var(--font);
  color: #4fd6b8;
  background: transparent;
  border: none;
  border-top: 1px solid #ffffff12;
  border-radius: 0 0 var(--r-md) var(--r-md);
  cursor: pointer;
  text-align: left;
  position: sticky; left: 0;
}
.try-btn:hover { background: #ffffff08; }

/* ---- Fortschritt: Wochenziel und geheime Abzeichen ---- */
.pg-goal { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 16px; font-size: 14px; }
.pg-goal-label { font-weight: 700; }
.goal-opts { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.goal-opt {
  min-width: 38px; height: 32px;
  font: 700 14px var(--font);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}
.goal-opt + .goal-opt { border-left: 1px solid var(--border); }
.goal-opt:hover { color: var(--text); background: var(--surface-2); }
.goal-opt.active { color: var(--on-accent); background: var(--accent); }
.pg-goal-note { flex-basis: 100%; font-size: 13px; color: var(--text-muted); }

/* ---- Effekte (juice.js) ---- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 260; overflow: hidden; }
.fx-spark {
  position: fixed; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 1px; background: var(--c);
  animation: fx-spark .85s cubic-bezier(.15,.7,.3,1) forwards;
}
.fx-spark.sq { width: 5px; height: 5px; }
@keyframes fx-spark {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 40px)) scale(.3) rotate(160deg); opacity: 0; }
}
.fx-xp {
  position: fixed; z-index: 261; pointer-events: none;
  transform: translate(-50%, -50%);
  font: 750 14px var(--font);
  color: var(--on-accent); background: var(--accent);
  padding: 2px 8px; border-radius: var(--r-sm);
  animation: fx-fly .9s cubic-bezier(.5,0,.3,1) forwards;
}
@keyframes fx-fly {
  0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  15% { transform: translate(-50%, -90%) scale(1.05); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.5); opacity: .2; }
}
.fx-pulse { animation: fx-pulse .45s ease; }
@keyframes fx-pulse { 40% { transform: scale(1.3); } }
.fx-level {
  position: fixed; inset: 0; z-index: 240;
  display: grid; place-items: center;
  background: rgba(14, 13, 11, .94);
  animation: rise .2s ease;
  cursor: pointer;
}
.fx-level.out { opacity: 0; transition: opacity .3s ease; }
.fx-level-card { text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; }
.fx-level-n {
  display: grid; place-items: center;
  width: 92px; height: 104px;
  margin-top: 14px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--accent);
  font: 800 46px/1 var(--font);
  color: var(--on-accent);
  animation: fx-pop .5s cubic-bezier(.2,1.5,.4,1);
}
.fx-level-title { font: 750 24px var(--font); color: #eeebe4; margin-top: 16px; }
.fx-level-text { color: #bdb8ad; margin-top: 8px; max-width: 340px; }
@keyframes fx-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* =========================================================================
   Spielend lernen · Paket 2: Bühne (Bildschirm, Lautsprecher), Teilen, Werkstatt
   ========================================================================= */
.stage-card {
  padding: 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  width: fit-content;
  max-width: 100%;
}
.stage-screen {
  display: block;
  width: min(256px, 100%);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border-radius: var(--r-sm);
  border: 1px solid #2e2c28;
}
.stage-info { font-size: 13px; font-weight: 600; color: var(--chrome-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-info .linkbtn { font-size: 13px; color: #4fd6b8; }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { display: block; width: 3px; background: var(--teal); animation: eq .6s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: .2s; }
.eq i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { from { height: 3px; } to { height: 12px; } }

/* Teilen */
.share-link { width: 100%; margin-top: 14px; font-family: var(--mono); font-size: 13px; }
.share-note { font-size: 13px; }

/* Werkstatt */
.workshop-modal { max-width: 620px; }
.workshop-modal h3 { font-size: 15px; margin: 22px 0 10px; }
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.ws-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 8px 8px;
  font: inherit; color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.ws-opt:hover { border-color: var(--border-strong); background: var(--surface-2); }
.ws-opt.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ws-opt.locked { cursor: not-allowed; color: var(--text-faint); }
.ws-opt.locked:hover { background: transparent; border-color: var(--border); }
.ws-opt.locked .ws-swatch, .ws-opt.locked .ws-lumo { filter: grayscale(.7); opacity: .6; }
.ws-swatch { display: grid; grid-template-columns: repeat(4, 1fr); width: 72px; height: 24px; border-radius: var(--r-sm); overflow: hidden; }
.ws-swatch i { display: block; }
.ws-lumo { display: block; }
.ws-name { font-size: 13.5px; font-weight: 700; text-align: center; }
.ws-lock { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-faint); min-height: 1.3em; text-align: center; }
.ws-opt.active .ws-lock { color: var(--accent-ink); }

/* Editor-Farben (Werkstatt). Standard „Bernstein“ steht in design.css. */
:root[data-skin="night"] { --skin-bg: #10131f; }
:root[data-skin="aurora"] { --skin-bg: #0d1a1a; }
:root[data-skin="sunset"] { --skin-bg: #1f1218; }
:root[data-skin="mono"] { --skin-bg: #120d05; }
:root[data-skin]:not([data-skin="amber"]) .editor-host .CodeMirror,
:root[data-skin]:not([data-skin="amber"]) .editor-host .CodeMirror-gutters { background: var(--skin-bg); }
:root[data-skin="night"] .editor-host .CodeMirror { color: #e3e6f5; }
:root[data-skin="night"] .cm-s-default .cm-keyword, :root[data-skin="night"] .cm-s-default .cm-atom { color: #ff9de2; }
:root[data-skin="night"] .cm-s-default .cm-def, :root[data-skin="night"] .cm-s-default .cm-property { color: #7ee0ff; }
:root[data-skin="night"] .cm-s-default .cm-variable { color: #e3e6f5; }
:root[data-skin="night"] .cm-s-default .cm-builtin { color: #ffd36e; }
:root[data-skin="night"] .cm-s-default .cm-number { color: #ffb38a; }
:root[data-skin="night"] .cm-s-default .cm-string, :root[data-skin="night"] .cm-s-default .cm-string-2 { color: #a5f0a0; }
:root[data-skin="night"] .cm-s-default .cm-comment { color: #8b92b5; }
:root[data-skin="aurora"] .editor-host .CodeMirror { color: #e2f3ee; }
:root[data-skin="aurora"] .cm-s-default .cm-keyword, :root[data-skin="aurora"] .cm-s-default .cm-atom { color: #c3a2ff; }
:root[data-skin="aurora"] .cm-s-default .cm-def, :root[data-skin="aurora"] .cm-s-default .cm-property { color: #5ee0c8; }
:root[data-skin="aurora"] .cm-s-default .cm-variable { color: #e2f3ee; }
:root[data-skin="aurora"] .cm-s-default .cm-builtin { color: #ffd36e; }
:root[data-skin="aurora"] .cm-s-default .cm-number { color: #ffc58a; }
:root[data-skin="aurora"] .cm-s-default .cm-string, :root[data-skin="aurora"] .cm-s-default .cm-string-2 { color: #9ff0b0; }
:root[data-skin="aurora"] .cm-s-default .cm-comment { color: #85ab9f; }
:root[data-skin="sunset"] .editor-host .CodeMirror { color: #f7e6ea; }
:root[data-skin="sunset"] .cm-s-default .cm-keyword, :root[data-skin="sunset"] .cm-s-default .cm-atom { color: #ffa77b; }
:root[data-skin="sunset"] .cm-s-default .cm-def, :root[data-skin="sunset"] .cm-s-default .cm-property { color: #ff9cc8; }
:root[data-skin="sunset"] .cm-s-default .cm-variable { color: #f7e6ea; }
:root[data-skin="sunset"] .cm-s-default .cm-builtin { color: #ffd36e; }
:root[data-skin="sunset"] .cm-s-default .cm-number { color: #ffc8a0; }
:root[data-skin="sunset"] .cm-s-default .cm-string, :root[data-skin="sunset"] .cm-s-default .cm-string-2 { color: #f5e17a; }
:root[data-skin="sunset"] .cm-s-default .cm-comment { color: #b9939f; }
:root[data-skin="mono"] .editor-host .CodeMirror { color: #ffcf80; }
:root[data-skin="mono"] .cm-s-default span[class^="cm-"] { color: #ffcf80; }
:root[data-skin="mono"] .cm-s-default .cm-keyword, :root[data-skin="mono"] .cm-s-default .cm-atom { color: #ffe2a8; font-weight: 700; }
:root[data-skin="mono"] .cm-s-default .cm-builtin, :root[data-skin="mono"] .cm-s-default .cm-def { color: #ffb340; }
:root[data-skin="mono"] .cm-s-default .cm-string, :root[data-skin="mono"] .cm-s-default .cm-string-2 { color: #ffdba0; }
:root[data-skin="mono"] .cm-s-default .cm-comment { color: #b08850; }

/* =========================================================================
   Spielend lernen · Paket 3: Geschichte, Stationskarte, Bereich online
   ========================================================================= */
/* Lumo funkt: kurzer Aufhänger über der Erklärung */
.story {
  display: flex; align-items: flex-start; gap: 14px;
  margin-top: 18px;
  padding: 12px 16px 12px 12px;
  background: var(--surface);
  border-radius: var(--r-lg);
}
:root[data-theme="light"] .story { border: 1px solid var(--border-soft); }
.story-lumo { flex: none; margin-top: -2px; }
.story-text p { margin: 0; color: var(--text); line-height: 1.6; font-size: 15.5px; }
.story-who { font-weight: 750; color: var(--teal-ink); margin-right: 4px; }
.story-jump { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 13.5px; }
.story.boss { box-shadow: inset 0 0 0 1px var(--accent-line); }
.story.boss .story-who { color: var(--accent-ink); }
.region-banner {
  display: flex; align-items: flex-start; gap: 12px;
  margin-top: 18px; padding: 12px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  font-size: 15px;
}
.region-banner p { margin: 0; color: var(--text-muted); }
.region-banner b { color: var(--text); }
.rb-icon { display: inline-flex; color: var(--text-muted); margin-top: 2px; }

/* Lernpfad: Nebenmissionen */
.lesson-item.map-entry { margin-top: 0; }
.strand-head {
  margin: 26px 10px 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px; font-weight: 700;
  color: var(--text-muted);
}

/* Willkommen */
.welcome-modal { max-width: 480px; }
.welcome-lumo { display: flex; }
.welcome-parents { font-size: 13.5px; margin-top: 18px !important; }

/* Stationskarte */
.map-modal { max-width: 660px; }
.map-frame { margin-top: 16px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); background: #0f1114; }
.map-frame.small { max-width: 420px; }
.map-svg { display: block; width: 100%; height: auto; }
.map-stars circle { fill: #ffffff; opacity: .4; }
.map-planet circle { fill: none; stroke: #4a5361; stroke-width: 1.5; }
.map-planet ellipse { fill: none; stroke: #4a5361; stroke-width: 1.5; }
.map-ground { fill: #171b21; stroke: #232a33; stroke-width: 1; }
.map-corridor { stroke: #2c333d; stroke-width: 4; stroke-linecap: round; }
.map-corridor.lit { stroke: #24584e; }
.map-node { cursor: pointer; outline: none; }
.map-node .map-glow { fill: transparent; }
.map-node .map-hex { fill: #161a20; stroke: #4a525c; stroke-width: 1.5; stroke-dasharray: 4 3; }
.map-node .map-ring { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.map-node .map-icon { color: #6d7783; }
.map-node .map-label { font: 700 12.5px var(--font); fill: #95a0ad; paint-order: stroke; stroke: #0f1114; stroke-width: 4px; stroke-linejoin: round; }
.map-node.partly .map-hex { stroke: var(--accent); stroke-dasharray: none; }
.map-node.partly .map-icon { color: #f2b45a; }
.map-node.online .map-hex { fill: #10241f; stroke: var(--teal); stroke-dasharray: none; }
.map-node.online .map-ring { stroke: var(--teal); }
.map-node.online .map-icon { color: #4fd6b8; }
.map-node.online .map-label { fill: #cdeee6; }
.map-node.locked { cursor: not-allowed; }
.map-node:hover .map-hex { stroke-width: 2.5; }
.map-node:focus-visible .map-glow { fill: none; stroke: var(--accent); stroke-width: 2; }
.map-node.flash .map-hex { animation: map-flash 1.2s ease-in-out 3; }
@keyframes map-flash { 50% { fill: #1d4a40; } }
.map-lumo .lumo { overflow: visible; }
.map-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin-top: 12px; }
.map-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  font: inherit; color: var(--text); text-align: left;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  cursor: pointer;
}
.map-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.map-item.locked { cursor: not-allowed; color: var(--text-faint); }
.map-item.locked:hover { background: transparent; border-color: var(--border-soft); }
.map-item-icon { display: inline-flex; color: var(--text-muted); }
.map-item.online .map-item-icon { color: var(--teal-ink); }
.map-item.partly .map-item-icon { color: var(--accent-ink); }
.map-item-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.map-item-name { font-weight: 700; font-size: 14px; }
.map-item-label { font-weight: 500; font-size: 12.5px; color: var(--text-faint); }
.map-item-bar { display: block; height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.map-item-bar i { display: block; height: 100%; background: var(--accent); }
.map-item.online .map-item-bar i { background: var(--teal); }
.map-item-status { font-size: 12.5px; color: var(--text-muted); }

/* Bereich wieder online */
.region-modal { max-width: 500px; }
.region-lumo { display: flex; margin-bottom: 6px; }

/* =========================================================================
   Spielend lernen · Paket 4: Eisfeld (Drohnen-Einsätze), Nebenmissionen
   ========================================================================= */
.stage-world {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  border: 1px solid #2a323c;
  cursor: pointer;
}
.stage-world-info { font-size: 13px; font-weight: 600; color: var(--chrome-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-world-info .linkbtn { font-size: 13px; color: #4fd6b8; }
