:root {
  --bg: #0e1117;
  --bg-2: #151a23;
  --bg-3: #1d2430;
  --line: #2a3342;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --accent: #4cc9f0;
  --accent-2: #3a86ff;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* sonst überschreiben display-Regeln das hidden-Attribut */

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 230px 1fr 320px;
  grid-template-rows: auto minmax(0, 1fr); /* Kopfleiste + Rest; langes Menü verlängert die Seite nicht */
  height: 100vh;
}

/* ---------- Kopfleiste (Logo, aktuelle Anwendung, Blättern) ---------- */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; min-height: 58px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.topbar-sep { width: 1px; height: 30px; background: var(--line); flex: none; }
.current { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.current h1 { margin: 0; font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Navigation ---------- */
.nav {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.brand-home {
  background: none; border: none; color: var(--text); font: inherit; font-weight: 700; font-size: 17px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px; white-space: nowrap; flex: none;
}
.brand-home:hover { background: var(--bg-3); }
.brand-home .logo { color: var(--accent); }
.nav-toggle { display: none; }
.nav-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 14px; overflow-y: auto; min-height: 0; flex: 1; }

.search {
  display: flex; align-items: center; gap: 6px; margin: 0 2px 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px;
}
.search:focus-within { border-color: var(--accent); }
.search-icon { color: var(--muted); font-size: 15px; }
.search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font: inherit; padding: 7px 0; }
.search kbd {
  font: 11px system-ui, sans-serif; color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 5px; line-height: 16px;
}

#sim-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  background: none; border: none; cursor: pointer; font: inherit;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 12px 8px 4px; text-align: left;
}
.nav-group-head:hover { color: var(--text); }
.nav-group-head .chev { transition: transform .15s; display: inline-block; width: 10px; }
.nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group-head .count { margin-left: auto; background: var(--bg-3); border-radius: 99px; padding: 0 7px; font-size: 10px; letter-spacing: 0; }
.nav-group-items { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: 1px solid transparent; color: var(--text);
  padding: 6px 8px; border-radius: 8px; cursor: pointer; text-align: left; font: inherit;
}
.nav-item .ico { width: 22px; text-align: center; font-size: 15px; flex: none; }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover:not(:disabled) { background: var(--bg-3); }
.nav-item.active { background: var(--bg-3); border-color: var(--line); color: var(--accent); }
.nav-item:disabled { color: var(--muted); cursor: default; }
.nav-item mark { background: rgba(76,201,240,.25); color: inherit; border-radius: 3px; }
.nav-overview { margin-bottom: 4px; }
.nav-empty { color: var(--muted); font-size: 13px; padding: 6px 10px; margin: 0; }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  background: var(--bg-3); color: var(--muted); padding: 2px 6px; border-radius: 99px;
}
.nav-foot { margin-top: auto; color: var(--muted); font-size: 12px; padding: 10px 8px 0; }

/* ---------- Hauptbereich ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-desc { margin: 10px 20px 0; color: var(--muted); }
.stage-desc:empty { display: none; }
.title-text { min-width: 0; }

/* Blättern zwischen Simulationen (in der Kopfleiste) */
.sim-pager { display: flex; align-items: center; gap: 6px; flex: none; }
.is-home .sim-pager { display: none; }
.pager-btn {
  display: flex; align-items: center; gap: 8px; max-width: 220px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 5px 10px; font: inherit; cursor: pointer;
}
.pager-btn:hover { border-color: var(--accent); background: var(--bg-3); }
.pager-btn .arrow { font-size: 22px; line-height: 1; color: var(--accent); }
.pager-text { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.pager-btn.next .pager-text { text-align: right; }
.pager-text small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pager-text span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 46px; text-align: center; }
.title-icon { font-size: 26px; line-height: 1; }
.title-icon:empty { display: none; }
.crumb { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.crumb:empty { display: none; }

/* ---------- Übersicht ---------- */
.home { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 30px; }
.is-home .home { display: block; }
.is-home .stage, .is-home .toolbar, .is-home .panel { display: none; }
.is-home { grid-template-columns: 230px 1fr; }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.home h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 22px 0 10px; display: flex; align-items: center; gap: 8px;
}
.home h2 .count { background: var(--bg-3); border-radius: 99px; padding: 0 7px; font-size: 10px; letter-spacing: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.sim-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; color: var(--text); font: inherit; cursor: pointer;
  transition: border-color .15s, transform .15s, background .15s;
}
.sim-card:hover { border-color: var(--accent); background: var(--bg-3); transform: translateY(-2px); }
.sim-card .ico { font-size: 28px; line-height: 1; }
.sim-card .name { font-weight: 600; font-size: 15px; }
.sim-card .desc { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.stage { position: relative; flex: 1; min-height: 0; margin: 8px 20px; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #1a2130 0%, #0e1117 70%); }
#stage { display: block; touch-action: none; }
.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(21, 26, 35, .85); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 12px; border-radius: 99px; font-size: 13px; pointer-events: none;
  transition: opacity .4s; white-space: nowrap;
}
.hint.hidden { opacity: 0; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 0 20px 14px; flex-wrap: wrap; }
.speed { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-left: auto; }
.speed input { width: 140px; }
#speed-val { min-width: 44px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: #3b475b; background: #232b39; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: #2f74e0; }
.btn.ghost { background: none; padding: 7px 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-row .btn { flex: 1 1 auto; padding: 6px 8px; font-size: 13px; }

/* ---------- Panel ---------- */
.panel {
  background: var(--bg-2); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 14px 14px 30px;
}
.section { padding: 10px 2px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.section:last-child { border-bottom: none; }
.section h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.ctl { display: flex; flex-direction: column; gap: 4px; }
.ctl-top { display: flex; justify-content: space-between; gap: 8px; }
.ctl-top .val { color: var(--accent); font-variant-numeric: tabular-nums; }

input[type=range] { width: 100%; accent-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  border-radius: 99px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: #3b475b; }
.chip.active { border-color: var(--accent); color: var(--accent); }

.card { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

.stats { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.stats th { color: var(--muted); font-weight: 500; text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.stats td { text-align: right; padding: 4px; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.note { color: var(--muted); font-size: 12px; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .app, .is-home { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; height: auto; }
  .topbar { position: sticky; top: 0; z-index: 10; gap: 10px; padding: 8px 12px; }
  .stage { flex: none; height: 62vh; }
  .home { overflow: visible; }
  /* Menü als Überlagerung direkt unter der angehefteten Kopfleiste – unabhängig von der Scrollposition */
  .nav {
    display: none; position: fixed; left: 0; right: 0; top: var(--topbar-h, 58px); z-index: 20;
    max-height: calc(100vh - var(--topbar-h, 58px)); max-height: calc(100dvh - var(--topbar-h, 58px));
    border-right: none; border-bottom: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  }
  .nav.open { display: flex; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .45); }
  body.nav-locked { overflow: hidden; }
  .nav-toggle {
    display: block; background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
    border-radius: 8px; font-size: 18px; padding: 2px 10px; cursor: pointer;
  }
  .nav-body { max-height: none; }
  .stage { margin: 8px 12px; }
  .toolbar { padding: 0 12px 12px; }
  .panel { border-left: none; border-top: 1px solid var(--line); }
  .home { padding: 8px 12px 30px; }
  .hint { white-space: normal; width: max-content; max-width: 90%; text-align: center; border-radius: 12px; }
  .stage-desc { margin: 8px 12px 0; }
}
@media (max-width: 760px) {
  .pager-text, .topbar-sep, .crumb, .pager-count { display: none; }
  .pager-btn { padding: 4px 10px; }
  .brand-home .brand-text { display: none; }
}

/* Hinweisbox für die Perspektiven-Simulationen (eingeklappt) */
.disclaimer { border: 1px solid rgba(255, 209, 102, 0.4); background: rgba(255, 209, 102, 0.06); border-radius: 8px; font-size: 12px; line-height: 1.45; color: var(--text); }
.disclaimer summary { cursor: pointer; padding: 7px 10px; color: #ffd166; list-style: none; }
.disclaimer summary::-webkit-details-marker { display: none; }
.disclaimer summary::after { content: ' ▸'; color: var(--muted); }
.disclaimer[open] summary::after { content: ' ▾'; }
.disclaimer-body { padding: 0 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.disclaimer p { margin: 0; }
.disclaimer .src { color: var(--muted); font-size: 11px; }
.help-box { margin: 0; border-left: 3px solid #ffd166; padding: 6px 10px; font-size: 12px; line-height: 1.45; color: var(--text); background: rgba(255, 209, 102, 0.05); border-radius: 0 6px 6px 0; }
