/* ===== 李氏族谱 - 中式古典风格 ===== */

:root {
  --primary: #8B4513;
  --primary-dark: #5D2E0C;
  --primary-light: #D2691E;
  --accent: #C41E3A;
  --gold: #DAA520;
  --bg-paper: #FFF8F0;
  --bg-dark: #1a1410;
  --text-primary: #2c1810;
  --text-secondary: #5a4030;
  --text-light: #8b7355;
  --border-color: #d4c4a8;
  --shadow: rgba(44,24,16,0.12);
  --card-bg: #fffefa;
}

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

body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  background: var(--bg-paper);
  color: var(--text-primary);
  line-height: 1.8;
  min-height: 100vh;
}

/* ===== 导航栏 ===== */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: linear-gradient(135deg, var(--bg-dark) 0%, #2d2018 100%);
  padding: 0.6rem 0;
  box-shadow: 0 2px 20px var(--shadow);
}
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; }
.nav-brand {
  font-size: 1.5rem; font-weight: 700; color: var(--gold);
  text-decoration: none; letter-spacing: 0.15em;
  text-shadow: 0 0 20px rgba(218,165,32,0.3);
}
.nav-links { display: flex; gap: 0.5rem; }
.nav-links a {
  color: #e8dcc8; text-decoration: none; padding: 0.4rem 1rem;
  border-radius: 4px; font-size: 0.95rem; transition: all 0.25s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(218,165,32,0.15); color: var(--gold);
}

/* ===== Hero 区域 ===== */
.hero {
  position: relative; min-height: 440px; margin-top: 52px; padding: 3rem 1.5rem;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(139,69,19,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 30%, rgba(196,30,58,0.08) 0%, transparent 55%),
    linear-gradient(180deg, #f5ede0 0%, #ebe0cc 100%);
}
.hero-bg::before {
  content: ''; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30z' fill='none' stroke='%23d4c4a8' stroke-width='0.5' opacity='0.3'/%3E%3C/svg%3E");
  opacity: 0.4;
}
.hero-content { position: relative; z-index: 1; text-align: center; }
.hero h1 {
  font-size: 3.8rem; font-weight: 900; color: var(--primary-dark);
  letter-spacing: 0.3em; margin-bottom: 0.5rem;
  text-shadow: 2px 2px 0 #fff, 0 0 40px rgba(139,69,19,0.15);
}
.hero .subtitle {
  font-size: 1.2rem; color: var(--text-secondary); letter-spacing: 0.2em;
}
.year-mark {
  display: inline-block; margin-top: 1rem; padding: 0.3rem 1.5rem;
  border: 1px solid var(--border-color); border-radius: 20px;
  font-size: 0.9rem; color: var(--text-light);
  background: rgba(255,255,255,0.6);
}

/* ===== 首屏查找人名（hero 内）===== */
.hero-search {
  position: relative; z-index: 2;
  margin: 1.6rem auto 0; width: min(540px, 92%);
  display: flex; align-items: center; gap: 0.5rem;
  background: #fff; border-radius: 999px;
  padding: 0.35rem 0.45rem 0.35rem 1rem;
  box-shadow: 0 10px 34px rgba(139,69,19,0.20);
  border: 1px solid rgba(139,69,19,0.14);
}
.hero-search-icon { font-size: 1.05rem; opacity: 0.6; }
.hero-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 1.05rem; color: var(--text-primary); padding: 0.55rem 0.2rem;
}
.hero-search input::placeholder { color: #b9a98f; }
.hero-search button {
  flex: none; cursor: pointer; border: none; border-radius: 999px;
  padding: 0.7rem 1.5rem; font-size: 1rem; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #b22222 0%, #8B4513 100%);
  white-space: nowrap; transition: filter 0.15s ease;
}
.hero-search button:hover { filter: brightness(1.07); }
.hero-search button:active { transform: translateY(1px); }

/* 首屏明确提示 */
.hero-hint {
  position: relative; z-index: 2;
  margin: 1.1rem auto 0; width: min(560px, 92%);
  font-size: 0.92rem; line-height: 1.65; color: #6f5026;
  background: rgba(255,255,255,0.78); border: 1px solid rgba(200,160,90,0.40);
  border-radius: 14px; padding: 0.8rem 1.05rem; text-align: left;
}
.hero-hint strong { color: #9a3f12; font-weight: 700; }
.hero-hint a { color: #b22222; font-weight: 600; text-decoration: underline; }
.hero-hint a:hover { color: #8B4513; }

/* ===== 主内容区 ===== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.card {
  background: var(--card-bg); border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 2rem; margin-bottom: 2rem;
  box-shadow: 0 4px 24px var(--shadow);
}
.card h2 {
  font-size: 1.5rem; color: var(--primary-dark);
  margin-bottom: 1.5rem; padding-bottom: 0.8rem;
  border-bottom: 2px solid var(--border-color);
  position: relative;
}
.card h2::after {
  content: ''; position: absolute; bottom: -2px; left: 0;
  width: 80px; height: 2px; background: var(--accent);
}

/* ===== 简介 ===== */
.intro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.intro-item { display: flex; gap: 1rem; align-items: flex-start; }
.intro-icon { font-size: 2rem; flex-shrink: 0; }
.intro-item h3 { font-size: 1.1rem; color: var(--primary); margin-bottom: 0.4rem; }
.intro-item p { font-size: 0.95rem; color: var(--text-secondary); }
.zpai-text {
  font-family: "KaiTi", "STKaiti", serif; font-size: 1.05rem;
  letter-spacing: 0.3em; color: var(--primary-dark);
  line-height: 2; padding: 0.5rem 0;
}

/* ===== 统计卡片 ===== */
.stats-section { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; margin-bottom: 2rem; }
.stat-card {
  background: linear-gradient(135deg, var(--card-bg) 0%, #faf6ef 100%);
  border: 1px solid var(--border-color); border-radius: 12px;
  padding: 1.5rem; text-align: center;
  transition: transform 0.3s, box-shadow 0.3s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 8px 28px var(--shadow); }
.stat-number {
  font-size: 2.5rem; font-weight: 800; color: var(--primary);
  line-height: 1.2;
}
.stat-label { font-size: 0.9rem; color: var(--text-light); margin-top: 0.3rem; }

/* ===== 支系卡片 ===== */
.branch-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; }
.branch-card {
  display: block; padding: 1.5rem; border-radius: 10px;
  border: 1px solid var(--border-color); text-decoration: none;
  transition: all 0.3s; position: relative; overflow: hidden;
  background: var(--card-bg);
}
.branch-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.branch-color-1::before { background: #8B4513; }
.branch-color-2::before { background: #2E8B57; }
.branch-color-3::before { background: #4169E1; }
.branch-color-4::before { background: #9932CC; }
.branch-color-5::before { background: #CD853F; }

.branch-card:hover { transform: translateY(-3px); box-shadow: 0 6px 24px var(--shadow); }
.branch-card h3 { font-size: 1.1rem; color: var(--primary-dark); margin-bottom: 0.5rem; }
.branch-card p { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6; }
.branch-arrow {
  float: right; color: var(--primary); font-size: 1.3rem; margin-top: -2rem;
  transition: transform 0.3s;
}
.branch-card:hover .branch-arrow { transform: translateX(4px); }

/* ===== 先祖画像 ===== */
.portrait-gallery { display: flex; gap: 2rem; justify-content: center; flex-wrap: wrap; }
.portrait-item { text-align: center; max-width: 280px; }
.portrait-item img {
  width: 250px; height: auto; border-radius: 8px;
  border: 3px solid var(--border-color); box-shadow: 0 4px 16px var(--shadow);
}
.portrait-item figcaption { margin-top: 0.8rem; font-size: 0.95rem; color: var(--text-secondary); }

/* ===== 字派表 ===== */
.zpai-table-wrap { overflow-x: auto; }
.zpai-table { width: 100%; border-collapse: collapse; font-family: "KaiTi", "STKaiti", serif; }
.zpai-table th {
  background: var(--primary-dark); color: var(--gold); padding: 0.8rem;
  font-weight: 600; font-size: 1rem;
}
.zpai-table td {
  padding: 0.65rem; text-align: center; border-bottom: 1px solid #eee8dc;
  font-size: 1.1rem;
}
.zpai-table tr:hover td { background: #fdf8ee; }
.char-cell { font-size: 1.4rem !important; color: var(--primary); font-weight: 700; }

/* ===== 快速导航 ===== */
.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  padding: 2rem 1.5rem; border-radius: 12px; text-decoration: none;
  border: 2px solid var(--border-color); background: var(--card-bg);
  transition: all 0.3s;
}
.quick-btn:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 8px 28px var(--shadow); }
.quick-btn.primary { border-color: var(--primary); background: linear-gradient(135deg, #fef9f0 0%, #fff5e6 100%); }
.btn-icon { font-size: 2.2rem; }
.quick-btn span { font-size: 1.1rem; color: var(--primary-dark); font-weight: 600; }
.quick-btn small { font-size: 0.82rem; color: var(--text-light); }

/* ===== 页脚 ===== */
.site-footer {
  text-align: center; padding: 2rem; color: var(--text-light);
  font-size: 0.88rem; border-top: 1px solid var(--border-color);
  background: #f5efe4;
}
.footer-note { margin-top: 0.4rem; font-size: 0.8rem; color: #bbb; }

  padding: 0 0.6rem; font-size: 0.9rem; color: var(--text-secondary);
}

/* ===== 树页面特有样式 ===== */
.tree-container {
  position: relative; width: 100%; height: calc(100vh - 52px);
  margin-top: 52px; overflow: hidden; background: #faf8f5;
}
#tree-canvas { display: block; cursor: grab; }
#tree-canvas:active { cursor: grabbing; }

.tree-toolbar {
  position: fixed; top: 62px; left: 1rem; z-index: 100;
  display: flex; flex-direction: column; gap: 0.4rem;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  padding: 0.6rem; border-radius: 10px;
  box-shadow: 0 4px 16px var(--shadow); border: 1px solid var(--border-color);
}
.toolbar-btn {
  width: 38px; height: 38px; border: 1px solid var(--border-color);
  border-radius: 6px; background: white; cursor: pointer;
  font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; color: var(--text-secondary);
}
.toolbar-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.toolbar-btn.layout-btn { width: auto; padding: 0 0.7rem; font-size: 0.9rem; font-family: inherit; letter-spacing: 0.1em; }
.toolbar-btn.layout-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.toolbar-divider { height: 1px; background: var(--border-color); margin: 0.2rem 0; }

.search-bar {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; gap: 0.4rem;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  padding: 0.5rem 0.8rem; border-radius: 10px;
  box-shadow: 0 4px 16px var(--shadow); border: 1px solid var(--border-color);
}
.search-bar input {
  border: none; outline: none; font-size: 0.95rem;
  font-family: inherit; width: 220px; background: transparent;
  color: var(--text-primary);
}
.search-bar input::placeholder { color: var(--text-light); }

/* 详情面板 */
/* 详情弹窗：居中卡片 + 遮罩（替代原右侧/底部抽屉，避免遮挡工具栏） */
.detail-mask {
  position: fixed; inset: 0; background: rgba(40,24,16,0.45);
  z-index: 290; opacity: 0; visibility: hidden; transition: opacity 0.2s ease;
}
.detail-mask.open { opacity: 1; visibility: visible; }
.detail-panel {
  position: fixed; top: 50%; left: 50%; width: min(440px, 92vw);
  max-height: 82vh; overflow-y: auto; z-index: 300;
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 16px; box-shadow: 0 16px 56px rgba(0,0,0,0.30);
  padding: 1.6rem 1.6rem 1.4rem;
  transform: translate(-50%, -48%) scale(0.96); opacity: 0; visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.detail-panel.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
/* 亲属关系可点击跳转 */
.rel-link {
  color: var(--primary); cursor: pointer; font-weight: 600;
  border-bottom: 1px dashed transparent; transition: all 0.15s;
}
.rel-link:hover { border-bottom-color: var(--primary); color: var(--primary-dark); }
.detail-close {
  position: absolute; top: 0.8rem; right: 0.8rem; background: none;
  border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light);
}
.detail-name { font-size: 1.6rem; color: var(--primary-dark); font-weight: 700; margin-bottom: 0.3rem; }
.detail-gen { color: var(--accent); font-size: 0.95rem; margin-bottom: 1rem; }
.detail-field { margin-bottom: 0.8rem; }
.detail-field label { font-size: 0.82rem; color: var(--text-light); display: block; }
.detail-field value { font-size: 1rem; color: var(--text-primary); }
.detail-raw value { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7; }

/* 小地图 */
.minimap {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 100;
  width: 180px; height: 120px; background: rgba(255,255,255,0.9);
  border: 1px solid var(--border-color); border-radius: 8px;
  box-shadow: 0 2px 12px var(--shadow); overflow: hidden;
}
#minimap-canvas { width: 100%; height: 100%; }

/* 图例 */
.legend {
  position: fixed; bottom: 1rem; left: 1rem; z-index: 100;
  background: rgba(255,255,255,0.9); padding: 0.6rem 0.8rem;
  border-radius: 8px; border: 1px solid var(--border-color);
  font-size: 0.78rem; box-shadow: 0 2px 12px var(--shadow);
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.25rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-spouse {
  display: inline-block; width: 10px; height: 8px; border-radius: 2px;
  border: 1px dashed #e8a0b4; background: #fdf3f6; margin-right: 0.4rem;
}

/* 详情面板内"添加子女/配偶"操作 */
.detail-actions { display: flex; gap: 0.6rem; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px dashed var(--border-color); }
.detail-act-btn {
  flex: 1; padding: 0.6rem 0.4rem; font-family: inherit; font-size: 0.95rem;
  border: 1px solid var(--primary); color: var(--primary); background: #fffefa;
  border-radius: 7px; cursor: pointer; transition: all 0.2s; font-weight: 600;
}
.detail-act-btn:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }

/* 画布内申请弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(44,24,16,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem;
}
.modal {
  width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  background: var(--card-bg); border-radius: 14px; box-shadow: 0 12px 48px rgba(0,0,0,0.3);
  animation: pop 0.2s ease;
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border-color);
}
.modal-head h3 { font-size: 1.2rem; color: var(--primary-dark); margin: 0; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-light); }
.modal-close:hover { color: var(--accent); }
.modal-body { padding: 1.2rem 1.4rem; }
.modal-foot {
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 1rem 1.4rem; border-top: 1px solid var(--border-color);
}
.relate-hint {
  background: #fdf6e3; border: 1px solid var(--border-color); border-left: 4px solid var(--gold);
  border-radius: 8px; padding: 0.7rem 0.9rem; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7;
}
.relate-hint strong { color: var(--primary-dark); }

/* 弹窗内表单（复用通用栅格） */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.4rem; }
.form-item { display: flex; flex-direction: column; gap: 0.35rem; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 0.9rem; color: var(--text-secondary); }
.form-item label b { color: var(--accent); }
.form-item input, .form-item select, .form-item textarea {
  padding: 0.55rem 0.75rem; border: 1px solid var(--border-color); border-radius: 6px;
  font-family: inherit; font-size: 0.96rem; background: white; color: var(--text-primary); outline: none;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-item textarea { min-height: 70px; resize: vertical; }
.submit-btn {
  padding: 0.6rem 1.8rem; font-size: 1rem; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; letter-spacing: 0.1em;
}
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--shadow); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-ghost {
  padding: 0.55rem 1rem; border: 1px solid var(--border-color); border-radius: 6px;
  background: white; cursor: pointer; font-family: inherit; color: var(--text-secondary);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.result-msg { display: none; font-size: 0.95rem; line-height: 1.6; }
.result-msg.ok { display: block; background: #eef7ee; border: 1px solid #b5d8b5; color: #2e6b2e; padding: 0.6rem 0.8rem; border-radius: 8px; }
.result-msg.err { display: block; background: #fdf0ef; border: 1px solid #e5b8b5; color: #8c2f2a; padding: 0.6rem 0.8rem; border-radius: 8px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* 加载动画 */
.loading-overlay {
  position: fixed; inset: 0; background: var(--bg-paper);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; font-size: 1.2rem; color: var(--primary);
}
.loading-spinner {
  width: 40px; height: 40px; border: 3px solid var(--border-color);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin-right: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 搜索结果列表 */
.search-results {
  position: fixed; top: 110px; left: 50%; transform: translateX(-50%); z-index: 150;
  width: 320px; max-height: 400px; overflow-y: auto;
  background: white; border-radius: 8px;
  box-shadow: 0 4px 24px var(--shadow); border: 1px solid var(--border-color);
  display: none;
}
.search-results.show { display: block; }
.search-result-item {
  padding: 0.7rem 1rem; border-bottom: 1px solid #f0ead8;
  cursor: pointer; transition: background 0.15s;
}
.search-result-item:hover { background: #faf6ef; }
.result-name { font-weight: 600; color: var(--primary-dark); }
.result-info { font-size: 0.82rem; color: var(--text-light); margin-top: 0.15rem; }

/* 文章页样式 */
.article-content { max-width: 800px; margin: 0 auto; }
.article-content h2 {
  font-size: 1.6rem; color: var(--primary-dark);
  border-left: 4px solid var(--accent); padding-left: 1rem;
  margin: 2rem 0 1rem;
}
.article-content h3 {
  font-size: 1.2rem; color: var(--primary); margin: 1.5rem 0 0.8rem;
}
.article-content p { 
  text-indent: 2em; margin-bottom: 0.8rem; 
  text-align: justify; color: var(--text-secondary);
}
/* 文章块类型：诗行 / 署名 / 引用 / 表格 / 说明 */
.article-verse {
  text-align: center; font-family: "KaiTi", "STKaiti", serif;
  letter-spacing: 0.25em; margin-bottom: 0.35rem; color: var(--text-primary);
}
.article-sign { text-align: right; color: var(--text-secondary); font-size: 0.95rem; margin: 1.5rem 0; }
.article-quote {
  margin: 1rem 0; padding: 0.9rem 1.2rem;
  border-left: 3px solid var(--gold); background: #faf6ef;
  font-size: 1.05rem; color: var(--text-primary);
}
.article-from { text-align: right; color: var(--text-light); font-size: 0.9rem; margin: -0.4rem 0 1.2rem; padding-right: 0.5rem; }
.article-table { width: 100%; border-collapse: collapse; margin: 1rem 0 0.5rem; font-family: "KaiTi", "STKaiti", serif; }
.article-table th { background: var(--primary-dark); color: var(--gold); padding: 0.5rem; font-size: 0.95rem; }
.article-table td { border: 1px solid #e6dcc8; padding: 0.45rem; text-align: center; font-size: 1rem; }
.article-table tr:nth-child(even) td { background: #fdf8ee; }
.article-note { font-size: 0.85rem; color: var(--text-light); margin: 0.4rem 0 1.5rem; }
.article-toc {
  background: #faf6ef; border: 1px solid var(--border-color);
  border-radius: 8px; padding: 1.5rem; margin-bottom: 2rem;
}
.article-toc h3 { margin-top: 0; color: var(--primary-dark); }
.article-toc a {
  display: block; padding: 0.35rem 0; color: var(--text-secondary);
  text-decoration: none; font-size: 0.95rem; transition: color 0.2s;
}
.article-toc a:hover { color: var(--primary); }

/* 搜索页样式 */
.search-page-main { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }
.filter-bar {
  display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
  align-items: center;
}
.filter-bar select, .filter-bar input {
  padding: 0.5rem 0.8rem; border: 1px solid var(--border-color);
  border-radius: 6px; font-family: inherit; font-size: 0.95rem;
  background: white; color: var(--text-primary);
}
.person-list { display: flex; flex-direction: column; gap: 0.6rem; }
.person-row {
  display: flex; align-items: center; padding: 0.8rem 1.2rem;
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 8px; cursor: pointer; transition: all 0.2s;
  text-decoration: none; color: inherit;
}
.person-row:hover { border-color: var(--primary); transform: translateX(4px); box-shadow: 0 2px 12px var(--shadow); }
.pname { font-weight: 600; color: var(--primary-dark); min-width: 100px; }
.pgen { font-size: 0.85rem; color: var(--accent); min-width: 60px; }
.pbranch { font-size: 0.85rem; color: var(--text-light); flex: 1; }
.ploc { font-size: 0.85rem; color: var(--text-secondary); min-width: 100px; text-align: right; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .hero h1 { font-size: 2.4rem; letter-spacing: 0.15em; }
  .hero { min-height: 420px; padding: 2.2rem 1rem 2.6rem; }
  .hero-search { width: 94%; margin-top: 1.3rem; }
  .hero-search input { font-size: 1rem; padding: 0.55rem 0.1rem; }
  .hero-search button { padding: 0.65rem 1.15rem; font-size: 0.95rem; }
  .hero-hint { width: 94%; font-size: 0.86rem; line-height: 1.6; padding: 0.7rem 0.9rem; margin-top: 1rem; }
  .hero .subtitle { font-size: 1.02rem; }
  .stats-section { grid-template-columns: repeat(2, 1fr); }
  .quick-links { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .intro-grid { grid-template-columns: 1fr; }
  .branch-list { grid-template-columns: 1fr; }

  /* ===== 树页面移动适配 ===== */
  .tree-container { height: calc(100vh - 48px); margin-top: 48px; }
  /* 顶部搜索栏：贴顶全宽 */
  .search-bar {
    top: 48px; left: 8px; right: 8px; transform: none;
    padding: 0.4rem 0.7rem;
  }
  .search-bar input { width: 100%; font-size: 0.9rem; }
  /* 工具栏：移到底部水平横排（占位低、不挡画布） */
  .tree-toolbar {
    top: auto; bottom: 8px; left: 8px; right: 8px;
    flex-direction: row; flex-wrap: nowrap;
    justify-content: space-between; gap: 0.25rem;
    padding: 0.35rem; border-radius: 12px;
  }
  .toolbar-btn { width: 34px; height: 34px; font-size: 1rem; }
  .toolbar-btn.layout-btn { width: auto; flex: 1; font-size: 0.78rem; padding: 0 0.3rem; }
  .toolbar-divider { width: 1px; height: 22px; margin: 0 0.15rem; }
  /* 详情面板：移动端同样居中弹窗（避免遮挡底部工具栏） */
  .detail-panel {
    width: 92vw; max-height: 84vh; padding: 1.2rem 1.1rem 1.3rem; border-radius: 14px;
  }
  /* 图例与小地图：移动端简化 */
  .minimap { width: 110px; height: 70px; bottom: 60px; right: 8px; opacity: 0.85; }
  .legend { display: none; }
  /* 弹窗全屏化 */
  .modal-mask { padding: 0.5rem; }
  .modal { width: 100%; max-height: 92vh; }

  /* 移动端放大详情面板关闭按钮点按区 */
  .detail-close {
    width: 38px; height: 38px; font-size: 1.15rem;
    top: 0.55rem; right: 0.55rem;
  }

  /* ===== 搜索页移动适配 ===== */
  .search-page-main { padding: 1rem 1rem; }
  /* 筛选栏纵向堆叠：避免原生 select 因超长支系名选项(min-width:auto)撑宽整行 */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .filter-bar input,
  .filter-bar select {
    width: 100%;
    min-width: 0;          /* 关键：允许收缩到容器宽度，不被最长选项文本撑开 */
    max-width: 100%;
    flex: 1 1 auto;
  }
  /* 结果行：移动端紧凑，超长支系名省略，杜绝横向溢出 */
  .person-row {
    flex-wrap: wrap;
    padding: 0.6rem 0.8rem;
    gap: 0.15rem 0.6rem;
  }
  .pname { min-width: auto; flex: 1 1 100%; }
  .pgen { min-width: auto; }
  .pbranch {
    min-width: 0; flex: 1 1 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ploc { min-width: auto; text-align: left; flex: 1 1 100%; }
}

/* ===== 更窄屏优化（≤ 480px） ===== */
@media (max-width: 480px) {
  .search-bar { padding: 0.35rem 0.6rem; }
  .search-bar input { font-size: 0.85rem; }
  .toolbar-btn.layout-btn { font-size: 0.7rem; letter-spacing: 0.05em; }
  .tree-toolbar { padding: 0.3rem; }
}

/* ===== 移动端文章折叠（articles.html） ===== */
@media (max-width: 768px) {
  .article-section {
    position: relative;
    transition: max-height 0.25s ease;
  }
  .article-section.collapsed {
    max-height: 9rem;
    overflow: hidden;
  }
  .article-section.collapsed::after {
    content: '▼ 点击展开';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 1.6rem 0 0.6rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--primary);
    background: linear-gradient(to bottom, transparent, var(--card-bg) 70%);
    cursor: pointer;
    pointer-events: none;   /* 让父级 section 接收点击 */
  }
  .article-section.collapsed > h2 { cursor: pointer; }
}

/* ===== 搜索分页控件 ===== */
.pager {
  display: flex; justify-content: center; align-items: center;
  gap: 0.4rem; padding: 1.2rem 0.5rem; flex-wrap: wrap;
}
.pager button {
  border: 1px solid var(--border-color); background: white;
  padding: 0.5rem 0.8rem; border-radius: 6px;
  font-family: inherit; font-size: 0.9rem; color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s;
}
.pager button:hover:not(:disabled) {
  background: var(--primary); color: white; border-color: var(--primary);
}
.pager button:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.pager .pager-info {
