:root {
  --bg-base: #040812;
  --bg-overlay: rgba(7, 14, 30, 0.58);
  --bg-panel: rgba(11, 22, 45, 0.74);
  --border-soft: rgba(151, 176, 221, 0.34);
  --ink-strong: #e7eefc;
  --ink-muted: #9cb2d9;
  --status-allowed: #00a651;
  --status-restricted: #f1c40f;
  --status-banned: #e53935;
  --status-unknown: #6b7280;
  --shadow-lg: 0 24px 44px rgba(0, 0, 0, 0.48);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --ease-fast: 220ms ease;
  --ease-med: 280ms ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  background: radial-gradient(circle at 20% 20%, #132343 0%, #040812 58%);
  color: var(--ink-strong);
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

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

.glass-panel {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: var(--bg-overlay);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
}

.app-header {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 20;
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

#brand-logo {
  width: 58px;
  height: 44px;
  object-fit: contain;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 4px;
}

.brand-text h1 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.header-cta {
  text-decoration: none;
  color: #f7fbff;
  font-weight: 600;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.6rem 0.92rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  transition: transform var(--ease-fast), border-color var(--ease-fast), background var(--ease-fast);
  white-space: nowrap;
}

.header-cta:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.16);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #f2f7ff;
  border-radius: 999px;
  padding: 0.56rem 0.82rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--ease-fast), border-color var(--ease-fast), background var(--ease-fast);
  white-space: nowrap;
}

.header-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.16);
}

.header-pill.active {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.2);
  color: #bbffd2;
}

#search-root {
  position: absolute;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  width: min(560px, calc(100vw - 32px));
}

.search-shell {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: rgba(10, 20, 40, 0.85);
  backdrop-filter: blur(12px);
  padding: 8px;
  box-shadow: var(--shadow-lg);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(5, 10, 24, 0.7);
  color: #ecf3ff;
  font: inherit;
  padding: 0.62rem 0.74rem;
  outline: none;
}

.search-row input:focus {
  border-color: #78a2ff;
  box-shadow: 0 0 0 2px rgba(120, 162, 255, 0.24);
}

.clear-search-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #ecf3ff;
  border-radius: var(--radius-sm);
  padding: 0.56rem 0.7rem;
  cursor: pointer;
}

.search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 300px;
  overflow: auto;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(3, 9, 23, 0.94);
}

.search-results.visible {
  display: block;
}

.search-results li {
  padding: 0.58rem 0.72rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.search-results li:last-child {
  border-bottom: 0;
}

.search-results li:hover,
.search-results li.active {
  background: rgba(120, 162, 255, 0.24);
}

.search-meta {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  color: #9cb2d9;
}

.legend-root {
  position: absolute;
  left: 16px;
  bottom: 18px;
  z-index: 24;
  width: min(264px, calc(100vw - 32px));
}

.layer-controls-root {
  position: absolute;
  right: 16px;
  bottom: 18px;
  z-index: 24;
  width: min(264px, calc(100vw - 32px));
}

.legend-panel {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: rgba(9, 18, 39, 0.82);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.64rem 0.78rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-head h3 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.legend-toggle {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-strong);
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  cursor: pointer;
}

.legend-body {
  display: grid;
  gap: 0.42rem;
  padding: 0.72rem;
  transition: max-height var(--ease-med), opacity var(--ease-med), padding var(--ease-med);
  max-height: 220px;
  opacity: 1;
}

.legend-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.8rem;
  color: #deebff;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.layer-controls-panel {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: rgba(9, 18, 39, 0.82);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.layer-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.64rem 0.78rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.layer-controls-head h3 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
}

.layer-controls-toggle {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-strong);
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  cursor: pointer;
}

.layer-controls-body {
  display: grid;
  gap: 0.45rem;
  padding: 0.72rem;
  transition: max-height var(--ease-med), opacity var(--ease-med), padding var(--ease-med);
  max-height: 220px;
  opacity: 1;
}

.layer-controls-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.layer-row {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #deebff;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.56rem;
  font: inherit;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.layer-row.active {
  border-color: rgba(80, 205, 255, 0.65);
  background: rgba(56, 189, 248, 0.18);
}

.layer-row:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.layer-unavailable {
  font-size: 0.68rem;
  color: #9cb2d9;
}

.map-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 26;
  transform: translate(12px, -50%);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 10, 22, 0.92);
  padding: 0.44rem 0.55rem;
  min-width: 130px;
  font-size: 0.74rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 140ms ease;
}

.map-tooltip.visible {
  opacity: 1;
}

.mapboxgl-ctrl-bottom-right,
.mapboxgl-ctrl-bottom-left {
  bottom: 10px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: radial-gradient(circle at 50% 45%, rgba(32, 72, 132, 0.28) 0%, rgba(2, 8, 20, 0.96) 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  transition: opacity var(--ease-med), visibility var(--ease-med);
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-logo {
  width: min(220px, 48vw);
  max-height: 120px;
  object-fit: contain;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #83b4ff;
  animation: spin 0.9s linear infinite;
}

.loading-overlay p {
  margin: 0;
  color: #d8e7ff;
  font-size: 0.88rem;
}

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

.status-text {
  display: inline-block;
  font-size: 0.76rem;
  margin-top: 2px;
  color: var(--ink-muted);
}
