/* Schulweg-Karte – Optik wie vizsim/svz: weiße Panels, Systemschrift, Blau für Links. */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #map { height: 100%; width: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #222;
  background: #f2f3f4;
}
a { color: #4576c4; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
.leise { color: #8a8f95; }
.zahl { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
[hidden] { display: none !important; }

:root {
  --verdacht: #e8590c;
  --verdacht-dunkel: #8a3200;
  --kein: #8c939b;
  --schulfrei: #74b3e0;
  --schulfrei-dunkel: #2f6f9f;
  --rad: #2f8a4c;
  --rad-dunkel: #16683a;
  --panel: rgba(255, 255, 255, 0.97);
  --schatten: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* ---- Filter-Panel oben links ------------------------------------------------------ */
/* Endet über der Legende unten links: --legende-oben misst main.js, denn deren Höhe hängt von
   Thema, Ansicht und Zeilenumbruch ab (in schmalen Fenstern stehen auch Quellen und Maßstab dort). */
#panel {
  position: absolute; top: 12px; left: 12px; z-index: 2; width: 320px;
  max-height: max(160px, calc(var(--legende-oben, 100vh - 280px) - 22px)); overflow-y: auto;
  background: var(--panel); padding: 10px 14px 12px; border-radius: 8px; box-shadow: var(--schatten);
}
#panel header { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; }
#panel h1 { font-size: 17px; font-weight: 700; color: #1a1a1a; line-height: 1.25; }
#untertitel { grid-column: 1 / -1; font-size: 12px; color: #555; margin-top: 2px; }
#panel-toggle {
  grid-row: 1; grid-column: 2; align-self: start; display: none;
  background: none; border: 1px solid #d8d8d8; border-radius: 6px; padding: 2px 8px;
  font-size: 12px; font-weight: 600; color: #444; cursor: pointer;
}
/* Umschalter (Thema, Ansicht): zwei Knöpfe wie ein Segment */
.umschalter { display: flex; margin-top: 7px; }
#thema { grid-column: 1 / -1; }
.umschalter button {
  flex: 1; padding: 4px 8px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 1px solid #c9ced4; background: #fff; color: #555;
}
.umschalter button:first-child { border-radius: 6px 0 0 6px; }
.umschalter button:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.umschalter button[aria-pressed="true"] { background: #4576c4; border-color: #4576c4; color: #fff; }
.umschalter button:disabled { cursor: progress; opacity: 0.6; }
body[data-thema="rad"] .umschalter button[aria-pressed="true"] { background: var(--rad); border-color: var(--rad); }
.umschalter.klein { margin-top: 5px; }
.umschalter.klein button { font-size: 11.5px; padding: 3px 6px; }
.regler select { font: inherit; padding: 1px 2px; border: 1px solid #ccc; border-radius: 4px; background: #fff; }
fieldset { border: none; border-top: 1px solid #e8e8e8; margin-top: 9px; padding-top: 7px; }
fieldset legend { font-size: 11px; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: 0.03em; padding-right: 6px; }
.jahre { display: flex; gap: 14px; font-size: 13px; margin-top: 4px; }
.jahre select { font: inherit; padding: 1px 2px; border: 1px solid #ccc; border-radius: 4px; background: #fff; }
.regler { display: block; font-size: 12.5px; margin-top: 6px; line-height: 1.35; }
.regler output { font-weight: 700; color: var(--verdacht-dunkel); font-variant-numeric: tabular-nums; }
.regler input[type="range"] { width: 100%; margin-top: 3px; accent-color: var(--verdacht); }
.regler input[type="range"]:disabled { opacity: 0.4; }
.regler input[type="checkbox"], .check input { accent-color: var(--verdacht); vertical-align: -1px; }
.check { display: block; font-size: 12.5px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 5px; }
.chips button {
  min-width: 27px; padding: 2px 5px; font-size: 11.5px; font-weight: 600; cursor: pointer;
  border: 1px solid #d8d8d8; border-radius: 5px; background: #fff; color: #777;
  font-variant-numeric: tabular-nums;
}
.chips button[aria-pressed="true"] { background: #4576c4; border-color: #4576c4; color: #fff; }
.chips-text { font-size: 11.5px; color: #777; margin-left: 2px; }
#statistik, #statistik-rad { font-size: 12.5px; line-height: 1.45; margin-top: 10px; border-top: 1px solid #e8e8e8; padding-top: 8px; }
#statistik .t-verdacht { color: var(--verdacht-dunkel); }
#statistik-rad .t-aenderung { color: var(--rad-dunkel); }
#rad-vergleich .regler { margin-top: 7px; }
#methode { margin-top: 8px; font-size: 12px; line-height: 1.45; color: #333; }
#methode summary { cursor: pointer; font-weight: 600; font-size: 12px; color: #333; }
#methode p { margin-top: 6px; }
#quellen { margin: 6px 0 0 16px; }
#quellen li { margin-top: 3px; }
#methode .links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

/* ---- Legende unten links ------------------------------------------------------------ */
#legende {
  position: absolute; bottom: 22px; left: 12px; z-index: 2; width: 230px;
  background: var(--panel); padding: 9px 12px; border-radius: 8px; box-shadow: var(--schatten);
  font-size: 11.5px; color: #333;
}
/* Sobald die Karte steht, hängt main.js die Legende als Steuerelement in die Ecke unten links
   (über die Quellenangabe in schmalen Fenstern) – dann fließt sie im Stapel mit. */
.maplibregl-ctrl-bottom-left > #legende { position: relative; left: auto; bottom: auto; z-index: auto; }
.leg-titel { font-size: 11px; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: 0.03em; margin: 2px 0 3px; }
.leg-titel + .leg-zeile { margin-top: 0; }
.leg-zeile { display: flex; align-items: center; gap: 7px; margin: 2px 0; }
.leg-zeile .anzahl { margin-left: auto; color: #8a8f95; font-variant-numeric: tabular-nums; }
.leg-zeile + .leg-titel { margin-top: 7px; }
.leg-hinweis { font-size: 10.5px; color: #8a8f95; margin-top: 7px; line-height: 1.35; }
.punkt { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid #fff; }
.punkt.verdacht { background: var(--verdacht); border-color: var(--verdacht-dunkel); }
.punkt.kein { background: var(--kein); }
.punkt.schulfrei { background: var(--schulfrei); border-color: var(--schulfrei-dunkel); }
.punkt.unbekannt { background: #fff; border-color: var(--kein); }
.punkt.blass { opacity: 0.72; }
/* ohne genaue Lage: kein Punkt auf der Karte, nur im PLZ-Gebiet – gestrichelter Ring in Statusfarbe */
.punkt.ohne-lage { background: #fff; border-width: 1.5px; border-style: dashed; }
.punkt.ohne-lage.verdacht { border-color: var(--verdacht); }
.punkt.ohne-lage.kein { border-color: var(--kein); }
.punkt.ohne-lage.schulfrei { border-color: var(--schulfrei-dunkel); }
.nur-plz {
  display: inline-block; margin-left: 3px; padding: 0 5px; border: 1px dashed #a9afb6; border-radius: 8px;
  font-size: 10px; font-weight: 600; color: #6b7178; white-space: nowrap; vertical-align: 1px;
}
.flaeche { display: inline-block; width: 16px; height: 10px; border-radius: 2px; border: 1px solid #7d858e; flex: none; }
.flaeche.v1 { background: #ffdcb8; }
.flaeche.v2 { background: #ffb06b; }
.flaeche.v3 { background: #f0802e; }
.flaeche + .flaeche { margin-left: -5px; }
.flaeche.kein { background: rgba(207, 212, 218, 0.75); }

/* ---- Detailkarte rechts (mobil: unten) ------------------------------------------------ */
#karte-detail {
  position: absolute; top: 12px; right: 52px; z-index: 3; width: 380px; max-height: calc(100vh - 60px);
  overflow-y: auto; background: #fff; border-radius: 9px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
  padding: 12px 16px 14px; font-size: 13px; line-height: 1.45;
}
.schliessen {
  position: sticky; top: 0; float: right; margin: -4px -6px 0 8px; width: 28px; height: 28px;
  border: none; background: #fff; border-radius: 50%; font-size: 20px; line-height: 1; color: #777; cursor: pointer;
}
.schliessen:hover { background: #f0f0f0; color: #222; }
#karte-detail h2 { font-size: 15.5px; font-weight: 700; color: #111; margin-top: 4px; line-height: 1.3; }
.zurueck { background: none; border: none; color: #4576c4; cursor: pointer; font-size: 12px; padding: 0; margin-bottom: 6px; display: block; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 9px; letter-spacing: 0.02em; }
.b-verdacht { background: #ffe8d6; color: var(--verdacht-dunkel); }
.b-kein { background: #eef0f2; color: #555; }
.b-schulfrei { background: #e3f0fa; color: var(--schulfrei-dunkel); }
.b-unbekannt { background: #f4f4f4; color: #777; }
.b-rad { background: #e3f1dc; color: var(--rad-dunkel); }
.d-meta { color: #666; font-size: 12px; margin-top: 2px; }
.d-hinweis { margin-top: 6px; font-size: 12px; background: #f3f8fc; border-left: 3px solid var(--schulfrei); padding: 4px 8px; color: #2a4d66; }
.d-zahlen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 9px; }
.d-zahlen div { background: #f6f7f8; border-radius: 6px; padding: 5px 7px; }
.d-zahlen b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.d-zahlen span { display: block; font-size: 10.5px; color: #666; line-height: 1.25; }
.d-gruende { margin-top: 7px; font-size: 12px; color: var(--verdacht-dunkel); font-weight: 600; }
.d-gruende.schulfrei { color: var(--schulfrei-dunkel); font-weight: 500; }
.diagramm { width: 100%; height: auto; margin-top: 8px; display: block; }
.diagramm .gitter { stroke: #eceeef; stroke-width: 1; }
.diagramm .achse { font-size: 9px; fill: #7a7f85; }
.diagramm .schulstunde { fill: #4576c4; opacity: 0.07; }
.diagramm .balken { fill: #ffc59a; }
.diagramm .balken.ueber { fill: var(--verdacht); }
.diagramm .erwachsene { fill: none; stroke: #4c5560; stroke-width: 1.4; stroke-linejoin: round; }
.diagramm .schwelle { stroke: var(--verdacht-dunkel); stroke-width: 1; stroke-dasharray: 4 3; }
.diagramm .schwelle-text { fill: var(--verdacht-dunkel); }
.diagramm .fehlt { font-size: 10px; fill: #aaa; }
.diagramm .balken.rad { fill: #79c06f; }
.diagramm .kfz { fill: none; stroke: #6b7480; stroke-width: 1.4; stroke-dasharray: 3 2; }
.diagramm .kfz-achse { fill: #8a9198; }
.zeitreihe circle.voll { fill: var(--rad); stroke: #fff; stroke-width: 0.8; }
.zeitreihe circle.hohl { fill: #fff; stroke: var(--rad); stroke-width: 1.2; }
.diagramm-legende { font-size: 10.5px; color: #666; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 9px; margin-top: 2px; }
.sw { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; margin-right: 3px; }
.sw.balken { background: #ffc59a; }
.sw.balken.ueber { background: var(--verdacht); }
.sw.linie { height: 2px; background: #4c5560; vertical-align: 3px; }
.sw.band { background: rgba(69, 118, 196, 0.14); }
.sw.balken.rad { background: #79c06f; }
.sw.linie.kfz { background: repeating-linear-gradient(90deg, #6b7480 0 3px, transparent 3px 5px); }
.sw.voll { border-radius: 50%; background: var(--rad); }
.sw.hohl { border-radius: 50%; background: #fff; border: 1.2px solid var(--rad); }
.d-info { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-top: 10px; font-size: 12px; }
.d-info dt { color: #7a7f85; }
.d-info dd { color: #333; overflow-wrap: anywhere; }
.d-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; }
.link { background: none; border: none; color: #4576c4; cursor: pointer; padding: 0; font-size: 12.5px; }
.link:hover { text-decoration: underline; }
table.liste { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
table.liste th { text-align: left; font-size: 10.5px; color: #8a8f95; font-weight: 600; border-bottom: 1px solid #eee; padding: 0 4px 3px; }
table.liste td { padding: 3px 4px; border-bottom: 1px solid #f2f2f2; vertical-align: top; }
table.liste tbody tr { cursor: pointer; }
table.liste tbody tr:hover, table.liste tbody tr:focus { background: #f2f6fb; outline: none; }
table.liste tr.ausser td { color: #9aa0a6; }
table.liste.vergleich tbody tr { cursor: default; }
table.liste.vergleich th { font-weight: 600; color: #555; }

/* Tooltip über Punkten */
.tip .maplibregl-popup-content { padding: 5px 9px; font-size: 12px; line-height: 1.35; border-radius: 6px; }
.noscript { position: absolute; top: 40%; width: 100%; text-align: center; }

/* ---- schmale Screens ---------------------------------------------------------------- */
@media (max-width: 640px) {
  #panel {
    left: 8px; right: 8px; top: 8px; width: auto; padding: 8px 11px;
    max-height: min(55vh, max(120px, calc(var(--legende-oben, 100vh) - 16px)));
  }
  #panel h1 { font-size: 15px; }
  #panel-toggle { display: block; }
  #legende { left: 8px; bottom: 8px; width: 190px; padding: 6px 9px; font-size: 11px; }
  #legende .leg-hinweis, #legende .leg-plz, #legende .leg-lage { display: none; }
  #karte-detail {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 62vh;
    border-radius: 12px 12px 0 0; padding: 10px 14px 16px;
  }
  body.mit-detail #legende { display: none; }
}
