/* ============ 在线家谱网站 全局样式 ============ */
:root {
  --red: #8c2b2b;
  --red-light: #a8433f;
  --gold: #c9a35a;
  --paper: #f7f1e3;
  --paper-2: #efe5cf;
  --ink: #3a2c22;
  --ink-light: #6b5a48;
  --line: #d8c9a8;
  --male: #8c2b2b;
  --female: #9c5a3c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Songti SC", "SimSun", "STSong", serif;
  background: var(--paper);
  color: var(--ink);
}

/* ---------- 头部 ---------- */
.site-header {
  background: linear-gradient(135deg, var(--red), var(--red-light));
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.site-title {
  margin: 0; font-size: 22px; letter-spacing: 4px; font-weight: 700;
}
.header-actions .btn-link {
  color: #fff; text-decoration: none; font-size: 14px;
  border: 1px solid rgba(255,255,255,.6); padding: 5px 14px; border-radius: 20px;
  transition: background .2s;
}
.header-actions .btn-link:hover { background: rgba(255,255,255,.18); }

/* ---------- 密码遮罩 ---------- */
.unlock-mask {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(circle at 50% 30%, var(--paper-2), var(--paper));
  display: flex; align-items: center; justify-content: center;
}
.unlock-box {
  background: #fff; padding: 34px 30px; border-radius: 14px;
  width: min(92vw, 360px); text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.18);
  border: 1px solid var(--line);
}
.unlock-box h2 { margin: 0 0 8px; color: var(--red); letter-spacing: 2px; }
.unlock-tip { color: var(--ink-light); font-size: 13px; margin: 0 0 18px; }
.unlock-box input {
  width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 14px; background: var(--paper);
  text-align: center; outline: none;
}
.unlock-box input:focus { border-color: var(--gold); }
.btn-primary {
  width: 100%; padding: 12px; font-size: 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--red), var(--red-light));
  color: #fff; border: none; border-radius: 8px; letter-spacing: 4px;
  transition: filter .2s;
}
.btn-primary:hover { filter: brightness(1.1); }
.err-text { color: #c0392b; font-size: 13px; margin: 10px 0 0; min-height: 18px; }

/* ---------- 主内容 ---------- */
.main { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* 家谱选择 */
.family-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px;
}
.bar-label { font-size: 14px; color: var(--ink-light); }
.family-select {
  padding: 7px 10px; font-size: 15px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--paper); color: var(--ink); outline: none;
  flex: 1; min-width: 160px; max-width: 340px;
}
.btn-secondary {
  padding: 7px 14px; font-size: 14px; cursor: pointer;
  background: #fff; color: var(--red); border: 1px solid var(--red);
  border-radius: 8px; transition: all .2s;
}
.btn-secondary:hover { background: var(--red); color: #fff; }
.btn-secondary.btn-sm { padding: 6px 12px; font-size: 13px; }

/* 家谱信息 */
.family-info {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 14px; text-align: center;
}
.family-title {
  margin: 0 0 10px; color: var(--red); font-size: 22px; letter-spacing: 3px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px;
}
.lineage {
  font-size: 15px; line-height: 1.9; color: var(--ink);
  background: var(--paper); border-radius: 8px; padding: 10px 12px;
  border: 1px dashed var(--gold); margin-bottom: 10px; word-break: break-all;
}
.lineage-label { color: var(--red); font-weight: 700; margin-right: 6px; }
.family-intro { font-size: 14px; color: var(--ink-light); line-height: 1.8; margin: 0; }

/* ---------- 谱系图 ---------- */
.tree-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; position: relative; touch-action: none;
  height: 62vh; min-height: 380px;
}
.tree-canvas {
  position: absolute; inset: 0; transform-origin: 0 0;
  overflow: hidden;
}
.tree-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tree-nodes { position: absolute; inset: 0; }

/* 世系列标题 */
.gen-label {
  position: absolute; font-size: 12px; color: #fff;
  background: rgba(140,43,43,.85); padding: 3px 10px; border-radius: 12px;
  letter-spacing: 1px; pointer-events: none; white-space: nowrap;
}

/* 人物卡片 */
.person {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  background: #fff; border: 2px solid var(--male); border-radius: 8px;
  padding: 5px 8px; min-width: 78px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12); transition: transform .15s, box-shadow .15s;
  user-select: none;
}
.person:hover { transform: translateY(-2px); box-shadow: 0 5px 14px rgba(0,0,0,.18); }
.person.female { border-color: var(--female); }
.person .rank {
  font-size: 11px; color: var(--red); background: var(--paper);
  border-radius: 8px; padding: 1px 7px; margin-bottom: 2px; letter-spacing: 1px;
}
.person.female .rank { color: var(--female); }
.person .pname { font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.person .pgen { font-size: 10px; color: var(--ink-light); margin-top: 2px; }
.person .pspouse {
  font-size: 11px; color: var(--ink-light); margin-top: 3px;
  border-top: 1px dashed var(--line); padding-top: 3px; text-align: center;
}
.person .pbirth {
  font-size: 11px; color: var(--ink-light); margin-top: 3px; text-align: center;
  border-top: 1px dashed var(--line); padding-top: 3px; width: 100%;
}

/* 成员详情弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 22px 22px 18px;
  width: min(92vw, 420px); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 12px 46px rgba(0,0,0,.3); border: 1px solid var(--line);
  text-align: center; position: relative;
}
.detail-title { margin: 0 0 6px; color: var(--red); font-size: 22px; letter-spacing: 2px; }
.detail-tag {
  display: inline-block; font-size: 12px; color: var(--red); background: var(--paper);
  border-radius: 12px; padding: 2px 12px; margin-bottom: 12px;
}
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  text-align: left; margin-bottom: 12px;
}
.detail-item { background: var(--paper); border-radius: 8px; padding: 8px 10px; }
.detail-item label {
  display: block; font-size: 11px; color: var(--ink-light); margin-bottom: 2px;
}
.detail-item span { font-size: 14px; color: var(--ink); word-break: break-all; }
.detail-section { text-align: left; margin-bottom: 12px; }
.detail-section label {
  display: block; font-size: 12px; color: var(--red); font-weight: 700;
  margin-bottom: 4px; letter-spacing: 1px;
}
.detail-intro {
  margin: 0; font-size: 14px; line-height: 1.9; color: var(--ink);
  background: var(--paper); border-radius: 8px; padding: 10px 12px;
  white-space: pre-wrap; word-break: break-word;
}
.detail-box .btn-secondary { margin-top: 4px; }

/* 提示/图例 */
.legend {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 6px; font-size: 13px; color: var(--ink-light);
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-male { background: var(--male); }
.dot-female { background: var(--female); }
.legend-tip { color: var(--ink-light); }

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center; padding: 18px 16px 26px; color: var(--ink-light); font-size: 13px;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 600px) {
  .site-title { font-size: 18px; letter-spacing: 2px; }
  .family-title { font-size: 18px; }
  .lineage { font-size: 13px; }
  .family-intro { font-size: 13px; }
  .tree-wrap { height: 58vh; }
  .bar-label { display: none; }
}
