:root {
  --bg: #ffffff;
  --fg: #1d2421;
  --muted: #5f6b66;
  --line: #dde3e0;
  --accent: #1b5e20;
  --accent-soft: #e8f5e9;
  --c-abholung: #2e7d32;
  --c-sammelpunkt: #c0392b;
  --c-beides: #8e44ad;
  --c-unbekannt: #78909c;
  --shadow: 0 4px 18px rgba(0, 0, 0, .14);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: grid; grid-template-rows: auto 1fr; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Kopfzeile + Suche ---------- */
.topbar {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: relative; z-index: 3;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand h1 { font-size: 1.1rem; margin: 0; }
.brand p { margin: 0; font-size: .8rem; color: var(--muted); }

.search { position: relative; flex: 0 1 460px; display: flex; gap: 6px; }
.search input {
  flex: 1; font: inherit; font-size: 1rem; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); outline: none; min-width: 0;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-btn {
  flex: none; width: 44px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--accent); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--accent-soft); }

#suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 100px; margin: 0; padding: 4px;
  list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 50vh; overflow-y: auto;
}
#suggestions li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#suggestions li small { color: var(--muted); }
#suggestions li[aria-selected="true"], #suggestions li:hover { background: var(--accent-soft); }
#suggestions li.empty { color: var(--muted); cursor: default; background: none; }

/* ---------- Karte ---------- */
#map { position: relative; min-height: 0; }

.legend {
  position: fixed; left: 12px; bottom: 34px; z-index: 2;
  display: grid; gap: 4px; padding: 10px 12px; font-size: .8rem;
  background: rgba(255, 255, 255, .95); border-radius: var(--radius); box-shadow: var(--shadow);
}
.legend span { display: flex; align-items: center; gap: 8px; }
.sw { width: 14px; height: 14px; border-radius: 3px; border: 2px solid; display: inline-block; flex: none; }
.sw-abholung    { border-color: var(--c-abholung);    background: color-mix(in srgb, var(--c-abholung) 30%, transparent); }
.sw-sammelpunkt { border-color: var(--c-sammelpunkt); background: color-mix(in srgb, var(--c-sammelpunkt) 30%, transparent); }
.sw-beides      { border-color: var(--c-beides);      background: color-mix(in srgb, var(--c-beides) 30%, transparent); }
.sw-unbekannt   { border-color: var(--c-unbekannt);   background: color-mix(in srgb, var(--c-unbekannt) 30%, transparent); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 4px solid #b71c1c; display: inline-block; flex: none; }

.demo-banner {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 2;
  background: #fff8e1; border: 1px solid #ffe082; color: #6d4c00;
  padding: 6px 12px; border-radius: 999px; font-size: .8rem; box-shadow: var(--shadow); white-space: nowrap;
}
.footer { position: fixed; right: 12px; bottom: 30px; z-index: 2; font-size: .75rem; background: rgba(255,255,255,.9); padding: 3px 8px; border-radius: 6px; }
.footer a { color: var(--muted); }

/* ---------- Popup ---------- */
.maplibregl-popup-content { padding: 0; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.maplibregl-popup-close-button { font-size: 20px; width: 30px; height: 30px; color: #fff; }
.pop { width: min(330px, 80vw); font-size: .9rem; line-height: 1.4; }
.pop header { padding: 12px 36px 10px 14px; color: #fff; background: var(--accent); }
.pop header.art-abholung    { background: var(--c-abholung); }
.pop header.art-sammelpunkt { background: var(--c-sammelpunkt); }
.pop header.art-beides      { background: var(--c-beides); }
.pop header.art-unbekannt   { background: var(--c-unbekannt); }
.pop header small { display: block; opacity: .9; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.pop header h2 { margin: 2px 0 0; font-size: 1.1rem; }
.pop .addr { margin: 4px 0 0; font-size: .8rem; opacity: .95; }
.pop section { padding: 10px 14px; border-top: 1px solid var(--line); }
.pop section:first-of-type { border-top: 0; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; font-weight: 600; }
.pop h3 { margin: 0 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pop p { margin: 0 0 6px; }
.pop .iban, .pop .code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; background: #f4f6f5; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.pop .iban { user-select: all; }
.pop a.code { color: var(--fg); font-weight: 400; text-decoration: none; }
.pop .nowrap { white-space: nowrap; }
.pop .links { display: flex; gap: 12px; flex-wrap: wrap; }
.pop a { color: var(--accent); font-weight: 600; }
.pop .none { padding: 14px; }

/* ---------- Mobil ---------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 12px; }
  .brand p { display: none; }
  .search { flex: none; }
  .legend { bottom: 30px; font-size: .72rem; padding: 8px; }
  .demo-banner { top: auto; bottom: 150px; white-space: normal; width: calc(100% - 32px); text-align: center; border-radius: var(--radius); }
}

/* Popup darf nie höher als der sichtbare Kartenbereich werden */
.pop { max-height: 55vh; overflow-y: auto; }
.legend summary { cursor: pointer; font-weight: 700; list-style: none; }
.legend summary::-webkit-details-marker { display: none; }
.legend[open] summary { margin-bottom: 4px; }
.legend > div { display: grid; gap: 4px; }

@media (max-width: 640px) {
  .demo-banner { top: auto; bottom: auto; position: static; transform: none; width: auto; box-shadow: none; border-radius: 0; border-width: 0 0 1px; padding: 4px 12px; font-size: .72rem; }
  body { grid-template-rows: auto auto 1fr; }
  .pop { max-height: 48vh; }
}

/* ---------- Info-Fenster (zentriert) ---------- */
dialog.info {
  padding: 0; border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(600px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); overflow: hidden;
}
dialog.info::backdrop { background: rgba(20, 30, 25, .35); }
.info .pop { width: auto; max-height: calc(100dvh - 32px); overflow-y: auto; font-size: .95rem; }
.info .pop header { padding-right: 52px; }
.info-close {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; z-index: 1;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .18); color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer;
}
.info-close:hover, .info-close:focus-visible { background: rgba(255, 255, 255, .32); outline: 2px solid #fff; }

/* ---------- Begrüßung ---------- */
#help { font-weight: 700; font-size: 1.1rem; }
.welcome .pop header { background: var(--accent); }
.welcome .pop h2 { font-size: 1.2rem; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.steps li::before {
  content: counter(step); width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center;
}
.inline-icon { color: var(--accent); vertical-align: -3px; }
.welcome-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; color: var(--muted); }
.welcome-legend span { display: flex; align-items: center; gap: 6px; }
.welcome-actions { display: flex; gap: 8px; }
.welcome-actions button { flex: 1; font: inherit; font-weight: 600; padding: 11px 12px; border-radius: var(--radius); cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover { background: #2e7d32; }
.btn-secondary { background: var(--bg); color: var(--accent); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--accent-soft); }

/* Status + Sammelpunkt-Liste im Info-Fenster */
.pop .status { margin: 0; padding: 7px 14px; font-size: .8rem; background: #fff8e1; color: #6d4c00; border-bottom: 1px solid var(--line); }
.pop .status.ok { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pop .punkte { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pop .punkte li { padding-left: 22px; position: relative; }
.pop .punkte li::before { content: ''; position: absolute; left: 2px; top: 4px; width: 8px; height: 8px; border-radius: 50%; border: 3px solid #b71c1c; background: #fff; }
.pop .muted { color: var(--muted); }

/* Hinweis in der Begrüßung + Warnkasten für unklare Gebiete */
.welcome .notice { margin: 0; padding: 10px 14px; font-size: .85rem; background: #fff8e1; color: #6d4c00; border-top: 1px solid #ffe082; border-bottom: 1px solid #ffe082; }
.pop .warnung { margin: 10px 14px 4px; padding: 10px 12px; border: 2px solid #e65100; border-left-width: 6px; border-radius: 8px; background: #fff3e0; color: #4e2600; }
.pop .warnung strong { display: block; color: #bf360c; font-size: .95rem; margin-bottom: 4px; }
.pop .warnung p { margin: 0; }

/* Icons */
.ico { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.pop .icon-link { display: inline-flex; align-items: center; gap: 6px; }
.pop .icon-link .ico:last-child:not(:first-child) { width: 13px; height: 13px; opacity: .7; }
.pop .links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pop .addr .ico { width: 14px; height: 14px; vertical-align: -2px; }
