:root {
  --bg: #060913;
  --bg-2: #0a0f1e;
  --panel: #0e1528;
  --panel-2: #131c35;
  --border: #2b3c64;
  --border-soft: #1b2440;
  --text: #f2efe6;
  --text-dim: #a9b3d1;
  --text-faint: #626e93;
  --gold: #c9a24d;
  --gold-bright: #f0d288;
  --gold-rgb: 201, 162, 77;
  --gold-bright-rgb: 240, 210, 136;
  --navy-rgb: 20, 32, 62;
  --emerald: #45c99a;
  --amber: #e2a44f;
  --red: #e2685f;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(800px 460px at 50% -10%, rgba(var(--gold-rgb),0.16), transparent 60%),
    radial-gradient(1000px 650px at 88% 6%, rgba(43,60,110,0.45), transparent 60%),
    radial-gradient(1000px 750px at 6% 95%, rgba(var(--gold-rgb),0.06), transparent 60%),
    linear-gradient(180deg, #060913 0%, #080c1a 45%, #05070f 100%);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(19,28,53,0.55), rgba(19,28,53,0));
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 32px; height: 32px;
  color: var(--gold-bright);
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(var(--gold-rgb),0.35));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--gold-bright), var(--gold) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}


.stage {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.hero {
  text-align: center;
  padding-top: 78px;
  padding-bottom: 8px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 43px;
  letter-spacing: 0.005em;
  margin: 0 0 16px;
  background: linear-gradient(180deg, #ffffff 0%, #e7d9b8 55%, var(--gold) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 15.5px;
  max-width: 560px;
  margin: 0 auto 34px;
  line-height: 1.65;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin: 0 auto 36px;
}

.hero-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hs-num {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 34px;
  line-height: 1;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px rgba(var(--gold-rgb),0.4);
}
.hs-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
}

.hero-stat-divider {
  width: 1px;
  height: 34px;
  background: linear-gradient(180deg, transparent, rgba(var(--gold-rgb),0.4), transparent);
}

.hero-stats-error { font-size: 13px; color: var(--text-faint); }

.search-shell {
  position: relative;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #141d38, #0d1428);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px 5px 22px;
  box-shadow: 0 24px 60px -22px rgba(0,0,0,0.75), inset 0 1px 0 rgba(255,255,255,0.03);
  transition: border-color .25s ease, box-shadow .25s ease;
}

.search-shell:focus-within {
  border-color: rgba(var(--gold-rgb),0.6);
  box-shadow: 0 0 0 4px rgba(var(--gold-rgb),0.12), 0 24px 60px -22px rgba(0,0,0,0.75);
}

.search-icon { width: 19px; height: 19px; color: var(--text-faint); flex-shrink: 0; }

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  padding: 15px 12px;
  font-family: var(--sans);
}
#searchInput::placeholder { color: var(--text-faint); }

.clear-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.clear-btn:hover { color: var(--text); border-color: var(--gold); }
.clear-btn.visible { display: flex; }

.ticker-wrap {
  position: relative;
  max-width: 720px;
  margin: 26px auto 0;
  padding: 13px 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(19,28,53,0.7), rgba(14,21,40,0.5));
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}

.ticker-track {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  animation: ticker-scroll 42s linear infinite;
}
.ticker-wrap:hover .ticker-track,
.ticker-wrap:focus-within .ticker-track {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s ease;
  letter-spacing: 0.01em;
}
.chip:hover { border-color: #46589a; color: var(--text); }
.chip.active {
  background: rgba(var(--gold-rgb),0.14);
  border-color: rgba(var(--gold-rgb),0.6);
  color: var(--gold-bright);
}
.chip .chip-flag { font-size: 13px; line-height: 1; }
.chip .chip-count { color: var(--text-faint); margin-left: 2px; }
.chip.active .chip-count { color: rgba(var(--gold-bright-rgb),0.75); }

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 40px 2px 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.results-meta .legend { display: flex; gap: 16px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.exact { background: var(--emerald); }
.dot.strong { background: var(--gold); }
.dot.possible { background: var(--amber); }
.dot.weak { background: var(--text-faint); }

.hidden { display: none !important; }

.results-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-card {
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .2s ease, transform .15s ease;
}
.result-card:hover {
  border-color: rgba(var(--gold-rgb),0.45);
  box-shadow: 0 10px 30px -18px rgba(var(--gold-rgb),0.35);
}

.rc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rc-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.rc-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.002em;
}

.rc-alias {
  font-size: 12.5px;
  color: var(--text-faint);
}
.rc-alias b { color: var(--text-dim); font-weight: 500; }

.rc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.tag {
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: rgba(255,255,255,0.02);
}
.tag.source { color: var(--gold-bright); border-color: rgba(var(--gold-rgb),0.4); background: rgba(var(--gold-rgb),0.08); }

.rc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }

.confidence {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.confidence .dot { width: 7px; height: 7px; }
.confidence.exact { background: rgba(69,201,154,0.14); color: var(--emerald); }
.confidence.strong { background: rgba(var(--gold-rgb),0.16); color: var(--gold-bright); }
.confidence.possible { background: rgba(224,169,74,0.14); color: var(--amber); }
.confidence.weak { background: rgba(98,110,147,0.16); color: var(--text-dim); }

.score { font-size: 11px; color: var(--text-faint); }

.rc-expand-hint { font-size: 11px; color: var(--text-faint); }

.rc-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
}
.result-card.open .rc-details { max-height: 900px; }

.rc-details-inner {
  padding-top: 16px;
  margin-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 28px;
  font-size: 13px;
}

.detail-block { min-width: 0; }
.detail-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 5px;
}
.detail-value { color: var(--text-dim); line-height: 1.55; word-break: break-word; }
.detail-value.remarks { color: var(--text-dim); }
.detail-block.full { grid-column: 1 / -1; }

.cr-panels { display: flex; flex-direction: column; gap: 12px; }

.cr-panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.cr-country {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 9px;
}

.cr-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.cr-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid currentColor;
}
.cr-score .cr-num { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1; }
.cr-score .cr-lbl { font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.03em; text-align: center; line-height: 1.3; margin-top: 3px; opacity: 0.85; }

.cr-score.cr-very-low  { color: var(--emerald); }
.cr-score.cr-low       { color: #8fd18a; }
.cr-score.cr-medium    { color: var(--amber); }
.cr-score.cr-high      { color: #e2794a; }
.cr-score.cr-very-high { color: var(--red); }

.cr-dims {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  flex: 1;
  min-width: 200px;
}

.cr-dim { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.cr-dim-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.cr-bar { width: 100%; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.cr-bar-fill { height: 100%; }
.cr-dim-val { font-size: 11.5px; color: var(--text-dim); }

.cr-conflict {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--red);
  background: rgba(226,104,95,0.1);
  border: 1px solid rgba(226,104,95,0.3);
  border-radius: 6px;
  padding: 5px 10px;
  display: inline-block;
}

.source-link {
  color: var(--gold-bright);
  text-decoration: none;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(var(--gold-rgb),0.4);
}
.source-link:hover { border-color: var(--gold-bright); }

.empty-state, .loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state h3, .loading-state h3 {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text);
  margin: 0 0 8px;
  font-weight: 500;
}
.empty-state p { font-size: 13.5px; color: var(--text-faint); }

.spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  margin: 0 auto 18px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.idle-state { margin-top: 46px; }
.idle-card {
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  text-align: center;
  box-shadow: 0 30px 70px -35px rgba(0,0,0,0.6);
}
.idle-card h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 21px;
  margin: 0 0 10px;
  color: var(--text);
}
.idle-card p {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.65;
  max-width: 560px;
  margin: 0 auto 26px;
}

.idle-sources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  text-align: left;
}

.region {
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: 0 14px 28px -18px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.03);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.region:hover {
  border-color: rgba(var(--gold-rgb),0.4);
  box-shadow: 0 18px 34px -16px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.04);
  transform: translateY(-1px);
}

.region-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.region:not(.single) .region-head { cursor: pointer; user-select: none; }

.region-id { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.region-flag { font-size: 16px; flex-shrink: 0; }
.region-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.region-count-label { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; letter-spacing: 0.02em; }

.region-chev {
  color: var(--text-faint);
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 4px;
  transition: transform .2s ease;
}
.region.open .region-chev { transform: rotate(180deg); }

.region-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}
.region.open .region-detail { max-height: 700px; }

.region-detail-inner {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.region-list-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
}
.region-list-row .l { color: var(--text-dim); }
.region-list-row .d { color: var(--text-faint); opacity: 0.75; font-size: 10px; flex-shrink: 0; }

.region.single .region-list-row { font-size: 11px; }
.region.single .region-list-row .l { display: none; }

.foot {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 30px 20px 40px;
  border-top: 1px solid var(--border-soft);
}

.foot-tagline {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.01em;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright) 55%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.55;
}

.foot-disclaimer {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .topbar { padding: 16px 18px; }
  .hero h1 { font-size: 30px; }
  .rc-details-inner { grid-template-columns: 1fr; }
  .hero-stats { gap: 18px; flex-wrap: wrap; }
  .hs-num { font-size: 26px; }
}
