* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #000;
  color: #fff;
}
#map {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 240px;
  background: #000;
}
#panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  overflow: auto;
  background: #000;
  border-right: 1px solid #222;
  padding: 12px 12px 20px;
  z-index: 2;
}
#rail-toggle {
  display: none;
}

h1 {
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.api-chip {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid #222;
  color: #888;
  background: #000;
  line-height: 1.4;
}
.api-chip.live { color: #aaa; border-color: #333; }
.api-chip.offline { color: #888; border-color: #333; }

h2 {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin: 0 0 2px;
}
h3 {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin: 12px 0 6px;
}

.layers { margin: 6px 0 0; }
.lg {
  border-top: 1px solid #222;
  padding: 5px 0 3px;
}
.lg:first-child { border-top: 0; padding-top: 0; }
.lg-streets { padding-top: 6px; }
.lg[hidden], .row[hidden] { display: none; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.2;
  margin: 1px 0;
  padding: 2px 2px;
  cursor: pointer;
  color: #fff;
}
.row:hover { background: #111; }
.row input { accent-color: #aaa; margin: 0; }
.row.busy::after {
  content: "";
  width: 10px;
  height: 10px;
  margin-left: auto;
  flex: 0 0 auto;
  border: 1.5px solid #333;
  border-top-color: #fff;
  border-radius: 50%;
  animation: layer-spin 0.7s linear infinite;
}
@keyframes layer-spin {
  to { transform: rotate(360deg); }
}
.swatch {
  width: 10px;
  height: 10px;
  border: 1px solid #222;
  flex: 0 0 auto;
  background: #111;
}
.swatch.round { border-radius: 50%; }
.swatch.line {
  height: 2px;
  width: 12px;
  border: 0;
  background: var(--c, #f2f2f2);
}
.disabled { opacity: 0.45; pointer-events: none; }
.note { font-size: 0.68rem; color: #888; line-height: 1.35; margin: 8px 0 0; }
.status-line { font-size: 0.68rem; color: #888; line-height: 1.35; margin: 10px 0 0; }
#status {
  white-space: pre-wrap;
  font-size: 0.68rem;
  background: #000;
  border: 1px solid #222;
  padding: 8px;
  color: #aaa;
  max-height: 160px;
  overflow: auto;
}
footer { margin-top: 12px; font-size: 0.68rem; color: #888; line-height: 1.4; }

.demo-banner {
  color: #888;
  font-size: 0.68rem;
  line-height: 1.35;
  margin: 8px 0 0;
  border-top: 1px solid #222;
  padding-top: 8px;
}
.demo-banner[hidden] { display: none; }

#find, #layer-filter, #geo-search, #ground-name, #ground-company, #ground-vs, #ground-titles {
  width: 100%;
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px solid #222;
  background: #000;
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
}
#find { margin: 0 0 4px; }
#layer-filter { margin: 0 0 2px; color: #aaa; font-size: 0.72rem; padding: 5px 8px; }
#geo-search { margin: 3px 0 0; }
#geo-search[hidden] { display: none; }
#find:focus, #layer-filter:focus, #geo-search:focus,
#ground-name:focus, #ground-company:focus, #ground-vs:focus, #ground-titles:focus {
  outline: 1px solid #aaa;
}
#find-results { max-height: 220px; overflow: auto; margin: 0 0 6px; }
.find-summary { font-size: 0.68rem; color: #888; line-height: 1.35; margin: 4px 0 6px; }
.find-summary strong { color: #fff; font-weight: 650; }
.find-hit {
  display: block;
  width: 100%;
  text-align: left;
  background: #000;
  border: 1px solid #222;
  color: #fff;
  padding: 6px 8px;
  margin: 4px 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
}
.find-hit:hover { background: #111; }
.find-hit strong { display: block; font-weight: 650; }
.find-hit span { color: #888; }

.kind-actions { display: flex; gap: 6px; margin: 0 0 6px; flex-wrap: wrap; }
.kind-actions button,
.tools button,
.popup-pin {
  background: #000;
  color: #fff;
  border: 1px solid #222;
  font: inherit;
  font-size: 0.72rem;
  padding: 5px 8px;
  cursor: pointer;
}
.kind-actions button:hover,
.tools button:hover,
.popup-pin:hover { background: #111; }

#mineral-more-btn, #land-more-btn {
  display: block;
  width: 100%;
  margin: 4px 0 0;
  padding: 3px 2px;
  background: transparent;
  color: #888;
  border: 0;
  font: inherit;
  font-size: 0.68rem;
  text-align: left;
  cursor: pointer;
}
#mineral-more-btn:hover, #land-more-btn:hover { color: #fff; }
#mineral-more-btn[hidden], #land-more-btn[hidden] { display: none; }
#mineral-more[hidden], #land-more[hidden] { display: none; }
.land-note { margin-top: 4px; font-size: 0.62rem; color: #888; }

.tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid #222;
}
.tools button { width: 100%; }
#open-ground.active,
#box-tool.active {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.more { margin-top: 10px; border-top: 1px solid #222; }
.more > summary {
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  padding: 8px 0;
  list-style: none;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "… "; color: #888; }
.myground { margin-top: 2px; }

.legend { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 0.68rem; color: #888; }
.legend .ramp { flex: 1; height: 6px; border: 1px solid #222; }
.legend .ramp.holes { background: linear-gradient(90deg, #1a3d00, #4a8c00, #c8ff00); }
.legend .ramp.gchem { background: linear-gradient(90deg, #5b21b6, #c77dff, #ff6d00); }
.legend[hidden] { display: none; }
.legend-live { margin-top: 8px; }
.legend-live:empty { display: none; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; margin: 3px 0; color: #aaa; }
.legend-empty { display: none; }
.legend-row.vs-a .swatch { background: #00c8ff; }
.legend-row.vs-b .swatch { background: #ff2bd6; }

.maplibregl-popup-content {
  background: #000 !important;
  color: #fff;
  border: 1px solid #222;
  border-radius: 0;
  padding: 10px 12px;
  box-shadow: none !important;
  max-width: 360px;
}
.maplibregl-popup-tip { border-top-color: #222 !important; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: #222 !important; }
.maplibregl-popup-close-button { color: #aaa; font-size: 18px; }
.maplibregl-popup-close-button:hover { color: #fff; background: transparent; }
.popup-title { font-weight: 650; margin-bottom: 8px; line-height: 1.3; }
.popup-kicker { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: #888; margin-bottom: 2px; }
.popup-row { display: grid; grid-template-columns: 86px 1fr; gap: 6px; font-size: 0.78rem; margin: 3px 0; align-items: start; }
.popup-row span:first-child { color: #888; }
.popup-row span:last-child { overflow-wrap: anywhere; }
.popup-demo { color: #aaa; font-style: italic; }
.popup-kicker.popup-open { color: #c8ff00; }
.popup-kicker.popup-held { color: #00c8ff; }
.popup-links { margin-top: 8px; }
.popup-links h4 {
  margin: 8px 0 4px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
}
.popup-link {
  display: block;
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.35;
  margin: 3px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.popup-link:hover { color: #aaa; }
.popup-id { font-size: 0.72rem; color: #aaa; margin: 2px 0; }
.popup-pin { margin-top: 8px; }
.popup-more { font-size: 0.68rem; color: #888; margin-top: 6px; line-height: 1.35; }

#draw-box {
  position: fixed;
  border: 1px solid #fff;
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
  z-index: 4;
}
.map-busy {
  position: absolute;
  left: 252px;
  top: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  background: #000;
  border: 1px solid #222;
  color: #aaa;
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 5px 8px;
  pointer-events: none;
}
.map-busy[hidden] { display: none; }
.map-busy .spin {
  width: 10px;
  height: 10px;
  border: 1.5px solid #333;
  border-top-color: #fff;
  border-radius: 50%;
  animation: layer-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
.occ-legend {
  position: absolute;
  left: 252px;
  bottom: 36px;
  z-index: 3;
  background: #000;
  border: 1px solid #222;
  padding: 6px 8px;
  min-width: 88px;
  pointer-events: none;
}
.occ-legend[hidden] { display: none; }
.occ-legend .legend-row { color: #fff; font-size: 0.72rem; margin: 2px 0; }

#pack {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: #000;
  border-left: 1px solid #222;
  z-index: 5;
  overflow: auto;
  padding: 12px 14px 20px;
}
#pack[hidden] { display: none; }
#pack header { display: flex; align-items: center; justify-content: space-between; }
#pack h2 { margin: 0; color: #fff; font-size: 0.8rem; letter-spacing: 0.04em; }
#pack-close {
  background: transparent;
  border: 0;
  color: #aaa;
  font-size: 22px;
  cursor: pointer;
}
#pack-close:hover { color: #fff; }
.pack-section { margin: 12px 0; }
.pack-section h3 { margin-bottom: 6px; }
.pack-row {
  display: block;
  width: 100%;
  text-align: left;
  background: #000;
  border: 1px solid #222;
  color: #fff;
  padding: 6px 8px;
  margin: 4px 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
}
.pack-row:hover { background: #111; }
.pack-row strong { display: block; }
.pack-row span { color: #888; }
.pack-row a { color: #fff; }

.maplibregl-ctrl-group {
  background: #000;
  border: 1px solid #222;
  box-shadow: none !important;
}
.maplibregl-ctrl-group button { background: #000; }
.maplibregl-ctrl-group button + button { border-top: 1px solid #222; }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib {
  background: rgba(0, 0, 0, 0.7) !important;
  color: #888;
}
.maplibregl-ctrl-attrib a { color: #aaa; }
.maplibregl-ctrl-scale {
  background: transparent;
  border-color: #444;
  color: #888;
}

@media (max-width: 720px) {
  .occ-legend { left: 10px; }
  .map-busy { left: 10px; top: 48px; }
  #map { left: 0; }
  #rail-toggle {
    display: block;
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 6;
    background: #000;
    color: #fff;
    border: 1px solid #222;
    font: inherit;
    font-size: 0.72rem;
    padding: 6px 10px;
    cursor: pointer;
  }
  #panel {
    transform: translateX(-100%);
    transition: transform 0.16s ease;
    width: min(240px, 86vw);
  }
  body.rail-open #panel { transform: translateX(0); }
  body.rail-open #rail-toggle { left: calc(min(240px, 86vw) + 8px); }
  #pack { width: min(320px, 92vw); }
}
