:root {
  --bg: #ffffff;
  --bg-soft: #f3f5f8;
  --text: #16202c;
  --muted: #5d6b7c;
  --line: #dfe4ea;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --spring: #1d4ed8;
  --fountain: #16a34a;
  --tap: #9333ea;
  --seasonal: #d97706;
  --no: #9ca3af;
  --warn: #b45309;
  --shadow: 0 2px 12px rgba(15, 30, 50, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b22;
    --bg-soft: #20262f;
    --text: #e6edf3;
    --muted: #9aa7b5;
    --line: #2f3742;
    --accent: #3b82f6;
    --warn: #f59e0b;
    --shadow: 0 2px 12px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

#map { position: absolute; inset: 0 0 0 360px; }

#panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 360px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px 10px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 2;
}

#panel > * { flex-shrink: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; }
h1 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 8px; }
h1 img { border-radius: 5px; }
.sub { margin: 2px 0 0; color: var(--muted); }
h2 { margin: 0; font-size: 15px; }

button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-soft); padding: 7px 12px; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { cursor: default; opacity: .6; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; padding: 10px; }
button.small { padding: 3px 9px; font-size: 13px; }
button.icon { border: 0; background: none; font-size: 22px; line-height: 1; padding: 2px 6px; }
#panel-close, #panel-open { display: none; }

.place { position: relative; }
#place {
  width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft);
}
#place-results {
  position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px 0;
  list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 5;
}
#place-results li { padding: 7px 11px; cursor: pointer; }
#place-results li:hover, #place-results li.active { background: var(--bg-soft); }
#place-results small { color: var(--muted); display: block; }

#status { margin: 0; min-height: 1.45em; color: var(--muted); }
#status.error { color: var(--warn); }

details { border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; }
summary { cursor: pointer; font-weight: 600; padding: 2px 0; }
details[open] summary { margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 6px 0; }
legend { color: var(--muted); padding: 0; margin-bottom: 2px; }
label.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
label.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-soft); }

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid transparent; }
.dot.spring { background: var(--spring); width: 14px; height: 14px; }
.dot.fountain { background: var(--fountain); }
.dot.tap { background: var(--tap); }
.dot.hollow { background: #fff; border-color: var(--spring); }
.dot.ring { border-color: var(--seasonal); background: transparent; }
.dot.no { background: var(--no); }
.dot.unknown { background: #fff; }
.dot.unknown.spring { border-color: var(--spring); }
.dot.unknown.fountain { border-color: var(--fountain); }
.dot.unknown.tap { border-color: var(--tap); }
.dot.notdrinkable { background: var(--no); }

#results { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.results-head { display: flex; justify-content: space-between; align-items: center; }
#list { list-style: none; margin: 0; padding: 0; }
#list li {
  display: flex; gap: 10px; align-items: center;
  padding: 7px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px;
}
#list li:hover { background: var(--bg-soft); }
#list .name { font-weight: 500; }
#list .meta { color: var(--muted); font-size: 12.5px; }
#list .more { color: var(--muted); padding: 8px 6px; cursor: default; }

#detail h2 { font-size: 18px; margin: 4px 0 2px; }
#detail .back { margin-bottom: 6px; }
#detail .kind { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge { border-radius: 999px; padding: 2px 9px; font-size: 12.5px; background: var(--bg-soft); border: 1px solid var(--line); }
.badge.yes { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge.no { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.desc { margin: 8px 0; white-space: pre-line; }
.coords { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.coords code { font-size: 13px; background: var(--bg-soft); padding: 4px 8px; border-radius: 6px; }
.nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.nav a, .nav button {
  display: block; text-align: center; text-decoration: none; color: var(--text);
  border: 1px solid var(--line); background: var(--bg-soft); border-radius: 8px; padding: 9px 6px; font-weight: 500;
}
.nav a.google { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0; }
table.tags { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tags td { border-top: 1px solid var(--line); padding: 3px 4px; vertical-align: top; word-break: break-word; }
table.tags td:first-child { color: var(--muted); white-space: nowrap; }

footer { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
footer p { margin: 6px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }

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

@media (max-width: 760px) {
  #map { left: 0; }
  #panel {
    width: min(360px, 90vw);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform .2s ease;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  body.panel-shown #panel { transform: none; }
  #panel-close { display: block; }
  #panel-open {
    display: block; position: absolute; z-index: 1;
    top: max(12px, env(safe-area-inset-top)); left: 12px;
    font-size: 18px; padding: 8px 12px; background: var(--bg); box-shadow: var(--shadow);
  }
}
