:root {
  --bg: #0a0a0c;
  --panel: rgba(18, 18, 22, 0.92);
  --panel-solid: #121216;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e8e8;
  --text-dim: rgba(255, 255, 255, 0.6);
  --text-faint: rgba(255, 255, 255, 0.35);
  --accent: #6ba6ff;

  --c-openai:    #10a37f;
  --c-anthropic: #d97757;
  --c-meta:      #1877f2;
  --c-google:    #fbbc04;
}

body.light-theme {
  --bg: #fafafa;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-solid: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1a1a1a;
  --text-dim: rgba(0, 0, 0, 0.62);
  --text-faint: rgba(0, 0, 0, 0.4);
  --accent: #2563eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

/* ─── Header ──────────────────────────────────────────────────── */
header {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 360px;
}

header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

header h1 a {
  color: var(--text);
  text-decoration: none;
}

header p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.45;
}

header .stats {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-faint);
}

header .stats b {
  color: var(--text);
  font-weight: 600;
  margin-right: 3px;
}

/* ─── Filter chips ────────────────────────────────────────────── */
.filters {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 420px;
}

.chip {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip:hover { color: var(--text); border-color: rgba(255,255,255,0.18); }
body.light-theme .chip:hover { border-color: rgba(0,0,0,0.18); }

.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.chip.active {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--panel-solid);
}

.chip.dim {
  opacity: 0.4;
}

.chip-row.toolbar .chip {
  font-size: 11px;
  padding: 5px 10px;
}

/* ─── Side panel ──────────────────────────────────────────────── */
#panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  z-index: 1100;
  overflow-y: auto;
  display: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

body.light-theme #panel {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

#panel.open { display: block; }

#panel .close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#panel .close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

body.light-theme #panel .close:hover { background: rgba(0,0,0,0.05); }

#panel .lab-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  color: white;
  margin-bottom: 8px;
}

#panel h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 4px;
  padding-right: 30px;
}

#panel .location {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

#panel .meta-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px 12px;
  font-size: 12px;
  margin-bottom: 16px;
}

#panel .meta-grid dt {
  color: var(--text-faint);
  font-weight: 500;
}

#panel .meta-grid dd {
  color: var(--text);
  line-height: 1.45;
}

#panel .notes {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

#panel .sources {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

#panel .sources h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
  font-weight: 600;
}

#panel .sources a {
  display: block;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 5px;
  word-break: break-all;
  line-height: 1.4;
}

#panel .sources a:hover { text-decoration: underline; }

#panel .power-bar {
  margin-top: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  height: 6px;
  position: relative;
  overflow: hidden;
}
body.light-theme #panel .power-bar { background: rgba(0,0,0,0.06); }

#panel .power-bar > span {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 4px;
}

/* ─── Undisclosed footer ──────────────────────────────────────── */
#undisclosed-toggle {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 1000;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
}

#undisclosed-toggle:hover { color: var(--text); }

#undisclosed {
  position: absolute;
  bottom: 60px;
  left: 16px;
  z-index: 1000;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  overflow-y: auto;
  display: none;
}

#undisclosed.open { display: block; }

#undisclosed h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 12px;
  font-weight: 600;
}

#undisclosed .item {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

#undisclosed .item:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

#undisclosed .item .lab-line {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#undisclosed .item .name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

#undisclosed .item .note {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

/* ─── Theme toggle ────────────────────────────────────────────── */
#theme-toggle {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

#theme-toggle:hover { color: var(--text); }

/* ─── Leaflet overrides ───────────────────────────────────────── */
.leaflet-control-attribution {
  background: var(--panel) !important;
  color: var(--text-faint) !important;
  font-size: 9.5px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--panel-solid) !important; }

.dc-marker {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

body.light-theme .dc-marker {
  border-color: rgba(255,255,255,0.95);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.15);
}

.dc-marker:hover {
  transform: scale(1.18);
  z-index: 1000;
}

.dc-marker.active {
  transform: scale(1.3);
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(107, 166, 255, 0.6);
}

.leaflet-tooltip.dc-tooltip {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.leaflet-tooltip.dc-tooltip::before { display: none; }

/* ─── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  header { max-width: calc(100vw - 32px); }
  .filters { top: auto; bottom: 60px; right: 16px; left: 16px; align-items: stretch; }
  .chip-row { justify-content: flex-start; max-width: none; }
  #panel { top: auto; right: 8px; left: 8px; bottom: 8px; height: 60vh; width: auto; }
  #undisclosed { width: calc(100vw - 32px); }
}
