:root {
  --ink: #16181c;
  --ink-2: #555b66;
  --ink-3: #8a909b;
  --paper: #fbfaf7;
  --line: #e4e1da;
  --accent: #f5c400;
  --accent-ink: #141414;
  --sel: #d6336c;
  --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 8px 28px rgba(20, 20, 20, .12);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #f2efe9; color: var(--ink); font: 15px/1.45 var(--sans); }
#map { position: fixed; inset: 0; }

#panel {
  position: fixed; top: 16px; left: 16px; z-index: 5;
  width: 360px; max-height: calc(100% - 32px); overflow: auto;
  background: var(--paper); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 16px 18px 12px; }
.stamp {
  font: 600 13px/1 var(--mono); letter-spacing: .04em;
  background: var(--accent); color: var(--accent-ink);
  padding: 9px 8px; border-radius: 8px; transform: rotate(-4deg);
}
h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.sub { margin: 1px 0 0; color: var(--ink-2); font-size: 13px; }

.search { position: relative; display: flex; gap: 8px; padding: 0 18px 14px; }
#q {
  flex: 1; min-width: 0; font: 16px var(--sans); color: var(--ink);
  padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  outline: none; transition: border-color .15s;
}
#q:focus { border-color: var(--ink); }
#locate {
  flex: none; width: 44px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  color: var(--ink-2); cursor: pointer; display: grid; place-items: center;
}
#locate:hover { color: var(--ink); border-color: var(--ink-3); }
#locate.busy { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

#results {
  position: absolute; left: 18px; right: 18px; top: 50px; z-index: 3;
  list-style: none; margin: 0; padding: 4px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 340px; overflow: auto;
}
#results li { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
#results li[aria-selected="true"], #results li:hover { background: #f4f1ea; }
#results .p { font: 600 14px var(--mono); }
#results .o { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results .empty { color: var(--ink-3); cursor: default; }

#detail { padding: 4px 18px 16px; border-top: 1px solid var(--line); }
.plzbig { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
#d-plz { font: 600 40px/1 var(--mono); letter-spacing: .02em; }
#d-close { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 4px 8px; }
#d-close:hover { color: var(--ink); }
.ort { font-size: 17px; font-weight: 500; margin: 6px 0 12px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.facts div { background: #f4f1ea; border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font: 500 15px var(--mono); font-variant-numeric: tabular-nums; }
.neighbors h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 500; margin: 0 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  font: 500 13px var(--mono); padding: 5px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.chips button:hover { border-color: var(--ink); }
.linkbtn { margin-top: 14px; border: 0; background: none; padding: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font: 13px var(--sans); }

#intro { padding: 2px 18px 14px; color: var(--ink-2); font-size: 14px; }
#intro p { margin: 0 0 12px; }
.legend { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.legend button {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font: 600 13px var(--mono); color: var(--ink);
}
.legend button:hover { border-color: var(--ink); }
.legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.foot { margin-top: auto; padding: 12px 18px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.foot p { margin: 8px 0 0; }
.foot a { color: inherit; }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 13px; cursor: pointer; }

#hover {
  position: fixed; z-index: 4; pointer-events: none;
  background: var(--ink); color: #fff; padding: 5px 9px; border-radius: 7px;
  font-size: 13px; white-space: nowrap; transform: translate(12px, 12px);
}
#hover b { font: 600 13px var(--mono); margin-right: 6px; }

.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 640px) {
  #panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto;
    max-height: 58%; border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .brand { padding: 12px 16px 8px; }
  .search { padding: 0 16px 10px; }
  #results { left: 16px; right: 16px; }
  #detail, #intro, .foot { padding-left: 16px; padding-right: 16px; }
  #intro p { display: none; }
  #d-plz { font-size: 32px; }
  #hover { display: none; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 58%; }
  .maplibregl-ctrl-top-right { top: env(safe-area-inset-top); }
}
