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

html, body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: #0f1420;
  color: #dfe6f3;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: 52px 1fr;
  grid-template-columns: 1fr 340px;
  grid-template-areas:
    "topbar topbar"
    "stage sidebar";
}

/* ---------- 顶栏 ---------- */
#topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: #161d2e;
  border-bottom: 1px solid #263050;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; color: #8fb4ff; }

.search-box { position: relative; flex: 0 1 320px; display: flex; }
#search-input {
  flex: 1;
  height: 32px;
  padding: 0 28px 0 10px;
  border-radius: 6px;
  border: 1px solid #33406a;
  background: #0f1420;
  color: #dfe6f3;
  outline: none;
}
#search-input:focus { border-color: #4c8dff; }
#search-clear {
  position: absolute; right: 4px; top: 4px;
  width: 24px; height: 24px;
  border: none; border-radius: 4px;
  background: transparent; color: #7c8bb0;
  cursor: pointer;
}
#search-clear:hover { background: #263050; color: #fff; }
#search-results {
  position: absolute; top: 36px; left: 0; right: 0;
  max-height: 300px; overflow-y: auto;
  background: #1a2236;
  border: 1px solid #33406a;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 20;
}
#search-results .sr-item {
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
#search-results .sr-item:hover { background: #263050; }
#search-results .sr-item .sr-id { color: #7c8bb0; font-size: 12px; }
.hidden { display: none !important; }

#type-filters { display: flex; gap: 10px; flex-wrap: wrap; }
#type-filters label {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; cursor: pointer; user-select: none;
}
#type-filters .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

#reset-btn, #path-run {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #33406a;
  border-radius: 6px;
  background: #22304f;
  color: #cfe0ff;
  cursor: pointer;
  white-space: nowrap;
}
#reset-btn:hover, #path-run:hover { background: #2c3d63; }

/* ---------- 图谱区 ---------- */
#stage { grid-area: stage; position: relative; overflow: hidden; }
#graph-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#graph-canvas.dragging { cursor: grabbing; }
#graph-hint {
  position: absolute; left: 12px; bottom: 10px;
  font-size: 12px; color: #5d6d94;
  pointer-events: none;
}

/* ---------- 侧栏 ---------- */
#sidebar {
  grid-area: sidebar;
  overflow-y: auto;
  background: #131a2a;
  border-left: 1px solid #263050;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel {
  background: #1a2236;
  border: 1px solid #263050;
  border-radius: 8px;
  padding: 12px;
}
.panel h2 { font-size: 14px; color: #8fb4ff; margin-bottom: 8px; }
.panel h3 { font-size: 13px; color: #a9bcd8; margin: 12px 0 6px; }
.muted { color: #7c8bb0; font-size: 13px; line-height: 1.6; }

/* 节点详情 */
#node-detail .nd-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
#node-detail .nd-meta { font-size: 12px; color: #7c8bb0; margin: 4px 0 8px; }
#node-detail .nd-desc { font-size: 13px; line-height: 1.6; color: #c6d2e8; margin-bottom: 8px; }
#node-detail .nd-aliases { font-size: 12px; color: #7c8bb0; margin-bottom: 8px; }
#node-detail ul { list-style: none; max-height: 220px; overflow-y: auto; }
#node-detail li {
  font-size: 12px;
  padding: 5px 6px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
#node-detail li:hover { background: #263050; }
#node-detail li .rel-type { color: #8fb4ff; flex-shrink: 0; }
#node-detail li .nb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 11px; padding: 1px 7px; border-radius: 8px;
  color: #0f1420; font-weight: 600;
}

/* 路径查询 */
.path-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.path-form input {
  height: 32px; padding: 0 10px;
  border-radius: 6px; border: 1px solid #33406a;
  background: #0f1420; color: #dfe6f3; outline: none;
}
.path-form input:focus { border-color: #4c8dff; }
#path-result { font-size: 13px; line-height: 1.7; }
#path-result .path-msg { margin-bottom: 6px; }
#path-result .path-msg.err { color: #ff8a8a; }
#path-result .path-msg.ok { color: #6fe3a5; }
#path-result .path-node {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 8px;
  border-radius: 10px;
  background: #22304f;
  border: 1px solid #ff9d45;
  cursor: pointer;
  font-size: 12px;
}
#path-result .path-node:hover { background: #2c3d63; }
#path-result .path-arrow { color: #ff9d45; margin-right: 4px; }

/* 统计榜单 */
.stats-list { list-style: none; }
.stats-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 5px 6px;
  border-radius: 4px;
}
.stats-list li .s-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-list li .s-count { color: #8fb4ff; font-variant-numeric: tabular-nums; flex-shrink: 0; }
#stats-top { counter-reset: top; }
#stats-top li { cursor: pointer; counter-increment: top; }
#stats-top li:hover { background: #263050; }
#stats-top li .s-name::before {
  content: counter(top) ". ";
  color: #5d6d94;
}
