:root {
  --bg: #0b0d12;
  --bg-elev: #12161f;
  --bg-soft: #181d29;
  --border: #2a3344;
  --text: #e8edf7;
  --muted: #8b95a8;
  --accent: #7c6cff;
  --accent-2: #3dd6c6;
  --danger: #ff6b8a;
  --warn: #f0b429;
  --product: #5b8cff;
  --company: #3dd6c6;
  --person: #f0b429;
  --vc_firm: #c084fc;
  --link: rgba(140, 155, 180, 0.22);
  --path: #ff6b8a;
  --radius: 12px;
  --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: minmax(300px, 360px) 1fr;
  height: 100vh;
}

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

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 2px 8px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(135deg, #7c6cff, #3dd6c6);
  box-shadow: 0 8px 24px rgba(124, 108, 255, 0.35);
}
.brand h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.row { display: flex; gap: 8px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
input[type="search"],
input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  outline: none;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18);
}

button {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { background: #1f2635; border-color: #3a465c; }
button:active { transform: translateY(1px); }
button.primary {
  width: 100%;
  background: linear-gradient(135deg, #6a5af9, #4f8cff);
  border-color: transparent;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.block { width: 100%; }

.type-filters {
  display: grid;
  gap: 6px;
}
.type-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.type-filters label:hover { border-color: var(--border); }
.type-filters input { accent-color: var(--accent); }
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.count-pill {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.hits {
  margin-top: 8px;
  max-height: 160px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.hit {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 8px 10px;
  font-size: 12px;
}
.hit:last-child { border-bottom: 0; }
.hit:hover { background: #1a2030; }
.hit .t { color: var(--muted); font-size: 11px; margin-left: auto; }

.path-result {
  margin-top: 10px;
  min-height: 28px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px dashed var(--border);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  word-break: break-word;
}
.path-result[data-bench-path-status="ok"] {
  border-style: solid;
  border-color: rgba(255, 107, 138, 0.45);
  color: var(--text);
}
.path-result[data-bench-path-status="unreachable"],
.path-result[data-bench-path-status="same"],
.path-result[data-bench-path-status="invalid"] {
  border-style: solid;
  border-color: rgba(240, 180, 41, 0.4);
  color: var(--warn);
}
.path-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 2px 2px 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 107, 138, 0.15);
  border: 1px solid rgba(255, 107, 138, 0.35);
  color: #ffd0da;
  font-size: 11px;
  cursor: pointer;
}
.path-arrow { color: var(--muted); margin: 0 2px; }

.node-detail {
  font-size: 13px;
  line-height: 1.5;
}
.node-detail.empty { color: var(--muted); font-size: 12px; }
.node-detail .name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.node-detail .meta-line {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.node-detail .desc {
  color: #c9d2e3;
  margin-bottom: 10px;
  font-size: 12px;
}
.node-detail .tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  margin-right: 4px;
  background: rgba(124, 108, 255, 0.15);
  border: 1px solid rgba(124, 108, 255, 0.3);
}
.neighbors {
  margin-top: 8px;
  max-height: 180px;
  overflow: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.neighbor {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid rgba(42, 51, 68, 0.6);
  font-size: 12px;
  cursor: pointer;
}
.neighbor:hover .n-name { color: var(--accent-2); }
.neighbor .rel {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  min-width: 92px;
}
.neighbor .n-name { flex: 1; }
.neighbor .dir { color: #5a6578; font-size: 10px; }

.stats-list { display: grid; gap: 4px; }
.stats-list.rel { max-height: 220px; overflow: auto; }
.stat-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  width: 100%;
  color: inherit;
}
.stat-row:hover { border-color: var(--border); background: #1c2331; }
.stat-row .rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 11px;
}
.stat-row .val {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-weight: 600;
}
.stat-row.rel-row {
  grid-template-columns: 1fr auto;
  cursor: default;
}
.stat-row.rel-row:hover { background: var(--bg-soft); border-color: transparent; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.type-card {
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.type-card .label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.type-card .num {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 4px;
}
.meta {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 70% 20%, rgba(124, 108, 255, 0.08), transparent 60%),
    radial-gradient(900px 700px at 20% 80%, rgba(61, 214, 198, 0.06), transparent 55%),
    #080a0f;
}
#graph {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#graph.dragging { cursor: grabbing; }

.hud {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  font-size: 12px;
  color: var(--muted);
}
#hud-hint, #hud-stats {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.72);
  border: 1px solid rgba(42, 51, 68, 0.8);
  backdrop-filter: blur(8px);
}

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(18, 22, 31, 0.95);
  border: 1px solid var(--border);
  font-size: 12px;
  max-width: 240px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transform: translate(12px, 12px);
}
.tooltip .tt-name { font-weight: 700; margin-bottom: 2px; }
.tooltip .tt-sub { color: var(--muted); font-size: 11px; }

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