:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f1e1b;
  --muted: #5f5d57;
  --border: #dedad0;
  --accent: #1d6e5a;
  --accent-text: #ffffff;
  --warn-bg: #fdf1dc;
  --warn-text: #6b4508;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171715;
    --surface: #211f1d;
    --text: #ecebe6;
    --muted: #aaa79e;
    --border: #3b3934;
    --accent: #5dcaa5;
    --accent-text: #0b2a22;
    --warn-bg: #3d2c0f;
    --warn-text: #f6d79a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}

.brand { color: var(--text); font-weight: 600; text-decoration: none; }

.tag {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  font-size: 14px;
  text-align: center;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--accent); text-decoration: underline; }
body.fullscreen .site-footer { padding: 6px 16px; font-size: 13px; }

h1 { font-size: 28px; line-height: 1.25; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 0 0 6px; }
a { color: var(--accent); }

.lead { color: var(--muted); max-width: 60ch; }
.meta { color: var(--muted); font-size: 14px; margin-top: 0; }
.crumbs { font-size: 14px; }

.cards { list-style: none; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card a { text-decoration: none; }
.card p { margin: 0 0 8px; }

.vis { margin: 24px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }

.vis-notice {
  font-size: 13px;
  padding: 6px 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-bottom: 1px solid var(--border);
}

.vis-stage {
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.vis-stage iframe { display: block; width: 100%; border: 0; background: #fff; }
.vis-stage:fullscreen iframe { height: 100% !important; }

.vis-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); min-height: 48px; }
.vis-status { margin: 0; font-size: 14px; color: var(--muted); }
.vis-status[data-kind="warning"] { color: var(--warn-text); }

button {
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.vis-start { background: var(--accent); color: var(--accent-text); border-color: var(--accent); padding: 10px 20px; font-size: 16px; }

.assumptions { font-size: 14px; color: var(--muted); }

.columns { display: grid; gap: 32px; grid-template-columns: minmax(180px, 1fr) 3fr; align-items: start; }
@media (max-width: 720px) { .columns { grid-template-columns: 1fr; } }

.topic-tree { list-style: none; padding-left: 0; margin: 0; }
.topic-tree .topic-tree { padding-left: 16px; }
.topic-tree li { margin: 4px 0; }

.votes { white-space: nowrap; }

.badge {
  display: inline-block;
  font-size: 12px;
  line-height: 1.5;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge-pending_review, .badge-blocked { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

.notice { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 15px; }
.notice-warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

.versions { padding-left: 24px; }
.versions li { margin: 4px 0; }
.versions li[aria-current="page"] > a { font-weight: 600; }
.changelog { display: block; font-size: 14px; color: var(--muted); }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 15px; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.form { display: grid; gap: 16px; max-width: 420px; margin: 16px 0; }
.form label { display: grid; gap: 4px; font-weight: 500; }
.form input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { font-size: 13px; font-weight: 400; color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); justify-self: start; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.form-wide { max-width: 640px; }
.form textarea, .form select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.form label.check input { margin-top: 5px; }
.problems { padding-left: 20px; }
.problems code { font-size: 14px; }
.own { list-style: none; padding: 0; }
.own > li { margin: 12px 0; }
.badge-rejected { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }

.tabs { display: flex; gap: 16px; margin: 8px 0 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table .num { text-align: right; white-space: nowrap; color: var(--muted); }
.files .change-add td:nth-child(2) { color: var(--accent); }
.files .change-mod td:nth-child(2), .files .change-del td:nth-child(2) { color: var(--warn-text); }
.files .change-same { color: var(--muted); }
.risk-hoch, .risk-mittel { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.hints { padding-left: 20px; }
.hints li { margin: 8px 0; }
.hint-high strong { color: var(--warn-text); }
.excerpt { display: block; font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-all; }
pre.code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  max-height: 70vh;
}
pre.code .ln:target { background: var(--warn-bg); }
.d-add { color: var(--accent); }
.d-del { color: var(--warn-text); text-decoration: line-through; }
.d-gap { color: var(--muted); }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
button.danger { border-color: var(--warn-text); color: var(--warn-text); }
.log { padding-left: 20px; font-size: 14px; }
.reports { list-style: none; padding: 0; display: grid; gap: 12px; }
.report-box { margin: 24px 0; font-size: 15px; }
.report-box summary { cursor: pointer; color: var(--muted); }

.vote { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.vote button { min-width: 64px; }
.vote button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.vote-count { color: var(--muted); font-size: 15px; }

/* --- Themenkarte (3D-Sternenhimmel) --------------------------------------------------------- */
a.cta {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 500;
}

body.fullscreen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.fullscreen main { max-width: none; padding: 0; flex: 1; min-height: 0; margin: 0; }

.topicmap { position: relative; height: 100%; }
.map-stage { display: none; }
.map-controls, .map-panel, .map-help { display: none; }
.topicmap .map-list { max-width: 960px; margin: 0 auto; padding: 24px 16px; overflow: auto; height: 100%; }

/* Erst wenn das Skript die Karte gebaut hat, ersetzt sie die Liste */
/* Mit Karte wird die Linkliste zum ausklappbaren Seitenmenü links (Overlay) */
.topicmap.map-ready .map-list {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--drawer-width);
  max-width: none;
  margin: 0;
  padding: 12px 16px 24px;
  overflow-y: auto;
  z-index: 7;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgb(0 0 0 / 0.2);
  transform: translateX(-102%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0s linear 0.3s;
}
.topicmap.map-ready.drawer-open .map-list { transform: none; visibility: visible; transition: transform 0.3s ease; }
.topicmap { --drawer-width: min(320px, 86vw); }
.topicmap.map-ready .map-stage {
  display: block;
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(ellipse at center, var(--sky-inner), var(--sky-outer) 75%);
}
.topicmap.map-ready .map-stage:active { cursor: grabbing; }
.map-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
:root { --sky-inner: #f3f1ea; --sky-outer: #e4e0d4; --sky-star: #8b877c; --star-glow: color-mix(in srgb, var(--accent) 35%, transparent); }
@media (prefers-color-scheme: dark) {
  :root { --sky-inner: #1b2230; --sky-outer: #0b0d12; --sky-star: #c9d4ea; }
}

.map-svg { width: 100%; height: 100%; display: block; user-select: none; }
.map-sky circle { fill: var(--sky-star); }
.map-edge { stroke: var(--accent); stroke-width: 1.2; }

.map-node, .map-logo { cursor: pointer; outline: none; }
/* Leuchtende Punkte mit Namen daneben */
.map-node circle { fill: var(--accent); stroke: var(--star-glow); stroke-width: 6; paint-order: stroke; }
.map-node circle.leaf { fill: color-mix(in srgb, var(--accent) 60%, var(--text)); }
.map-node text { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--sky-outer); stroke-width: 3px; stroke-linejoin: round; }
.map-node:hover circle, .map-node:focus-visible circle { stroke-width: 10; }
.map-node:focus-visible text { text-decoration: underline; }
.map-node.is-focus circle { stroke-width: 12; }
.map-node.is-focus text { font-weight: 700; }
.map-logo text { fill: var(--text); font-weight: 800; letter-spacing: -0.02em; }
.map-logo:focus-visible text { text-decoration: underline; }

.topicmap.map-ready .map-controls { display: flex; gap: 6px; position: absolute; top: 12px; right: 12px; }
.map-controls button { min-width: 36px; background: var(--surface); }

.topicmap.map-ready .map-panel {
  display: block;
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(380px, calc(100% - 24px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}
.map-panel h1 { font-size: 20px; margin: 0 0 4px; }
.map-panel p { margin: 0 0 10px; }

.topicmap.map-ready .map-help {
  display: block;
  position: absolute;
  top: 12px;
  left: 12px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 50%;
}
@media (max-width: 720px) { .topicmap.map-ready .map-help { display: none; } }
[hidden] { display: none !important; }

/* --- Suche ------------------------------------------------------------------------------------ */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.search-box { position: relative; display: flex; align-items: center; margin: 16px auto; max-width: 560px; }
.search-box input {
  flex: 1;
  font: inherit;
  font-size: 16px;
  padding: 11px 48px 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 6px 28px rgb(0 0 0 / 0.25), 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box button {
  position: absolute;
  right: 6px;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  padding: 6px 10px;
  color: var(--muted);
  border-radius: 999px;
}
.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 32px rgb(0 0 0 / 0.25);
  max-height: min(60vh, 440px);
  overflow-y: auto;
  z-index: 5;
}
.search-suggestions .group { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 12px 4px; }
.search-suggestions [role="option"] { padding: 8px 12px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.search-suggestions [role="option"][aria-selected="true"], .search-suggestions [role="option"]:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.search-suggestions .hit-title mark { background: none; color: inherit; font-weight: 700; }
.search-suggestions .hit-meta { font-size: 13px; color: var(--muted); }
.search-suggestions .empty { padding: 10px 12px; color: var(--muted); }

/* Auf der Karte: schwebt oben in der Mitte über dem Sternenhimmel */
.topicmap .search-box { display: none; }
.topicmap.map-ready .search-box {
  display: flex;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  margin: 0;
  z-index: 4;
}
.topicmap.map-ready .map-help { top: auto; bottom: 12px; left: auto; right: 12px; text-align: right; max-width: 40%; }
@media (max-width: 900px) {
  .topicmap.map-ready .map-controls { top: 68px; }
}

.search-page-form { display: flex; gap: 8px; max-width: 560px; margin: 16px 0 24px; }
.search-page-form input { flex: 1; font: inherit; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.search-results { padding-left: 0; list-style: none; display: grid; gap: 12px; }

/* Start wie bei Google: Suchmaske unter dem Logo; sie fliegt mit dem Logo (Position aus JS)
   und steht, sobald sie aus dem Bild ist, fest am oberen Rand */
.topicmap.map-ready .search-box { top: 0; left: 0; transform-origin: 0 0; }
.topicmap.map-ready .search-box.docked { top: 12px; left: 50%; transform: translateX(-50%); animation: search-dock 0.35s ease; }
@keyframes search-dock { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translateX(-50%); } }
.topicmap.map-ready.is-home .map-panel { display: none; }
@media (prefers-reduced-motion: reduce) { .topicmap.map-ready .search-box.docked { animation: none; } }
.map-node.is-dot circle { stroke-width: 4; }

/* --- Ladebildschirm der Startseite --------------------------------------------------------------
   Mit JavaScript (Klasse .js, gesetzt von map-boot.js) bleibt die Linkliste verborgen; bis die Karte
   steht, zeigt die Seite den Sternenhimmel mit dem Schriftzug – an derselben Stelle wie das Logo der
   Karte, damit der Übergang nahtlos ist. Ohne JavaScript oder im Notfall: die Linkliste. */
.map-loading { display: none; }
.js .topicmap .map-loading {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 6;
  background: radial-gradient(ellipse at center, var(--sky-inner), var(--sky-outer) 75%);
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}
.js .topicmap.map-ready .map-loading { opacity: 0; visibility: hidden; }
.js .topicmap:not(.map-ready) .map-list { display: none; }
.map-loading-logo {
  position: absolute;
  left: 50%;
  top: calc(32% - 56px);
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  animation: map-loading-pulse 1.6s ease-in-out infinite;
}
@keyframes map-loading-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .map-loading-logo { animation: none; } }
.map-fallback .topicmap .map-loading { display: none; }
.map-fallback .topicmap:not(.map-ready) .map-list { display: block; }

/* --- Seitenmenü der Themenkarte ------------------------------------------------------------- */
.map-drawer-toggle, .map-drawer-head, .map-drawer-all { display: none; }
.topicmap.map-ready .map-drawer-toggle { display: block; position: absolute; top: 12px; left: 12px; z-index: 6; background: var(--surface); }
.topicmap.map-ready .map-drawer-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -12px; padding: 4px 0 8px; background: inherit; }
.topicmap.map-ready .map-drawer-head h2 { margin: 0; }
.map-drawer-close { border: 0; background: none; font-size: 18px; padding: 4px 8px; color: var(--muted); }
.topicmap.map-ready .map-drawer-all { display: block; margin: 0 0 8px; }
.map-list .topic-tree a { text-decoration: none; }
.map-list .topic-tree a:hover { text-decoration: underline; }
.map-list a[aria-current="true"] { font-weight: 700; color: var(--text); background: color-mix(in srgb, var(--accent) 20%, transparent); border-radius: 6px; padding: 1px 6px; margin-left: -6px; }
@media (min-width: 721px) {
  /* Breite Schirme: Panel rückt neben das offene Menü */
  .topicmap.map-ready.drawer-open .map-panel { left: calc(var(--drawer-width) + 12px); }
  .topicmap.map-ready.drawer-open .map-drawer-toggle { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) { .topicmap.map-ready .map-list { transition: none; } }

/* Aufklappbare Menüpunkte im Seitenmenü */
.menu-collapsible .topic-tree li:not(.is-open) > ul { display: none; }
.menu-collapsible .topic-tree .topic-tree { padding-left: 28px; }
.menu-collapsible .topic-tree li:not(.has-children) { padding-left: 32px; }
.menu-toggle {
  width: 30px;
  height: 30px;
  padding: 0;
  margin-right: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 19px;
  line-height: 30px;
  vertical-align: middle;
  border-radius: 6px;
}
.menu-toggle::before { content: '▸'; display: inline-block; transition: transform 0.15s ease; }
.menu-toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.menu-toggle:hover, .menu-toggle:focus-visible { color: var(--text); background: color-mix(in srgb, var(--accent) 15%, transparent); }

/* Lupe in der Suchmaske */
.search-box button { display: flex; align-items: center; justify-content: center; padding: 6px 12px; }
.search-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.search-box button:hover { color: var(--text); }
