:root {
  --night: #1b1410;
  --paper: #fff8ec;
  --ink: #2a1d14;
  --muted: #7a6a5c;
  --glow: #ffb547;
  --ember: #e8701a;
  --line: rgba(255, 200, 120, .25);
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  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(--night); }
body { display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  position: relative; z-index: 3;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--night); color: var(--paper); border-bottom: 1px solid var(--line);
}
.title h1 { margin: 0; font-size: 1.05rem; letter-spacing: .01em; }
.title p { margin: 2px 0 8px; font-size: .82rem; color: #e9d8c2; }

.search { display: flex; gap: 6px; }
.search input {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; font: inherit; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px; background: #2b2019; color: var(--paper);
}
.search input::placeholder { color: #b8a490; }
.search button {
  min-height: 44px; padding: 0 16px; font: inherit; font-weight: 600; border: 0; border-radius: 10px;
  background: var(--glow); color: var(--night); cursor: pointer;
}

.results {
  list-style: none; margin: 8px 0 0; padding: 0; max-height: 40vh; overflow-y: auto;
  background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow);
}
.results li { border-bottom: 1px solid #efe3d2; }
.results li:last-child { border-bottom: 0; }
.results button {
  display: flex; width: 100%; gap: 10px; align-items: center; min-height: 52px; padding: 8px 12px;
  border: 0; background: none; font: inherit; text-align: left; cursor: pointer;
}
.results .rank { font-weight: 700; color: var(--ember); min-width: 1.4em; }
.results .what { flex: 1; }
.results .what small { display: block; color: var(--muted); }
.results .note { padding: 10px 12px; font-size: .9rem; color: var(--muted); }

#map { flex: 1; min-height: 0; }

.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  max-height: 65vh; overflow-y: auto;
  background: var(--paper); border-radius: 14px 14px 0 0; box-shadow: var(--shadow);
  padding: 0 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.panel-toggle {
  display: block; width: 100%; min-height: 48px; border: 0; background: none;
  font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.panel-toggle::after { content: "▴"; float: right; }
.panel-toggle[aria-expanded="true"]::after { content: "▾"; }

.legend { list-style: none; margin: 0 0 8px; padding: 0; font-size: .88rem; }
.legend li { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.glow { width: 22px; height: 22px; border-radius: 50%; flex: none;
        background: radial-gradient(circle, #fff3c4 0%, #ffb547 40%, rgba(232, 112, 26, .5) 70%, transparent 72%); }
.seen-dot { width: 18px; height: 18px; border-radius: 50%; flex: none; margin: 0 2px;
            background: #ffe14d; border: 3px solid #e8701a; }
.glow-potentie { width: 22px; height: 22px; border-radius: 50%; flex: none;
                 background: radial-gradient(circle, rgba(235,225,210,.9) 0%, rgba(190,170,150,.5) 50%, transparent 72%); }
.legend .legend-head { font-weight: 700; margin: 10px 0 2px; }
.layers { border: 0; padding: 0; margin: 4px 0 8px; font-size: .9rem; }
.layers legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
.layers label { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.layers input { width: 20px; height: 20px; accent-color: var(--ember); }

.about { font-size: .86rem; line-height: 1.5; border-top: 1px solid #efe3d2; padding-top: 4px; }
.about summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.about h3 { font-size: .9rem; margin: 10px 0 2px; }
.about p, .about ul { margin: 4px 0; }
.about ul { padding-left: 18px; }

.maplibregl-popup-content { font: inherit; font-size: .9rem; line-height: 1.4; padding: 12px 14px; border-radius: 12px; max-width: 280px; }
.pop-title { font-weight: 700; }
.pop-sub { color: var(--muted); font-size: .82rem; margin-bottom: 6px; }
.pop-klasse { display: inline-block; font-weight: 700; padding: 2px 10px; border-radius: 999px; margin: 2px 0 6px; }
.pop-klasse.topstraat { background: #ffb547; color: var(--night); }
.pop-klasse.goed { background: #ffe0a8; color: var(--night); }
.pop-klasse.matig { background: #eee3d6; color: var(--ink); }
.pop-row { margin: 3px 0; }
.pop-sources { margin: 6px 0 0; padding-left: 18px; }
.pop-sources li { margin: 3px 0; }
.pop-potentie { color: var(--muted); font-style: italic; }
.pop-status { color: #8a4b12; font-size: .82rem; margin-top: 4px; }
.pop-klasse.potentie { background: #e7e1d8; color: var(--muted); }
.pop-year { font-size: 1.25rem; font-weight: 800; color: var(--ember); line-height: 1.1; margin-bottom: 2px; }
.pop-old { display: inline-block; vertical-align: middle; font-size: .72rem; font-weight: 700; color: #fff;
           background: #9a8a7a; border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.pop-note { color: var(--muted); font-size: .8rem; margin-top: 6px; }

@media (min-width: 720px) {
  .topbar { display: grid; grid-template-columns: 1fr minmax(280px, 420px); gap: 16px; align-items: center; }
  .title p { margin-bottom: 0; }
  .results { position: absolute; right: 16px; top: 100%; width: min(420px, calc(100vw - 32px)); }
  .panel { left: 12px; right: auto; bottom: 12px; width: 340px; border-radius: 12px; max-height: calc(100vh - 110px); }
}
