:root {
  --bg: #f7f5f0;
  --panel: #ffffff;
  --ink: #1d1d1b;
  --muted: #5f5b53;
  --line: #e2ddd3;
  --accent: #0b4f6c;
  --chip: #f0ece4;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; background: var(--bg); }

body {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: 100vh;
}

#panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px 20px 32px;
}

#map { height: 100%; width: 100%; }
.leaflet-container { background: #dce7ea; }

.kicker { margin: 0; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 4px 0 0; font-size: 26px; line-height: 1.15; }
.sub { margin: 2px 0 12px; color: var(--muted); }
.intro { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 8px; }
section { border-top: 1px solid var(--line); }
code { font-size: 12px; background: var(--chip); padding: 1px 4px; border-radius: 3px; overflow-wrap: anywhere; }
#panel, #map { min-width: 0; }
#panel { overflow-wrap: break-word; }

.segments { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.segments button {
  width: 100%; display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center;
  text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 14px; color: inherit; cursor: pointer;
}
.segments button[aria-pressed="false"] { opacity: .45; }
.segments button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch { width: 22px; height: 4px; border-radius: 2px; }
.swatch.dashed { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px) !important; }
.seg-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.seg-label small { display: block; color: var(--muted); font-size: 12px; }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.stats dt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.stats dd { margin: 0; color: var(--muted); }

.records { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.records li { display: grid; grid-template-columns: 56px 1fr; gap: 8px; font-size: 13px; line-height: 1.35; }
.records li.noimg { grid-template-columns: 1fr; }
.records img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--chip); }
.records a { color: var(--accent); }
.records .meta { color: var(--muted); font-size: 12px; }
.lic { display: inline-block; font-size: 11px; background: var(--chip); border-radius: 3px; padding: 0 4px; }

.plain { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); }
details summary { cursor: pointer; font-size: 14px; margin-top: 14px; }
.generated { font-size: 12px; color: var(--muted); }

/* popups */
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.4; width: 300px; }
.pop h3 { margin: 0; font-size: 16px; }
.pop .where { color: var(--muted); margin: 2px 0 8px; }
.pop .names { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.pop .name { background: var(--chip); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.pop .name.attested { background: #dcebf2; font-weight: 600; }
.pop h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pop .records { max-height: 220px; overflow-y: auto; }
.pop .links a { margin-right: 8px; }
.pop .caveat { font-size: 11px; color: var(--muted); margin-top: 6px; }

@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 60vh auto; height: auto; }
  .segments button { grid-template-columns: 22px minmax(0, 1fr); }
  .seg-meta { grid-column: 2; white-space: normal; }
  #map { order: 1; height: 60vh; }
  #panel { order: 2; border-right: 0; border-top: 1px solid var(--line); padding: 16px; }
  .leaflet-popup-content { width: 240px !important; }
}
