:root {
  --blau: #2b6cb0;
  --blau-dunkel: #1e4e82;
  --blau-hell: #e8f0fa;
  --grau: #94a3b8;
  --grau-hell: #cbd5e1;
  --mess: #c2410c;
  --text: #0f172a;
  --text-leise: #475569;
  --linie: #d7dee8;
  --flaeche: #ffffff;
  --grund: #f5f7fa;
  --warn: #b45309;
  --radius: 12px;
  --schatten: 0 2px 8px rgba(15, 23, 42, .16);
  --schatten-gross: 0 8px 24px rgba(15, 23, 42, .16);
  --panel-breite: 400px;
  --gruen: #166534;
  --gruen-hell: #e6f4ea;
  --gelb-hell: #fef3c7;
  --rot: #b91c1c;
  --rot-hell: #fdecec;
  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; overscroll-behavior: none; }
body { display: flex; flex-direction: column; background: var(--grund); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, strong { font-weight: 600; }
button { transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out; }
:focus-visible { outline: 2px solid var(--blau); outline-offset: 2px; }

/* Icons: Lucide als Sprite in index.html */
.sprite { position: absolute; width: 0; height: 0; }
.ikon { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ikon.gross { width: 20px; height: 20px; }

/* Kopf */
.kopf { display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: var(--flaeche); border-bottom: 1px solid var(--linie); z-index: 10; }
.marke { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 16px; white-space: nowrap; }
.marke-zeichen { flex: none; width: 24px; height: 24px; fill: var(--blau); }
.suche { position: relative; flex: 1; display: flex; max-width: 560px; }
.suche input { flex: 1; padding: 12px 12px; border: 1px solid var(--linie); border-radius: 8px 0 0 8px; min-width: 0; }
.suche input:focus { outline: 2px solid var(--blau); outline-offset: -1px; }
.suche button { padding: 0 16px; border: 0; background: var(--blau); color: #fff; border-radius: 0 8px 8px 0; cursor: pointer; }
.treffer { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten); max-height: 320px; overflow: auto; z-index: 20; }
.treffer li { padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.treffer li small { display: block; color: var(--text-leise); }
.treffer li:hover, .treffer li[aria-selected="true"] { background: var(--blau-hell); }

/* Bühne */
.buehne { position: relative; flex: 1; min-height: 0; }
.karte { position: absolute; inset: 0; }
.karte .ol-viewport { touch-action: none !important; } /* Wischen gehört allein der Karte */
.karte:focus { outline: none; }
.karte:focus-visible { outline: 2px solid var(--blau); outline-offset: -2px; }

/* Panel */
.panel { position: absolute; top: 12px; left: 12px; bottom: 12px; width: var(--panel-breite); display: flex; flex-direction: column; background: var(--flaeche); border-radius: 16px; box-shadow: var(--schatten-gross); overflow: hidden; z-index: 5; }
.blatt-griff, .nur-mobil { display: none; } /* nur mobil */

/* Bereichs-Chips: schwebende Knopfzeile über der Karte (Desktop rechts neben dem Panel) */
.bereiche { display: flex; flex-wrap: nowrap; position: absolute; top: 8px; left: calc(var(--panel-breite) + 20px); gap: 8px; max-width: calc(100% - var(--panel-breite) - 32px); padding: 4px 4px 8px; overflow-x: auto; z-index: 6; pointer-events: none; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.bereiche::-webkit-scrollbar { display: none; }
.bereiche button { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 16px; pointer-events: auto; border: 1px solid var(--linie); border-radius: 999px; background: var(--flaeche); box-shadow: var(--schatten); font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; }
.bereiche button:hover { border-color: var(--blau); }
.bereiche button[aria-selected="true"] { background: var(--blau); border-color: var(--blau); color: #fff; }

/* Karten-Kachel unten links: zeigt die aktive Grundkarte, tippen öffnet die Auswahl */
.ebenen { display: grid; place-items: center; position: absolute; left: calc(var(--panel-breite) + 24px); bottom: 24px; width: 56px; height: 56px; padding: 4px; border: 2px solid #fff; border-radius: 12px; background: var(--flaeche); box-shadow: var(--schatten); z-index: 4; font-size: 11px; font-weight: 500; line-height: 1.2; color: var(--text); cursor: pointer; }
.ebenen[hidden] { display: none; }

/* Auswahlkarte über der Kachel: welche Grundkarte, mit einem Satz Erklärung */
.ebenen-wahl { display: grid; position: absolute; left: calc(var(--panel-breite) + 24px); bottom: 88px; z-index: 7; gap: 2px; width: min(300px, calc(100% - 16px)); padding: 8px; background: var(--flaeche); border-radius: 16px; box-shadow: var(--schatten-gross); }
.ebenen-wahl[hidden] { display: none; }
.ebenen-wahl button { display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: center; padding: 8px; border: 1px solid transparent; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.ebenen-wahl button[aria-pressed="true"] { border-color: var(--blau); background: var(--blau-hell); }
.ebenen-wahl .ebene-symbol { display: grid; place-items: center; color: var(--text-leise); }
.ebenen-wahl strong { font-size: 13px; font-weight: 500; display: block; }
.ebenen-wahl small { display: block; color: var(--text-leise); font-size: 12px; line-height: 1.3; }
.ebenen-wahl .klein { margin: 4px 8px 2px; }

/* Standort (GPS): am Desktop über den Zoom-Knöpfen, mobil frei unten rechts */
.standort { display: grid; place-items: center; position: absolute; right: 12px; bottom: 132px; width: 44px; height: 44px; border: 1px solid var(--linie); border-radius: 50%; background: var(--flaeche); box-shadow: var(--schatten); z-index: 4; color: var(--blau); cursor: pointer; }
.standort:hover { border-color: var(--blau); }
.inhalt { flex: 1; overflow: auto; padding: 16px; overscroll-behavior: contain; }
.lead { margin: 0 0 16px; font-size: 14px; line-height: 1.45; }
.info { font-size: 13px; color: var(--text-leise); line-height: 1.45; margin: 12px 0; }
.info strong { color: var(--text); }
.klein { font-size: 12px; color: var(--text-leise); }
.zeile { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.zeile input[type="search"] { flex: 1; padding: 8px 12px; border: 1px solid var(--linie); border-radius: 8px; }
select { padding: 8px 8px; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); }
input[type="range"] { width: 100%; accent-color: var(--blau); }
.schalter { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.schalter input { accent-color: var(--blau); width: 18px; height: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); cursor: pointer; font-size: 14px; line-height: 1.2; text-align: left; }
.chip small { display: block; font-weight: 400; font-size: 12px; color: var(--text-leise); }
.chip[aria-checked="true"] { border-color: var(--blau); background: var(--blau-hell); color: var(--blau-dunkel); font-weight: 500; }

.jahrwahl { margin: 16px 0 4px; padding: 12px; background: var(--grund); border-radius: var(--radius); }
.jahrwahl label { display: flex; justify-content: space-between; font-size: 14px; }
.jahrwahl output { font-size: 20px; font-weight: 500; color: var(--blau-dunkel); font-variant-numeric: tabular-nums; }
.jahr-knoepfe { display: flex; justify-content: space-between; margin-top: 4px; }
.jahr-knoepfe button { width: 40px; height: 32px; line-height: 1; border: 1px solid var(--linie); background: var(--flaeche); border-radius: 8px; cursor: pointer; font-size: 16px; }

.themen { display: grid; gap: 8px; }
.thema { display: grid; grid-template-columns: 20px 1fr; gap: 4px 12px; padding: 12px; border: 1px solid var(--linie); border-radius: var(--radius); cursor: pointer; }
.thema input { margin-top: 2px; accent-color: var(--blau); width: 18px; height: 18px; }
.thema span { font-weight: 500; font-size: 14px; }
.thema small { grid-column: 2; color: var(--text-leise); font-size: 12px; line-height: 1.4; }

.steckbrief { margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--linie); }
.steckbrief h3 { margin: 0 0 4px; font-size: 16px; }
.steckbrief .eintrag { margin: 12px 0; padding: 12px; background: var(--grund); border-radius: 8px; font-size: 13px; }
.steckbrief .eintrag h5 { margin: 0 0 8px; font-size: 13px; }
.gruppe { margin: 16px 0 8px; font-size: 13px; font-weight: 500; color: var(--text-leise); }
.themen .gruppe:first-child, .sb-gruppe:first-of-type .gruppe { margin-top: 8px; }
.themen-box { margin-top: 8px; }
.themen-box summary { cursor: pointer; font-weight: 500; font-size: 14px; padding: 8px 0; color: var(--blau); }
.abschnitt { margin: 16px 0 8px; font-size: 14px; }
.steckbrief .eintrag .ergebnis { max-height: 220px; overflow: auto; }
.steckbrief .eintrag table { border-collapse: collapse; font-size: 12px; }
.steckbrief .eintrag td, .steckbrief .eintrag th { padding: 2px 8px 2px 0; text-align: left; vertical-align: top; }
.steckbrief a { color: var(--blau); }
.fakten { font-variant-numeric: tabular-nums; display: grid; grid-template-columns: minmax(90px, 40%) 1fr; gap: 4px 12px; margin: 8px 0 8px; font-size: 12px; }
.fakten dt { color: var(--text-leise); }
.fakten dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.auskunft-text { margin: 8px 0 0; font-size: 12px; line-height: 1.45; }

.katalog { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.katalog li { padding: 12px; border: 1px solid var(--linie); border-radius: var(--radius); font-size: 13px; }
.katalog li strong { display: block; font-size: 14px; margin-bottom: 2px; }
.katalog .meta { color: var(--text-leise); font-size: 12px; }
.katalog .aktionen { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.knopf { padding: 8px 12px; border: 1px solid var(--blau); background: var(--blau); color: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; }
.knopf.zweit { background: var(--flaeche); color: var(--blau); }
.lizenz { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--gruen-hell); color: var(--gruen); font-size: 12px; font-weight: 500; }
.lizenz.nc { background: var(--gelb-hell); color: var(--warn); }
.eigene:empty { display: none; }
.optionen:empty { display: none; }
.optionen { margin-top: 8px; padding: 8px 12px; background: var(--grund); border-radius: 8px; font-size: 12px; }
.optionen ul { margin: 0; padding-left: 16px; }
a.knopf { text-decoration: none; display: inline-block; }
.eigene { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--linie); font-size: 13px; }

.panel-fuss { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--linie); }
.fuss-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; flex-basis: 100%; }
.knopf[hidden] { display: none; }
.link { padding: 0; border: 0; background: none; color: var(--blau); text-decoration: underline; cursor: pointer; font-size: inherit; }

/* Startseite */
.start-titel { margin: 2px 0 8px; font-size: 20px; line-height: 1.25; }
.einstiege { display: grid; gap: 12px; }
.einstieg { display: grid; grid-template-columns: 20px 1fr; gap: 12px; align-items: start; width: 100%; padding: 16px; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); text-align: left; cursor: pointer; }
.einstieg:hover { border-color: var(--blau); background: var(--blau-hell); }
.einstieg-symbol { color: var(--text-leise); padding-top: 2px; }
.einstieg-symbol .ikon { display: block; width: 20px; height: 20px; }
.einstieg-text { display: grid; gap: 4px; }
.einstieg-text strong { font-size: 16px; font-weight: 500; color: var(--text); }
.einstieg-text span { font-size: 13px; line-height: 1.4; color: var(--text); }
.einstieg-text small { font-size: 12px; color: var(--text-leise); }
.start-beispiele { margin-top: 16px; line-height: 1.8; }

/* Zeitreise: was gibt es hier? */
.jahrgaenge:empty { display: none; }
.jahrgaenge { margin: 12px 0 0; }
.jahrgaenge .klein { margin: 0 0 8px; }
.hinweis { margin: 0; padding: 12px 12px; border-radius: 8px; background: var(--grund); font-size: 13px; line-height: 1.45; color: var(--text-leise); }
.hinweis.ok { background: var(--gruen-hell); color: var(--gruen); }
.hinweis.warn { background: var(--gelb-hell); color: var(--warn); }
.jahr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.jahr-chip { min-width: 52px; padding: 8px 8px; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.jahr-chip:hover { border-color: var(--blau); }
.jahr-chip[aria-pressed="true"] { background: var(--blau); border-color: var(--blau); color: #fff; font-weight: 500; }

/* Steckbrief-Ampel */
.sb-summe { margin: 8px 0 4px; padding: 12px 12px; border-radius: 8px; background: var(--blau-hell); font-size: 13px; line-height: 1.45; }
.ampel { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--linie); vertical-align: 0; }
.eintrag[data-status="ja"] { background: var(--gelb-hell); }
.eintrag[data-status="ja"] .ampel { background: var(--warn); }
.eintrag[data-status="nein"] .ampel { background: var(--gruen); }
.eintrag[data-status="offen"] .ampel { background: var(--grau); }
.eintrag[data-status="info"] .ampel { background: var(--blau); }
.eintrag[data-status="leer"] .ampel { background: var(--grau-hell); }
.eintrag[data-status="laedt"] .ampel { animation: puls 1s infinite alternate; }
@keyframes puls { to { background: var(--blau); } }

/* Vergleichs-Schieber */
.schieber { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.schieber-linie { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 0 1px rgba(15,23,42,.3); }
.schieber-griff { position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; display: grid; place-items: center; background: var(--blau); color: #fff; border: 3px solid #fff; border-radius: 50%; box-shadow: var(--schatten); cursor: ew-resize; pointer-events: auto; touch-action: none; user-select: none; }
.schieber-label { position: absolute; top: 112px; padding: 4px 12px; background: rgba(15,23,42,.75); color: #fff; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.schieber-label.links { right: calc(50% + 12px); }
.schieber-label.rechts { left: calc(50% + 12px); }

.meldung { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); max-width: 90%; padding: 12px 16px; background: var(--text); color: #fff; border-radius: 8px; font-size: 14px; z-index: 30; box-shadow: var(--schatten); }

.dialog { max-width: 560px; border: 0; border-radius: 16px; box-shadow: var(--schatten-gross); padding: 24px; line-height: 1.5; }
.dialog::backdrop { background: rgba(15,23,42,.4); }
.dialog h2 { margin-top: 0; }

/* OpenLayers anpassen */
.ol-attribution { font-size: 11px; max-width: calc(100% - var(--panel-breite) - 40px); }
.ol-attribution.ol-uncollapsible { border-radius: 8px 0 0 0; }
.ol-zoom { top: auto; bottom: 48px; left: auto; right: 12px; }
.ol-zoom button { width: 36px; height: 36px; font-size: 20px; }
.ol-scale-line { left: auto; right: 60px; bottom: 12px; }

/* Werkzeuge: Messen & Drucken */
.werkzeuge { position: absolute; top: 64px; right: 12px; z-index: 6; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.werkzeuge button { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); box-shadow: var(--schatten); cursor: pointer; font-size: 13px; }
.werkzeuge button:hover { border-color: var(--blau); }
.werkzeuge button[aria-pressed="true"] { background: var(--mess); border-color: var(--mess); color: #fff; }
.werkzeuge button[hidden], .werkzeuge button.nur-mobil { display: none; }
.mess-etikett { padding: 4px 8px; border-radius: 4px; background: rgba(15, 23, 42, .85); color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none; }
.mess-etikett.fest { background: var(--mess); }
.druck-form { display: grid; gap: 12px; }
.druck-form label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
.druck-form input, .druck-form select { padding: 8px 12px; border: 1px solid var(--linie); border-radius: 8px; font-weight: 400; }

/* Druckansicht (Klasse „druck“ am body, gesetzt von druckeKarte) */
.druck-rahmen { display: none; }
body.druck { display: block; background: #fff; }
body.druck .kopf, body.druck .panel, body.druck .werkzeuge, body.druck .ol-zoom, body.druck .schieber-griff, body.druck .meldung, body.druck .bereiche, body.druck .ebenen, body.druck .ebenen-wahl, body.druck .standort { display: none !important; }
body.druck .druck-rahmen { display: flex; }
body.druck #druck-kopf { justify-content: space-between; align-items: flex-start; height: 14mm; font-size: 11pt; }
body.druck #druck-kopf span { font-size: 9pt; color: var(--text-leise); }
body.druck .druck-nord { font-weight: 700; text-align: center; line-height: 1; font-size: 12pt; }
body.druck #druck-fuss { height: 10mm; align-items: flex-end; font-size: 7pt; color: var(--text-leise); }
body.druck .buehne { position: static; }
body.druck .karte { position: relative; inset: auto; border: 0.3mm solid #0f172a; }
body.druck .ol-attribution { display: none; }

/* Die Chips übernehmen die Reiter, die Kachel die Grundkarten-Wahl (steht nach den
   Originalregeln, damit es sie überschreibt) */
.reiter { display: none; }
.grundkarten-wahl { display: none; }
#zur-start { display: none; } /* zur Übersicht führt das Logo oben links */

/* Mobil: Karte im Vollbild, Panel als aufziehbares Bodenblatt (zu / halb / voll) */
@media (max-width: 760px) {
  .kopf { flex-wrap: nowrap; gap: 8px; padding: 8px; }
  .marke span { display: none; } /* nur der Landesumriss, die Suche braucht den Platz */
  .suche { max-width: none; flex: 1; }

  /* Bodenblatt: Höhe setzt js/app.js (Stufen zu/halb/voll, Ziehen am Griff) */
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--blatt-px, 46dvh); max-height: 94dvh; border-radius: 16px 16px 0 0; transition: height 0.25s ease; }
  .panel.ziehen { transition: none; }
  .panel.zu .inhalt, .panel.zu .panel-fuss { display: none; }

  .blatt-griff { display: block; flex: none; width: 100%; padding: 12px 0 8px; border: 0; background: none; cursor: grab; touch-action: none; }
  .blatt-griff::before { content: ''; display: block; width: 44px; height: 4px; margin: 0 auto; border-radius: 2px; background: var(--grau-hell); }

  .einstieg { padding: 12px; }
  .panel-fuss { padding: 8px 12px; }

  /* Chips, Kachel, Auswahl und Standort rücken mobil an die Ränder */
  .bereiche { top: 4px; left: 0; right: 0; max-width: none; padding: 4px 8px 8px; }
  .ebenen { left: 8px; bottom: calc(var(--blatt-px, 46dvh) + 12px); }
  .ebenen-wahl { left: 8px; bottom: calc(var(--blatt-px, 46dvh) + 76px); }
  .standort { right: 8px; bottom: calc(var(--blatt-px, 46dvh) + 12px); width: 48px; height: 48px; }

  /* Voll aufgezogen verdeckt das Blatt die Karte – die Kartenknöpfe dann auch weg */
  body.blatt-voll .ebenen, body.blatt-voll .standort { display: none; }

  /* Auf dem Handy zoomt man mit zwei Fingern; Drucken gibt es am Rechner */
  .ol-zoom { display: none; }
  #druck-auf { display: none; }
  .ol-scale-line { display: none; }
  .ol-attribution { max-width: 100%; bottom: calc(var(--blatt-px, 46dvh) + 2px); }
  .meldung { bottom: calc(var(--blatt-px, 46dvh) + 12px); }
  .werkzeuge { top: 58px; right: 8px; z-index: 4; flex-direction: column; align-items: flex-end; } /* Knopfspalte direkt unter den Chips */
  .werkzeuge button { justify-content: center; width: 40px; height: 40px; padding: 0; }
  .werkzeuge button.nur-mobil { display: flex; }
  .werkzeuge .ikon { width: 20px; height: 20px; }
  .schieber-label { display: none; } /* der Regler erklärt sich, die Jahre stehen im Blatt */

  /* Doppelte Knöpfe unten: Übersicht machen die Chips, Bild und Link die Karten-Knöpfe */
  #zur-start, #bild, #teilen { display: none; }
  .werkzeuge button span { display: none; }
  .schieber-griff { top: 24%; }
}

@media print {
  .kopf, .reiter, .panel-fuss, .ol-zoom, .schieber, .themen, .lead { display: none !important; }
  .panel { position: static; width: 100%; box-shadow: none; }
  .buehne { display: flex; flex-direction: column; }
  .karte { position: relative; height: 60vh; }
}
