:root {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --panel: #1b2029;
  --line: #2a313d;
  --text: #e8eaed;
  --text-dim: #98a1ae;
  --accent: #ff8a3d;
  --accent-2: #ff3d81;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- 顶栏 ---------- */
header {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #14181f, #0f1115);
  flex: 0 0 auto;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { font-size: 12px; color: var(--text-dim); }
.updated { font-size: 12px; color: #6f7885; margin-left: auto; }

.stats {
  margin-top: 8px;
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-dim);
}
.stats b { color: var(--text); font-size: 14px; }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

#search {
  width: 210px;
  padding: 7px 30px 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.search-hint {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: #5f6874;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.chip:hover { border-color: #3c4553; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.off { opacity: .35; }

.btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}
.btn:hover { color: var(--text); border-color: #3c4553; }
.btn.active { color: #fff; border-color: var(--accent); background: rgba(255,138,61,.14); }

.spacer { flex: 1; }

/* ---------- 主体 ---------- */
main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}

#graph-wrap {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
}

svg { width: 100%; height: 100%; display: block; cursor: grab; }
svg:active { cursor: grabbing; }

.link { stroke: #3a4351; stroke-opacity: .55; }
.link.hl { stroke: var(--accent); stroke-opacity: .95; stroke-width: 2; }
.node circle { stroke: #0f1115; stroke-width: 1.5px; cursor: pointer; }
.node.hl circle { stroke: #fff; stroke-width: 2.2px; }
.node.dim { opacity: .12; }
.link.dim { stroke-opacity: .06; }

.node text {
  font-size: 11px;
  fill: #c8ced8;
  pointer-events: none;
  paint-order: stroke;
  stroke: #0f1115;
  stroke-width: 3px;
  stroke-linejoin: round;
}
.node.hl text, .node.sel text { fill: #fff; font-weight: 600; }
.node.sel circle { stroke: #ffd166; stroke-width: 3px; }
.match-info {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(15,17,21,.85);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* ---------- 侧栏 ---------- */
#panel {
  flex: 0 0 340px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 16px 18px 40px;
}

#panel h2 { margin: 0 0 6px; font-size: 16px; line-height: 1.4; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  color: #0f1115;
  font-weight: 700;
  margin-bottom: 10px;
}

.summary { font-size: 13px; line-height: 1.7; color: #ccd3dc; }

.section-title {
  margin: 18px 0 8px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.fact {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed #262d38;
}
.fact .k { color: var(--text-dim); flex: 0 0 auto; }
.fact .v { color: var(--text); text-align: right; font-weight: 600; }

.rel-list { display: flex; flex-direction: column; gap: 5px; }
.rel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #20262f;
  cursor: pointer;
}
.rel-item:hover { background: #29313d; }
.rel-item .rel { color: #ffb37a; flex: 0 0 auto; font-size: 11px; }
.rel-item .name { color: var(--text); }
.rel-item .arrow { color: #5f6874; font-size: 11px; }

.sources { display: flex; flex-direction: column; gap: 6px; }
.sources a {
  color: #7fb2ff;
  font-size: 12px;
  text-decoration: none;
  line-height: 1.5;
  word-break: break-all;
}
.sources a:hover { text-decoration: underline; }

.empty { color: var(--text-dim); font-size: 13px; line-height: 1.8; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; }
.legend div { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.hint-box {
  margin-top: 14px;
  font-size: 11px;
  line-height: 1.7;
  color: #6f7885;
}

/* ---------- 页脚 ---------- */
#foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  background: #12151b;
  font-size: 11px;
  color: #6f7885;
}
#foot a {
  color: #7fb2ff;
  text-decoration: none;
}
#foot a:hover { text-decoration: underline; }

@media (max-width: 860px) {
  main { flex-direction: column; }
  #panel { flex: 0 0 auto; max-height: 45vh; border-left: none; border-top: 1px solid var(--line); }
  #search { width: 150px; }
}
