:root {
  --bg: #0a0e1a;
  --panel: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --text: #dbe2f0;
  --dim: #8b95ab;
  --accent: #7dd3fc;
  --green: #34d399;
  --slate: #5b6b83;
  --red: #f87171;
}

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

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 700px at 75% -10%, rgba(56, 89, 179, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(125, 60, 152, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand h1 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.3px;
}

.brand h1 span {
  background: linear-gradient(90deg, #7dd3fc, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand p { color: var(--dim); font-size: 12px; }

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

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: center;
}

.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat i { font-style: normal; color: var(--dim); font-size: 11px; }
.stat.green b { color: var(--green); }
.stat.red b { color: var(--red); }

.controls { margin-left: auto; display: flex; gap: 10px; align-items: center; }

#search {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 12px;
  width: 220px;
  outline: none;
}

#search:focus { border-color: var(--accent); }

.toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.toggle button {
  background: transparent;
  border: 0;
  color: var(--dim);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}

.toggle button.active { background: rgba(125, 211, 252, 0.14); color: var(--accent); }

main { flex: 1; display: flex; min-height: 0; }

#sidebar {
  width: 360px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: #2a3350 transparent;
}

.side-heading { margin: 6px 2px 10px; }
.side-heading h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.side-heading .hint { font-size: 11px; color: #5d6880; }
.side-heading:not(:first-child) { margin-top: 22px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.card:hover { border-color: rgba(125, 211, 252, 0.45); }
.card.selected { border-color: var(--accent); background: rgba(125, 211, 252, 0.07); }

.card .row1 { display: flex; align-items: center; gap: 8px; }
.card .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.card .terms {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .size { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }

.card .bar {
  display: flex;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0 6px;
  background: rgba(255, 255, 255, 0.05);
}
.card .bar .a { background: var(--green); }
.card .bar .w { background: var(--slate); }
.card .bar .u { background: var(--red); }

.card .meta { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; gap: 8px; }
.card .meta .area { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card .exemplars { display: none; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.card.selected .exemplars { display: block; }
.card .exemplars a {
  display: block;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  margin: 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .exemplars a:hover { text-decoration: underline; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
table td, table th { padding: 5px 6px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
table th { color: var(--dim); font-weight: 500; font-size: 11px; }
table td:not(:first-child), table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.footnote { color: #5d6880; font-size: 11px; margin-top: 18px; }

#stage { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }

#tooltip {
  position: absolute;
  max-width: 320px;
  background: rgba(13, 18, 34, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  pointer-events: none;
  font-size: 12px;
  z-index: 5;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#tooltip .t { font-weight: 600; margin-bottom: 3px; }
#tooltip .c { color: var(--dim); }
#tooltip .s { margin-top: 3px; font-size: 11px; }
#tooltip .s.a { color: var(--green); }
#tooltip .s.w { color: var(--slate); }
#tooltip .s.u { color: var(--red); }

#legend {
  position: absolute;
  right: 14px;
  bottom: 14px;
  background: rgba(13, 18, 34, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--dim);
}
#legend .chip { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

#viewhint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  color: #46506a;
  font-size: 11px;
  pointer-events: none;
}
