:root {
  --ink: #241816;
  --burgundy: #6e2428;
  --burgundy-deep: #4c1518;
  --gold: #8d6a30;
  --paper: #f6f1e8;
  --panel: rgba(255, 252, 248, 0.96);
  --line: #e3d5c4;
  --muted: #6d5c52;
  --map: #d7e0e4;
  --shadow: 0 16px 40px rgba(36, 24, 22, 0.16);
  font-family: "Segoe UI", "Helvetica Neue", Ubuntu, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#map { position: absolute; inset: 0; background: var(--map); }

header {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 10px 12px 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.brand img { height: 42px; width: auto; }
.brand strong { display: block; font-size: 1.15rem; letter-spacing: 0.01em; }
.brand em { display: block; margin-top: 2px; font-style: normal; color: var(--muted); font-size: 0.78rem; line-height: 1.3; }

nav { display: flex; gap: 6px; flex: none; }
nav button, .tabs button, .actions button, .copy, .run {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
}
nav button.active, .tabs button.active {
  background: var(--burgundy);
  color: white;
}
nav button:not(.active):hover, .tabs button:not(.active):hover { background: #f3e6df; }

#panel-toggle, .actions button, .copy, .run {
  background: var(--burgundy);
  color: white;
}
#panel-toggle {
  position: absolute;
  z-index: 3;
  top: 92px;
  left: 28px;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  box-shadow: var(--shadow);
}
.actions button:hover, .copy:hover, .run:hover, #panel-toggle:hover { background: var(--burgundy-deep); }

#panel {
  position: absolute;
  z-index: 2;
  top: 92px;
  left: 14px;
  bottom: 14px;
  width: min(390px, calc(100vw - 28px));
  overflow: auto;
  padding: 18px 18px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
body.panel-hidden #panel { display: none; }
#panel h2 { margin: 0 0 6px; font-size: 1.25rem; }
#panel h3 { margin: 18px 0 8px; font-size: 0.92rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--burgundy); }
.lede, .hint, .credit { color: var(--muted); line-height: 1.45; }
.lede { margin-top: 0; }
#panel section { display: none; }
#panel section.active { display: block; }
label { display: block; margin: 12px 0; font-size: 0.92rem; }
label.check { display: flex; gap: 8px; align-items: center; }
input[type="range"], select, input[type="number"] { width: 100%; margin-top: 6px; }
select, input[type="number"] {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 8px;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #2a211c;
  color: #f6f1e8;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.45;
}
.meta-card, .query-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  background: white;
}
.meta-card strong, .query-card strong { display: block; }
.query-card p { margin: 6px 0; color: var(--muted); font-size: 0.88rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.maplibregl-ctrl-top-right { top: 86px; right: 8px; }
.maplibregl-ctrl-bottom-left { left: 8px; }
.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 860px) {
  header { flex-direction: column; align-items: stretch; top: 8px; left: 8px; right: 8px; }
  .brand em { display: none; }
  nav button { flex: 1; }
  #panel-toggle { top: auto; bottom: calc(42vh + 18px); left: 16px; }
  #panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 42vh;
  }
  body.panel-hidden #panel-toggle { bottom: 16px; }
}
