:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #0e131b;
  --panel-strong: #121925;
  --surface: #171f2b;
  --surface-hover: #1d2836;
  --line: #263141;
  --line-soft: #1a2330;
  --text: #eef4f7;
  --muted: #8e9aaa;
  --subtle: #586678;
  --accent: #d9f556;
  --accent-dark: #839528;
  --danger: #ff6a74;
  --product: #6ee7ff;
  --company: #ffb45e;
  --person: #b795ff;
  --vc: #67e8a5;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

button { color: inherit; }

button:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: 300px 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  background: rgba(8, 11, 16, 0.96);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #111609;
  background: var(--accent);
  border-radius: 7px 7px 7px 2px;
  font-weight: 900;
  font-size: 19px;
  box-shadow: 0 0 26px rgba(217, 245, 86, 0.16);
}

.brand h1 { margin: 0; font-size: 17px; line-height: 1.1; letter-spacing: .01em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }

.dataset-summary { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font-size: 12px; }
.dataset-summary strong { color: var(--text); font-family: var(--font-mono); font-size: 14px; }
.dataset-summary i { width: 3px; height: 3px; border-radius: 50%; background: var(--subtle); }

.button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.button:hover { background: var(--surface-hover); border-color: #3a495e; }
.button:active { transform: translateY(1px); }
.button-primary { color: #111609; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: #e5ff69; border-color: #e5ff69; }
.button-wide { width: 100%; margin-top: 13px; }

.workspace {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 300px minmax(360px, 1fr) 330px;
  min-height: 0;
}

.panel {
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.controls-panel { border-right: 1px solid var(--line); }
.insight-panel { border-left: 1px solid var(--line); }

.panel-section { padding: 21px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-section:last-child { border-bottom: 0; }

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 15px; }
.section-heading.compact { align-items: center; margin-bottom: 12px; }
.section-heading h2, .legend-section h2 { margin: 0; font-size: 14px; letter-spacing: .01em; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--accent); font: 700 9px/1 var(--font-mono); letter-spacing: .17em; }
.section-note { margin: -6px 0 15px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.field-label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.field-hint { margin: 8px 0 0; color: var(--subtle); font-size: 10px; line-height: 1.5; }

.search-section { position: relative; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 15px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-box input, .text-input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #0a0f16;
  font-size: 12px;
}
.text-input { padding: 0 11px; font-family: var(--font-mono); }
.search-box input::placeholder, .text-input::placeholder { color: #4f5b6a; }
.search-box input:focus, .text-input:focus { border-color: #56687d; }
.icon-button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 19px; }
.icon-button:hover { color: var(--text); background: var(--surface); }
.search-box .icon-button { position: absolute; right: 5px; top: 5px; }

.search-results {
  position: absolute;
  z-index: 30;
  left: 18px;
  right: 18px;
  margin-top: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101722;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .42);
}
.search-result { width: 100%; display: grid; grid-template-columns: 8px 1fr auto; gap: 9px; align-items: center; padding: 10px 11px; border: 0; border-bottom: 1px solid var(--line-soft); color: var(--text); text-align: left; background: transparent; cursor: pointer; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--surface); }
.search-result-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--node-color); }
.search-result strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.search-result small { display: block; margin-top: 3px; color: var(--muted); font: 9px var(--font-mono); }
.search-result-type { color: var(--muted); font-size: 9px; }
.search-none { padding: 13px; color: var(--muted); font-size: 11px; text-align: center; }

.text-button { padding: 3px; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; }
.text-button:hover { color: var(--accent); }
.type-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.type-filter { display: flex; align-items: center; justify-content: space-between; min-height: 36px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #0a0f16; cursor: pointer; font-size: 10px; }
.type-filter:hover { border-color: #3d4b5d; }
.type-filter[aria-pressed="true"] { color: var(--text); border-color: color-mix(in srgb, var(--node-color) 46%, var(--line)); background: color-mix(in srgb, var(--node-color) 8%, #0a0f16); }
.type-name { display: flex; align-items: center; gap: 7px; }
.type-shape { width: 8px; height: 8px; background: var(--node-color); }
.type-shape.product { border-radius: 50%; }
.type-shape.person { transform: rotate(45deg); }
.type-shape.vc_firm { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.type-filter b { font: 10px var(--font-mono); }

.path-rail { height: 24px; margin-left: 9px; display: flex; flex-direction: column; align-items: center; width: 1px; background: var(--line); position: relative; }
.path-rail span { position: absolute; width: 5px; height: 5px; border: 1px solid var(--accent-dark); border-radius: 50%; background: var(--panel); }
.path-rail span:first-child { top: -2px; }
.path-rail span:last-child { bottom: -2px; }
.path-rail i { position: absolute; top: 50%; width: 7px; border-top: 1px solid var(--line); }

.path-result { min-height: 42px; margin-top: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); background: rgba(0, 0, 0, .12); font-size: 10px; line-height: 1.5; }
.path-result[data-bench-path-status="ok"] { border-style: solid; border-color: #667329; background: rgba(217, 245, 86, .035); }
.path-result[data-bench-path-status="invalid"], .path-result[data-bench-path-status="unreachable"] { border-color: #6e3338; color: #ff9da4; }
.path-result[data-bench-path-status="same"] { border-color: #765f2c; color: #f1cc77; }
.empty-result { color: var(--subtle); }
.path-status-title { display: block; margin-bottom: 7px; color: var(--text); font-weight: 700; }
.path-nodes { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.path-node { padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--accent); background: #11170d; font-family: var(--font-mono); cursor: pointer; }
.path-node:hover { border-color: var(--accent-dark); }
.path-arrow { color: var(--subtle); }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; }
.legend-item { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.legend-symbol { width: 9px; height: 9px; background: var(--node-color); box-shadow: 0 0 8px color-mix(in srgb, var(--node-color) 45%, transparent); }
.legend-symbol.product { border-radius: 50%; }
.legend-symbol.person { transform: rotate(45deg); }
.legend-symbol.vc_firm { clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.graph-stage { min-width: 0; min-height: 0; position: relative; overflow: hidden; background-color: #080c12; background-image: radial-gradient(rgba(116, 138, 161, .13) .65px, transparent .65px); background-size: 19px 19px; }
.graph-stage::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 42%, transparent 20%, rgba(5, 8, 12, .64) 100%); }
#graph-canvas { display: block; width: 100%; height: 100%; position: relative; cursor: grab; touch-action: none; }
#graph-canvas.is-dragging { cursor: grabbing; }

.graph-loading { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(8, 12, 18, .9); transition: opacity .25s ease; }
.graph-loading.is-hidden { opacity: 0; pointer-events: none; }
.graph-loading strong { font-size: 13px; }
.graph-loading small { color: var(--muted); font-size: 10px; }
.loader { width: 28px; height: 28px; margin-bottom: 5px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.graph-badge, .graph-help { position: absolute; z-index: 3; color: var(--muted); border: 1px solid var(--line); background: rgba(12, 17, 24, .88); backdrop-filter: blur(8px); }
.graph-badge { top: 14px; left: 14px; padding: 6px 9px; border-radius: 4px; font: 9px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.graph-help { left: 50%; bottom: 15px; padding: 6px 10px; border-radius: 20px; transform: translateX(-50%); font-size: 9px; white-space: nowrap; }

.zoom-controls { position: absolute; z-index: 3; right: 14px; bottom: 14px; display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: rgba(12, 17, 24, .9); box-shadow: 0 8px 22px rgba(0, 0, 0, .25); }
.zoom-controls button { width: 34px; height: 34px; padding: 0; border: 0; border-bottom: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; font-size: 17px; }
.zoom-controls button:last-child { border-bottom: 0; }
.zoom-controls button:hover { color: var(--accent); background: var(--surface); }
.zoom-controls svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.detail-section { min-height: 210px; }
.detail-close { margin-top: -4px; }
.empty-detail { min-height: 135px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--subtle); text-align: center; font-size: 10px; }
.empty-orbit { width: 52px; height: 52px; margin-bottom: 7px; position: relative; border: 1px solid var(--line); border-radius: 50%; }
.empty-orbit::before, .empty-orbit::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--line); transform-origin: left center; }
.empty-orbit::before { width: 22px; height: 1px; transform: rotate(25deg); }
.empty-orbit::after { width: 20px; height: 1px; transform: rotate(145deg); }
.empty-orbit i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--subtle); }
.empty-orbit i:nth-child(1) { left: 22px; top: 22px; background: var(--accent); }
.empty-orbit i:nth-child(2) { right: 3px; top: 32px; }
.empty-orbit i:nth-child(3) { left: 2px; top: 11px; }

.detail-title-row { display: flex; gap: 10px; align-items: center; }
.detail-symbol { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--node-color) 50%, var(--line)); border-radius: 7px; color: var(--node-color); background: color-mix(in srgb, var(--node-color) 8%, transparent); font-weight: 800; }
.detail-title-row h3 { margin: 0; font-size: 16px; }
.detail-id { display: block; margin-top: 4px; color: var(--muted); font: 9px var(--font-mono); overflow-wrap: anywhere; }
.detail-description { margin: 14px 0; color: #b4beca; font-size: 11px; line-height: 1.65; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 13px; }
.metric { padding: 8px; border: 1px solid var(--line-soft); border-radius: 5px; background: #0a0f16; }
.metric strong { display: block; color: var(--text); font: 13px var(--font-mono); }
.metric span { display: block; margin-top: 3px; color: var(--subtle); font-size: 8px; text-transform: uppercase; }
.alias-row { margin-bottom: 13px; }
.alias-row > span, .adjacent-title { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.aliases { display: flex; flex-wrap: wrap; gap: 4px; }
.alias { padding: 3px 5px; border-radius: 3px; color: var(--muted); background: var(--surface); font-size: 9px; }
.adjacent-list { max-height: 245px; overflow: auto; border-top: 1px solid var(--line-soft); }
.adjacent-item { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--line-soft); color: var(--text); background: transparent; text-align: left; cursor: pointer; }
.adjacent-item:hover strong { color: var(--accent); }
.adjacent-item strong { display: block; font-size: 10px; }
.adjacent-item small { display: block; max-width: 190px; margin-top: 3px; overflow: hidden; color: var(--subtle); font: 8px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.adjacent-weight { color: var(--muted); font: 9px var(--font-mono); }

.stats-section h3 { margin: 0 0 9px; color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.type-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.type-stat { padding: 9px; border: 1px solid var(--line-soft); border-radius: 5px; background: #0a0f16; }
.type-stat span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.type-stat i { width: 6px; height: 6px; border-radius: 50%; background: var(--node-color); }
.type-stat strong { display: block; margin-top: 5px; font: 16px var(--font-mono); }
.subheading-row { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 0 8px; }
.subheading-row h3 { margin: 0; }
.subheading-row > span { color: var(--subtle); font: 8px var(--font-mono); text-transform: uppercase; }
.top-list { counter-reset: ranking; }
.top-row { counter-increment: ranking; width: 100%; min-height: 34px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; padding: 0 5px; border: 0; border-bottom: 1px solid var(--line-soft); color: var(--text); background: transparent; cursor: pointer; text-align: left; }
.top-row::before { content: counter(ranking, decimal-leading-zero); color: var(--subtle); font: 8px var(--font-mono); }
.top-row:hover { background: var(--surface); }
.top-row:hover .top-name { color: var(--accent); }
.top-name { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.top-degree { min-width: 24px; color: var(--muted); font: 10px var(--font-mono); text-align: right; }
.relation-stats { display: grid; grid-template-columns: 1fr 1fr; column-gap: 13px; }
.relation-stat { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 5px; min-height: 27px; border-bottom: 1px solid var(--line-soft); }
.relation-stat span { overflow: hidden; color: var(--muted); font: 8px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.relation-stat strong { color: var(--text); font: 9px var(--font-mono); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 270px minmax(340px, 1fr) 290px; }
  .topbar { grid-template-columns: 270px 1fr auto; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .topbar { height: auto; min-height: 64px; grid-template-columns: 1fr auto; padding: 10px 13px; }
  .dataset-summary { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .workspace { height: auto; min-height: calc(100vh - 92px); display: grid; grid-template-columns: 1fr 1fr; }
  .graph-stage { grid-column: 1 / -1; grid-row: 1; height: 62vh; min-height: 430px; border-bottom: 1px solid var(--line); }
  .controls-panel { grid-column: 1; grid-row: 2; border-right: 1px solid var(--line); overflow: visible; }
  .insight-panel { grid-column: 2; grid-row: 2; border-left: 0; overflow: visible; }
}

@media (max-width: 620px) {
  .brand p { display: none; }
  .topbar .button { padding: 0 9px; }
  .dataset-summary { gap: 9px; }
  .workspace { display: flex; flex-direction: column; }
  .graph-stage { order: 0; height: 62vh; min-height: 410px; }
  .controls-panel { order: 1; border-right: 0; }
  .insight-panel { order: 2; border-top: 1px solid var(--line); }
  .graph-help { display: none; }
  .relation-stats { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
