:root {
  --bg: #f7f8fa;
  --card: #fff;
  --ink: #1f2329;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --green: #16a34a;
}
/* 暗色主题:覆盖设计令牌 + 少量组件底色(图谱在暗色下最惊艳)*/
:root[data-theme="dark"] {
  --bg: #0f1117; --card: #1a1d27; --ink: #e8eaed; --muted: #9aa3b2; --line: #2a3040;
}
:root[data-theme="dark"] .topbar { background: rgba(20,23,31,.9); }
:root[data-theme="dark"] .conn { background: #161922; }
:root[data-theme="dark"] .conn.mutual { background: #10231a; }
:root[data-theme="dark"] .stat,
:root[data-theme="dark"] .cluster-tag,
:root[data-theme="dark"] .g-chip { background: #262b38; }
:root[data-theme="dark"] #q,
:root[data-theme="dark"] #g-search,
:root[data-theme="dark"] .suggest li,
:root[data-theme="dark"] .browse li a,
:root[data-theme="dark"] .cta.ghost { background: #1a1d27; color: var(--ink); }
:root[data-theme="dark"] .chip.give { background: #16233a; color: #93c5fd; }
:root[data-theme="dark"] .chip.need { background: #3a2616; color: #fdba74; }
:root[data-theme="dark"] #cy { background: radial-gradient(circle at 50% 40%, #1a1d27, #0f1117); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6; font-size: 16px;
  transition: background .3s, color .3s;
}
/* 主题切换钮 */
.theme-toggle { margin-left: auto; background: none; border: none; font-size: 18px; cursor: pointer; padding: 4px 8px; line-height: 1; }
/* 卡片错位淡入 */
.node .card:nth-child(2) { animation-delay: .05s; }
.node .card:nth-child(3) { animation-delay: .1s; }
.node .card:nth-child(4) { animation-delay: .15s; }
.node .card:nth-child(5) { animation-delay: .2s; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.3; }

/* 顶栏(sticky) */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar.home { justify-content: flex-start; }
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar .node-id { font-family: monospace; color: var(--muted); font-size: 12px; }

/* 卡片 */
.node { max-width: 720px; margin: 0 auto; padding: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(16,24,40,.04);
  animation: fade .4s ease both;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card h1 { margin: 6px 0; font-size: 24px; }
.card h2 { font-size: 18px; margin: 0 0 14px; }
.card h3 { font-size: 13px; color: var(--muted); margin: 16px 0 8px; }
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; }

/* 类型徽章 + 色板 */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .3px;
  padding: 2px 9px; border-radius: 6px; background: #eef2f7; color: #475569; white-space: nowrap;
}
.badge.type-core      { background: #fef3c7; color: #b45309; }
.badge.type-connector { background: #dcfce7; color: #15803d; }
.badge.type-platform  { background: #ede9fe; color: #6d28d9; }
.badge.type-person    { background: #dbeafe; color: #1d4ed8; }
.badge.type-team      { background: #cffafe; color: #0e7490; }
.badge.type-model     { background: #ffedd5; color: #c2410c; }
.badge.type-demand    { background: #fee2e2; color: #b91c1c; }

/* 名片式身份卡:渐变头图 + 头像 */
.identity { padding: 0; overflow: hidden; }
.hero-band { height: 84px; position: relative; }
.hero-band.cluster-overseas { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.hero-band.cluster-content  { background: linear-gradient(135deg, #ea580c, #f97316); }
.hero-band.cluster-salon    { background: linear-gradient(135deg, #16a34a, #22c55e); }
.hero-band.cluster-capital  { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.hero-band.cluster-other    { background: linear-gradient(135deg, #64748b, #94a3b8); }
.avatar {
  position: absolute; left: 24px; bottom: -28px; width: 64px; height: 64px;
  border-radius: 50%; background: var(--card); border: 3px solid var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: var(--ink);
}
.id-body { padding: 38px 24px 22px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.stat { font-size: 13px; color: var(--muted); background: #f1f5f9; padding: 4px 10px; border-radius: 8px; }
.stat b { color: var(--accent); font-size: 15px; }
.tagrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 4px; }
.cluster-tag { font-size: 12px; color: var(--muted); background: #f1f5f9; padding: 2px 9px; border-radius: 6px; }
.tagline { margin: 2px 0 10px; font-size: 16px; color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip { font-size: 13px; padding: 4px 11px; border-radius: 999px; }
.chip.give { background: #eff6ff; color: #1d4ed8; }
.chip.need { background: #fff7ed; color: #c2410c; }

/* 利益共同体(核心区) */
.union { border-color: var(--green); }
.union h2 { color: #15803d; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.union .count { font-size: 13px; font-weight: 400; color: var(--muted); }
.conn-list { list-style: none; padding: 0; margin: 0; }
.conn {
  padding: 14px 16px; margin-bottom: 10px; border: 1px solid var(--line);
  border-radius: 12px; background: #fafbfc; transition: border-color .15s, box-shadow .15s;
}
.conn:last-child { margin-bottom: 0; }
.conn:hover { box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.conn.mutual { border-color: var(--green); background: #f0fdf4; }   /* 双向=更强的共同体 */
.conn-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.conn-tag { font-size: 12px; color: #15803d; background: #dcfce7; padding: 1px 8px; border-radius: 6px; }
.dir { margin: 8px 0 0; font-size: 14px; }
.dir b { display: block; font-size: 12px; margin-bottom: 2px; }
.dir.give b { color: var(--accent); }
.dir.get b { color: var(--green); }
.dir span { display: block; padding-left: 14px; position: relative; }
.dir span::before { content: "·"; position: absolute; left: 4px; color: var(--muted); }
.empty { color: var(--muted); }

/* 还可以认识(推荐) */
.recommend { border-color: #c4b5fd; }
.recommend h2 { color: #6d28d9; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.recommend .count { font-size: 13px; font-weight: 400; color: var(--muted); }
.conn-tag.rec { color: #6d28d9; background: #ede9fe; }
.rec-reason { margin: 8px 0 0; font-size: 13.5px; color: var(--ink); }
:root[data-theme="dark"] .recommend { border-color: #4c3a8a; }

/* 联系方式 + 引荐 + 分享 */
.masked { color: var(--muted); font-style: italic; margin: 0; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.cta {
  display: inline-block; padding: 10px 18px; border: none; cursor: pointer;
  background: var(--accent); color: #fff; border-radius: 10px; font-size: 15px;
  transition: background .15s, border-color .15s;
}
.cta:hover { background: #1e40af; }
.cta.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
.cta.ghost:hover { background: #f1f5f9; border-color: var(--accent); }

/* 首页门户 */
.portal { max-width: 820px; margin: 0 auto; padding: 18px; }
.hero {
  text-align: center; padding: 58px 26px 42px; position: relative; overflow: hidden;
  border-radius: 24px; color: #fff; margin-bottom: 10px;
  background: radial-gradient(130% 130% at 50% 0%, #4f46e5 0%, #1d4ed8 46%, #6d28d9 100%);
  box-shadow: 0 20px 50px rgba(29,78,216,.34);
}
.hero::before {  /* 网络感点阵 */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .45;
  background-image: radial-gradient(rgba(255,255,255,.20) 1px, transparent 1px);
  background-size: 24px 24px;
}
.hero::after {  /* 顶部柔光 */
  content: ""; position: absolute; top: -40%; left: 50%; transform: translateX(-50%);
  width: 460px; height: 320px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,255,255,.28), transparent);
}
.hero-inner { position: relative; }
.brand-mark { font-size: 13px; letter-spacing: 2px; font-weight: 700; opacity: .92; margin: 0 0 16px; text-transform: none; }
.hero h1 { font-size: 30px; line-height: 1.28; margin: 0 0 10px; color: #fff; font-weight: 800; letter-spacing: .5px; }
.hero-sub { color: rgba(255,255,255,.86); margin: 0; font-size: 15px; }
.hero-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 22px 0 6px; }
.stat-pill {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  padding: 9px 18px; border-radius: 14px; font-size: 12px; color: rgba(255,255,255,.85);
  backdrop-filter: blur(4px);
}
.stat-pill b { display: block; font-size: 20px; font-weight: 800; color: #fff; }
.hero-note { margin: 14px 0 0; font-size: 12px; color: rgba(255,255,255,.7); }
#lookup-form { display: flex; gap: 8px; margin: 20px auto 0; max-width: 440px; }
#q { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
#lookup-form button { padding: 0 20px; border: none; border-radius: 10px; background: var(--accent); color: #fff; font-size: 15px; cursor: pointer; }
.suggest { list-style: none; padding: 0; margin: 8px auto 0; max-width: 440px; text-align: left; }
.suggest li { padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; background: var(--card); cursor: pointer; }
.suggest li:hover { border-color: var(--accent); }
.err { color: #dc2626; margin-top: 12px; }

/* 筛选式目录 */
.facets { display: flex; flex-direction: column; gap: 10px; margin: 22px 0 6px; }
.facet-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.facet-label { font-size: 12px; color: var(--muted); width: 30px; flex: none; }
.facet-chip {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink); font-size: 13px; cursor: pointer; transition: all .15s;
}
.facet-chip:hover { border-color: var(--accent); }
.facet-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.result-count { font-size: 13px; color: var(--muted); margin: 8px 0 12px; }

.section-title { font-size: 16px; margin: 26px 0 12px; }
.track { margin-bottom: 18px; }
.track h3 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.track h3 .n, .all summary .n { font-size: 12px; color: var(--muted); font-weight: 400; }
.browse { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
@media (min-width: 560px) { .browse { grid-template-columns: 1fr 1fr; } }
.browse li a {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.browse li a:hover { border-color: var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.all { margin-top: 8px; }
.all summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.all .browse { margin-top: 10px; }

/* 进图谱的大按钮(首页 hero 上,白底)*/
.graph-entry {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  padding: 12px 24px; border-radius: 12px; font-size: 15px; font-weight: 700;
  color: #1d4ed8; background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); transition: transform .15s, box-shadow .15s;
}
.graph-entry:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.24); color: #1d4ed8; }

/* 关系图谱页 */
.graph-body { overflow: hidden; }
.graph-controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
#g-search { flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.g-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.g-chip {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 13px; cursor: pointer; transition: all .15s;
}
.g-chip:hover { border-color: var(--accent); }
.g-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.g-toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; }
#cy {
  width: 100%; height: calc(100vh - 110px);
  background: radial-gradient(circle at 50% 40%, #ffffff, #eef2f8);
}
.g-hint { position: fixed; bottom: 8px; left: 0; right: 0; text-align: center; margin: 0; font-size: 12px; color: var(--muted); pointer-events: none; }
