:root {
  color-scheme: dark;
  --bg: #111814;
  --ink: #f5f0e5;
  --muted: #b6b6a5;
  --line: rgba(244, 232, 203, 0.18);
  --panel: rgba(27, 35, 29, 0.82);
  --panel-strong: rgba(31, 40, 33, 0.96);
  --accent: #b8d8a7;
  --gold: #d8a85e;
  --clay: #c77b5d;
  --danger: #ff6b6b;
  --blue: #74a7ff;
  --violet: #c79bff;
  font-family: "Avenir Next", Avenir, Inter, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }

.atlas-shell { position: relative; width: 100vw; height: 100vh; overflow: hidden; background: radial-gradient(circle at 52% 45%, #293b2b 0, #111814 58%); }
.atlas-shell::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .25; background-image: radial-gradient(rgba(245,240,229,.16) .6px, transparent .6px); background-size: 7px 7px; mix-blend-mode: screen; }
#atlasCanvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#atlasCanvas:active { cursor: grabbing; }

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: minmax(230px, 320px) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: start;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand, .search-wrap, .mode-switch, .filter-panel, .detail-panel, .hover-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 12px;
  border-radius: 18px;
  box-shadow: 0 20px 70px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.08);
}
.eyebrow { color: var(--gold); font-size: 9px; letter-spacing: .14em; vertical-align: middle; margin-left: 5px; }
.brand-mark {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(94, 224, 194, 0.45);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(94, 224, 194, 0.96) 0 4px, transparent 5px),
    conic-gradient(from 40deg, rgba(94,224,194,0.1), rgba(233,196,106,0.6), rgba(116,167,255,0.4), rgba(94,224,194,0.1));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.05; font-weight: 750; letter-spacing: 0; }
.brand p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.search-wrap { display: flex; min-height: 44px; }
.search-wrap { border-radius: 14px; }
.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  padding: 0 14px;
}
.search-wrap button, .mode-switch button {
  border: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  padding: 0 13px;
  min-height: 44px;
  cursor: pointer;
}
.search-wrap button:hover, .mode-switch button:hover { background: rgba(255, 255, 255, 0.12); }

.mode-switch {
  display: grid;
  grid-template-columns: repeat(6, minmax(74px, 1fr));
  overflow: hidden;
  border-radius: 14px;
}
.mode-switch button {
  border-left: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}
.mode-switch button:first-child { border-left: 0; }
.mode-switch button.active { background: rgba(184, 216, 167, 0.2); color: #f5f0e5; }

.filter-panel {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border-radius: 18px;
}
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.metric-grid div { border: 1px solid var(--line); padding: 9px; min-height: 58px; }
.metric-grid strong { display: block; font-size: 20px; line-height: 1.1; }
.metric-grid span { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }

label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; margin-top: 10px; }
select {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  min-height: 36px;
  padding: 0 10px;
  outline: none;
}

.legend { display: grid; gap: 7px; margin-top: 14px; }
.legend-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ethics-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-panel {
  position: absolute;
  right: 16px;
  top: 96px;
  bottom: 16px;
  width: min(430px, calc(100vw - 32px));
  padding: 18px;
  overflow: auto;
  border-radius: 22px;
  scrollbar-color: rgba(216,168,94,.55) transparent;
}
.detail-panel h2 { font-size: 22px; line-height: 1.12; margin-bottom: 7px; }
.detail-panel h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; letter-spacing: 0.04em; }
.detail-panel p, .detail-panel li { color: #d9e4e1; font-size: 13px; line-height: 1.5; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.pill { border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: #d9e4e1; padding: 4px 7px; font-size: 11px; }
.pill { border-radius: 999px; }
.field { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.field strong { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; margin-bottom: 5px; letter-spacing: 0.04em; }
.field a { color: var(--accent); word-break: break-word; }
.source-link { display: block; width: 100%; text-align: left; color: var(--accent); background: rgba(255,255,255,.04); border: 1px solid var(--line); padding: 9px 10px; margin-top: 6px; cursor: pointer; border-radius: 10px; }
.empty-state { height: 100%; display: grid; place-content: center; gap: 8px; text-align: left; }
.empty-state p { color: var(--muted); max-width: 320px; }

.hover-card {
  position: absolute;
  display: none;
  max-width: 320px;
  padding: 12px;
  pointer-events: none;
  z-index: 8;
  border-radius: 14px;
}
.hover-card h3 { font-size: 14px; margin-bottom: 5px; }
.hover-card p { color: var(--muted); font-size: 12px; line-height: 1.4; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr; right: 16px; }
  .mode-switch { grid-template-columns: repeat(3, 1fr); }
  .filter-panel { display: none; }
  .detail-panel { top: auto; left: 16px; right: 16px; bottom: 16px; width: auto; height: 42vh; }
}
@media (max-width: 620px) {
  html, body { overflow: auto; }
  .atlas-shell { min-height: 100vh; height: auto; overflow: visible; padding-bottom: 18px; }
  #atlasCanvas { position: fixed; opacity: .34; }
  .topbar { position: relative; top: auto; left: auto; right: auto; padding: 14px; gap: 9px; }
  .mode-switch { grid-template-columns: repeat(2, 1fr); }
  .filter-panel { display: block; position: relative; left: auto; bottom: auto; width: auto; margin: 0 14px; }
  .detail-panel { position: relative; left: auto; right: auto; bottom: auto; top: auto; width: auto; height: auto; min-height: 42vh; margin: 14px; }
  .brand, .search-wrap, .mode-switch, .filter-panel, .detail-panel { background: rgba(27,35,29,.92); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
