:root {
  --bg: #0b1024;
  --panel: rgba(16, 22, 48, 0.88);
  --panel-solid: #141b3a;
  --border: rgba(160, 180, 255, 0.18);
  --text: #e8ecff;
  --muted: #9aa5cf;
  --accent: #f5c451;
  --radius: 14px;
  --panel-w: min(420px, 38vw);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- 3D-Bühne ---------- */
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; touch-action: none; }
#stage.pointer canvas { cursor: pointer; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }

.node-label {
  pointer-events: auto;
  cursor: pointer;
  padding: 3px 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(11, 16, 36, 0.62);
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
  transition: opacity .25s, background .2s, border-color .2s, transform .2s;
}
.node-label:hover,
.node-label.is-hover { border-color: var(--border); background: rgba(20, 28, 64, 0.9); }
.node-label.is-selected { border-color: var(--accent); color: #fff; }
.node-label.is-dim { opacity: .18 !important; }
.node-label.is-picked { border: 1px dashed var(--accent); color: #fff; background: rgba(245, 196, 81, 0.18); }

.edge-label {
  pointer-events: none;
  font-size: 11px;
  color: var(--muted);
  background: rgba(11, 16, 36, 0.75);
  padding: 1px 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .25s;
}
.edge-label.is-visible { opacity: 1; }

/* ---------- Kopfzeile ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: .01em; }
.brand span { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.actions button, #help-close {
  background: var(--panel); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 999px; font-size: 14px;
  backdrop-filter: blur(8px);
}
.actions button:hover, #help-close:hover { border-color: var(--accent); }
#btn-help { width: 36px; padding: 7px 0; }

/* ---------- Seitenleiste (Liste/Suche) ---------- */
#sidebar {
  position: fixed; top: 64px; left: 16px; bottom: 16px;
  width: 260px; display: flex; flex-direction: column; gap: 10px;
  padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
#sidebar[hidden] { display: none; }
#search {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(0,0,0,.25); color: var(--text); font: inherit;
}
#legend, #node-list { list-style: none; margin: 0; padding: 0; }
#legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
#legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
#node-list { overflow-y: auto; flex: 1; }
#node-list button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; padding: 7px 8px; border-radius: 8px; font-size: 14px;
}
#node-list button:hover, #node-list button:focus-visible { background: rgba(255,255,255,.07); }
#node-list button.is-selected { background: rgba(245,196,81,.15); }

/* ---------- Inhalts-Panel ---------- */
#popup {
  position: fixed; top: 64px; right: 16px; bottom: 16px;
  width: var(--panel-w);
  overflow-y: auto;
  padding: 22px 22px 26px;
  border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  animation: slide-in .28s ease-out;
}
#popup[hidden] { display: none; }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
#popup-close {
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  background: none; border: 1px solid transparent; font-size: 22px; line-height: 1;
}
#popup-close:hover { border-color: var(--border); }
.kicker { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#popup h2 { margin: 0 40px 14px 0; font-size: 22px; line-height: 1.25; }
#popup-text { font-size: 15px; line-height: 1.6; }
#popup-text p { margin: 0 0 .8em; }
#popup-text a { color: var(--accent); }
#popup-text img { max-width: 100%; border-radius: 8px; }

#popup-media:empty { display: none; }
#popup-media { margin-bottom: 16px; }
.media-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; }
.media-frame iframe, .media-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-consent {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 100%; padding: 16px; text-align: center; font-size: 13px; color: var(--muted);
  background: repeating-linear-gradient(135deg, #10163a 0 12px, #121a42 12px 24px);
}
.media-consent button {
  background: var(--accent); color: #1a1400; border: 0; border-radius: 999px;
  padding: 8px 16px; font-weight: 600;
}
.media-link { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.media-link:hover { color: var(--accent); }
.media-fallback { position: absolute; inset: 0; background: #000 center / cover no-repeat; }
.media-fallback-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 16px; text-align: center; font-size: 13px; background: rgba(5, 8, 20, .72);
}
.media-fallback-inner p { margin: 0; max-width: 34ch; }
.media-fallback-inner a {
  background: #ff3d3d; color: #fff; text-decoration: none; font-weight: 600;
  padding: 9px 16px; border-radius: 999px;
}
.media-note { padding: 12px; font-size: 13px; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; }

#popup-related h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
#popup-related ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#popup-related button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: rgba(255,255,255,.04); border: 1px solid transparent; border-radius: 8px;
  padding: 7px 10px; font-size: 14px;
}
#popup-related button:hover { border-color: var(--border); }
#popup-related small { color: var(--muted); margin-left: auto; font-size: 12px; }

#popup-docs h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
#popup-docs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#popup-docs button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 14px;
}
#popup-docs button:hover { border-color: var(--accent); }
.doc-icon { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .04em; color: #fff; background: #e5484d; border-radius: 4px; padding: 3px 5px; }

/* ---------- PDF-Anzeige ---------- */
#doc-viewer { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); }
#doc-viewer[hidden] { display: none; }
.doc-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.doc-bar h2 { flex: 1; margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-bar a { color: var(--text); font-size: 13px; text-decoration: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; }
.doc-bar a:hover { border-color: var(--accent); }
#doc-close { width: 34px; height: 34px; border-radius: 50%; background: none; border: 1px solid var(--border); font-size: 20px; line-height: 1; }
#doc-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- Hilfe ---------- */
#help { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5,8,20,.55); padding: 16px; }
#help[hidden] { display: none; }
.help-card { max-width: 640px; width: 100%; padding: 24px; border-radius: var(--radius); background: var(--panel-solid); border: 1px solid var(--border); }
.help-card h2 { margin: 0 0 14px; font-size: 20px; }
.help-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.help-cols dl { margin: 0; }
.help-cols dt { font-weight: 650; margin-bottom: 6px; }
.help-cols dd { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
#help-close { margin-top: 18px; background: var(--accent); color: #1a1400; border: 0; font-weight: 600; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--bg); transition: opacity .4s; }
#loading.is-done { opacity: 0; pointer-events: none; }
#loading.is-error { color: #ff9a8a; padding: 24px; text-align: center; }

/* ---------- Mobil: Panel als Bottom-Sheet ---------- */
@media (max-width: 760px) {
  .brand span { display: none; }
  #sidebar { top: 60px; left: 16px; right: 16px; width: auto; bottom: auto; max-height: 55vh; }
  #popup {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 58vh; border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(26px + env(safe-area-inset-bottom));
    animation-name: slide-up;
  }
  @keyframes slide-up { from { opacity: 0; transform: translateY(30px); } }
}

@media (prefers-reduced-motion: reduce) {
  #popup { animation: none; }
}
.node-label.is-free { margin-top: 0; font-weight: 600; font-size: 14px; background: rgba(11, 16, 36, 0.8); border-color: var(--border); }
.node-label.is-model { font-size: 16px; font-weight: 600; padding: 6px 16px; border-color: var(--accent); background: rgba(11, 16, 36, 0.85); }
.node-label.is-continent { font-weight: 600; border-color: rgba(245, 196, 81, 0.75); background: rgba(11, 16, 36, 0.88); position: relative; margin: 0 0 10px; padding-right: 22px; }
/* Fähnchen: Pfeil nach unten und kleine Spitze, die auf den Kontinent zeigt */
.node-label.is-continent::before { content: '↓'; position: absolute; right: 8px; top: 50%; transform: translateY(-52%); color: #f5c451; font-weight: 700; }
.node-label.is-continent::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 2px; height: 9px; margin-left: -1px; background: rgba(245, 196, 81, 0.75); }
.node-label.is-continent:hover, .node-label.is-continent:focus-visible { background: #f5c451; color: #1a1400; }
.node-label.is-continent:hover::before { color: #1a1400; }
.node-label.is-callout { margin-top: 0; font-weight: 600; background: rgba(11, 16, 36, 0.85); border-color: rgba(232, 236, 255, 0.5); }
.node-label.is-orphan { border-style: dashed; opacity: .6; }

/* ---------- Universum ---------- */
#fade { position: fixed; inset: 0; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 30; }
#fade.is-on { opacity: 1; }
.in-universe .node-label, .in-universe .edge-label { display: none !important; }
.in-universe #btn-list, .in-universe #btn-universe, .in-universe #popup:not(.is-info), .in-universe #sidebar { display: none !important; }
#btn-universe[hidden] { display: none; }
.galaxy-label {
  pointer-events: auto; cursor: pointer; user-select: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 14px; border-radius: 14px; text-align: center;
  background: rgba(11, 16, 36, 0.55); border: 1px solid transparent;
  transition: background .2s, border-color .2s;
}
.galaxy-label strong { font-size: 16px; letter-spacing: .02em; }
.galaxy-label span { font-size: 12px; color: var(--muted); }
.galaxy-label:hover, .galaxy-label.is-hover { background: rgba(20, 28, 64, 0.9); border-color: var(--accent); }

/* ---------- Aufträge ---------- */
#popup-tasks h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.task { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: rgba(255,255,255,.03); }
.task-kind { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.task-question { margin: 0 0 10px; font-weight: 600; line-height: 1.45; }
.task-hint { margin: -4px 0 8px; font-size: 12px; color: var(--muted); }
.task audio { width: 100%; margin-bottom: 10px; }
.task-options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task-options label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; line-height: 1.4; }
.task-options input { margin-top: 3px; accent-color: var(--accent); }
.task-options li.is-ok label, .task-match-row.is-ok { border-color: #5fd3b3; background: rgba(95,211,179,.12); }
.task-options li.is-wrong label, .task-match-row.is-wrong { border-color: #ff8a7a; background: rgba(255,138,122,.12); }
.task-match { display: flex; flex-direction: column; gap: 6px; }
.task-match-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.task-match-row select { font: inherit; font-size: 14px; color: var(--text); background: rgba(0,0,0,.3); border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; }
.task-actions { display: flex; gap: 8px; margin-top: 10px; }
.task-actions button { font-size: 13px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.06); }
.task-actions button.is-primary { background: var(--accent); color: #1a1400; border-color: var(--accent); font-weight: 600; }
.task-msg { margin: 8px 0 0; font-size: 14px; min-height: 1em; }
.task-msg.is-ok { color: #5fd3b3; font-weight: 600; }
.task-msg.is-wrong { color: #ff9a8a; }

/* ---------- Portal ---------- */
.portal-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 18px; padding: 12px 14px; text-align: left;
  border-radius: 12px; border: 1px solid rgba(199,146,234,.6); font-size: 15px; font-weight: 600;
  background: linear-gradient(135deg, rgba(199,146,234,.22), rgba(122,162,255,.18));
}
.portal-btn:hover { border-color: #c792ea; }
.portal-icon { font-size: 20px; color: #c792ea; }

/* ---------- Derselbe Begriff anderswo ---------- */
#popup-elsewhere h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
#popup-elsewhere ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#popup-elsewhere button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: rgba(199,146,234,.08); border: 1px solid rgba(199,146,234,.35); border-radius: 8px; padding: 7px 10px; font-size: 14px;
}
#popup-elsewhere button:hover { border-color: #c792ea; }

/* ---------- Querverweise ---------- */
.xref-badge { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 8px; font-size: 11px; font-weight: 700; color: #1b1030; background: #c792ea; vertical-align: 1px; }
.node-label.is-xref { border-color: #c792ea; color: #fff; box-shadow: 0 0 0 2px rgba(199, 146, 234, 0.35); }
#btn-xref.is-on { background: rgba(199, 146, 234, 0.25); border-color: #c792ea; }
.xref-link { padding: 3px 9px; border-radius: 10px; font-size: 12px; color: var(--text); background: rgba(40, 22, 60, 0.9); border: 1px solid #c792ea; white-space: nowrap; opacity: 0; transition: opacity .2s; }
.xref-link.is-visible { opacity: 1; }

/* ---------- Listenansicht ---------- */
#listview { position: fixed; inset: 0; z-index: 40; overflow-y: auto; background: var(--bg); color: var(--text); }
#listview[hidden] { display: none; }
.lv-head { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; padding: 18px max(20px, calc((100vw - 900px) / 2)) 14px; background: rgba(11, 16, 36, 0.96); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.lv-title h2 { margin: 0; font-size: 24px; }
.lv-title .kicker, .cmp-head .kicker { margin: 0 0 2px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lv-sub { margin: 2px 0 0; color: var(--muted); }
.lv-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lv-tools input, .lv-tools select, .lv-tools button, .cmp-tools select, .cmp-tools button {
  min-height: 36px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-solid); color: var(--text); font: inherit; }
.lv-tools input { min-width: 200px; }
.lv-close { background: var(--accent) !important; color: #1b1b1f !important; border-color: var(--accent) !important; font-weight: 600; }
.lv-body { max-width: 900px; margin: 0 auto; padding: 10px 20px 80px; }
.lv-section { margin-top: 18px; }
.lv-h { margin: 18px 0 8px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lv-item { margin: 6px 0; border: 1px solid var(--border); border-radius: 12px; background: rgba(20, 27, 58, 0.6); }
.lv-item > summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
.lv-item > summary::-webkit-details-marker { display: none; }
.lv-item > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.lv-item[open] > summary::before { transform: rotate(90deg); }
.lv-item .swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.lv-name { font-weight: 600; }
.lv-kind { color: var(--muted); }
.lv-xref { margin-left: auto; padding: 1px 7px; border-radius: 8px; background: #c792ea; color: #1b1030; font-weight: 700; }
.lv-item.is-empty > summary .lv-name { font-weight: 500; }
.lv-content { padding: 0 16px 6px 36px; line-height: 1.55; }
.lv-content:empty { display: none; }
.lv-content h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.lv-media img, .lv-media iframe, .lv-media video { max-width: 560px; }
.lv-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.lv-link, .lv-show { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-solid); color: var(--text); font: inherit; font-size: 14px; }
.lv-show { margin: 14px 0 8px; border-color: var(--accent); }
.lv-note { color: var(--muted); }
.lv-children { padding: 0 10px 8px 26px; }
.lv-item.is-flash { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow .3s; }
.lv-empty { color: var(--muted); }
body.no-3d #stage, body.no-3d #topbar { display: none; }

/* ---------- Vergleich ---------- */
#compare { position: fixed; inset: 0; z-index: 41; overflow-y: auto; background: rgba(11, 16, 36, 0.97); color: var(--text); padding: 0 0 40px; }
#compare[hidden] { display: none; }
.cmp-head { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; align-items: flex-end; padding: 18px 24px 12px; background: rgba(11, 16, 36, 0.96); border-bottom: 1px solid var(--border); }
.cmp-head h2 { margin: 0; font-size: 22px; }
.cmp-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cmp-tools select { max-width: 280px; }
.cmp-close { width: 38px; font-size: 20px !important; padding: 0 !important; }
.cmp-link-mode.is-on { background: rgba(245, 196, 81, 0.25) !important; border-color: var(--accent) !important; }
.cmp-hint { margin: 12px 24px; color: var(--muted); }
.cmp-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 18vw) minmax(0, 1fr); align-items: stretch; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.cmp-col { display: flex; flex-direction: column; }
.cmp-col[data-side="a"] { align-items: flex-end; text-align: right; }
.cmp-col[data-side="b"] { align-items: flex-start; }
.cmp-title { margin: 0 0 10px; font-size: 16px; }
.cmp-rows { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.cmp-col[data-side="a"] .cmp-rows { align-items: flex-end; }
.cmp-bar { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; border: 0; border-radius: 8px; font: inherit; font-size: 15px; text-align: inherit; transition: opacity .15s, transform .15s, box-shadow .15s; }
.cmp-col[data-side="a"] .cmp-bar { justify-content: flex-end; }
.cmp-bar:hover, .cmp-bar:focus-visible { transform: scale(1.015); box-shadow: 0 0 0 2px var(--accent); outline: none; }
.cmp-bar.is-dim { opacity: .3; }
.cmp-bar.is-from { box-shadow: 0 0 0 3px var(--accent); }
.cmp-mark { flex: none; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.18); font-style: italic; font-weight: 600; }
.cmp-name { flex: 1 1 auto; }
.cmp-links { width: 100%; height: 100%; overflow: visible; }
.cmp-links path { fill: none; stroke: #c792ea; stroke-width: 2.5; opacity: .75; transition: opacity .15s; }
.cmp-links path.is-on { stroke: var(--accent); stroke-width: 3.5; opacity: 1; }
.cmp-links path.is-dim, .cmp-links text.is-dim { opacity: .08; }
.cmp-links text { fill: var(--text); font-size: 12px; paint-order: stroke; stroke: rgba(11, 16, 36, 0.9); stroke-width: 4px; }
.cmp-detail { position: relative; max-width: 760px; margin: 26px auto 0; padding: 18px 22px; border-radius: var(--radius); background: var(--panel-solid); border: 1px solid var(--border); line-height: 1.55; }
.cmp-detail h3 { margin: 0 0 10px; }
.cmp-detail-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; color: var(--muted); }
.cmp-show { margin-top: 12px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--accent); background: none; color: var(--text); font: inherit; }
@media (max-width: 760px) {
  .cmp-stage { grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); padding: 0 10px; }
  .cmp-bar { font-size: 13px; min-height: 40px; padding: 6px 8px; }
  .lv-head { padding: 14px 16px 10px; }
  .lv-content { padding-left: 16px; }
  .lv-children { padding-left: 12px; }
}

/* ---------- Rundgang ---------- */
#tourbar { position: fixed; left: 16px; bottom: 16px; z-index: 30; display: flex; gap: 16px; align-items: center;
  width: min(640px, calc(100vw - var(--panel-w) - 56px)); padding: 12px 14px 12px 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--accent); backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
#tourbar[hidden] { display: none; }
.tb-info { flex: 1 1 auto; min-width: 0; }
.tb-kicker { margin: 0; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.tb-name { margin: 2px 0 0; font-size: 18px; font-weight: 650; }
.tb-note { margin: 4px 0 0; font-size: 14px; color: var(--text); opacity: .9; }
.tb-dots { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.tb-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); }
.tb-dots span.is-done { background: rgba(245, 196, 81, .5); }
.tb-dots span.is-on { background: var(--accent); transform: scale(1.3); }
.tb-buttons { display: flex; gap: 6px; flex: none; }
.tb-buttons button { min-height: 40px; min-width: 40px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel-solid); color: var(--text); font: inherit; }
.tb-buttons .tb-next { background: var(--accent); color: #1b1b1f; border-color: var(--accent); font-weight: 650; padding: 6px 18px; }
.tb-buttons button:disabled { opacity: .35; cursor: default; }
body.in-tour #popup { font-size: 1.06em; }
.tour-menu { position: fixed; z-index: 35; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--border); }
.tour-menu[hidden] { display: none; }
.tour-menu button { text-align: left; padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; }
.tour-menu button:hover { background: rgba(255,255,255,.08); }
@media (max-width: 760px) {
  #tourbar { top: 64px; bottom: auto; left: 8px; right: 8px; width: auto; flex-wrap: wrap; gap: 8px; }
  .tb-name { font-size: 16px; }
}
.tb-pop { background: rgba(199, 146, 234, 0.2) !important; border-color: #c792ea !important; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tour-popup { position: fixed; z-index: 32; top: 72px; left: 16px; width: min(640px, calc(100vw - var(--panel-w) - 56px)); max-height: calc(100vh - 72px - 150px);
  overflow-y: auto; padding: 22px 24px; border-radius: var(--radius); background: var(--panel-solid); border: 1px solid #c792ea; box-shadow: 0 18px 50px rgba(0,0,0,.5); line-height: 1.55; animation: tp-in .25s ease-out; }
#tour-popup[hidden] { display: none; }
@keyframes tp-in { from { opacity: 0; transform: translateY(10px); } }
#tour-popup h2 { margin: 0 34px 12px 0; font-size: 20px; }
.tp-close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: var(--text); font-size: 20px; }
.tp-text { margin-top: 12px; }
@media (max-width: 760px) {
  #tour-popup { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 60vh; }
}

/* Lokal (server.py): Knopf zum Editor */
.btn-edit { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px; background: #f5c451; color: #1a1400; font-weight: 600; font-size: 14px; text-decoration: none; }
.btn-edit:hover, .btn-edit:focus-visible { background: #ffd877; }
/* Teil eines Modells (ohne Landen): Beschriftung wie ein Fähnchen, aber ohne Pfeil */
.node-label.is-continent.is-part { padding-right: 8px; font-weight: 500; border-color: rgba(255,255,255,0.35); }
.node-label.is-continent.is-part::before { content: none; }
.node-label.is-continent.is-part::after { background: rgba(255,255,255,0.45); }
.node-label.is-continent.is-part:hover { background: #f5c451; color: #1a1400; }

/* Namen von Monden und Abbildern erst aus der Nähe (oder beim Zeigen) */
.node-label.is-far { opacity: 0 !important; pointer-events: none; }

/* ---------- Aufgepeppt: Kopf in der Farbe der Figur, Vorschaubild, Abschnitte ---------- */
#popup.has-accent { border-top: 0; padding-top: 0; }
#popup.has-accent::before {
  content: ""; display: block; height: 6px; margin: 0 -22px 18px;
  background: linear-gradient(90deg, var(--node, #8ea6ff), color-mix(in srgb, var(--node, #8ea6ff) 30%, transparent));
  box-shadow: 0 0 18px color-mix(in srgb, var(--node, #8ea6ff) 55%, transparent);
}
#popup-thumb {
  float: right; width: 96px; height: 67px; object-fit: contain; margin: 4px 30px 6px 10px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .45));
}
#popup-thumb[hidden] { display: none; }
#popup.has-accent h2 { clear: none; }
#popup-text::after { content: ""; display: block; clear: both; }
.popup-sec { margin: 0 0 6px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .06); }
.popup-sec > summary {
  list-style: none; cursor: pointer; padding: 9px 12px; font-weight: 700; display: flex; align-items: center; gap: 9px;
  border-radius: 10px;
}
.popup-sec > summary::-webkit-details-marker { display: none; }
.popup-sec > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
.popup-sec:not([open]) > summary::after { transform: rotate(-90deg); }
.popup-sec > summary:hover { background: rgba(255, 255, 255, .05); }
.popup-sec[open] > summary { border-bottom: 1px solid rgba(255, 255, 255, .06); border-radius: 10px 10px 0 0; }
.popup-sec > :not(summary) { padding: 0 12px; }
.popup-sec > :not(summary):first-of-type { padding-top: 10px; }
.popup-sec-icon { width: 22px; text-align: center; }

/* Fokus: der Rand des Bildes dunkelt ab, wenn eine Figur geöffnet ist */
#stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s;
  background: radial-gradient(ellipse at 42% 50%, transparent 35%, rgba(3, 5, 15, .65) 100%);
}
body.is-focus #stage::after { opacity: 1; }

/* Klang-Knopf */
#btn-sound[aria-pressed="true"] { border-color: var(--accent); }
.popup-sec-icon img { width: 22px; height: 22px; object-fit: contain; display: block; }

/* Urheberangabe unten rechts */
#credit { position: fixed; right: 14px; bottom: 10px; z-index: 5; font-size: 12px; color: rgba(200, 210, 255, .6); text-decoration: none; text-shadow: 0 1px 4px #000; padding: 4px 8px; border-radius: 8px; }
#credit:hover { color: #fff; background: rgba(14, 20, 48, .6); }
#credit b { font-weight: 600; }
@media (max-width: 700px) { #credit { bottom: calc(6px + env(safe-area-inset-bottom)); font-size: 11px; } }
