:root {
  --bg: #1a1c1a;
  --bg-deep: #121412;
  --panel: #242724;
  --panel-border: #353a34;
  --line: #3a4038;
  --text: #d8dbd4;
  --muted: #8b9286;
  --olive: #7a8f5a;
  --olive-dim: #5c6b45;
  --amber: #c4a35a;
  --amber-dim: #8a7340;
  --danger: #b86a4a;
  --focus: #9aaf72;
  --mono: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
  --sans: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--sans);
}

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  min-height: 100vh;
}

#topbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--panel-border);
  z-index: 5;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.9rem;
  min-width: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 9rem;
  flex-shrink: 0;
}

.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--olive);
  font-size: 0.95rem;
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--muted);
}

.warning {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--amber);
  border-left: 2px solid var(--amber-dim);
  padding-left: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coords {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  min-width: 12.5rem;
  text-align: right;
  flex-shrink: 0;
}

#map-shell {
  position: relative;
  overflow: hidden;
  background: #0e100e;
  cursor: grab;
  min-height: 0;
}

#map-shell.dragging {
  cursor: grabbing;
}

#terrain,
#markers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#markers {
  pointer-events: none;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(4px);
}

#controls {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem;
  z-index: 6;
  border-radius: 4px;
  width: 11.5rem;
  max-height: calc(100% - 1.7rem);
  overflow-y: auto;
  pointer-events: auto;
}

#controls button {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.05rem;
  line-height: 1;
  height: 2rem;
  border-radius: 3px;
  cursor: pointer;
}

#controls button:hover,
#controls button:focus-visible {
  border-color: var(--olive);
  color: var(--olive);
  outline: none;
}

#controls button.active {
  border-color: var(--olive);
  color: var(--bg-deep);
  background: var(--olive);
}

.measure-hud {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--text);
  line-height: 1.4;
}

.measure-hud.hidden {
  display: none;
}

.measure-hud-title {
  color: var(--olive);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.measure-hud-body {
  color: var(--muted);
  word-break: break-word;
}

#map-shell.measure-mode {
  cursor: crosshair;
}

.layer-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
  cursor: pointer;
  user-select: none;
}

.layer-toggles .toggle {
  margin-top: 0;
}

.toggle input {
  accent-color: var(--olive);
}

.meta {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--muted);
  padding: 0.15rem 0.1rem 0;
  line-height: 1.35;
  word-break: break-word;
}

#search {
  position: relative;
  flex: 0 1 22rem;
  min-width: 12rem;
  max-width: 24rem;
  z-index: 6;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

#search-input {
  flex: 1;
  min-width: 0;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.76rem;
  padding: 0.38rem 0.5rem;
  border-radius: 3px;
  outline: none;
}

#search-input:focus {
  border-color: var(--olive);
}

#search-input::placeholder {
  color: var(--muted);
}

#search-clear {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

#search-clear:hover,
#search-clear:focus-visible {
  border-color: var(--olive);
  color: var(--olive);
  outline: none;
}

.search-status {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  margin: 0;
  padding: 0.28rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  pointer-events: none;
  z-index: 7;
}

.search-status:empty {
  display: none;
}

.search-status.empty {
  color: #c9a27a;
}

.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  list-style: none;
  margin: 0;
  padding: 0.2rem 0;
  max-height: min(18rem, 46vh);
  overflow: auto;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 8;
}

.search-results[hidden] {
  display: none;
}

#search:has(.search-results:not([hidden])) .search-status {
  display: none;
}

.search-results li {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.search-results button {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0.42rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.35;
}

.search-results button:hover,
.search-results button:focus-visible,
.search-results button.active {
  background: rgba(140, 158, 90, 0.12);
  color: var(--olive);
  outline: none;
}

.search-results .sr-class {
  display: block;
  word-break: break-word;
}

.search-results .sr-meta {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  margin-top: 0.12rem;
}

.search-results .sr-kind {
  display: inline-block;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--olive);
  margin-bottom: 0.1rem;
}

.search-results .sr-kind.hazard {
  color: #c9a27a;
}

.search-results .sr-kind.ce {
  color: #b8a46a;
}

.search-results .sr-kind.asset {
  color: #7ad0ff;
}

.search-results .sr-kind.loc {
  color: #e4d7a8;
}

.search-section-label {
  margin: 0.35rem 0 0.15rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.info-confidence {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  vertical-align: middle;
}

.info-confidence.high {
  border-color: rgba(140, 158, 90, 0.55);
  color: var(--olive);
}

.info-confidence.medium {
  border-color: rgba(201, 162, 122, 0.55);
  color: #c9a27a;
}

.filters-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  border-top: 1px solid var(--panel-border);
  background: color-mix(in srgb, var(--bg) 88%, var(--panel));
  min-height: 0;
}

.filter-block {
  flex: 1 1 10rem;
  min-width: 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.filter-block:last-child {
  border-right: none;
}

.filter-block:not(.collapsed) {
  flex: 1 1 100%;
  background: rgba(0, 0, 0, 0.14);
  border-right: none;
  border-top: 1px solid var(--line);
}

.filter-toggle {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.42rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
}

.filter-toggle:hover,
.filter-toggle:focus-visible {
  background: rgba(122, 143, 90, 0.1);
  outline: none;
}

.filter-block:not(.collapsed) .filter-toggle {
  background: rgba(122, 143, 90, 0.08);
}

.filter-chevron {
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-top: -0.08rem;
}

.filter-block:not(.collapsed) .filter-chevron {
  transform: rotate(45deg);
  border-color: var(--olive);
}

.filter-title {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--olive);
}

.filter-match {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  justify-self: end;
  max-width: 8.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-match.active {
  color: var(--olive);
}

.filter-match.empty {
  color: #c9a27a;
}

.filter-body {
  padding: 0 0.75rem 0.65rem 1.45rem;
  max-height: min(28vh, 14rem);
  overflow: auto;
}

.filter-block.collapsed .filter-body,
.filter-body[hidden] {
  display: none;
}

.filter-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.3rem;
}

.filter-clear {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.68rem;
  cursor: pointer;
  padding: 0.12rem 0.35rem;
  border-radius: 3px;
}

.filter-clear:hover,
.filter-clear:focus-visible {
  color: var(--olive);
  border-color: var(--line);
  outline: none;
}

.filter-clear:disabled {
  opacity: 0.35;
  cursor: default;
  border-color: transparent;
}

.filter-section {
  margin-top: 0.4rem;
}

.filter-section-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-bottom: 0.28rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.26rem;
}

.filter-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.64rem;
  line-height: 1.2;
  padding: 0.2rem 0.38rem;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 0.26rem;
}

.filter-chip .chip-count {
  color: var(--muted);
  font-size: 0.58rem;
}

.filter-chip:hover,
.filter-chip:focus-visible {
  border-color: var(--olive);
  outline: none;
}

.filter-chip.active {
  border-color: var(--olive);
  background: rgba(140, 158, 90, 0.18);
  color: var(--olive);
}

.filter-chip.active .chip-count {
  color: rgba(140, 158, 90, 0.85);
}

.filter-chip.dimmed:not(.active) {
  opacity: 0.45;
}

#info {
  position: absolute;
  top: auto;
  bottom: 0.85rem;
  right: 0.85rem;
  width: min(22rem, calc(100% - 1.7rem));
  max-height: min(58vh, calc(100% - 1.7rem));
  overflow: auto;
  z-index: 4;
  border-radius: 4px;
  padding: 0.75rem 0.85rem 0.9rem;
}

@media (max-width: 640px) {
  #info {
    bottom: 0.55rem;
    right: 0.55rem;
    left: 0.55rem;
    width: auto;
    max-height: 32vh;
  }

  .search-results {
    max-height: 18vh;
  }

  .filter-block {
    flex-basis: 50%;
  }
}

#info.hidden {
  display: none;
}

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.info-head h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--olive);
}

.info-preview {
  margin: 0 0 0.55rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: #0c0e0c;
  max-width: 9.5rem;
}

.info-preview.hidden {
  display: none;
}

.info-preview img {
  display: block;
  width: 100%;
  max-height: 9rem;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  image-rendering: auto;
  background: #161816;
  padding: 0.25rem;
  box-sizing: border-box;
}

.info-preview figcaption {
  margin: 0;
  padding: 0.2rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btn-close-info {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}

#btn-close-info:hover {
  color: var(--text);
}

#info-body {
  margin: 0;
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

#info-body dt {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

#info-body dd {
  margin: 0;
  font-family: var(--mono);
  word-break: break-word;
  color: var(--text);
}

.hover-preview {
  position: absolute;
  z-index: 1100;
  pointer-events: none;
  width: 120px;
  height: 90px;
  padding: 0;
  border: 1px solid #000;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.85);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hover-preview.hidden {
  display: none;
}

.hover-preview.label-only {
  width: auto;
  height: auto;
  max-width: 14rem;
  padding: 0.28rem 0.45rem;
  border: 1px solid rgba(145, 120, 70, 0.65);
  background: rgba(15, 15, 15, 0.92);
}

.hover-preview.label-only .hover-preview-label {
  position: static;
  padding: 0;
  background: none;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
}

.hover-preview img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: transparent;
}

.hover-preview-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.12rem 0.2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-transform: capitalize;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  word-break: break-word;
}

.info-note {
  margin: 0.75rem 0 0;
  font-size: 0.72rem;
  color: var(--amber-dim);
  line-height: 1.35;
}

.building-loot {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.building-loot.hidden {
  display: none;
}

.building-loot__heading {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--olive);
}

.building-loot__disclaimer {
  margin: 0 0 0.65rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line));
  border-radius: 3px;
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--text);
  font-size: 0.68rem;
  line-height: 1.4;
}

.building-loot__status,
.building-loot__unavailable {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.building-loot__unavailable code,
.building-loot__meta code {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  word-break: break-all;
}

.building-loot__meta {
  margin: 0 0 0.55rem;
  display: grid;
  grid-template-columns: 6.4rem 1fr;
  gap: 0.28rem 0.45rem;
  font-size: 0.74rem;
}

.building-loot__meta--compact {
  margin-bottom: 0.35rem;
}

.building-loot__meta dt {
  margin: 0;
  color: var(--muted);
}

.building-loot__meta dd {
  margin: 0;
  color: var(--text);
}

.building-loot__na {
  color: var(--muted);
  font-style: italic;
}

.building-loot__chip {
  display: inline-block;
  margin: 0.08rem 0.2rem 0.08rem 0;
  padding: 0.05rem 0.3rem;
  border-radius: 2px;
  background: rgba(165, 168, 117, 0.14);
  color: var(--olive);
  font-size: 0.66rem;
  font-weight: 600;
}

.building-loot__containers {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.building-loot__container {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: color-mix(in srgb, var(--panel) 88%, #000);
}

.building-loot__container-title {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text);
}

.building-loot__browse {
  display: inline-block;
  margin-top: 0.15rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--olive);
  border-radius: 3px;
  color: var(--olive);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
}

.building-loot__browse:hover,
.building-loot__browse:focus-visible {
  background: rgba(165, 168, 117, 0.14);
  outline: none;
}

.building-loot__browse-note {
  margin: 0.35rem 0 0;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 640px) {
  #info {
    max-height: 42vh;
  }
}

.loading {
  position: absolute;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.75rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  z-index: 3;
  font-size: 0.75rem;
  color: var(--muted);
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid var(--panel-border);
  border-top-color: var(--olive);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#status {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.9rem;
  background: var(--bg);
  border-top: 1px solid var(--panel-border);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

#status-hint {
  margin-left: auto;
  color: #6d7468;
}

@media (max-width: 960px) {
  .topbar-main {
    flex-wrap: wrap;
    gap: 0.55rem 0.75rem;
  }

  .warning {
    order: 4;
    flex-basis: 100%;
    border-left: none;
    border-top: 1px solid var(--amber-dim);
    padding: 0.35rem 0 0;
    white-space: normal;
  }

  #search {
    flex: 1 1 14rem;
    max-width: none;
    order: 2;
  }

  .coords {
    min-width: 0;
    text-align: left;
    order: 3;
  }

  #status-hint {
    margin-left: 0;
  }
}

/* —— UX Phase 1: presets, groups, legend —— */
#controls {
  width: 11.5rem;
  max-height: calc(100% - 1.7rem);
  overflow-y: auto;
}

.layer-presets {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.2rem;
}

.preset-btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--bg-deep);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
  height: 1.55rem;
  border-radius: 3px;
  cursor: pointer;
  padding: 0 0.35rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  position: relative;
}

.preset-btn input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.preset-btn:hover,
.preset-btn:focus-within {
  border-color: var(--olive);
  color: var(--olive);
  outline: none;
}

.preset-btn:has(input:checked),
.preset-btn.active {
  border-color: var(--olive);
  color: var(--bg-deep);
  background: var(--olive);
}

.layer-group {
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.1rem 0 0.15rem;
}

.layer-group + .layer-group {
  border-top: 1px solid var(--line);
  margin-top: 0.15rem;
  padding-top: 0.2rem;
}

.layer-group > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--olive);
  padding: 0.15rem 0.1rem;
  user-select: none;
}

.layer-group > summary::-webkit-details-marker {
  display: none;
}

.layer-group > summary::before {
  content: "";
  display: inline-block;
  width: 0.35rem;
  height: 0.35rem;
  margin-right: 0.35rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  vertical-align: 0.1rem;
}

.layer-group[open] > summary::before {
  transform: rotate(45deg);
  border-color: var(--olive);
  vertical-align: 0.2rem;
}

.map-legend {
  margin-top: 0.35rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--line);
}

.map-legend > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber);
  padding: 0.1rem;
  user-select: none;
}

.map-legend > summary::-webkit-details-marker {
  display: none;
}

.legend-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.64rem;
  color: var(--muted);
  line-height: 1.2;
}

.legend-list .legend-note {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.58rem;
  color: var(--muted);
  opacity: 0.85;
  line-height: 1.35;
}

.lg {
  --c: #ddd;
  width: 0.85rem;
  height: 0.85rem;
  flex: 0 0 auto;
  position: relative;
  display: inline-block;
}

.lg-circle::before {
  content: "";
  position: absolute;
  inset: 0.12rem;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
}

.lg-square::before {
  content: "";
  position: absolute;
  inset: 0.15rem;
  background: var(--c);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
}

.lg-diamond::before {
  content: "";
  position: absolute;
  inset: 0.18rem;
  background: var(--c);
  transform: rotate(45deg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
}

.lg-tri::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.08rem;
  transform: translateX(-50%);
  border-left: 0.38rem solid transparent;
  border-right: 0.38rem solid transparent;
  border-bottom: 0.65rem solid var(--c);
  filter: drop-shadow(0 0 0.5px #000);
}

.lg-invtri::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0.08rem;
  transform: translateX(-50%);
  border-left: 0.38rem solid transparent;
  border-right: 0.38rem solid transparent;
  border-top: 0.65rem solid var(--c);
  filter: drop-shadow(0 0 0.5px #000);
}

.lg-star::before {
  content: "★";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c);
  font-size: 0.85rem;
  line-height: 1;
  text-shadow: 0 0 1px #000;
}

.lg-ring::before {
  content: "";
  position: absolute;
  inset: 0.1rem;
  border-radius: 50%;
  border: 2px solid var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.45);
}

.lg-chevron::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.12rem;
  width: 0.55rem;
  height: 0.55rem;
  border-left: 2px solid var(--c);
  border-top: 2px solid var(--c);
  transform: translateX(-50%) rotate(45deg);
  filter: drop-shadow(0 0 0.5px #000);
}

.lg-halo::before {
  content: "";
  position: absolute;
  inset: 0.05rem;
  border-radius: 50%;
  border: 1.5px solid var(--c);
  background: color-mix(in srgb, var(--c) 28%, transparent);
}

.lg-sqdot::before {
  content: "";
  position: absolute;
  inset: 0.25rem;
  background: var(--c);
}

.layer-reset-btn {
  appearance: none;
  border: 1px dashed var(--panel-border);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  height: 1.4rem;
  border-radius: 3px;
  cursor: pointer;
  padding: 0 0.35rem;
  text-align: left;
  margin: 0.15rem 0 0;
}

.layer-reset-btn:hover,
.layer-reset-btn:focus-visible {
  border-color: var(--olive);
  color: var(--olive);
  outline: none;
}

.legend-section {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--olive);
  opacity: 0.95;
}

.legend-section:first-child {
  margin-top: 0;
}

.lg-road {
  width: 1.05rem;
  height: 0.85rem;
}

.lg-road::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 0;
  border-top: 2px solid var(--c);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

.lg-road-major::before {
  border-top-width: 3px;
}

.lg-road-mid::before {
  border-top-width: 2px;
}

.lg-road-minor::before {
  border-top-width: 1.5px;
  opacity: 0.85;
}

