:root {
  color-scheme: dark;
  --bg: #07110f;
  --glass: rgba(7, 17, 15, 0.76);
  --glass-strong: rgba(6, 15, 13, 0.92);
  --line: rgba(226, 235, 228, 0.16);
  --line-bright: rgba(226, 235, 228, 0.28);
  --text: #f3f5ee;
  --muted: #aab5ae;
  --accent: #d5ff72;
  --accent-dim: rgba(213, 255, 114, 0.18);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

.search-results { max-height: min(65vh, 560px); overflow-y: auto; }
.search-note { padding: 14px 16px; color: var(--muted); font-size: 12px; }
.search-attribution { display: block; padding: 10px 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; }

* {
  box-sizing: border-box;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.startup-status {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  text-align: center;
  transform: translate(-50%, -50%);
  transition: opacity 220ms;
}

#startupPreview {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

#startupPreview img {
  position: absolute;
  max-width: none;
}

.startup-status.ready {
  opacity: 0;
  pointer-events: none;
}

.startup-status.failed strong {
  color: #ffd1a9;
}

.startup-status small {
  color: var(--muted);
  font-size: 10px;
}

.startup-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(213, 255, 114, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#map {
  position: absolute;
  inset: 0;
  background: #0a1818;
}

.maplibregl-canvas {
  cursor: grab;
}

.maplibregl-canvas:active {
  cursor: grabbing;
}

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-logo {
  display: none !important;
}

.atlas-building-popup .maplibregl-popup-content {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-bright);
  border-radius: 12px;
  background: rgba(6, 15, 13, 0.96);
  color: var(--text);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.48);
}

.atlas-building-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: rgba(6, 15, 13, 0.96);
}

.atlas-building-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.atlas-building-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.atlas-building-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: rgba(6, 15, 13, 0.96);
}

.atlas-building-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: rgba(6, 15, 13, 0.96);
}

.atlas-building-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: rgba(6, 15, 13, 0.96);
}

.atlas-building-popup .maplibregl-popup-close-button {
  z-index: 1;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 19px;
}

.atlas-building-popup .maplibregl-popup-close-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.building-card {
  width: 280px;
  padding: 16px;
  user-select: text;
}

.building-card > small {
  color: var(--accent);
  font-size: 7px;
  letter-spacing: 0.14em;
}

.building-card h3 {
  margin: 5px 28px 11px 0;
  font-size: 17px;
  font-weight: 570;
}

.building-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}

.building-metrics strong,
.building-metrics span {
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 9px;
}

.building-metrics strong {
  background: var(--accent);
  color: #13251e;
}

.building-metrics span {
  background: rgba(255, 255, 255, 0.08);
  color: #c4cdc6;
}

.building-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 9px;
}

.building-card dt {
  color: #7f8b84;
}

.building-card dd {
  margin: 0;
  color: #d6ddd7;
  text-align: right;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 10, 9, 0.28) 0, transparent 20%, transparent 74%, rgba(3, 10, 9, 0.28) 100%),
    linear-gradient(90deg, rgba(3, 10, 9, 0.15), transparent 19%, transparent 80%, rgba(3, 10, 9, 0.12));
  z-index: 2;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(130%);
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 20px;
  left: 20px;
  right: 20px;
  height: 66px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  padding: 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 48px;
  padding: 0 4px 0 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  box-shadow: 0 0 28px rgba(213, 255, 114, 0.12);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: #13251e;
}

.brand-mark .spark {
  fill: #527131;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 119px;
  line-height: 1;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: 0.18em;
}

.brand-copy span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: 0.26em;
}

.topbar-divider {
  width: 1px;
  height: 28px;
  margin: 0 24px;
  background: var(--line);
}

.search-wrap {
  position: relative;
  height: 42px;
  max-width: 540px;
  flex: 1;
}

.search-wrap input {
  width: 100%;
  height: 100%;
  padding: 0 60px 0 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--text);
  transition: border-color 150ms, background 150ms;
}

.search-wrap input:hover,
.search-wrap input:focus {
  border-color: var(--line-bright);
  background: rgba(255, 255, 255, 0.09);
}

.search-wrap input::placeholder {
  color: #98a39c;
}

.search-icon {
  position: absolute;
  z-index: 1;
  top: 11px;
  left: 13px;
  width: 20px;
  fill: none;
  stroke: #aeb8b1;
  stroke-linecap: round;
  stroke-width: 1.7;
  pointer-events: none;
}

kbd {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: #929d96;
  font: 10px/1.2 inherit;
}

.search-results {
  position: absolute;
  top: 52px;
  left: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: var(--glass-strong);
}

.search-result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.search-result:hover,
.search-result.active {
  background: rgba(255, 255, 255, 0.08);
}

.result-pin {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
}

.result-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.result-copy small {
  color: var(--muted);
  font-size: 11px;
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding-left: 22px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(213, 255, 114, 0.1), 0 0 12px rgba(213, 255, 114, 0.65);
}

.connection-label {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.connection.offline .connection-dot {
  background: #ffb06b;
  box-shadow: 0 0 0 4px rgba(255, 176, 107, 0.1);
}

.connection.offline .connection-label {
  color: #ffc28c;
}

.explore {
  position: absolute;
  z-index: 8;
  top: 106px;
  left: 20px;
  width: 280px;
  max-height: calc(100vh - 180px);
  padding: 19px 10px 13px;
  border-radius: 14px;
  overflow: hidden;
  transition: opacity 180ms, transform 180ms;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  padding: 0 10px 13px;
}

.eyebrow,
.layer-main small,
.quality-copy small {
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.panel-heading h1 {
  margin: 5px 0 0;
  font-size: 18px;
  font-weight: 570;
  letter-spacing: -0.02em;
}

.place-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: calc(100vh - 305px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.place-card {
  position: relative;
  width: 100%;
  min-height: 55px;
  padding: 9px 42px 9px 13px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 150ms, border-color 150ms;
}

.place-card:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.055);
}

.place-card.active {
  border-color: rgba(213, 255, 114, 0.3);
  background: linear-gradient(90deg, rgba(213, 255, 114, 0.13), rgba(213, 255, 114, 0.025));
}

.place-card::after {
  content: "↗";
  position: absolute;
  top: 18px;
  right: 14px;
  color: #77827b;
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity 150ms, transform 150ms;
}

.place-card:hover::after,
.place-card.active::after {
  opacity: 1;
  transform: none;
}

.place-card strong,
.place-card small {
  display: block;
}

.place-card strong {
  font-size: 13px;
  font-weight: 580;
}

.place-card small {
  margin-top: 5px;
  color: #94a099;
  font-size: 10px;
}

.tip {
  margin: 12px 9px 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: #86928b;
  font-size: 10px;
  line-height: 1.4;
}

.tip span {
  margin-right: 6px;
  color: var(--accent);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.map-tools {
  position: absolute;
  z-index: 8;
  top: 106px;
  right: 20px;
  display: flex;
  flex-direction: column;
  width: 45px;
  padding: 4px;
  border-radius: 12px;
}

.debug-trigger {
  position: absolute;
  z-index: 8;
  top: 302px;
  right: 20px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 9px;
  color: #abb6af;
  cursor: pointer;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.debug-trigger:hover,
.debug-trigger[aria-expanded="true"] {
  color: var(--text);
  background: var(--glass-strong);
}

.debug-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a099;
}

.debug-trigger.has-error .debug-dot {
  background: #ff986e;
  box-shadow: 0 0 8px rgba(255, 152, 110, 0.8);
}

.debug-panel {
  position: absolute;
  z-index: 40;
  top: 96px;
  right: 76px;
  width: min(560px, calc(100vw - 110px));
  padding: 17px;
  border-radius: 14px;
  background: rgba(5, 13, 11, 0.95);
}

.debug-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.debug-heading h2 {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 570;
}

.debug-heading .icon-button {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 21px;
}

.debug-heading .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

#debugSummary {
  margin: 13px 0 8px;
  color: var(--muted);
  font-size: 11px;
}

#debugOutput {
  height: min(360px, calc(100vh - 315px));
  min-height: 170px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  color: #c9d1cb;
  font: 10px/1.55 Consolas, "Cascadia Mono", monospace;
  user-select: text;
  white-space: pre-wrap;
}

.debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.debug-actions button {
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #c9d1cb;
  cursor: pointer;
  font-size: 10px;
}

.debug-actions button:hover {
  border-color: var(--line-bright);
  background: rgba(255, 255, 255, 0.09);
}

.debug-actions .debug-primary {
  border-color: rgba(213, 255, 114, 0.28);
  background: var(--accent);
  color: #13251e;
  font-weight: 700;
}

.debug-hint {
  display: block;
  margin-top: 9px;
  color: #7f8b84;
  font-size: 9px;
}

.tool-button,
.icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tool-button {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #dee4df;
  font-size: 21px;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.09);
}

.tool-divider {
  height: 1px;
  margin: 4px 5px;
  background: var(--line);
}

.compass svg {
  width: 22px;
  transition: transform 100ms;
}

.compass path {
  stroke-width: 0;
}

.compass .north {
  fill: var(--accent);
}

.compass .south {
  fill: #9da7a1;
}

.view-mode {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.layer-control {
  position: absolute;
  z-index: 8;
  right: 20px;
  bottom: 92px;
  width: 212px;
  overflow: hidden;
  border-radius: 13px;
}

.layer-main {
  width: 100%;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.layer-main:hover {
  background: rgba(255, 255, 255, 0.05);
}

.layer-preview {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 40%, rgba(212, 221, 184, 0.45) 41% 47%, transparent 48%),
    radial-gradient(ellipse at 30% 40%, #68805c 0 20%, transparent 21%),
    radial-gradient(ellipse at 65% 72%, #8d7f5c 0 23%, transparent 24%),
    #1b5156;
}

.layer-main > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 5px;
}

.layer-main strong {
  overflow: hidden;
  font-size: 11px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-main svg {
  width: 17px;
  fill: none;
  stroke: #a4aea7;
  stroke-width: 1.5;
  transition: transform 150ms;
}

.layer-main[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.layer-menu {
  padding: 2px 11px 11px;
  border-top: 1px solid var(--line);
}

.layer-menu label {
  display: flex;
  align-items: center;
  padding-top: 10px;
  cursor: pointer;
}

.layer-menu label + label {
  margin-top: 9px;
  border-top: 1px solid var(--line);
}

.layer-menu label > span:first-child {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

.layer-menu strong {
  font-size: 11px;
  font-weight: 550;
}

.layer-menu small {
  color: var(--muted);
  font-size: 9px;
}

.layer-menu input {
  position: absolute;
  opacity: 0;
}

.switch {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 150ms;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #a9b3ac;
  transition: transform 150ms, background 150ms;
}

.layer-menu input:checked + .switch {
  background: rgba(213, 255, 114, 0.28);
}

.layer-menu input:checked + .switch::after {
  background: var(--accent);
  transform: translateX(15px);
}

.quality {
  position: absolute;
  z-index: 8;
  left: 319px;
  bottom: 48px;
  min-width: 278px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border-radius: 11px;
}

.quality-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-dim);
}

.quality-icon svg {
  width: 16px;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.quality-copy {
  display: flex;
  min-width: 89px;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.quality-copy small {
  font-size: 7px;
}

.quality-copy strong {
  font-size: 10px;
  font-weight: 550;
  white-space: nowrap;
}

.quality-bars {
  height: 19px;
  display: flex;
  align-items: end;
  gap: 2px;
}

.quality-bars i {
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}

.quality-bars i:nth-child(1) { height: 5px; }
.quality-bars i:nth-child(2) { height: 8px; }
.quality-bars i:nth-child(3) { height: 11px; }
.quality-bars i:nth-child(4) { height: 14px; }
.quality-bars i:nth-child(5) { height: 18px; }

.quality-bars i.on {
  background: var(--accent);
  box-shadow: 0 0 5px rgba(213, 255, 114, 0.35);
}

.statusbar {
  position: absolute;
  z-index: 7;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 21px;
  border-top: 1px solid var(--line);
  background: rgba(5, 13, 11, 0.86);
  color: #9aa59e;
  font-size: 9px;
  letter-spacing: 0.035em;
  backdrop-filter: blur(18px);
}

.status-divider {
  width: 1px;
  height: 11px;
  margin: 0 12px;
  background: var(--line);
}

.status-spacer {
  flex: 1;
}

#tileStatus {
  white-space: nowrap;
}

#tileStatus i {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

#tileStatus.loading i {
  animation: pulse 900ms infinite alternate;
}

.attribution {
  white-space: nowrap;
}

.attribution a {
  color: #c3cbc5;
  text-decoration: none;
}

.attribution a:hover {
  text-decoration: underline;
}

.offline-notice {
  position: absolute;
  z-index: 20;
  top: 102px;
  left: 50%;
  width: min(390px, calc(100vw - 40px));
  padding: 13px 16px;
  border-color: rgba(255, 176, 107, 0.32);
  border-radius: 12px;
  background: rgba(31, 21, 12, 0.9);
  transform: translateX(-50%);
}

.offline-notice strong,
.offline-notice span {
  display: block;
}

.offline-notice strong {
  color: #ffd1a9;
  font-size: 12px;
}

.offline-notice span {
  margin-top: 4px;
  color: #c6b2a2;
  font-size: 10px;
}

.explore-trigger {
  position: absolute;
  z-index: 8;
  left: 20px;
  bottom: 48px;
  height: 46px;
  padding: 0 18px;
  border-radius: 11px;
  color: var(--text);
  cursor: pointer;
}

.mobile-only {
  display: none;
}

@keyframes pulse {
  to { opacity: 0.25; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .brand-copy,
  .topbar-divider,
  .connection-label,
  .attribution {
    display: none;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .search-wrap {
    margin-left: 12px;
  }

  .connection {
    padding-left: 14px;
  }
}

@media (max-width: 760px) {
  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .explore {
    top: 90px;
    left: 12px;
    max-height: calc(100vh - 140px);
  }

  .explore.closed {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
  }

  .mobile-only {
    display: block;
  }

  .icon-button.subtle {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 20px;
  }

  .icon-button.subtle:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .explore-trigger.visible {
    display: block;
  }

  .map-tools {
    top: 90px;
    right: 12px;
  }

  .debug-trigger {
    top: 286px;
    right: 12px;
  }

  .debug-panel {
    top: 88px;
    right: 12px;
    width: calc(100vw - 24px);
  }

  .layer-control {
    right: 12px;
    bottom: 82px;
  }

  .quality {
    left: 12px;
    bottom: 42px;
  }

  .statusbar {
    padding: 0 12px;
  }
}

@media (max-height: 690px) {
  .place-list {
    max-height: calc(100vh - 300px);
  }

  .tip {
    display: none;
  }
}
