:root,
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4efe6;
  --muted: rgba(244, 239, 230, 0.62);
  --line: rgba(244, 239, 230, 0.12);
  --panel: rgba(10, 12, 16, 0.78);
  --gold: #e0b36a;
  --cream: #f4efe6;
  --bg: #07080b;
  --search-bg: rgba(255, 255, 255, 0.04);
  --legend-bg: rgba(10, 12, 16, 0.72);
  --popup-bg: rgba(12, 14, 18, 0.94);
  --card-hover: rgba(224, 179, 106, 0.08);
  --marker: #f4efe6;
  --marker-ring: rgba(244, 239, 230, 0.2);
  --marker-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  --active-glow: rgba(224, 179, 106, 0.4);
  --pin-label: #f4efe6;
  --pin-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

[data-theme="light"] {
  color-scheme: light;
  --ink: #1b1712;
  --muted: rgba(27, 23, 18, 0.58);
  --line: rgba(27, 23, 18, 0.12);
  --panel: rgba(255, 250, 242, 0.92);
  --gold: #b07a28;
  --cream: #f4efe6;
  --bg: #f3ece1;
  --search-bg: rgba(27, 23, 18, 0.05);
  --legend-bg: rgba(255, 250, 242, 0.9);
  --popup-bg: rgba(255, 250, 242, 0.96);
  --card-hover: rgba(176, 122, 40, 0.1);
  --marker: #1b1712;
  --marker-ring: rgba(27, 23, 18, 0.16);
  --marker-shadow: 0 8px 18px rgba(40, 28, 12, 0.18);
  --active-glow: rgba(176, 122, 40, 0.38);
  --pin-label: #1b1712;
  --pin-shadow: 0 1px 2px rgba(255, 250, 242, 0.9);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: Outfit, "Source Sans Pro", system-ui, sans-serif;
  letter-spacing: 0.01em;
}

.map-app {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  height: 100%;
}

.map-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(22px);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.map-panel__top { padding: 28px 24px 12px; }
.map-panel__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.map-home {
  color: var(--gold);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.map-home:hover { color: var(--ink); }
.map-theme {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -6px -8px -6px 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.map-theme:hover,
.map-theme:focus-visible {
  color: var(--gold);
  border-color: var(--gold);
  outline: none;
}
.map-theme svg {
  width: 16px;
  height: 16px;
  display: block;
}
.map-theme .icon-moon { display: none; }
[data-theme="light"] .map-theme .icon-sun { display: none; }
[data-theme="light"] .map-theme .icon-moon { display: block; }
h1 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  font-size: 32px;
  line-height: 1.1;
  margin: 14px 0 8px;
}
.map-lede {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.map-search input {
  width: 100%;
  background: var(--search-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.map-search input::placeholder { color: var(--muted); }
.map-search input:focus { border-color: var(--gold); }

.map-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.map-chips button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.map-chips button.is-on,
.map-chips button:hover {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}
.map-chips button.chip-home.is-on {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1408;
}

.map-list {
  overflow: auto;
  padding: 8px 12px 32px;
  min-height: 0;
}
.map-card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  color: inherit;
  padding: 14px 12px;
  cursor: pointer;
  font: inherit;
}
.map-card:hover, .map-card.is-active {
  background: var(--card-hover);
}
.map-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.map-card__count {
  flex: 0 0 auto;
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.02em;
  line-height: 1;
}
.map-card__ident {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.map-card__name {
  font-family: Fraunces, Georgia, serif;
  font-size: 18px;
  margin: 0 0 4px;
}
.map-card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.map-card__note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.map-stage { position: relative; }
#map { position: absolute; inset: 0; }
.map-legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 1;
  display: flex;
  gap: 14px;
  background: var(--legend-bg);
  backdrop-filter: blur(12px);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--marker);
  margin-right: 6px;
  box-shadow: 0 0 0 3px var(--marker-ring);
}
.dot.home {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(224, 179, 106, 0.28);
}
.dot.logbook {
  background: var(--marker);
  box-shadow: 0 0 0 3px var(--marker-ring);
}

.map-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
}
.map-pin__ident {
  order: -1;
  margin-bottom: 4px;
  font-family: Outfit, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pin-label);
  text-shadow: var(--pin-shadow);
  white-space: nowrap;
}
.map-pin.home .map-pin__ident { color: var(--gold); }
.map-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--marker);
  box-shadow: 0 0 0 4px var(--marker-ring), var(--marker-shadow);
}
.map-pin.home .map-marker {
  width: 16px;
  height: 16px;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(224, 179, 106, 0.28), var(--marker-shadow);
}
.map-pin.is-active .map-marker {
  transform: scale(1.25);
  box-shadow: 0 0 0 6px var(--active-glow), var(--marker-shadow);
}

.maplibregl-popup-content {
  background: var(--popup-bg) !important;
  color: var(--ink);
  border-radius: 12px !important;
  padding: 12px 14px !important;
  font-family: Outfit, sans-serif;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--popup-bg) !important; }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--popup-bg) !important; }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--popup-bg) !important; }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--popup-bg) !important; }
.popup-name { font-family: Fraunces, serif; font-size: 16px; margin: 0 0 4px; }
.popup-meta { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
.popup-blurb { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

@media (max-width: 860px) {
  html, body { height: auto; min-height: 100%; }
  .map-app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }
  .map-stage {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 3;
    height: 38vh;
    min-height: 220px;
    flex: 0 0 auto;
  }
  .map-panel {
    border-right: 0;
    height: auto;
    flex: 1 1 auto;
  }
  .map-panel__top { padding: 18px 18px 8px; }
  .map-lede { margin-bottom: 12px; }
  h1 { font-size: 24px; margin: 8px 0 8px; }
  .map-search input { font-size: 16px; }
  .map-chips {
    margin: 12px -18px 0;
    padding: 0 18px 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 8px;
  }
  .map-chips::-webkit-scrollbar { display: none; }
  .map-chips button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 12px;
  }
  .map-list {
    overflow: visible;
    padding-bottom: 56px;
  }
  .map-legend { left: 10px; bottom: 8px; font-size: 10px; padding: 6px 10px; }
  .maplibregl-ctrl-bottom-right {
    max-width: 52%;
    font-size: 9px;
  }
  .maplibregl-ctrl-top-right .maplibregl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
  }
}
