:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212d;
  --border: #243041;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --accent: #5b9dff;
  --accent-2: #7c5cff;
  --ok: #3dd68c;
  --warn: #f5a524;
  --danger: #f31260;
  --product: #5b9dff;
  --company: #3dd68c;
  --person: #f5a524;
  --vc_firm: #c084fc;
  --radius: 10px;
  --font: "SF Pro Text", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #10161f 0%, #0c1219 100%);
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 16px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #9ec1ff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="search"],
input[type="text"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 157, 255, 0.15);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  flex: 1;
}
button:hover { border-color: #3a4d66; background: #1c2735; }
button.primary {
  width: 100%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-color: transparent;
  font-weight: 600;
  margin-top: 4px;
}
button.primary:hover { filter: brightness(1.08); }

.type-filters {
  display: grid;
  gap: 6px;
}
.type-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  padding: 4px 2px;
}
.type-filters .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.type-filters .count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.search-results {
  margin-top: 6px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.search-results button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}
.search-results button:last-child { border-bottom: 0; }
.search-results .tag {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: #243041;
  color: var(--muted);
}
.search-results .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats-list.dense { gap: 2px; max-height: 280px; overflow: auto; }
.stats-list .item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.84rem;
  text-align: left;
  width: 100%;
}
.stats-list .item:hover {
  border-color: var(--border);
  background: #1c2735;
}
.stats-list .item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-list .item .val {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.stats-list .item.rel .val { color: var(--muted); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.stats-grid .chip {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats-grid .chip .t {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-grid .chip .n {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.path-result {
  margin-top: 10px;
  min-height: 28px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
  word-break: break-word;
}
.path-result[data-bench-path-status="ok"] { color: var(--ok); }
.path-result[data-bench-path-status="unreachable"],
.path-result[data-bench-path-status="invalid"],
.path-result[data-bench-path-status="same"] { color: var(--warn); }
.path-result .path-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.path-result .path-node {
  background: #1a2a1f;
  border: 1px solid #2d4a38;
  color: var(--ok);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.path-result .path-sep {
  color: #3d5a48;
  align-self: center;
  font-size: 0.75rem;
}

.stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 70% 30%, rgba(91, 157, 255, 0.06), transparent 60%),
    radial-gradient(900px 600px at 20% 80%, rgba(124, 92, 255, 0.05), transparent 55%),
    var(--bg);
}
#graph {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#graph.dragging { cursor: grabbing; }

.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: rgba(18, 24, 33, 0.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.tooltip .tt-name { font-weight: 600; margin-bottom: 2px; }
.tooltip .tt-meta { color: var(--muted); font-size: 0.74rem; }

.detail {
  position: absolute;
  right: 16px;
  top: 16px;
  width: min(360px, calc(100% - 32px));
  max-height: calc(100% - 80px);
  overflow: auto;
  background: rgba(18, 24, 33, 0.96);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px 16px;
  z-index: 6;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
}
#detail-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 8px;
}
.detail h3 {
  margin: 0 28px 6px 0;
  font-size: 1.05rem;
}
.detail .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.detail .badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #243041;
  color: var(--muted);
}
.detail .desc {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
  margin-bottom: 12px;
}
.detail h4 {
  margin: 12px 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.detail .rel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
}
.detail .rel button {
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  flex: none;
}
.detail .rel .rtype {
  color: var(--accent);
  font-size: 0.72rem;
  font-family: var(--mono);
}
.detail .rel .rname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail .aliases {
  color: var(--muted);
  font-size: 0.8rem;
}

.hud {
  position: absolute;
  left: 16px;
  bottom: 14px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  color: var(--muted);
  font-size: 0.78rem;
}
.hud .hint { opacity: 0.75; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}
