/* KOVA TWIN — Bürgerkarte. Design ist Daten: nur Tokens, Komponenten lesen Tokens.
   Light-first ("Daylight", Haus-Designsprache), Dark folgt dem System. */
:root {
  color-scheme: light dark;
  --page: #f6f4ef; --surface: rgba(255,255,255,.92); --ink: #121212; --ink-2: #4e4c47; --muted: #8b887f;
  --border: rgba(18,18,18,.10); --brand: #0e2a47; --brand-2: #f5b52e; --accent: #2a78d6;
  --good: #0ca30c; --warn: #fab219; --bad: #d03b3b; --radius: 12px; --shadow: 0 6px 24px rgba(0,0,0,.12);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="daylight"]) { --page:#12151a; --surface:rgba(24,28,34,.94); --ink:#f1f1ee; --ink-2:#c3c2ba; --muted:#8a8c90; --border:rgba(255,255,255,.12); }
}
:root[data-theme="dark"] { --page:#12151a; --surface:rgba(24,28,34,.94); --ink:#f1f1ee; --ink-2:#c3c2ba; --muted:#8a8c90; --border:rgba(255,255,255,.12); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--ink); }
#map { position: fixed; inset: 0; }
.hidden { display: none !important; }
button, input { font: inherit; }

.top { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; gap: 10px; align-items: center; z-index: 5; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { background: var(--brand); color: #fff; padding: 10px 14px; border-radius: var(--radius); font-weight: 700; letter-spacing: .02em; box-shadow: var(--shadow); white-space: nowrap; }
.brand .mark { color: var(--brand-2); }
.brand .sub { font-weight: 400; opacity: .7; font-size: .8em; margin-left: 6px; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.results { position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.results li:hover, .results li.active { background: rgba(42,120,214,.12); }
.results small { display: block; color: var(--muted); }
.lang { display: flex; gap: 2px; background: var(--surface); border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow); }
.lang button { border: 0; background: transparent; color: var(--ink-2); padding: 6px 9px; border-radius: 8px; cursor: pointer; }
.lang button.on { background: var(--brand); color: #fff; }

.panel { position: fixed; top: 70px; left: 12px; width: 300px; max-height: calc(100vh - 90px); overflow: auto; background: var(--surface); backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px 10px; z-index: 4; }
.panel.collapsed { width: auto; }
.panel.collapsed > :not(.panel-head) { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel h1 { font-size: 1rem; margin: 0; }
#panel-toggle { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; color: var(--ink-2); }
.group { margin: 10px 0 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.layer { display: flex; align-items: center; gap: 8px; padding: 5px 2px; cursor: pointer; }
.layer input { accent-color: var(--brand); }
.layer .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.layer .n { flex: 1; font-size: .92rem; }
.layer .c { color: var(--muted); font-size: .78rem; }
.layer .mode { font-size: .66rem; padding: 1px 6px; border-radius: 6px; background: rgba(245,181,46,.25); color: #6b4d00; }
.layer .mode.live { background: rgba(12,163,12,.15); color: #0a5c0a; }
.now { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(42,120,214,.08); font-size: .85rem; color: var(--ink-2); }
.foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--border); background: transparent; color: var(--ink-2); padding: 5px 10px; border-radius: 999px; font-size: .8rem; cursor: pointer; text-decoration: none; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.attrib { font-size: .68rem; color: var(--muted); margin: 10px 0 0; line-height: 1.35; }

.banner { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); background: #3b2f00; color: #ffe9a8; padding: 8px 14px; border-radius: 999px; font-size: .82rem; z-index: 6; box-shadow: var(--shadow); max-width: 92vw; }
.live { position: fixed; top: 70px; right: 12px; background: var(--surface); padding: 6px 10px; border-radius: 999px; font-size: .78rem; display: flex; gap: 6px; align-items: center; box-shadow: var(--shadow); z-index: 4; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

.kv { display: grid; grid-template-columns: 1fr 1.4fr; gap: 3px 10px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.meter { height: 8px; border-radius: 4px; background: rgba(0,0,0,.08); overflow: hidden; margin: 6px 0; }
.meter i { display: block; height: 100%; background: var(--good); }
.spark { width: 100%; height: 70px; margin-top: 8px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark text { font-size: 10px; fill: var(--muted); }
.late { color: #b42318; font-weight: 600; } .ok { color: #0a5c0a; }
.tag { display: inline-block; font-size: .7rem; padding: 1px 7px; border-radius: 6px; background: rgba(245,181,46,.25); color: #6b4d00; margin-left: 6px; vertical-align: middle; }
.maplibregl-ctrl-group { box-shadow: var(--shadow) !important; }

@media (max-width: 720px) {
  .brand .sub { display: none; }
  .lang { display: none; }
  .panel { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: 45vh; }
  .panel.collapsed { right: auto; }
  .banner { bottom: auto; top: 64px; }
  .live { top: auto; bottom: 14px; right: 12px; }
}

/* ── Kontext-Karte (UX-WIDGETS.md §3 + §5) ────────────────────────────────────────────────────────
   Desktop: Seitenkarte rechts. Mobil: Bottom-Sheet in zwei Stufen (data-stage="peek": Kopf + Jetzt,
   "full": alles; Griff schaltet). Tipp-Ziele ≥ --tap, Schrift ≥ 16 px auf Mobil, Fokus sichtbar,
   prefers-reduced-motion. Nur Tokens: neue Werte stehen hier am :root, Komponenten lesen sie. */
:root {
  --tap: 44px; --sheet-w: 420px; --sheet-gap: 12px; --sheet-max: 70vh; --sheet-peek: 44vh; --sheet-full: 88vh;
  --sheet-fs: .95rem; --sheet-fs-small: .8rem; --sheet-fs-seal: .7rem; --sheet-pad: 14px 16px; --sheet-radius-sm: 8px;
  --focus: var(--accent); --focus-w: 2px; --hover: rgba(42,120,214,.12); --grip: var(--muted); --grip-w: 40px; --grip-h: 5px;
  --open-bg: rgba(12,163,12,.15); --open-ink: #0a5c0a; --closed-bg: rgba(208,59,59,.14); --closed-ink: #8f1f1f;
  --motion: .22s; --gap-xs: 4px; --gap-s: 8px; --gap-m: 12px;
  --sheet-fs-title: 1.1rem; --sheet-fs-close: 1.5rem; --swatch: 10px; --pill: 999px; --caps-spacing: .08em;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="daylight"]) { --open-bg: rgba(12,163,12,.25); --open-ink: #8ee28e; --closed-bg: rgba(208,59,59,.25); --closed-ink: #ffb3b3; --hover: rgba(42,120,214,.25); }
}
:root[data-theme="dark"] { --open-bg: rgba(12,163,12,.25); --open-ink: #8ee28e; --closed-bg: rgba(208,59,59,.25); --closed-ink: #ffb3b3; --hover: rgba(42,120,214,.25); }
@media (max-width: 720px) { :root { --sheet-fs: 1rem; --sheet-fs-small: 1rem; --sheet-fs-seal: 1rem; --sheet-fs-title: 1.15rem; } }
@media (prefers-reduced-motion: reduce) { :root { --motion: 0s; } }

.sheet { position: fixed; right: var(--sheet-gap); bottom: var(--sheet-gap); width: min(var(--sheet-w), calc(100vw - 2 * var(--sheet-gap))); max-height: var(--sheet-max); overflow: auto; overscroll-behavior: contain; background: var(--surface); backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sheet-pad); z-index: 5; font-size: var(--sheet-fs); transition: max-height var(--motion) ease; }
.sheet:focus { outline: none; }
.sheet :focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-w); }
.sheet h2 { font-size: var(--sheet-fs-title); margin: 0 var(--tap) var(--gap-xs) 0; line-height: 1.3; }
.sheet h3 { font-size: var(--sheet-fs-small); text-transform: uppercase; letter-spacing: var(--caps-spacing); color: var(--muted); margin: var(--gap-m) 0 var(--gap-xs); font-weight: 600; }
.sheet h4 { font-size: var(--sheet-fs); margin: var(--gap-s) 0 var(--gap-xs); }
.sheet .close { position: absolute; right: var(--gap-xs); top: var(--gap-xs); min-width: var(--tap); min-height: var(--tap); border: 0; border-radius: var(--radius); background: transparent; font-size: var(--sheet-fs-close); line-height: 1; cursor: pointer; color: var(--ink-2); }
.sheet .grip { display: none; }
.sheet img { width: 100%; border-radius: var(--sheet-radius-sm); margin-top: var(--gap-s); }
.sheet .kv { font-size: var(--sheet-fs); }
.sheet .attrib, .sheet .tag { font-size: var(--sheet-fs-seal); }
.sheet small { font-size: var(--sheet-fs-small); color: var(--muted); }
.sheet .muted { color: var(--muted); margin: var(--gap-xs) 0; }
.sheet .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

.sheet .meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-xs) var(--gap-s); margin-bottom: var(--gap-xs); font-size: var(--sheet-fs-small); color: var(--ink-2); }
.sheet .meta .type { display: inline-flex; align-items: center; gap: var(--gap-xs); }
.sheet .meta .sw { width: var(--swatch); height: var(--swatch); border-radius: 50%; flex: none; display: inline-block; }
.sheet .meta .dist:empty { display: none; }
.sheet .oh { padding: 1px var(--gap-s); border-radius: var(--sheet-radius-sm); font-weight: 600; }
.sheet .oh.is-open { background: var(--open-bg); color: var(--open-ink); }
.sheet .oh.is-closed { background: var(--closed-bg); color: var(--closed-ink); }

.sheet .near { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap-xs); }
.sheet .near li { display: grid; gap: 0; }
.sheet .near .k { font-size: var(--sheet-fs-small); color: var(--muted); }
.sheet .jump { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-s); width: 100%; min-height: var(--tap); padding: var(--gap-xs) var(--gap-s); border: 1px solid var(--border); border-radius: var(--sheet-radius-sm); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.sheet .jump:hover { background: var(--hover); }
.sheet .jump .d { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet .jump.inline { display: inline-flex; width: auto; color: var(--accent); }
.sheet .actions { display: flex; flex-wrap: wrap; gap: var(--gap-s); margin-top: var(--gap-s); }
.sheet .act { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--gap-m); border: 1px solid var(--border); border-radius: var(--pill); background: transparent; color: var(--ink); text-decoration: none; cursor: pointer; font-size: var(--sheet-fs); }
.sheet .act:hover { background: var(--hover); }
.sheet .share-status { margin: var(--gap-xs) 0 0; font-size: var(--sheet-fs-small); color: var(--ink-2); word-break: break-all; }
.sheet .share-status:empty { display: none; }

@media (max-width: 720px) {
  .sheet { left: 0; right: 0; bottom: 0; width: auto; max-height: var(--sheet-peek); border-radius: var(--radius) var(--radius) 0 0; padding-top: 0; padding-bottom: calc(var(--gap-m) + env(safe-area-inset-bottom)); }
  .sheet[data-stage="full"] { max-height: var(--sheet-full); }
  .sheet .grip { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--tap); border: 0; background: transparent; cursor: pointer; position: sticky; top: 0; }
  .sheet .grip span { width: var(--grip-w); height: var(--grip-h); border-radius: var(--grip-h); background: var(--grip); }
  .sheet .close { top: 0; }
  .sheet[data-stage="peek"] .sec:not(.sec-now), .sheet[data-stage="peek"] .seal { display: none; }
  .sheet[data-stage="peek"]:not([data-has-now]) .sec-facts { display: block; }
  .sheet .meta, .sheet .kv, .sheet .near .k { font-size: var(--sheet-fs); }
}
/* ── Sonne & Schatten (web/sun-ui.js) ─────────────────────────────────────────────────────── */
.sun-panel { position: fixed; top: 112px; right: 12px; width: min(320px, calc(100vw - 24px)); max-height: calc(100vh - 220px); overflow: auto; background: var(--surface); backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px 12px; z-index: 4; font-size: .88rem; }
.sun-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sun-head .close { border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; color: var(--ink-2); min-width: 32px; min-height: 32px; }
.sun-row { display: grid; grid-template-columns: 4.2em 1fr 5.6em; align-items: center; gap: 8px; margin: 6px 0; }
.sun-row span { color: var(--muted); }
.sun-row input[type=range] { width: 100%; accent-color: var(--brand-2); min-height: 28px; }
.sun-row output { text-align: right; font-variant-numeric: tabular-nums; }
.sun-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.sun-pos { margin: 6px 0; color: var(--ink-2); }
.sun-check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.sun-check input { accent-color: var(--brand); }
.sun-status { margin: 4px 0; color: var(--muted); font-size: .82rem; }
.sun-status.warn { color: var(--ink-2); background: rgba(245,181,46,.18); border-radius: 8px; padding: 4px 8px; }
.sun-section { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.sun-section h4 { margin: 0 0 6px; font-size: .95rem; }
.sun-line { margin: 0 0 6px; }
.sun-sky { width: 100%; height: auto; margin-top: 8px; display: block; }
.sun-sky .sun-horizon { fill: var(--ink-2); fill-opacity: .28; stroke: var(--ink-2); stroke-width: 1; }
.sun-sky .sun-path { fill: none; stroke: var(--brand-2); stroke-width: 2; }
.sun-sky .sun-path.alt { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.sun-sky .sun-dot { fill: var(--brand-2); stroke: var(--ink); stroke-width: 1; }
.sun-sky text { font-size: 10px; fill: var(--muted); }
.sun-marker { width: 16px; height: 16px; border-radius: 50%; background: var(--brand-2); border: 2px solid var(--brand); box-shadow: var(--shadow); }
#sun-probe:empty { display: none; }
@media (max-width: 720px) {
  .sun-panel { top: 64px; left: 12px; right: 12px; width: auto; max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) { .sun-panel { backdrop-filter: none; } }
