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

:root {
  --gold:       #C9A84C;
  --gold-light: #E8C76A;
  --bg:         #0E0805;
  --bg2:        #1A0E06;
  --bg3:        #2C1A0A;
  --text:       #E8E8F0;
  --text-dim:   rgba(232,232,240,.55);
  --border:     rgba(201,168,76,.2);
  --line:       rgba(201,168,76,.22);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans SC', sans-serif;
  min-height: 100vh;
  /* 支持手机上的双指缩放 */
  touch-action: manipulation;
}

/* ─── NAV ─────────────────────────────────────────────────── */
.ft-nav {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: rgba(14,8,5,.96); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px;
  z-index: 200; gap: 12px;
}
.ft-nav-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--gold); font-weight: 700; flex-shrink: 0;
}
.ft-nav-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg,#8B1A1A,#5C1010);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Serif SC', serif; font-size: 1.05rem;
}
.ft-nav-title {
  flex: 1; text-align: center;
  font-family: 'Noto Serif SC', serif; font-size: 1.1rem;
  color: var(--gold); letter-spacing: .2em;
}
.ft-nav-back {
  color: var(--text-dim); text-decoration: none;
  font-size: .8rem; display: flex; align-items: center; gap: 5px;
  transition: color .2s; white-space: nowrap; flex-shrink: 0;
}
.ft-nav-back:hover { color: var(--gold); }

/* ─── CONTAINER ───────────────────────────────────────────── */
.ft-container { padding: 72px 16px 40px; max-width: 1800px; margin: 0 auto; }

.ft-header { text-align: center; padding: 24px 0 18px; }
.ft-title {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  color: var(--gold); letter-spacing: .15em; margin-bottom: 8px;
}
.ft-title-deco { font-size: .75em; opacity: .55; }
.ft-subtitle { color: var(--text-dim); font-size: .875rem; }

/* ─── SEARCH ──────────────────────────────────────────────── */
.ft-search-wrap {
  position: relative;
  max-width: 520px; margin: 0 auto 24px;
}
.ft-search-inner {
  display: flex; align-items: center;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 0 16px; gap: 10px;
  transition: border-color .2s;
}
.ft-search-inner:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}
.ft-search-icon { color: var(--gold); font-size: .9rem; flex-shrink: 0; }
.ft-search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: .9rem; padding: 11px 0;
  font-family: 'Noto Sans SC', sans-serif;
}
.ft-search-input::placeholder { color: var(--text-dim); }
.ft-search-clear {
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.1); border: none;
  color: var(--text-dim); width: 22px; height: 22px;
  border-radius: 50%; cursor: pointer; font-size: .75rem;
  transition: all .2s; flex-shrink: 0;
}
.ft-search-clear:hover { background: rgba(255,255,255,.2); color: var(--text); }

.ft-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #1E1208; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  z-index: 300; max-height: 360px; overflow-y: auto;
  display: none;
}
.ft-search-loading, .ft-search-empty, .ft-search-more {
  padding: 16px 20px; text-align: center;
  color: var(--text-dim); font-size: .85rem;
}
.ft-search-loading { color: var(--gold); }
.ft-search-more { font-size: .75rem; border-top: 1px solid var(--border); }

.ft-search-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  transition: background .15s; border-bottom: 1px solid rgba(201,168,76,.08);
}
.ft-search-item:last-child { border-bottom: none; }
.ft-search-item:hover { background: rgba(201,168,76,.08); }

.ft-si-icon {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; flex-shrink: 0;
}
.ft-si-icon.male  { background: rgba(74,158,245,.12); color: #4A9EF5; }
.ft-si-icon.female{ background: rgba(255,107,157,.12); color: #FF6B9D; }
.ft-si-icon.has-avatar { background: none; padding: 0; overflow: hidden; }
.ft-si-avatar { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

.ft-si-info { flex: 1; min-width: 0; }
.ft-si-name { font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-si-alias { color: var(--text-dim); font-size: .8rem; }
.ft-si-meta { font-size: .75rem; color: var(--text-dim); margin-top: 2px; }
.ft-si-arrow { color: var(--text-dim); font-size: .7rem; flex-shrink: 0; }

mark.ft-hl { background: rgba(201,168,76,.35); color: var(--gold-light); border-radius: 2px; }

/* ─── BRANCH TABS ─────────────────────────────────────────── */
.ft-branch-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-bottom: 24px;
}
.ft-tabs-loading { color: var(--gold); font-size: .875rem; padding: 16px; }
.ft-tab {
  background: rgba(201,168,76,.07); border: 1px solid var(--border);
  color: var(--text-dim); padding: 7px 18px; border-radius: 22px;
  cursor: pointer; font-size: .8rem; transition: all .2s;
  white-space: nowrap; font-family: 'Noto Sans SC', sans-serif;
}
.ft-tab:hover  { border-color: var(--gold); color: var(--text); }
.ft-tab.active {
  background: linear-gradient(135deg,rgba(201,168,76,.25),rgba(201,168,76,.1));
  border-color: var(--gold); color: var(--gold);
}

/* ─── TREE WRAP ───────────────────────────────────────────── */
.ft-tree-wrap {
  overflow-x: auto;
  overflow-y: visible;
  padding: 16px 0 48px;
  /* 提示用户可以横向滑动 */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.ft-tree-wrap:active { cursor: grabbing; }

/* 自定义滚动条 */
.ft-tree-wrap::-webkit-scrollbar { height: 5px; }
.ft-tree-wrap::-webkit-scrollbar-track { background: rgba(255,255,255,.04); border-radius: 3px; }
.ft-tree-wrap::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

.ft-tree-loading {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 80px; color: var(--gold); font-size: 1.4rem;
}
.ft-tree-loading span { font-size: .875rem; color: var(--text-dim); }

.ft-tree {
  display: inline-flex; flex-direction: column; align-items: center;
  min-width: 100%; padding: 10px 48px 20px;
}

/* ─── TREE NODES ──────────────────────────────────────────── */

/* 夫妻行 */
.ft-couple {
  display: flex; align-items: flex-end; gap: 4px; padding: 0 2px;
}

/* 配偶连线 — 双线 + 爱心图标 */
.ft-spouse-connector {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  width: 32px; flex-shrink: 0; margin-bottom: 24px; align-self: center;
}
.ft-spouse-connector::before,
.ft-spouse-connector::after {
  content: ''; display: block; width: 100%; height: 1.5px;
  background: linear-gradient(90deg,#4A9EF5,#FF6B9D);
}
.ft-spouse-heart {
  font-size: .9rem; color: #FF6B9D; line-height: 1;
  text-shadow: 0 0 8px rgba(255,107,157,.65);
  animation: heartbeat 2s ease-in-out infinite;
}
@keyframes heartbeat {
  0%,100% { transform: scale(1); }
  25%      { transform: scale(1.18); }
  50%      { transform: scale(1); }
  75%      { transform: scale(1.1); }
}

/* 折叠控制行（couple 与 children 之间） */
.ft-toggle-row {
  display: flex; justify-content: center; align-items: center;
  height: 24px; position: relative;
}
/* 垂直线贯穿 toggle 行 */
.ft-toggle-row::before {
  content: ''; position: absolute; inset: 0; left: 50%;
  width: 1px; background: var(--line); transform: translateX(-50%);
}

.ft-collapse-btn {
  position: relative; z-index: 1;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--gold); font-size: .62rem; padding: 1px 6px;
  border-radius: 8px; cursor: pointer; display: flex;
  align-items: center; gap: 3px; transition: all .2s;
  white-space: nowrap;
}
.ft-collapse-btn:hover { background: rgba(201,168,76,.2); border-color: var(--gold); }
.ft-collapse-btn span { font-size: .6rem; }

/* children 容器 */
.ft-branch { display: flex; flex-direction: column; align-items: center; }

.ft-node-children { display: flex; flex-direction: column; align-items: center; }
.ft-node-children.collapsed .ft-children-row-inner { display: none; }
.ft-node-children.collapsed .ft-down-line { height: 0; }

.ft-down-line { width: 1px; height: 20px; background: var(--line); }

.ft-children-row-inner {
  display: flex; align-items: flex-start;
  gap: 12px; position: relative;
}

/* 水平连线（多子女时） */
.ft-h-line-across {
  position: absolute; top: 0; height: 1px; background: var(--line);
  /* JS 会根据子女数量动态控制；这里 CSS 给个近似值 */
  left: 50px; right: 50px;
}

.ft-child-item {
  display: flex; flex-direction: column; align-items: center;
}
.ft-v-line { width: 1px; height: 20px; background: var(--line); }

/* ─── PERSON CARD ─────────────────────────────────────────── */
.ft-person {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 8px 8px;
  width: 96px; text-align: center;
  cursor: pointer; transition: all .22s; position: relative;
  flex-shrink: 0;
}
.ft-person:hover {
  border-color: var(--gold); background: var(--bg3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(201,168,76,.15);
}
.ft-person.male   { border-top: 2px solid #4A9EF5; }
.ft-person.female { border-top: 2px solid #FF6B9D; }
.ft-person.deceased { opacity: .68; }
/* 搜索高亮 */
.ft-person.ft-highlight {
  border-color: var(--gold-light) !important;
  box-shadow: 0 0 0 3px rgba(201,168,76,.4), 0 8px 28px rgba(201,168,76,.3) !important;
  animation: ft-pulse 1s ease-in-out 3;
}
@keyframes ft-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(201,168,76,.4); }
  50%      { box-shadow: 0 0 0 8px rgba(201,168,76,.15); }
}

.ft-person-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  margin: 0 auto 7px; overflow: hidden;
  background: var(--bg3); border: 2px solid var(--border);
}
.ft-person-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-avatar-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 1.1rem;
}

.ft-person-name {
  font-family: 'Noto Serif SC', serif; font-size: .78rem;
  color: var(--text); font-weight: 600; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ft-person-alias  { font-size: .63rem; color: rgba(201,168,76,.6); margin-bottom: 2px; }
.ft-person-gen    { font-size: .68rem; color: var(--gold); margin-bottom: 2px; }
.ft-person-years  { font-size: .62rem; color: var(--text-dim); }
.ft-person-deceased { position: absolute; top: 4px; right: 4px; color: var(--text-dim); font-size: .58rem; }

/* 子女序号徽章（长/次/三/四…） */
.ft-person-first-badge {
  position: absolute; top: 3px; left: 3px;
  background: linear-gradient(135deg, rgba(150,150,170,.55), rgba(100,100,120,.4));
  color: rgba(232,232,240,.75); font-size: .58rem; font-weight: 700;
  padding: 2px 5px; border-radius: 4px;
  font-family: 'Noto Serif SC', serif;
  letter-spacing: .04em;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  border: 1px solid rgba(200,200,220,.2);
  white-space: nowrap;
}
/* 长子/长女：金色徽章覆盖 */
.ft-order-badge-0 {
  background: linear-gradient(135deg, #C9A84C, #8B5A00) !important;
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(201,168,76,.5) !important;
  border-color: rgba(255,220,100,.35) !important;
}
/* 长子/长女：左侧金色边框 + 顶部加宽 */
.ft-person.ft-first-child {
  border-left: 3px solid var(--gold) !important;
  border-top-color: var(--gold) !important;
  box-shadow: -2px 0 8px rgba(201,168,76,.18);
}

/* ─── MODAL ───────────────────────────────────────────────── */
.ft-modal-wrap {
  display: none; position: fixed; inset: 0; z-index: 500;
  align-items: center; justify-content: center;
}
.ft-modal-wrap.open { display: flex; }
.ft-modal-overlay  { position: absolute; inset: 0; background: rgba(0,0,0,.78); }
.ft-modal-box {
  position: relative; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 28px 24px; width: 92%; max-width: 480px;
  z-index: 1; max-height: 85vh; overflow-y: auto;
}
.ft-modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; color: var(--text-dim);
  font-size: 1.05rem; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.ft-modal-close:hover { background: rgba(255,255,255,.1); color: var(--text); }

.member-detail-avatar {
  width: 76px; height: 76px; border-radius: 50%;
  margin: 0 auto 14px; overflow: hidden;
  background: var(--bg3); border: 3px solid var(--gold);
}
.member-detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-detail-name {
  text-align: center; font-family: 'Noto Serif SC', serif;
  font-size: 1.35rem; color: var(--gold); margin-bottom: 4px;
}
.member-detail-second { text-align: center; color: var(--text-dim); font-size: .85rem; margin-bottom: 14px; }
.member-detail-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.member-detail-item  {
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px;
}
.member-detail-label { font-size: .72rem; color: var(--text-dim); margin-bottom: 3px; }
.member-detail-value { font-size: .875rem; color: var(--text); }
.member-detail-remark {
  margin-top: 10px; background: rgba(255,255,255,.03);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
.member-detail-spouses { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.member-detail-spouses h4 { color: var(--gold); font-size: .85rem; margin-bottom: 10px; }
.spouse-item {
  display: flex; align-items: center; gap: 10px; padding: 7px;
  background: rgba(255,255,255,.03); border-radius: 8px;
  margin-bottom: 5px; cursor: pointer; transition: background .2s;
}
.spouse-item:hover { background: rgba(201,168,76,.08); }
.spouse-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg3); overflow: hidden; flex-shrink: 0;
}
.spouse-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─── LANG SWITCHER ───────────────────────────────────────── */
.lang-switcher {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.lang-btn {
  background: rgba(255,255,255,.05); border: 1px solid rgba(201,168,76,.18);
  color: var(--text-dim); font-size: .72rem; padding: 3px 8px;
  border-radius: 4px; cursor: pointer; transition: all .18s;
  font-family: 'Noto Sans SC', sans-serif; line-height: 1.4;
  white-space: nowrap;
}
.lang-btn:hover { border-color: var(--gold); color: var(--text); }
.lang-btn.active {
  background: rgba(201,168,76,.2); border-color: var(--gold);
  color: var(--gold); font-weight: 600;
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .ft-nav-title { display: none; }
  .ft-person { width: 78px; padding: 8px 5px 6px; }
  .ft-person-avatar { width: 38px; height: 38px; }
  .ft-person-name { font-size: .72rem; }
  .ft-children-row-inner { gap: 8px; }
  .ft-h-line-across { left: 40px; right: 40px; }
  .member-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .ft-container { padding-top: 66px; }
  .ft-person { width: 66px; padding: 6px 4px; }
  .ft-person-avatar { width: 30px; height: 30px; margin-bottom: 5px; }
  .ft-person-name { font-size: .67rem; }
  .ft-person-gen, .ft-person-alias, .ft-person-years { font-size: .58rem; }
  .ft-children-row-inner { gap: 6px; }
  .ft-h-line-across { left: 34px; right: 34px; }
  .ft-branch-tabs { gap: 6px; }
  .ft-tab { font-size: .75rem; padding: 6px 12px; }
  .ft-search-input { font-size: .85rem; }
  .ft-modal-box { padding: 22px 16px; }
}

/* 横屏手机 */
@media (max-height: 500px) and (orientation: landscape) {
  .ft-modal-box { max-height: 90vh; padding: 16px; }
}
