:root {
  color-scheme: dark;
  --panel: rgba(7, 17, 33, 0.82);
  --panel-strong: rgba(11, 24, 46, 0.95);
  --border: rgba(170, 205, 255, 0.14);
  --text: #edf4ff;
  --muted: #9cb4d8;
  --accent: #7df9c7;
  --accent-strong: #23cfa1;
  --danger: #ff857d;
  --warn: #ffc46b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(30, 107, 154, 0.35), transparent 30%),
    radial-gradient(circle at right center, rgba(48, 191, 157, 0.18), transparent 28%),
    linear-gradient(135deg, #07101e 0%, #0f1d35 44%, #091521 100%);
  color: var(--text);
}

button,
input,
a {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 410px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(6, 14, 28, 0.92), rgba(7, 16, 30, 0.78));
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.hero h1,
.map-overlay h2 {
  margin: 0;
  font-family: "Instrument Serif", serif;
  font-size: clamp(2.6rem, 5vw, 3.5rem);
  font-weight: 400;
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.intro,
.overlay-copy,
.debug-detail {
  color: var(--muted);
  line-height: 1.55;
}

.panel {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.ghost-button,
.jump-button,
.conflict-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.ghost-button,
.jump-button {
  padding: 10px 14px;
}

.ghost-button:hover,
.jump-button:hover,
.conflict-tab:hover,
.conflict-tab.active {
  transform: translateY(-1px);
  border-color: rgba(125, 249, 199, 0.45);
  background: rgba(125, 249, 199, 0.1);
}

.conflict-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.conflict-tab {
  padding: 10px 14px;
}

.field {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.field span,
.field strong {
  font-size: 0.95rem;
}

input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.badge,
.severity-pill,
.confidence-pill,
.debug-badge,
.meta-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.badge,
.meta-pill {
  background: rgba(125, 249, 199, 0.12);
  color: var(--accent);
}

.debug-badge-pending {
  background: rgba(255, 196, 107, 0.14);
  color: var(--warn);
}

.debug-badge-ok {
  background: rgba(125, 249, 199, 0.12);
  color: var(--accent);
}

.debug-badge-error {
  background: rgba(255, 133, 125, 0.14);
  color: var(--danger);
}

.event-list {
  display: grid;
  gap: 14px;
  max-height: min(48vh, 560px);
  overflow-y: auto;
  padding-right: 6px;
}

.event-list::-webkit-scrollbar {
  width: 10px;
}

.event-list::-webkit-scrollbar-thumb {
  background: rgba(125, 249, 199, 0.16);
  border-radius: 999px;
}

.event-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid rgba(170, 205, 255, 0.1);
}

.event-card-top,
.event-meta,
.overlay-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.event-card h3 {
  margin: 14px 0 10px;
  font-size: 1rem;
}

.event-description,
.event-location,
.debug-detail,
.event-link {
  color: var(--muted);
}

.event-description {
  margin: 0 0 14px;
  line-height: 1.5;
}

.event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tag-pill {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.event-link {
  display: inline-block;
  margin-top: 14px;
}

.map-stage {
  position: relative;
  padding: 20px;
}

.map-overlay {
  position: absolute;
  z-index: 500;
  top: 36px;
  left: 36px;
  max-width: min(500px, calc(100% - 72px));
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(7, 17, 33, 0.74);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.overlay-meta {
  margin-top: 14px;
}

#map {
  height: calc(100vh - 40px);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.custom-marker {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 0 8px rgba(255, 133, 125, 0.12);
}

.custom-marker.approximate {
  border-style: dashed;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #10203a;
  color: var(--text);
}

.popup-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.popup-copy {
  margin: 0 0 8px;
  color: var(--muted);
}

.popup-source {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .map-stage {
    padding: 16px;
  }

  .map-overlay {
    position: static;
    max-width: none;
    margin-bottom: 14px;
  }

  #map {
    height: 68vh;
  }
}
