:root {
  --bg: #18202d;
  --panel: #233147;
  --panel-2: #2a3a53;
  --line: #3f5470;
  --ink: #eef4fb;
  --muted: #a7b8ca;
  --quiet: #6f8398;
  --crash: #ff496b;
  --crash-g: rgba(255, 73, 107, .24);
  --strike: #ff8b3d;
  --strike-g: rgba(255, 139, 61, .24);
  --intercept: #35c8ff;
  --intercept-g: rgba(53, 200, 255, .24);
  --alert: #f2c94c;
  --alert-g: rgba(242, 201, 76, .24);
  --target: #c86bff;
  --target-g: rgba(200, 107, 255, .24);
  --accent: #82a2ff;
  --shadow: 0 12px 30px rgba(4, 10, 20, .36);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

body {
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.map-shell {
  position: relative;
  min-height: 100vh;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.leaflet-tile-pane {
  filter: brightness(1.68) contrast(.82) saturate(.56);
}

.topbar {
  position: fixed;
  z-index: 900;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px 42px;
  background: linear-gradient(180deg, rgba(21, 29, 43, .97) 0%, rgba(21, 29, 43, .76) 58%, transparent 100%);
  pointer-events: none;
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 920px;
  pointer-events: auto;
}

.kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.lang-switch {
  flex: 0 0 auto;
}

.lang-switch select {
  min-width: 58px;
  min-height: 30px;
  border: 1px solid rgba(130, 162, 255, .38);
  border-radius: 5px;
  background: rgba(31, 43, 62, .9);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(21px, 3.2vw, 36px);
  font-weight: 650;
  letter-spacing: 0;
}

.subtitle {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.controls {
  position: fixed;
  z-index: 950;
  left: 18px;
  bottom: 18px;
  width: min(340px, calc(100vw - 36px));
  background: rgba(31, 43, 62, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.controls-inner {
  padding: 13px 14px 14px;
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.control-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 15px;
  font-weight: 650;
}

.count {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.filter-grid {
  display: grid;
  gap: 7px;
}

.filter-row,
.layer-row {
  display: grid;
  grid-template-columns: 18px 14px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.25;
  cursor: pointer;
}

.filter-row input,
.layer-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.filter-row strong,
.layer-row strong {
  color: var(--ink);
  font-weight: 600;
}

.filter-row .amount {
  color: var(--quiet);
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.swatch.crash { background: var(--crash); box-shadow: 0 0 0 3px var(--crash-g); }
.swatch.strike { background: var(--strike); box-shadow: 0 0 0 3px var(--strike-g); }
.swatch.intercept { background: var(--intercept); box-shadow: 0 0 0 3px var(--intercept-g); }
.swatch.alert { background: var(--alert); box-shadow: 0 0 0 3px var(--alert-g); }
.swatch.target { background: var(--target); box-shadow: 0 0 0 3px var(--target-g); border-radius: 3px; }


.layer-controls {
  display: grid;
  gap: 7px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.layer-row {
  grid-template-columns: 68px 22px 1fr;
}


.select-wrap {
  min-width: 0;
}

.select-wrap select {
  width: 68px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, .06);
  color: var(--ink);
  font-size: 10px;
}

.label-key {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 4px;
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}

.side-list {
  position: fixed;
  z-index: 920;
  top: 128px;
  right: 18px;
  bottom: 18px;
  width: min(390px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: rgba(31, 43, 62, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.list-head {
  padding: 13px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.list-head h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
}

.list-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.incident-list {
  overflow: auto;
  padding: 7px;
}

.incident-button {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 9px;
  width: 100%;
  min-height: 64px;
  padding: 9px 8px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.incident-button:hover,
.incident-button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, .055);
}

.incident-button.hidden {
  display: none;
}

.incident-main {
  min-width: 0;
}

.incident-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 11.5px;
  font-weight: 600;
}

.incident-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}

.incident-summary {
  display: block;
  margin-top: 5px;
  color: var(--quiet);
  font-size: 9.5px;
  line-height: 1.45;
}

.mk {
  border: 2px solid rgba(18, 24, 36, .86);
  border-radius: 50%;
}

.mk.crash { width: 13px; height: 13px; background: var(--crash); box-shadow: 0 0 0 3px var(--crash-g), 0 1px 6px #0005; }
.mk.strike { width: 14px; height: 14px; background: var(--strike); box-shadow: 0 0 0 3px var(--strike-g), 0 1px 6px #0005; }
.mk.intercept { width: 15px; height: 15px; background: var(--intercept); box-shadow: 0 0 0 4px var(--intercept-g), 0 1px 6px #0005; }
.mk.alert { width: 10px; height: 10px; background: var(--alert); box-shadow: 0 0 0 3px var(--alert-g), 0 1px 6px #0005; }
.mk.target { width: 14px; height: 14px; background: var(--target); box-shadow: 0 0 0 4px var(--target-g), 0 1px 6px #0005; border-radius: 3px; }

.incident-cluster {
  display: grid;
  place-items: center;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
}

.cluster-ring {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(130, 162, 255, .14), 0 7px 18px rgba(0, 0, 0, .45);
}

.cluster-ring span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(24, 32, 48, .94);
  border: 1px solid rgba(255, 255, 255, .14);
  font-size: 11px;
  font-weight: 650;
}

.cluster-bars {
  display: flex;
  gap: 2px;
  width: 38px;
  height: 5px;
  margin-top: 4px;
}

.cluster-bar {
  min-width: 4px;
  height: 5px;
  border-radius: 999px;
}

.cluster-bar.crash { background: var(--crash); }
.cluster-bar.strike { background: var(--strike); }
.cluster-bar.intercept { background: var(--intercept); }
.cluster-bar.alert { background: var(--alert); }
.cluster-bar.target { background: var(--target); }

.marker-cluster-spider-leg {
  background: rgba(130, 162, 255, .42);
}

.leaflet-tooltip.lbl {
  background: rgba(24, 32, 48, .9);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 5px;
  box-shadow: none;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  line-height: 1.45;
  padding: 3px 7px;
  white-space: nowrap;
}

.leaflet-tooltip.lbl::before {
  display: none;
}

.lname {
  display: block;
  font-weight: 600;
}

.ldate {
  display: block;
  font-size: 9.5px;
}

.lbl.crash .ldate { color: #ff9aaa; }
.lbl.strike .ldate { color: #ffb37a; }
.lbl.intercept .ldate { color: #88ddff; }
.lbl.alert .ldate { color: #f5d87a; }
.lbl.target .ldate { color: #e099ff; }


.leaflet-popup-content-wrapper {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .48);
  color: var(--ink);
}

.leaflet-popup-tip {
  background: var(--panel);
}

.leaflet-popup-content {
  margin: 12px 15px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  line-height: 1.6;
}

.pop-name {
  display: block;
  margin-bottom: 4px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 15px;
  font-weight: 650;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.badge.crash { background: var(--crash-g); color: #ff9aaa; }
.badge.strike { background: var(--strike-g); color: #ffb37a; }
.badge.intercept { background: var(--intercept-g); color: #88ddff; }
.badge.alert { background: var(--alert-g); color: #f5d87a; }
.badge.target { background: var(--target-g); color: #e099ff; }

.popup-link,
.primary-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 10px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, .06);
  color: var(--ink);
  font-size: 10px;
  text-decoration: none;
}

.popup-link:hover,
.primary-link:hover {
  background: rgba(255, 255, 255, .1);
}

.leaflet-control-attribution {
  background: rgba(24, 32, 46, .82) !important;
  color: #66768b !important;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.leaflet-bar a {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.leaflet-bar a:hover {
  background: #34415a;
}

.detail-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(18, 27, 40, .94), rgba(24, 32, 45, 1) 340px),
    url("https://tile.openstreetmap.org/6/36/19.png");
}

.detail-wrap {
  width: min(1100px, calc(100vw - 34px));
  margin: 0 auto;
  padding: 24px 0 54px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

.detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-nav .back-link {
  margin-bottom: 0;
}

.detail-language {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: start;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.detail-hero h1 {
  margin: 10px 0 10px;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(32px, 6vw, 64px);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.02;
}

.lede {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.fact-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(35, 49, 71, .86);
}

.fact-row {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.fact-row:last-child {
  border-bottom: 0;
}

.fact-label {
  display: block;
  color: var(--quiet);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.fact-value {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 34px;
  margin-top: 28px;
}

.detail-section {
  margin-bottom: 28px;
}

.detail-section h2,
.source-panel h2 {
  margin: 0 0 12px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  font-weight: 650;
}

.detail-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.uncertainty {
  margin: 0;
  padding: 14px 15px;
  border-left: 3px solid var(--alert);
  background: rgba(242, 201, 76, .08);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.source-panel {
  align-self: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(35, 49, 71, .74);
}

.source-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.source-card {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.source-card:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.source-card a {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.source-meta {
  margin: 5px 0 0;
  color: var(--quiet);
  font-size: 9.5px;
}

.source-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}

.not-found {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.not-found h1 {
  font-family: "Fraunces", Georgia, serif;
}

@media (max-width: 920px) {
  #map {
    position: absolute;
    height: 66vh;
  }

  .map-shell {
    padding-top: 66vh;
  }

  .topbar {
    position: absolute;
  }

  .controls,
  .side-list {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    width: calc(100vw - 24px);
    margin: 12px;
  }

  .side-list {
    max-height: none;
  }

  .incident-list {
    max-height: none;
  }

  .detail-hero,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 13px 14px 36px;
  }

  .subtitle {
    font-size: 11px;
  }

  .filter-row {
    grid-template-columns: 18px 14px 1fr;
  }

  .filter-row .amount {
    display: none;
  }

  .detail-wrap {
    width: min(100vw - 24px, 1100px);
    padding-top: 16px;
  }
}
