:root {
  --floor: #121214;
  --surface: #1c1c1e;
  --surface-high: #282934;
  --on-surface: #e1e1ef;
  --on-surface-variant: #c3c5d9;
  --outline: #434656;
  --primary: #0052ff;
  --primary-light: #b7c4ff;
  --accent-cyan: #00f0ff;
  --accent-lime: #c3f400;
  --danger: #ff6a4d;
  --font-display: "Lexend", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--floor);
  color: var(--on-surface);
  font-family: var(--font-body);
  overflow: hidden;
}

#map { position: fixed; inset: 0; }

/* --- Topbar --- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(18, 18, 20, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--outline);
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--on-surface);
}

.brand-dot { color: var(--outline); }

.brand-by {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--on-surface-variant);
  flex: 1;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--outline);
  color: var(--on-surface);
  border-radius: 0.375rem;
  width: 36px; height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--accent-cyan); }
.icon-btn.active { border-color: var(--accent-cyan); background: rgba(0, 240, 255, 0.1); }

.icon-btn.icon-btn-wide {
  width: auto;
  padding: 0 10px;
  gap: 4px;
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  white-space: nowrap;
}

.panel-hint {
  font-size: 11px;
  color: var(--on-surface-variant);
  margin: 4px 0 0;
  font-style: italic;
}

/* --- Panel --- */
.panel {
  position: fixed;
  top: 74px; right: 16px;
  z-index: 15;
  width: 320px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: rgba(28, 28, 30, 0.88);
  backdrop-filter: blur(20px);
  border: 1px solid var(--outline);
  border-radius: 0.5rem;
  padding: 16px;
  padding-top: 36px;
}
.panel.hidden { display: none; }

.panel-left {
  right: auto;
  left: 16px;
  width: 340px;
}

.panel-close {
  position: absolute;
  top: 10px; right: 10px;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  font-size: 14px;
  cursor: pointer;
  width: 26px; height: 26px;
  border-radius: 0.25rem;
}
.panel-close:hover { color: var(--on-surface); background: rgba(255, 255, 255, 0.06); }

.panel-body {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--on-surface-variant);
  margin: 0;
}
.panel-body a { color: var(--accent-cyan); }
.panel-body strong { color: var(--on-surface); }
.panel-body em { color: var(--on-surface); font-style: normal; }

.panel-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 7px;
}
.panel-list li {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--on-surface-variant);
}
.panel-list .swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

.panel-note code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 4px;
  border-radius: 0.25rem;
}

.panel-section {
  border-top: 1px solid var(--outline);
  padding-top: 12px;
  margin-top: 12px;
}
.panel-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.panel-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin: 0 0 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--on-surface-variant);
  padding: 5px 2px;
  cursor: pointer;
  border-radius: 0.25rem;
}
.toggle:hover { color: var(--on-surface); background: rgba(0, 240, 255, 0.05); }
.toggle input { accent-color: var(--accent-cyan); }

.swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-block;
}
.swatch.outline {
  background: transparent;
  border: 2px solid #999;
}

.panel-note p {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--on-surface-variant);
  margin: 0;
}
.panel-note strong { color: var(--danger); }

.panel-toggle { display: none; }

/* --- MapLibre popup override --- */
.maplibregl-popup-content {
  background: var(--surface) !important;
  color: var(--on-surface) !important;
  border: 1px solid var(--outline);
  border-radius: 0.375rem;
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 10px 12px !important;
}
.maplibregl-popup-content h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.maplibregl-popup-content table { border-collapse: collapse; }
.maplibregl-popup-content td { padding: 1px 6px 1px 0; vertical-align: top; }
.maplibregl-popup-content td:first-child { color: var(--on-surface-variant); white-space: nowrap; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { color: var(--on-surface-variant); font-size: 16px; }

.maplibregl-ctrl-attrib { background: rgba(18, 18, 20, 0.7) !important; }
.maplibregl-ctrl-attrib a { color: var(--on-surface-variant) !important; }

#popup-content[hidden] { display: none; }

@media (max-width: 720px) {
  .subtitle { display: none; }
  .brand-by { display: none; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-actions { gap: 4px; }

  /* Paneles como hoja inferior compacta -- NUNCA ocupan todo el mapa, y ambos
     arrancan cerrados en movil (controlado por JS, ver setPanel() en app.js) */
  .panel, .panel-left {
    top: auto; bottom: 0; right: 0; left: 0;
    width: auto;
    max-height: 42vh;
    border-radius: 0.75rem 0.75rem 0 0;
  }
}
