:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e3e6ea;
  --ink: #1b1f24;
  --ink-soft: #626b76;
  --accent: #d62828;
  --accent-soft: #fdeaea;
  --ok: #1f9d55;
  --warn: #b45309;
  --radius: 10px;
  --sidebar-w: 340px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --topbar-bg: rgba(246, 247, 249, .92);
  --transition: .15s ease;
}

* { box-sizing: border-box; }

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

/* ── Sidebar ───────────────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding-bottom: 24px;
}

.sidebar-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.01em;
}

.sidebar-header h1::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

.sidebar-sub { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }

.sidebar-section { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sidebar-section:last-child { border-bottom: 0; }

.field-group { margin-bottom: 18px; }
.field-group:last-child { margin-bottom: 0; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: inherit;
  font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.range-row { display: flex; align-items: center; gap: 8px; }
.range-row .input { flex: 1; min-width: 0; }
.range-sep { color: var(--ink-soft); font-size: 13px; }

.radius-row { display: flex; align-items: center; gap: 10px; }
.radius-row input[type=range] { flex: 1; accent-color: var(--accent); }

.radius-out {
  min-width: 62px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.hint { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); }
.hint--ok { color: var(--ok); }
.hint--bad { color: var(--accent); }

/* Ort + GPS-Knopf */
.ort-row { display: flex; gap: 8px; }
.ort-row .input { flex: 1; min-width: 0; }

.btn-geo {
  flex: none;
  padding: 8px 12px;
  font-size: 15px;
  line-height: 1.2;
}

/* Zeitraum-Chips: die haeufigsten Fragen als Klick. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.chip {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition);
}

.chip:hover { border-color: #cfd4da; color: var(--ink); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.check-list { display: flex; flex-direction: column; gap: 2px; }
.check-list--scroll { max-height: 260px; overflow-y: auto; padding-right: 4px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.check:hover { background: var(--bg); }
.check input { accent-color: var(--accent); flex: none; }
.check span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check .count { flex: none; color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.link-btn:hover { text-decoration: underline; }

/* ── Buttons ───────────────────────────────── */

.btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: inherit;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.btn:hover:not(:disabled) { background: var(--bg); border-color: #cfd4da; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

.log {
  margin: 10px 0 0;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  background: #10151b;
  color: #cbd5e1;
  border-radius: var(--radius);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

/* ── Main ──────────────────────────────────── */

.main { margin-left: var(--sidebar-w); min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--topbar-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.summary { font-size: 14px; color: var(--ink-soft); }
.summary strong { color: var(--ink); font-size: 16px; }

.notice {
  margin: 14px 24px 0;
  padding: 9px 12px;
  border: 1px solid #f0d9a8;
  border-radius: var(--radius);
  background: #fdf6e7;
  color: var(--warn);
  font-size: 13px;
}

.map {
  height: 380px;
  margin: 16px 24px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  z-index: 1;
}

.map.is-hidden { display: none; }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding: 16px 24px 40px;
}

/* Waehrend eines Abrufs bleibt die alte Liste sichtbar, aber deutlich
   abgeschwaecht - so sieht man, dass gearbeitet wird, ohne den Kontext
   zu verlieren. */
.results.is-loading { opacity: .55; pointer-events: none; }

/* Monatsgrenzen in der Trefferliste. */
.month-sep {
  grid-column: 1 / -1;
  margin: 18px 0 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

.month-sep:first-child { margin-top: 0; }

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 80px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-date { font-size: 13px; font-weight: 600; color: var(--accent); }

.badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.card h3 { margin: 0; font-size: 15px; line-height: 1.35; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.tag--src { background: var(--accent-soft); border-color: #f6cfcf; color: #9b1c1c; }
.tag--nogeo { background: #fdf6e7; border-color: #f0d9a8; color: var(--warn); }

.card-links { display: flex; gap: 12px; font-size: 13px; }
.card-links a { color: var(--accent); text-decoration: none; }
.card-links a:hover { text-decoration: underline; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-soft);
}

.leaflet-popup-content { margin: 10px 12px; font: inherit; font-size: 13px; }
.leaflet-popup-content b { display: block; margin-bottom: 2px; }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { margin-left: 0; }
  .topbar { position: static; }
  .map { height: 300px; margin: 12px; }
  .results { padding: 12px; }
}

/* ── Fusszeile der Sidebar ─────────────────── */

.sidebar-footer {
  padding: 16px 20px 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.sidebar-footer a { color: var(--ink-soft); }
.sidebar-footer a:hover { color: var(--accent); }
.sidebar-footer .hint { margin-top: 8px; }

/* ── Impressum / Datenschutz ───────────────── */

.legal-page { background: var(--bg); }

.legal {
  max-width: 44rem;
  margin: 0 auto;
  padding: 32px 20px 64px;
  background: var(--panel);
  min-height: 100vh;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.legal h1 { font-size: 24px; letter-spacing: -.01em; margin: 0 0 24px; }
.legal h2 { font-size: 16px; margin: 28px 0 6px; }
.legal p { margin: 0 0 12px; }
.legal code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.legal-back { margin-bottom: 20px; font-size: 13px; }
.legal-back a { color: var(--ink-soft); text-decoration: none; }
.legal-back a:hover { color: var(--accent); }

/* Platzhalter sollen ins Auge springen, solange sie nicht ersetzt sind. */
.legal mark {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

.legal-todo {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--ink);
}

/* ── Dunkles Farbschema ────────────────────── */
/* Nur Variablen und die paar hart codierten Weiss-Toene - der Rest der
   Oberflaeche faerbt sich ueber die Variablen von selbst. Die Karte bleibt
   hell (die OSM-Kacheln sind hell), Popups bleiben also auch hell. */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1d2129;
    --line: #2e343e;
    --ink: #e7eaee;
    --ink-soft: #98a2ae;
    --accent: #f05a52;
    --accent-soft: #40201f;
    --topbar-bg: rgba(20, 23, 28, .92);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .35);
  }

  /* Hart codierte Hellwerte aus dem hellen Schema. */
  .input,
  .btn { background: var(--panel); }
  .chip { color: var(--ink-soft); }
  .btn:hover:not(:disabled),
  .chip:hover { border-color: #4a5260; }
  .log { background: #10151b; }

  /* Warntoene: das helle Creme wuerde im Dunkeln grellen. */
  .notice {
    background: #33270e;
    border-color: #5c4715;
    color: #e0b45f;
  }
  .tag--nogeo {
    background: #33270e;
    border-color: #5c4715;
    color: #e0b45f;
  }
  .tag--src {
    background: var(--accent-soft);
    border-color: #55302f;
    color: #eda49e;
  }
}
