:root {
  --bg: #071011;
  --bg-2: #0f1c1f;
  --panel: rgba(10, 17, 18, 0.82);
  --panel-strong: rgba(7, 12, 14, 0.94);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f1e7;
  --muted: #a7b5b1;
  --accent: #ff7a21;
  --accent-2: #2fd1c3;
  --accent-3: #f3ca4d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 24px;
  --radius-lg: 30px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(47, 209, 195, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 122, 33, 0.12), transparent 34%),
    linear-gradient(180deg, #091112 0%, #05090a 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body {
  overflow: hidden;
}

a {
  color: var(--accent-2);
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.map-app,
.map-stage {
  height: 100vh;
  width: 100vw;
}

.map-stage {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

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

.map-stage::before,
.map-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.map-stage::before {
  background:
    radial-gradient(circle at 24% 18%, rgba(47, 209, 195, 0.17), transparent 22%),
    radial-gradient(circle at 78% 26%, rgba(255, 122, 33, 0.13), transparent 24%),
    linear-gradient(180deg, rgba(4, 6, 7, 0.1), rgba(4, 6, 7, 0.34));
}

.map-stage::after {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.018) 0,
      rgba(255, 255, 255, 0.018) 1px,
      transparent 1px,
      transparent 72px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.015) 0,
      rgba(255, 255, 255, 0.015) 1px,
      transparent 1px,
      transparent 72px
    );
  mix-blend-mode: screen;
  opacity: 0.5;
}

.map-topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
  z-index: 4;
}

.brand-chip,
.hud-card,
.overlay-panel,
.detail-sheet {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 26, 28, 0.84), rgba(7, 12, 14, 0.9));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.brand-chip {
  pointer-events: auto;
  width: min(430px, calc(100vw - 36px));
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  animation: chrome-float 800ms ease both;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 4px;
}

.brand-row h1,
.panel-header h2,
.detail-empty h2,
.loading-card h2 {
  margin: 0;
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.brand-row h1 {
  font-size: clamp(2rem, 5vw, 3.65rem);
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 122, 33, 0.14);
  border: 1px solid rgba(255, 122, 33, 0.3);
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow,
.hud-eyebrow,
.field-label,
.section-block h3,
.sources-block summary {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-3);
}

.subcopy,
.detail-copy,
.source-note,
.detail-empty p,
.hud-card p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.topbar-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chrome-button,
.ghost-button,
.search-shell button,
.detail-action,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.chrome-button:hover,
.ghost-button:hover,
.search-shell button:hover,
.detail-action:hover,
.icon-button:hover,
.chrome-button.is-active {
  transform: translateY(-1px);
  border-color: rgba(47, 209, 195, 0.45);
  background: rgba(47, 209, 195, 0.09);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.icon-button {
  min-width: 46px;
  padding: 11px 14px;
}

.overlay-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 7;
}

.overlay-panel.is-open {
  opacity: 1;
  pointer-events: auto;
}

.search-dialog {
  top: 104px;
  left: 50%;
  width: min(620px, calc(100vw - 36px));
  max-height: min(72vh, 740px);
  transform: translateX(-50%) translateY(-18px) scale(0.98);
  z-index: 9;
}

.search-dialog.is-open {
  transform: translateX(-50%) translateY(0) scale(1);
}

.search-dialog .search-results {
  flex: 1 1 auto;
  min-height: 0;
}

.drawer {
  top: 104px;
  bottom: 142px;
  width: min(380px, calc(100vw - 36px));
  overflow: auto;
}

.atlas-drawer {
  left: 18px;
  transform: translateX(-24px);
}

.atlas-drawer.is-open {
  transform: translateX(0);
}

.layers-drawer {
  right: 18px;
  width: min(340px, calc(100vw - 36px));
  transform: translateX(24px);
}

.disaster-drawer {
  right: 18px;
  width: min(360px, calc(100vw - 36px));
  transform: translateX(24px);
}

.disaster-drawer.is-open,
.layers-drawer.is-open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-header h2,
.detail-empty h2,
.loading-card h2 {
  font-size: clamp(1.55rem, 2vw, 2.35rem);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card,
.legend-chip,
.source-item,
.meta-card,
.direction-card,
.flow-chip {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.stat-card {
  padding: 14px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.75rem;
  line-height: 1;
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.section-block h3 {
  color: var(--text);
}

.search-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-shell input {
  width: 100%;
  min-height: 50px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.search-shell input:focus {
  outline: 2px solid rgba(47, 209, 195, 0.2);
  border-color: rgba(47, 209, 195, 0.45);
}

.search-results,
.legend-list,
.source-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-results {
  max-height: min(52vh, 460px);
  overflow: auto;
}

.search-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.search-result:hover {
  border-color: rgba(47, 209, 195, 0.45);
  background: rgba(47, 209, 195, 0.08);
}

.search-result strong {
  font-size: 1rem;
}

.search-result span {
  color: var(--muted);
  font-size: 0.88rem;
}

.toggle-grid {
  display: grid;
  gap: 10px;
}

.toggle-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.toggle-pill input {
  accent-color: var(--accent);
}

.toggle-pill:has(input:disabled) {
  opacity: 0.52;
}

.legend-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.legend-swatch {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.source-item {
  padding: 12px 14px;
}

.source-item strong {
  display: block;
  margin-bottom: 8px;
}

.source-item a {
  text-decoration: none;
}

.source-item a:hover {
  text-decoration: underline;
}

.map-hud {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 3;
  transition: opacity 180ms ease, transform 180ms ease;
}

.hud-card {
  pointer-events: auto;
  padding: 13px 15px;
  border-radius: 20px;
  animation: chrome-float 900ms ease both;
}

.hud-card-compact {
  max-width: min(340px, calc(100vw - 36px));
}

.hud-card-flow {
  width: min(520px, calc(100vw - 36px));
}

.flow-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.flow-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
}

.flow-swatch {
  width: 12px;
  height: 44px;
  border-radius: 999px;
  box-shadow: 0 0 18px currentColor;
}

.flow-chip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.96rem;
}

.flow-chip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.detail-sheet {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(440px, calc(100vw - 36px));
  max-height: min(60vh, 620px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 18px;
  border-radius: 28px;
  overflow: auto;
  transform: translateY(calc(100% - 104px));
  transition: transform 260ms ease, opacity 180ms ease;
  z-index: 6;
}

.detail-sheet.is-open {
  transform: translateY(0);
}

.sheet-grabber {
  width: 54px;
  height: 5px;
  margin: 2px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.detail-empty,
.detail-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.58rem;
  line-height: 1;
}

.detail-tag-row,
.detail-meta-grid,
.detail-action-row,
.direction-columns,
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.84rem;
}

.meta-card,
.direction-card {
  flex: 1 1 150px;
  min-width: 0;
  padding: 14px;
}

.meta-card strong,
.direction-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-3);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.direction-card ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.direction-card li + li {
  margin-top: 6px;
}

.loading-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(47, 209, 195, 0.18), transparent 30%),
    linear-gradient(180deg, rgba(6, 10, 11, 0.9), rgba(6, 10, 11, 0.97));
  transition: opacity 260ms ease, visibility 260ms ease;
  z-index: 8;
}

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

.loading-card {
  width: min(430px, calc(100vw - 36px));
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.maplibregl-popup-content {
  border-radius: 14px;
  background: rgba(7, 12, 14, 0.96);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.maplibregl-popup-tip {
  opacity: 0.8;
}

.maplibregl-ctrl-top-right {
  top: 110px;
  right: 18px;
  transition: opacity 180ms ease, transform 180ms ease;
}

body[data-active-panel="searchDialog"] .map-hud,
body[data-active-panel="searchDialog"] .detail-sheet,
body[data-active-panel="searchDialog"] .maplibregl-ctrl-top-right {
  opacity: 0;
  pointer-events: none;
}

.maplibregl-ctrl-group {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.maplibregl-ctrl button {
  background-color: rgba(8, 13, 14, 0.92);
}

.maplibregl-ctrl button span {
  filter: invert(1);
}

@keyframes chrome-float {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1120px) {
  .drawer {
    bottom: 168px;
  }

  .map-hud {
    align-items: stretch;
    flex-direction: column;
    left: 18px;
    right: auto;
    max-width: min(520px, calc(100vw - 36px));
  }
}

@media (max-width: 820px) {
  .map-topbar {
    top: 12px;
    left: 12px;
    right: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .brand-chip {
    width: 100%;
    padding: 14px 16px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chrome-button {
    width: 100%;
  }

  .search-dialog {
    top: 94px;
    left: 12px;
    right: 12px;
    bottom: max(16px, calc(16px + env(safe-area-inset-bottom)));
    width: auto;
    max-height: none;
    transform: translateY(24px);
  }

  .search-dialog.is-open {
    transform: translateY(0);
  }

  .drawer {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 126px;
    width: auto;
    max-height: calc(100dvh - 260px);
    transform: translateY(24px);
  }

  .atlas-drawer.is-open,
  .disaster-drawer.is-open,
  .layers-drawer.is-open {
    transform: translateY(0);
  }

  .atlas-drawer,
  .disaster-drawer,
  .layers-drawer {
    bottom: 126px;
  }

  .map-hud {
    left: 12px;
    right: 12px;
    bottom: 112px;
    max-width: none;
  }

  .hud-card,
  .hud-card-flow {
    width: 100%;
    max-width: none;
  }

  .flow-chip-list {
    display: grid;
    grid-template-columns: 1fr;
  }

  .detail-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 72vh;
    padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(calc(100% - 118px));
  }

  .maplibregl-ctrl-top-right {
    top: 158px;
    right: 12px;
  }

  body[data-active-panel="searchDialog"] .map-hud {
    transform: translateY(24px);
  }

  body[data-active-panel="searchDialog"] .detail-sheet {
    transform: translateY(100%);
  }

  body[data-active-panel="searchDialog"] .maplibregl-ctrl-top-right {
    transform: translateY(-14px);
  }
}

@media (max-width: 560px) {
  .brand-row {
    gap: 10px;
  }

  .brand-row h1 {
    font-size: 2.2rem;
  }

  .topbar-actions {
    gap: 8px;
  }

  .chrome-button,
  .ghost-button,
  .search-shell button,
  .detail-action,
  .icon-button {
    min-height: 42px;
    padding: 10px 12px;
    font-size: 0.92rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .detail-header h2,
  .panel-header h2,
  .detail-empty h2 {
    font-size: 1.4rem;
  }

  .search-shell {
    grid-template-columns: 1fr;
  }

  .detail-sheet {
    max-height: 78vh;
  }
}
