:root {
  --bg: #0a0f14;
  --panel: #121a22;
  --line: #223040;
  --fg: #e8eef2;
  --muted: #8aa0b0;
  --stable: #35d2a0;
  --amber: #e8a33d;
  --danger: #e2543a;
  --accent: #3fa8f5;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

header.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 32px; border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace; font-size: 13px;
}
.mark { letter-spacing: 0.06em; color: var(--accent); font-weight: 600; }
.top-note { color: var(--muted); }

main { max-width: 880px; margin: 0 auto; padding: 48px 24px 80px; }

.hero h1 {
  font-family: 'Fraunces', serif; font-weight: 500; font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.1; margin: 0 0 20px;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.lede { color: var(--muted); font-size: 1.05rem; max-width: 620px; margin: 0 0 28px; }

#search { display: flex; gap: 10px; max-width: 560px; }
#addr {
  flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--fg);
  padding: 14px 16px; border-radius: 10px; font-size: 1rem; font-family: inherit;
}
#addr::placeholder { color: var(--muted); }
#search button {
  background: var(--accent); color: #05202f; border: none; border-radius: 10px;
  padding: 14px 22px; font-weight: 600; font-size: 1rem; cursor: pointer;
}
#search button:hover { filter: brightness(1.1); }
#search button:focus-visible, #addr:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint { margin: 14px 0 0; color: var(--muted); font-size: 0.9rem; }
.chip {
  background: transparent; border: 1px solid var(--line); color: var(--fg);
  border-radius: 999px; padding: 5px 14px; margin-left: 6px; font-size: 0.85rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.result { margin-top: 48px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.detail { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.detail-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-val { font-family: 'IBM Plex Mono', monospace; font-size: 0.95rem; }

.scenario-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.scenario-row label { color: var(--muted); font-size: 0.9rem; }
#scenario-select {
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-family: inherit; font-size: 0.95rem; flex: 1; max-width: 320px;
}

.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.score { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.score-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.lvl-chip { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; font-weight: 600; width: fit-content; }
.lvl-chip.lvl-na { color: var(--muted); border-color: var(--line); background: transparent; }

.map-wrap { position: relative; margin-bottom: 24px; }
#map { height: 420px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.map-legend {
  position: absolute; bottom: 12px; left: 12px; background: rgba(10,15,20,0.85);
  border-radius: 8px; padding: 8px 12px; font-size: 0.78rem; display: flex; gap: 16px; align-items: center;
}
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.map-legend-note { color: var(--muted); }

.provenance { color: var(--muted); font-size: 0.85rem; }
.provenance a { color: var(--accent); }

.empty, .loading { margin-top: 40px; color: var(--muted); }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.about { margin-top: 64px; border-top: 1px solid var(--line); padding-top: 32px; }
.about h2 { font-family: 'Fraunces', serif; font-weight: 500; font-size: 1.4rem; }
.about p { color: var(--muted); max-width: 680px; }
.about .limits strong { color: var(--amber); }
.about p strong { color: var(--fg); }

footer { border-top: 1px solid var(--line); padding: 20px 32px; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8rem; font-family: 'IBM Plex Mono', monospace; }

@media (max-width: 560px) {
  #search { flex-direction: column; }
  header.top { flex-direction: column; align-items: flex-start; gap: 4px; }
}
