/* ===== 心理学人物知识树 · 样式（移动端优先） ===== */

:root {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --ink: #202A37;
  --muted: #5E6A77;
  --line: #E3E8EF;
  --accent: #0F766E;
  --accent-soft: #E6F2F0;
  --header-bg: #1D2733;
  --header-sub: #A9B4C0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 26px -18px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== 页头 ===== */
.site-header {
  background: var(--header-bg);
  color: #F2F5F9;
  padding: 18px 16px 14px;
  border-bottom: 3px solid var(--accent);
}
.site-header h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 22px;
  letter-spacing: .5px;
}
.site-header .sub {
  margin: 2px 0 0;
  color: var(--header-sub);
  font-size: 12.5px;
}
.page-link {
  display: inline-block;
  margin-top: 10px;
  background: #FFFFFF;
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 15px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.5;
  transition: background .15s, color .15s;
}
.page-link:hover { background: var(--accent-soft); color: var(--accent); }
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 12px;
}
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--header-sub); font-size: 12px; margin-left: 6px; }

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.search-wrap { position: relative; flex: 1 1 220px; max-width: 420px; }
.search-wrap input {
  width: 100%;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  color: var(--ink);
  background: #F7F9FB;
}
.search-wrap input:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: #fff; }
.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  border-radius: 50%;
}
.search-clear:hover { background: #E9EDF3; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  cursor: pointer;
  line-height: 1.5;
}
.chip:hover { border-color: #C9D2DE; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.match-info { font-size: 12.5px; color: var(--muted); }
.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== 主区布局 ===== */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
  padding-bottom: 16px;
}

.tree-panel, .detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.tree-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 46vh;
}
.detail-panel { overflow: auto; min-height: 46vh; }

/* ===== 树面板 ===== */
.tree-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #FBFCFE;
}
.tree-head .title { font-weight: 600; font-size: 13px; color: var(--muted); }
.tree-actions { margin-left: auto; display: flex; gap: 6px; }
.tree-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.tree-actions button:hover { color: var(--ink); border-color: #C9D2DE; }

.tree { overflow: auto; padding: 8px; flex: 1; }

.tree-empty { color: var(--muted); font-size: 13px; padding: 12px; }

/* 分支行 */
.branch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.branch-row:hover { background: #F2F5F9; }
.branch-row.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.branch-row .chev {
  display: inline-flex;
  flex: none;
  width: 16px;
  height: 16px;
  color: #9AA4B1;
  transition: transform .15s ease;
}
.branch-row.open .chev { transform: rotate(90deg); }
.branch-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.branch-row .bname { font-weight: 600; font-size: 14.5px; min-width: 0; }
.branch-row .bname i {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
  font-size: 11.5px;
  margin-left: 6px;
  white-space: nowrap;
}
.branch-row .cnt {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  background: #EEF2F6;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.branch-row .cnt.t1 { background: #E4E8EE; color: #3A4653; }

/* 人物容器与节点 */
.people-container {
  margin: 0 0 4px 16px;
  padding: 2px 0 6px 10px;
  border-left: 1px solid #E3E8EF;
}
.person-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  min-width: 0;
}
.person-row:hover { background: #F2F5F9; }
.person-row.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

.tb {
  flex: none;
  font-size: 11px;
  border-radius: 5px;
  padding: 1px 6px;
  font-weight: 600;
  line-height: 1.6;
}
.tb.t1 { background: #202A37; color: #fff; }
.tb.t2 { background: #E9EDF3; color: #5E6A77; }

.pname { font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pyears { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pcountry {
  margin-left: auto;
  font-size: 11.5px;
  color: #8A94A1;
  white-space: nowrap;
}

mark { background: #FFF3C4; border-radius: 2px; padding: 0 1px; color: inherit; }

/* ===== 详情面板 ===== */
.empty-state {
  height: 100%;
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
  gap: 10px;
}
.empty-state p { margin: 0; font-size: 14px; }
/* hidden 属性必须显式生效（.empty-state 的 display:flex 会覆盖 UA 默认的 display:none） */
.empty-state[hidden],
#detailContent[hidden] { display: none !important; }

.detail-inner { padding: 18px 20px 26px; max-width: 760px; }

.d-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip-branch, .chip-soft {
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 10px;
  line-height: 1.6;
}
.chip-branch { color: #fff; }
.chip-soft { background: #EEF2F6; color: #3A4653; }
.chip-solid { background: #202A37; color: #fff; }

.d-name {
  font-family: Georgia, "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 26px;
  margin: 0;
  line-height: 1.3;
}
.d-en { color: var(--muted); margin: 2px 0 12px; font-size: 14px; }

.d-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.d-meta .k { color: #9AA4B1; margin-right: 4px; }

.d-section h3 {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 1.5px;
  margin: 18px 0 6px;
  font-weight: 600;
}
.d-summary {
  background: #F7F9FB;
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 14.5px;
  color: #29323E;
}
.d-bio { font-size: 14px; color: #33404D; margin: 0; }
.d-list { margin: 0; padding-left: 20px; font-size: 14px; }
.d-list li { margin-bottom: 5px; }
.d-works { list-style: none; padding-left: 0; margin: 0; }
.d-works li { padding: 5px 0; border-bottom: 1px dashed #EDF1F5; font-size: 13.5px; }
.d-works li:last-child { border-bottom: none; }

/* 分支详情 · 范式开创者速览 */
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.branch-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.6;
}
.branch-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ===== 页脚 ===== */
.site-footer {
  padding: 12px 16px;
  font-size: 12px;
  color: #7A8491;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.site-footer p { margin: 2px 0; }
.site-footer code { background: #EEF2F6; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* ===== 窄屏布局 ===== */
@media (max-width: 899px) {
  main { overflow: visible; }
  .tree-panel { border-left: none; border-right: none; border-top: none; box-shadow: none; }
  .detail-panel { border-left: none; border-right: none; border-bottom: none; box-shadow: none; }
}

/* ===== 桌面布局 ===== */
@media (min-width: 900px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  main {
    grid-template-columns: minmax(340px, 440px) 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
    min-height: 0;
  }
  .tree-panel, .detail-panel {
    border-radius: var(--radius);
    max-height: none;
    min-height: 0;
  }
  .detail-panel { min-height: 0; }
  .site-header { padding: 20px 24px 16px; }
  .site-header h1 { font-size: 26px; }
  .toolbar { padding: 12px 24px; }
  .site-footer { padding: 12px 24px; }
}

/* 动效偏好：减弱动画 */
@media (prefers-reduced-motion: reduce) {
  .branch-row .chev { transition: none; }
}
