:root {
  --green: #1f4d3a;
  --green-2: #2f6b52;
  --green-soft: #e3efe8;
  --sand: #f6f2ea;
  --ink: #1d2420;
  --muted: #6b746f;
  --line: #e2ddd2;
  --accent: #e07a3f;
  --white: #fff;
  --radius: 12px;
  --panel-w: 400px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--sand); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--green); color: var(--white);
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; background: none; border: 0; color: inherit; padding: 0; }
.d-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.d-actions .cta { margin: 0; }
.cta-2 { background: var(--white) !important; color: var(--green) !important; border: 1.5px solid var(--green); }
.gewaehlt { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--white); background: var(--accent); border-radius: 999px; padding: 1px 7px; }
#q {
  flex: 1; max-width: 420px; height: 38px; border: 0; border-radius: 999px;
  padding: 0 16px; font: inherit; background: rgba(255,255,255,.95);
}
/* Impressum/Datenschutz unten im Filterbereich */
.app-fuss { margin: 24px 0 8px; font-size: 13px; color: var(--muted, #667); text-align: center; }
.app-fuss a { color: inherit; }
/* Sprachumschalter DE/EN rechts in der Kopfzeile */
.lang-btn {
  margin-left: auto; flex: none; height: 32px; min-width: 40px; padding: 0 8px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.6); background: transparent; color: var(--white); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}

main { position: relative; height: calc(100% - 56px); display: flex; }
#map { flex: 1; height: 100%; position: relative; }

/* Seitenleiste (Desktop) */
.panel {
  width: var(--panel-w); height: 100%; background: var(--white);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 500;
}
.sheet-handle { display: none; }
.count { font-weight: 600; }

.tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tabs button {
  flex: 1; padding: 12px; background: none; border: 0; border-bottom: 3px solid transparent;
  font-weight: 600; color: var(--muted);
}
.tabs button.active { color: var(--green); border-bottom-color: var(--green); }
.badge { background: var(--accent); color: var(--white); border-radius: 999px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }

.tab-body { flex: 1; overflow-y: auto; padding: 16px; }

.basics { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.basics label, .extra label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--ink); }
.link { background: none; border: 0; color: var(--green-2); text-decoration: underline; font-size: 13px; padding: 6px 0; }

.level { font-size: 16px; margin: 18px 0 10px; }
.level small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* Schnellfilter */
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.qf { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--white); text-align: left; font-size: 14px; font-weight: 600; }
.qf-ico { font-size: 20px; }
.qf-label { flex: 1; }
.qf .n { font-size: 11px; font-weight: 400; color: var(--muted); }
.qf.on { background: var(--green); border-color: var(--green); color: var(--white); }
.qf.on .n { color: rgba(255,255,255,.8); }
.qf.empty { opacity: .45; }

/* Ebene 1: Themen-Kacheln */
.layers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.layer {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--white); font-size: 12px; font-weight: 600;
}
.layer .ico { font-size: 22px; }
.layer { position: relative; }
/* gewählt, aber zugeklappt: dezent */
.layer.on { border-color: var(--green-2); background: var(--green-soft); color: var(--green); }
/* gerade aufgeklappt: kräftig */
.layer.on.focus { background: var(--green); border-color: var(--green); color: var(--white); box-shadow: 0 2px 8px rgba(31,77,58,.35); }
.layer .lz {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--white); font-size: 11px; line-height: 20px;
}

/* Ebene 2 + 3: geöffnetes Thema als eigene Karte, Gruppen als Zeilen, Einzelmerkmale als Chips */
.layer-block {
  margin-top: 14px; padding: 14px 12px 6px; background: var(--white);
  border: 1.5px solid var(--green); border-radius: 16px; box-shadow: 0 4px 14px rgba(31,77,58,.10);
  scroll-margin-top: 12px;
}
.layer-block h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; color: var(--green); }
.layer-block .hint { margin: 4px 0 12px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.layer-block .hint b { color: var(--ink); font-weight: 600; }
.extra { display: flex; gap: 12px; margin-bottom: 10px; }

.sub { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; background: var(--white); transition: border-color .15s; }
.sub.on { border-color: var(--green-2); }
.sub-head { display: flex; align-items: stretch; min-height: 48px; }
.sub-toggle {
  flex: 1; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 12px; background: var(--white); border: 0; font-weight: 600; font-size: 14.5px; color: var(--ink);
}
.sub-toggle .box {
  width: 20px; height: 20px; border: 2px solid #b9c2bd; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; color: var(--white); transition: background .15s, border-color .15s;
}
.sub.on .sub-toggle { background: var(--green-soft); color: var(--green); }
.sub.on .box { background: var(--green); border-color: var(--green); }
.sub-toggle .n {
  margin-left: auto; font-weight: 500; font-size: 12px; color: var(--muted);
  background: var(--sand); border-radius: 999px; padding: 2px 8px;
}
.sub.on .sub-toggle .n { background: var(--white); }
.sub-toggle .gewaehlt { font-size: 11px; font-weight: 700; color: var(--white); background: var(--accent); border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; white-space: nowrap; flex-shrink: 0; }
.sub-expand {
  display: flex; align-items: center; gap: 4px; border: 0; border-left: 1px solid var(--line);
  background: var(--white); padding: 0 12px; color: var(--green-2); font-size: 12.5px; font-weight: 600;
}
.sub-expand .chev { display: inline-block; transition: transform .2s; }
.sub-expand[aria-expanded="true"] { background: var(--sand); }
.sub-expand[aria-expanded="true"] .chev { transform: rotate(180deg); }
/* Einzelmerkmale: Zeilen mit Symbol, Name, Trefferzahl und Schalter (Entwurf A + C) */
.sub-fields { display: block; padding: 2px 0 2px; background: var(--white); border-top: 1px solid var(--line); }
.mz {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 12px 8px 14px;
  background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font-size: 14.5px; color: var(--ink);
}
.mz:last-child { border-bottom: 0; }
.mz-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; flex-shrink: 0; }
.sym { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mz-l { flex: 1; line-height: 1.3; }
.mz .n { font-size: 12px; color: var(--muted); }
.sw { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #cfd6d2; flex-shrink: 0; transition: background .18s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .18s; }
.mz.on .sw { background: var(--green); }
.mz.on .sw::after { left: 21px; }
.mz.on .mz-l { font-weight: 600; color: var(--green); }
.mz.empty { opacity: .45; }
.mz:active { background: var(--sand); }

.chip {
  border: 1.5px solid var(--line); background: var(--white); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; color: var(--ink);
}
.chip .n { color: var(--muted); font-size: 11px; }
.chip .ck { font-weight: 700; }
.chip.on { background: var(--green); border-color: var(--green); color: var(--white); }
.chip.on .n { color: rgba(255,255,255,.75); }
.chip.empty { opacity: .45; }

/* Sofortige Rückmeldung beim Antippen (bevor neu gerechnet ist) */
.layer.pending, .qf.pending, .chip.pending, .sub-toggle.pending { outline: 3px solid var(--accent); outline-offset: -3px; }
.layer:active, .qf:active, .chip:active, .sub-toggle:active, .sub-expand:active { transform: scale(.97); }

/* Ergebnisliste */
.results { list-style: none; margin: 0; padding: 0; }
.results li { border-bottom: 1px solid var(--line); }
.results button {
  width: 100%; text-align: left; background: none; border: 0; padding: 12px 4px;
  display: grid; gap: 3px;
}
.results button:hover { background: var(--sand); }
.r-name { font-weight: 600; }
.r-meta { font-size: 13px; color: var(--muted); }
.r-tags { font-size: 12px; color: var(--green-2); }
.near-head { margin-top: 14px; padding: 10px 4px 6px; font-weight: 700; color: var(--accent); border-bottom: 2px solid var(--accent) !important; display: grid; gap: 2px; }
.near-head span { font-weight: 400; font-size: 12px; color: var(--muted); }
.near .r-score { font-size: 12px; font-weight: 600; color: var(--accent); }
.near .r-miss { font-size: 12px; color: var(--muted); }
.near .r-miss b { color: #a33a2c; font-weight: 600; }
.pin.near { background: var(--white); border: 3px solid var(--accent); width: 13px; height: 13px; }
.layer-block.collapsed { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.lb-head { flex: 1; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 10px 12px; font-weight: 700; font-size: 14px; text-align: left; }
.lb-n { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.lb-chev { color: var(--muted); font-size: 12px; }
.lb-x { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 6px 10px; }
.lb-x:hover { color: #a33a2c; }
.lb-top { display: flex; align-items: center; justify-content: space-between; }
.lb-top h3 { margin: 0; }
.more { text-align: center; padding: 14px; color: var(--muted); font-size: 13px; }

/* Detailansicht */
.back { background: none; border: 0; color: var(--green-2); padding: 0 0 12px; font-weight: 600; }
.d-name { margin: 0 0 4px; font-size: 21px; }
.d-meta { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.cta {
  display: block; text-align: center; background: var(--accent); color: var(--white); text-decoration: none;
  font-weight: 700; padding: 12px; border-radius: var(--radius); margin-bottom: 16px;
}
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.fact { background: var(--sand); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.d-layer { margin-bottom: 14px; }
.d-layer h4 { margin: 0 0 6px; font-size: 14px; }
.d-layer .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.d-layer .chip.match { background: var(--green); color: var(--white); border-color: var(--green); }
.belege { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.belege li { display: grid; gap: 2px; border-left: 3px solid var(--green-soft); padding-left: 8px; }
.belege li.match { border-left-color: var(--green); }
.belege li.nein { border-left-color: #f2c4bd; }
.belege li.nein .b-name { color: #a33a2c; }
.b-name { font-size: 14px; font-weight: 600; }
.b-name em { font-weight: 400; color: var(--muted); }
.b-zitat { font-size: 12px; color: var(--muted); }
.b-zitat a { color: var(--green-2); white-space: nowrap; }
.note { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

/* Karte */
.pin { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--white); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.pin.sel { width: 22px; height: 22px; background: var(--green); }
.marker-cluster { background: rgba(31,77,58,.25); border-radius: 50%; }
.marker-cluster div {
  width: 30px; height: 30px; margin: 5px; border-radius: 50%; background: var(--green);
  color: var(--white); font-weight: 700; font-size: 12px; display: grid; place-items: center;
}

/* Kurzübersicht beim Platz */
.blick, .passt { margin-top: 12px; }
.blick h4, .passt h4 { margin: 0 0 6px; font-size: 14px; }
.blick-liste { display: flex; flex-wrap: wrap; gap: 6px; }
.blick-item { background: var(--green-soft); color: var(--green); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.passt ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 14px; }
.passt li.ja { color: var(--green); }
.passt li.nein { color: #a33a2c; }
.alle { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.alle > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--green-2); padding: 4px 0; }
.alle[open] > summary { margin-bottom: 8px; }

/* WLAN & Handynetz */
.netz { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.netz h4 { margin: 0 0 8px; font-size: 14px; }
.netz-liste { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.netz-n, .netz-hinweis { color: var(--muted); font-size: 12px; }
.netz-leer { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.nf-manuell summary { cursor: pointer; font-size: 13px; color: var(--green-2); }
.nf-werte { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.nf-werte input { font: inherit; padding: 6px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }
.netz-status { font-size: 13px; font-weight: 600; color: var(--green); margin: 0; min-height: 1em; }

/* Fehler melden */
.b-melden { margin-left: 6px; background: none; border: 0; padding: 0 2px; font-size: 11px; color: var(--muted); text-decoration: underline; font-weight: 400; }
.report { margin-top: 14px; }
.report-btn { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); }
.report-form { display: grid; gap: 10px; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sand); }
.report-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.report-form small { font-weight: 400; }
.report-form textarea { font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.report-form select { max-width: 100%; }
.rf-actions { display: flex; align-items: center; gap: 12px; }
.rf-actions .cta { border: 0; }
.report-ok { color: var(--green); font-weight: 600; }

/* Standort-Knopf auf der Karte */
.locate-btn {
  width: 34px; height: 34px; border: 2px solid rgba(0,0,0,.2); border-radius: 4px; background: var(--white);
  font-size: 17px; line-height: 1; padding: 0; background-clip: padding-box;
}
.locate-btn.busy { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* Hinweiszeilen über der Ergebnisliste */
.results .geo-hint button { color: var(--green-2); font-weight: 600; }
.results .sort-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--muted); background: var(--green-soft); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px;
}
.results .sort-hint b { white-space: nowrap; }
.results .sort-hint button { background: none; border: 0; padding: 2px 6px; font-size: 14px; }

/* Kurze Meldung unten */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--white); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

/* Handy: Seitenleiste wird zum Bottom-Sheet über der Karte */
@media (max-width: 767px) {
  .topbar { gap: 10px; }
  .brand { font-size: 0; }
  .brand::first-letter { font-size: 22px; }
  main { display: block; }
  #map { position: absolute; inset: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 72%;
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 16px rgba(0,0,0,.15);
    transition: height .25s ease;
  }
  .panel.collapsed { height: 64px; }
  .panel.collapsed .tabs, .panel.collapsed .tab-body { display: none; }
  .sheet-handle {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: none; border: 0; padding: 8px 16px 10px; flex-shrink: 0;
  }
  .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
  .layers { grid-template-columns: repeat(4, 1fr); }
  .tab-body { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
}
