/* ============================================================
   宗谱电子谱 · 全局样式
   设计取向：宣纸底色 + 朱印点缀，庄重克制；
             正文字号整体放大（适配家族长辈阅读习惯）。
   ============================================================ */

:root {
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-mute: #78716c;
  --paper: #faf7f2;
  --paper-2: #f5efe6;
  --paper-3: #ece3d6;
  --line: #e0d5c5;
  --line-strong: #cbb99f;
  --seal: #7c2d12;
  --seal-light: #9a3412;
  --seal-soft: #fdf2ee;
  --bamboo: #3f6212;
  --gold: #a16207;
  /* 「谱系待完善」提醒卡片用的浅琥珀底色，与 .tag--warn 保持一致 */
  --gold-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --info: #1d4ed8;
  --info-soft: #eff6ff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .06), 0 1px 3px rgba(28, 25, 23, .08);
  --shadow: 0 2px 6px rgba(28, 25, 23, .08), 0 6px 18px rgba(28, 25, 23, .06);
  --shadow-lg: 0 8px 32px rgba(28, 25, 23, .16);

  /* 字号放大：长辈友好 */
  --fs-base: 17px;
  --fs-sm: 15px;
  --fs-xs: 13.5px;
  --fs-lg: 20px;
  --fs-xl: 25px;
  --fs-2xl: 32px;

  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --serif: "Songti SC", "SimSun", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 12% 8%, rgba(124, 45, 18, .035), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(63, 98, 18, .03), transparent 45%);
  background-attachment: fixed;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

a { color: var(--seal); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0 0 .5em; line-height: 1.35; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

/* ------------------------------------------------------------ 启动占位 */

.boot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 1.2rem;
}
.boot__seal {
  width: 84px; height: 84px; border-radius: 14px;
  background: var(--seal); color: #f5e6d3;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 48px;
  box-shadow: var(--shadow-lg);
}
.boot__text { color: var(--ink-mute); letter-spacing: .18em; }

/* ------------------------------------------------------------ 布局 */

.app-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(250, 247, 242, .93);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line-strong);
}
.app-header__inner {
  max-width: 1680px; margin: 0 auto; padding: .5rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .7rem; cursor: pointer; user-select: none; }
.brand__logo {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  background: var(--seal); color: #f5e6d3;
  display: grid; place-items: center; font-family: var(--serif); font-size: 26px;
  flex-shrink: 0;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__title { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: .06em; }
.brand__sub { font-size: var(--fs-xs); color: var(--ink-mute); letter-spacing: .14em; }

.nav { display: flex; gap: .1rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav__item {
  padding: .38rem .55rem; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 12.5px; font-weight: 500;
  white-space: nowrap; transition: background .15s, color .15s;
}
.nav__item:hover { background: var(--paper-3); text-decoration: none; }
.nav__item--active { background: var(--seal); color: #fff; }
.nav__item--active:hover { background: var(--seal-light); }

/**
 * 顶栏放不下「品牌 + 检索框 + 导航」一行时，让**检索框**单独占一行并排在最后。
 *
 * 为什么必须有这条：检索框已移到导航之前，若不管它，窗口一窄被挤到第二行的
 * 就会是**主导航** —— 那比改之前更糟。用 order:9 把检索框钉在最后。
 *
 * 1680 容器里顶栏内容约需 1100px（品牌 175 + 检索框 240 + 导航 700 + 间距），
 * 加左右内边距 32px，窗口约 1480 以上即可排成一行。
 */
@media (max-width: 1100px) {
  .header-search { flex: 1 1 100%; margin-left: 0; order: 9; }
}

.app-main { flex: 1; max-width: 1680px; width: 100%; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.app-main--wide { max-width: none; padding-left: .5rem; padding-right: .5rem; }

.page-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head__text { flex: 1; min-width: 240px; }
.page-head h1 { margin: 0; }
.page-head__desc { color: var(--ink-mute); font-size: var(--fs-sm); margin-top: .2rem; }

.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.3rem; margin-bottom: 1rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex; align-items: center; gap: .75rem;
  padding: .8rem 1.3rem; border-bottom: 1px solid var(--line); background: var(--paper-2);
}
.card__head h3 { margin: 0; font-size: var(--fs-base); letter-spacing: .04em; }
.card__body { padding: 1.1rem 1.3rem; }

.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .62rem 1.15rem; min-height: 44px;
  font-size: var(--fs-sm); font-weight: 600; font-family: var(--sans);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--paper-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--seal); border-color: var(--seal); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--seal-light); border-color: var(--seal-light); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--seal); }
.btn--ghost:hover { background: var(--seal-soft); }
.btn--danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { filter: brightness(1.08); }
.btn--sm { padding: .38rem .75rem; min-height: 36px; font-size: var(--fs-xs); }
.btn--lg { padding: .85rem 1.6rem; min-height: 52px; font-size: var(--fs-base); }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ 表单 */

.form-grid { display: grid; gap: 1rem 1.25rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.form-grid--full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); display: flex; align-items: center; gap: .35rem; }
.field__req { color: var(--danger); }
.field__hint { font-size: var(--fs-xs); color: var(--ink-mute); line-height: 1.5; }
.field__error { font-size: var(--fs-xs); color: var(--danger); }

.input, .select, .textarea {
  width: 100%; padding: .6rem .75rem; min-height: 44px;
  font-size: var(--fs-base); font-family: var(--sans); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.65; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px rgba(124, 45, 18, .12);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--paper-2); color: var(--ink-mute); }

.checkbox { display: flex; align-items: center; gap: .5rem; font-size: var(--fs-sm); min-height: 44px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--seal); }

.section-title {
  grid-column: 1 / -1; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600;
  color: var(--seal); padding-bottom: .35rem; border-bottom: 2px solid var(--line);
  margin-top: .6rem;
}
.section-title:first-child { margin-top: 0; }

/* 农历 / 公历切换 */
.cal-toggle { display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.cal-toggle button {
  padding: .35rem .8rem; font-size: var(--fs-xs); font-family: var(--sans);
  background: #fff; border: none; cursor: pointer; color: var(--ink-soft); min-height: 34px;
}
.cal-toggle button + button { border-left: 1.5px solid var(--line-strong); }
.cal-toggle button.is-active { background: var(--seal); color: #fff; font-weight: 600; }

/* ------------------------------------------------------------ 表格 */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.tbl th, table.tbl td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { background: var(--paper-2); font-weight: 600; color: var(--ink-soft); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.tbl tbody tr:hover { background: var(--paper); }
table.tbl td.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ 徽标 */

.tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .12rem .5rem; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.7;
  border: 1px solid transparent;
}
.tag--seal { background: var(--seal-soft); color: var(--seal); border-color: #f3d3c8; }
.tag--ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.tag--warn { background: var(--gold-soft); color: var(--gold); border-color: #fde68a; }
.tag--danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag--info { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.tag--mute { background: var(--paper-3); color: var(--ink-mute); border-color: var(--line); }
.tag--male { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.tag--female { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }

/* ------------------------------------------------------------ 统计卡 */

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); }
.stat__value { font-family: var(--serif); font-size: var(--fs-2xl); font-weight: 700; color: var(--seal); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat__label { font-size: var(--fs-sm); color: var(--ink-mute); margin-top: .15rem; }

/* ------------------------------------------------------------ 谱图 */

.chart-shell {
  position: relative; background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  overflow: hidden; touch-action: none; user-select: none;
  background-image: linear-gradient(rgba(203, 185, 159, .16) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(203, 185, 159, .16) 1px, transparent 1px);
  background-size: 40px 40px;
}
.chart-shell svg { display: block; cursor: grab; }
.chart-shell svg.is-panning { cursor: grabbing; }

.chart-toolbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .55rem .8rem; background: var(--paper-2);
  border: 1px solid var(--line-strong); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.chart-toolbar + .chart-shell { border-radius: 0 0 var(--radius) var(--radius); }
.chart-toolbar__spacer { flex: 1; }
.chart-zoom { font-size: var(--fs-xs); color: var(--ink-mute); min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }

.node-box { cursor: pointer; }
.node-box rect { transition: fill .12s, stroke .12s; }
.node-box:hover rect { filter: brightness(.97); }
.node-text { font-family: var(--serif); pointer-events: none; }
.node-rank { font-family: var(--sans); pointer-events: none; }
.node-sub { font-family: var(--sans); pointer-events: none; }
.gen-header { font-family: var(--serif); font-weight: 700; fill: var(--seal); }

.page-link-badge { cursor: pointer; }
.page-link-badge:hover text { text-decoration: underline; }

/* 世代导航条 */
.gen-nav { display: flex; gap: .35rem; flex-wrap: wrap; }
.gen-nav__item {
  padding: .25rem .6rem; border-radius: var(--radius-sm); font-size: var(--fs-xs);
  border: 1px solid var(--line-strong); background: #fff; cursor: pointer; color: var(--ink-soft);
}
.gen-nav__item:hover { background: var(--paper-2); }
.gen-nav__item.is-active { background: var(--seal); color: #fff; border-color: var(--seal); }

/* 步骤条（批量导入等分步流程） */
.steps {
  display: flex; align-items: center; gap: .5rem;
  padding: .8rem 1rem; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.steps__item {
  display: flex; align-items: center; gap: .45rem;
  font-size: var(--fs-sm); color: var(--ink-mute); white-space: nowrap;
}
.steps__item.is-active { color: var(--seal); font-weight: 700; }
.steps__item.is-done { color: var(--ink-soft); }
.steps__no {
  width: 1.7em; height: 1.7em; border-radius: 50%;
  display: grid; place-items: center; font-size: var(--fs-xs);
  background: var(--paper-3); color: var(--ink-soft); flex-shrink: 0;
}
.steps__item.is-active .steps__no { background: var(--seal); color: #fff; }
.steps__item.is-done .steps__no { background: var(--ok-soft); color: var(--ok); }
.steps__line { flex: 1; min-width: 12px; height: 1px; background: var(--line-strong); }

/* 预览表格中的问题行 */
.table tr.is-bad { background: #fef2f2; }
.table tr.is-warn { background: #fffbeb; }

/* ============================================================
   传统分层谱式
   —— 依纸质宗谱观感：人物无框、一列文字；世代为横向层带，
      右侧标「第N层 + 该世字辈字」；实线为生育，虚线为承祧/收养。
   ============================================================ */

.trad-layer {
  font-family: var(--serif);
  letter-spacing: .1em;
}
.trad-layer-char {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: .08em;
}
.trad-empty-note {
  font-family: var(--sans);
  letter-spacing: .04em;
}
.trad-spouse {
  font-family: var(--sans);
  letter-spacing: .02em;
}
.trad-name {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: .06em;
}
.trad-serial {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: .1em;
}
.trad-rank {
  font-family: var(--serif);
  letter-spacing: .04em;
}

/* 可勾选的行传明细：生 / 卒 / 葬 / 生子 / 生女 / 见后 */
.trad-birth,
.trad-death,
.trad-sons,
.trad-daughters {
  font-family: var(--sans);
  letter-spacing: .01em;
}
.trad-burial {
  font-family: var(--sans);
  letter-spacing: .01em;
}
.trad-death { font-variant-numeric: tabular-nums; }
.trad-birth { font-variant-numeric: tabular-nums; }
/* 「见后」：本图末世，后裔载于下图 */
.trad-see-later {
  font-family: var(--serif);
  letter-spacing: .08em;
  font-weight: 600;
}

/* 竖排文字：逐字排在列中，行距略紧以免超出层带 */
.node-box--trad text {
  dominant-baseline: auto;
  writing-mode: horizontal-tb;
}

/* ------------------------------------------------------------ 显示内容勾选 */

.field-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .9rem;
  padding: .5rem .75rem;
  margin-bottom: .75rem;
  background: var(--paper-2, #faf7f2);
  border: 1px solid var(--line, #e7e1d8);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.field-picker__label {
  color: var(--ink-3, #78716c);
  font-weight: 600;
}
.field-picker__item {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
  user-select: none;
  padding: .1rem .25rem;
  border-radius: 4px;
}
.field-picker__item:hover { background: rgba(124, 45, 18, 0.06); }
.field-picker__item input { cursor: pointer; margin: 0; }
.field-picker__note {
  color: var(--ink-4, #a8a29e);
  font-size: .9em;
  margin-left: auto;
  margin-right: .5rem;
}

/* 无框节点的可点击区域与悬停反馈 */
.node-box--trad .trad-hit { cursor: pointer; }
.node-box--trad:hover .trad-name { fill: var(--seal); }
.node-box--trad:hover .trad-hit { fill: rgba(124, 45, 18, 0.05); }

/* 传统谱式的题记（标题下的小字说明） */
.trad-captions {
  margin: .2rem 0 1rem;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--ink-mute);
  line-height: 1.9;
}
.trad-captions div { letter-spacing: .02em; }

.trad-legend {
  display: flex;
  justify-content: center;
  gap: 1.6rem;
  flex-wrap: wrap;
  margin-top: .5rem;
  font-size: var(--fs-xs);
  color: var(--ink-mute);
}
.trad-legend__item { display: inline-flex; align-items: center; gap: .4rem; }
.trad-legend__line {
  display: inline-block;
  width: 30px; height: 0;
  border-top: 2px solid #c0aa8e;
}
.trad-legend__line--dashed { border-top: 2px dashed #b45309; }

@media print {
  .trad-captions, .trad-legend { color: #333 !important; }
}

/* 附件上传区 */
.attach-drop {
  display: flex; align-items: center; flex-wrap: wrap;
  padding: .9rem 1rem; border: 2px dashed var(--line-strong);
  border-radius: var(--radius-sm); background: var(--paper);
  transition: border-color .15s, background .15s;
}
.attach-drop.is-over { border-color: var(--seal); background: var(--seal-soft); }

.attach-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; margin-bottom: .35rem;
  font-size: var(--fs-sm);
}
.attach-row__idx {
  min-width: 1.9em; height: 1.9em; border-radius: 50%;
  background: var(--paper-3); color: var(--ink-soft);
  display: grid; place-items: center; font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.attach-row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 检索下拉（族人选择器） */
.picker {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
  background: #fff; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); max-height: 264px; overflow: auto;
}
.picker__item {
  padding: .5rem .75rem; cursor: pointer; border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.picker__item:last-child { border-bottom: none; }
.picker__item:hover, .picker__item:focus { background: var(--paper-2); text-decoration: none; }

/* ------------------------------------------------------------ 其他 */

.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-mute); }
.empty__icon { font-size: 46px; opacity: .35; margin-bottom: .6rem; font-family: var(--serif); }

.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: var(--fs-sm); border: 1px solid; margin-bottom: .9rem; }
.alert--error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.alert--warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert--ok { background: var(--ok-soft); border-color: #bbf7d0; color: var(--ok); }
.alert--info { background: var(--info-soft); border-color: #bfdbfe; color: var(--info); }

/* 「服务端代码已更新、但进程未重启」提示条 */
.build-stale { margin: 0; border-radius: 0; border-left: none; border-right: none; border-top: none; }
.build-stale__body { margin-top: .3rem; font-size: .92em; line-height: 1.5; }
.build-stale__ids { margin-top: .35rem; font-size: .82em; opacity: .65; font-family: Consolas, "Courier New", monospace; }

/* ------------------------------------------------------------ 顶栏常驻检索框 */

.header-search {
  display: flex;
  align-items: center;
  gap: .35rem;
  /**
   * ⚠️ 这里【不能】是 margin-left: auto —— 那会把检索框自己推到最右边，
   * 于是顶栏变成「品牌 …(空白)… 检索框」一行、导航被挤到第二行。
   * 改为 0，它才会真的贴在品牌右边（导航的 margin-left:auto 仍然让它靠右）。
   */
  margin-left: 0;
  flex: 0 1 240px;
  min-width: 130px;
}
.header-search__input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 190px;
  /* 触摸屏上要够大才好点 */
  min-height: 34px;
  font-size: 14px;
}
.header-search__btn { white-space: nowrap; }

@media (max-width: 720px) {
  .header-search { flex: 1 1 100%; margin-left: 0; order: 9; }
}

/* ------------------------------------------------------------ 检索页 */

.search-box { padding: .9rem 1rem; }
.search-box__row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.search-box__input {
  flex: 1;
  min-width: 220px;
  /* 展示机多为触摸屏：加大字号与点按高度 */
  font-size: 18px;
  min-height: 48px;
  padding: .6rem .9rem;
}
.search-box__btn { min-height: 48px; padding: .6rem 1.4rem; font-size: 16px; }
.search-box__hint { margin-top: .55rem; min-height: 1.4em; }

.search-hit { margin: 0; cursor: pointer; }
.search-hit__name { font-family: var(--serif); font-size: 20px; font-weight: 600; }

/* 触摸屏：点击目标不小于 44px（iOS 人机界面指南） */
@media (pointer: coarse) {
  .search-hit .btn { min-height: 44px; }
  .field-picker__item { min-height: 40px; }
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(28, 25, 23, .5);
  display: grid; place-items: center; z-index: 100; padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 640px; width: 100%; max-height: 88vh; overflow: auto;
}
.modal--wide { max-width: 880px; }
.modal__head { padding: 1.1rem 1.4rem .7rem; font-family: var(--serif); font-size: var(--fs-xl); font-weight: 600; }
.modal__body { padding: 0 1.4rem 1rem; }
.modal__foot { padding: .9rem 1.4rem 1.2rem; display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.modal__close { position: absolute; top: .8rem; right: 1rem; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-mute); background: none; border: none; }

.spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--line-strong);
  border-top-color: var(--seal); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   家族公告（首页显眼位置）
   ============================================================
   未读时轻微呼吸 + 红点闪烁，提醒族人进来看；
   点过「知道了」之后停止闪烁 —— 一直闪会让人烦躁，反而被忽略。
   `prefers-reduced-motion` 下完全不动画（前庭功能障碍者会不适）。 */
.notice {
  position: relative;
  border: 1.5px solid #f0c9a0;
  background: linear-gradient(135deg, #fffaf3, #fff4e6);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: 0 2px 10px rgba(154, 52, 18, .06);
}
.notice--unread {
  border-color: var(--seal);
  box-shadow: 0 3px 16px rgba(154, 52, 18, .16);
  animation: notice-breathe 2.6s ease-in-out infinite;
}
@keyframes notice-breathe {
  0%, 100% { box-shadow: 0 3px 16px rgba(154, 52, 18, .14); }
  50%      { box-shadow: 0 3px 26px rgba(154, 52, 18, .34); }
}

/* 未读红点：闪的是这个点，不是整块内容 —— 不干扰阅读 */
.notice__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); display: inline-block; flex: 0 0 auto;
}
.notice--unread .notice__dot { animation: notice-blink 1.1s ease-in-out infinite; }
@keyframes notice-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .25; transform: scale(.7); }
}

.notice__badge {
  background: var(--danger); color: #fff;
  font-size: 11px; line-height: 1; font-weight: 700;
  padding: 3px 7px; border-radius: 999px;
}
.notice__body {
  white-space: pre-wrap; line-height: 1.85;
  font-family: var(--serif); font-size: 15.5px;
  max-height: 12rem; overflow: auto;
}
.notice__more { border-top: 1px dashed var(--line-strong); margin-top: .8rem; padding-top: .6rem; }
.notice__more-item { padding: .3rem 0; cursor: pointer; }
.notice__more-item:hover { color: var(--seal); }

@media (prefers-reduced-motion: reduce) {
  .notice--unread, .notice--unread .notice__dot { animation: none; }
  .notice--unread { border-width: 2.5px; }
}


.muted { color: var(--ink-mute); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.mt1 { margin-top: .5rem; } .mt2 { margin-top: 1rem; } .mt3 { margin-top: 1.5rem; }
.mb1 { margin-bottom: .5rem; } .mb2 { margin-bottom: 1rem; }
.flex { display: flex; } .items-center { align-items: center; } .gap1 { gap: .5rem; } .gap2 { gap: 1rem; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }

/* 行传详情排版 */
.xingzhuan {
  font-family: var(--serif); font-size: 19px; line-height: 2.05;
  text-align: justify; text-indent: 2em; color: var(--ink);
  background: var(--paper); border-left: 4px solid var(--seal);
  padding: 1.1rem 1.4rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .1rem 1.5rem; }
.detail-row { display: flex; gap: .6rem; padding: .42rem 0; border-bottom: 1px dotted var(--line); font-size: var(--fs-sm); }
.detail-row__k { color: var(--ink-mute); min-width: 6.5em; flex-shrink: 0; }
.detail-row__v { color: var(--ink); word-break: break-word; }

.doc-content { font-family: var(--serif); font-size: 18px; line-height: 2; white-space: pre-wrap; }

/* ============================================================
   打印
   —— 谱局常要把行传打印出来归档，因此打印时：
      · 隐藏导航、按钮、提示等界面元素
      · 只保留谱页内容：谱名抬头 + 行传正文 + 细目
      · 用宋体、加大行距、避免分页切断段落
   ============================================================ */

/* 仅打印时显示的元素（屏幕上不占位） */
.print-only { display: none; }

.print-page-head {
  text-align: center;
  border-bottom: 2px solid var(--ink);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}
.print-page-head .print-clan { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: .3em; }
.print-page-head .print-sub { font-size: 12px; color: var(--ink-mute); margin-top: .3rem; }
.print-foot {
  margin-top: 1.4rem; padding-top: .5rem;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-mute);
  display: flex; justify-content: space-between;
}

@media print {
  .app-header, .chart-toolbar, .nav, .btn, .no-print, .toast-stack { display: none !important; }
  .print-only { display: block !important; }

  html, body {
    background: #fff !important;
    font-size: 12.5pt;
    color: #000;
  }
  body { background-image: none !important; }

  .app-main { max-width: none !important; padding: 0 !important; margin: 0 !important; }

  .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 0 .8rem !important;
    break-inside: avoid;
  }
  .card__head { background: none !important; border-bottom: 1.5px solid #000 !important; padding: 0 0 .3rem !important; }
  .card__body { padding: 0 !important; }

  h1 { font-size: 20pt; }
  h2 { font-size: 15pt; }
  h3 { font-size: 13pt; border-bottom: 1px solid #999; padding-bottom: .15rem; }

  /* 行传正文：谱页样式，段落不被分页切断 */
  .xingzhuan {
    font-size: 13pt !important;
    line-height: 2.1 !important;
    text-indent: 2em;
    background: none !important;
    border-left: 3px solid #000 !important;
    padding: .2rem 0 .2rem .8rem !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .detail-list { display: block !important; }
  .detail-row {
    display: flex; gap: .5rem;
    padding: .18rem 0;
    border-bottom: 1px dotted #bbb !important;
    break-inside: avoid;
    font-size: 11.5pt;
  }
  .detail-row__k { color: #444 !important; }

  .tag { border: 1px solid #666 !important; background: none !important; color: #000 !important; }
  .muted { color: #444 !important; }

  a { color: #000 !important; text-decoration: none !important; }

  @page { size: A4 portrait; margin: 18mm 16mm; }
}

@media (max-width: 720px) {
  :root { --fs-base: 16.5px; --fs-2xl: 27px; --fs-xl: 22px; }
  .app-main { padding: .9rem .7rem 3.5rem; }
  .brand__sub { display: none; }
  .nav__item { padding: .4rem .6rem; font-size: var(--fs-xs); }
}
/* ============================================================
   承继关系图例与徽标
   ------------------------------------------------------------
   出继 / 承继 / 兼祧 三色与行传文字、节点徽标同源
   （见 shared 包的 ADOPTION_COLORS），三处同色才对得起来。
   ============================================================ */

.trad-legend__item--adopt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.trad-legend__swatch {
  display: inline-block;
  width: 22px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid currentColor;
  font-style: normal;
  vertical-align: -1px;
}
.trad-legend__swatch--out {
  color: #b45309;
  background: rgba(180, 83, 9, 0.13);
}
.trad-legend__swatch--in {
  color: #1e6091;
  background: rgba(30, 96, 145, 0.13);
}
.trad-legend__swatch--dual {
  color: #3f6212;
  background: rgba(63, 98, 18, 0.13);
}

/* 可点击的承继徽标：虚线边框提示"这个能点" */
.node-mark--clickable:hover rect {
  fill-opacity: 0.28;
}
.node-mark--clickable:hover {
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.18));
}
/* ============================================================
   手机端查询页（/m）
   ------------------------------------------------------------
   独立于桌面版，专为竖屏手机设计，类名统一 m- 前缀。
   几条硬规矩：
     · 输入框字号 ≥16px —— 否则 iOS 聚焦时会自动放大整页
     · 可点区域 ≥44px —— 手指点得中
     · 只用系统字体、不引外部资源 —— 手机流量下也要秒开
   ============================================================ */

.m-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 .8rem calc(2rem + env(safe-area-inset-bottom, 0px));
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
  line-height: 1.7;
}

.m-head { padding: .9rem .2rem .6rem; }
.m-head__row { display: flex; align-items: center; gap: .5rem; }
.m-logo {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  background: var(--seal, #7c2d12); color: #fff;
  border-radius: 6px; font-weight: 700; font-size: 17px;
}
.m-title { font-size: 18px; font-weight: 700; flex: 1; }
.m-link {
  background: none; border: 0; color: var(--seal, #7c2d12);
  font-size: 15px; padding: .5rem .6rem; min-height: 44px;
  cursor: pointer;
}
.m-sub { font-size: 13px; color: #78716c; margin-top: .2rem; }

/* 搜索 */
.m-search { position: relative; margin: .2rem 0 .6rem; }
.m-input {
  width: 100%; box-sizing: border-box;
  min-height: 52px; padding: .7rem 2.6rem .7rem 1rem;
  font-size: 17px;                     /* ≥16px：iOS 不放大 */
  border: 2px solid var(--line-strong, #d6cdbd);
  border-radius: 12px; background: #fff; color: #1c1917;
  -webkit-appearance: none; appearance: none;
}
.m-input:focus { outline: none; border-color: var(--seal, #7c2d12); }
.m-clear {
  position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: none;
  font-size: 18px; color: #a8a29e; cursor: pointer;
}

.m-hint { padding: 1.6rem .4rem; color: #78716c; font-size: 15px; text-align: center; }
.m-hint__sub { font-size: 13px; color: #a8a29e; }

/* 结果卡片 */
.m-list { display: flex; flex-direction: column; gap: .6rem; }
.m-card {
  text-align: left; width: 100%;
  background: #fff; border: 1px solid var(--line, #e7e1d6);
  border-radius: 12px; padding: .85rem .9rem;
  min-height: 44px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.m-card:active { background: var(--gold-soft, #fffbeb); }
.m-card__top { display: flex; align-items: center; gap: .5rem; }
.m-name { font-size: 19px; }
.m-card__meta { font-size: 14px; color: #57534e; margin-top: .25rem; }
.m-card__hit { font-size: 12.5px; color: #a8a29e; margin-top: .2rem; }

.m-tag {
  display: inline-block; font-size: 13px; line-height: 1.5;
  padding: .05rem .45rem; border-radius: 5px;
  border: 1px solid #d6cdbd; color: #57534e; background: #faf7f2;
}
.m-tag--info { border-color: #c7d2e0; color: #1e6091; background: #f2f6fa; }

/* 详情 */
.m-detail__bar { display: flex; justify-content: space-between; padding: .2rem 0; }
.m-detail__head { padding: .2rem 0 .8rem; border-bottom: 1px solid var(--line, #e7e1d6); }
.m-detail__name { font-size: 26px; font-weight: 700; letter-spacing: .04em; }
.m-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }

.m-block { padding: .9rem 0; border-bottom: 1px solid var(--line, #e7e1d6); }
.m-block__title {
  font-size: 14px; font-weight: 700; color: var(--seal, #7c2d12);
  margin-bottom: .5rem; letter-spacing: .04em;
}
.m-block__title--btn {
  background: none; border: 0; padding: .3rem 0; min-height: 44px;
  font-size: 14px; font-weight: 700; color: var(--seal, #7c2d12); cursor: pointer;
}
.m-xingzhuan { margin: 0; font-size: 17px; line-height: 1.9; text-align: justify; }

.m-rows { display: flex; flex-direction: column; }
.m-row {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px dashed var(--line, #e7e1d6);
  padding: .75rem .2rem; min-height: 48px; font-size: 16px; color: #1c1917;
  cursor: default;
}
.m-row--link { cursor: pointer; }
.m-row--link:active { background: var(--gold-soft, #fffbeb); }
.m-row__k { flex: 0 0 3.4rem; color: #78716c; font-size: 14px; }
.m-row__v { flex: 1; }
.m-row__go { color: #c4b8a6; font-size: 20px; }
.m-dim { color: #a8a29e; font-size: 13px; margin-left: .3rem; }
.m-empty { color: #a8a29e; font-size: 14px; padding: .3rem 0; }
.m-foot { text-align: center; color: #a8a29e; font-size: 12.5px; padding: 1.2rem 0 .6rem; }

/* 桌面端窗口很窄时也顺一下间距 */
@media (max-width: 480px) {
  .m-page { padding-left: .6rem; padding-right: .6rem; }
  .m-detail__name { font-size: 24px; }
}
/* 手机端页面：去掉桌面版主容器的左右留白与最大宽度限制 */
.app-main--mobile {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
/* ---------- 手机首页（/m）---------- */
.m-hero { text-align: center; padding: 2rem 0 1.6rem; }
.m-seal {
  width: 68px; height: 68px; margin: 0 auto .8rem;
  display: grid; place-items: center;
  background: var(--seal, #7c2d12); color: #fff;
  border-radius: 12px; font-size: 34px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(124,45,18,.22);
}
.m-hero__title { margin: 0; font-size: 26px; letter-spacing: .06em; }
.m-hero__sub { margin-top: .35rem; color: #78716c; font-size: 13px; }

/* 主按钮：要大、要好点 */
.m-big {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  min-height: 76px; padding: .9rem 1rem; margin-bottom: 1rem;
  background: var(--seal, #7c2d12); color: #fff;
  border: 0; border-radius: 14px; cursor: pointer;
  box-shadow: 0 5px 16px rgba(124,45,18,.26);
  text-align: left;
}
.m-big:active { transform: translateY(1px); }
.m-big__icon { font-size: 26px; }
.m-big__text { flex: 1; display: flex; flex-direction: column; }
.m-big__text strong { font-size: 21px; letter-spacing: .06em; }
.m-big__text small { font-size: 12.5px; opacity: .85; margin-top: .15rem; }
.m-big__go { font-size: 26px; opacity: .8; }

/* 三个次要入口 */
.m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.m-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: .2rem;
  min-height: 92px; padding: .85rem .9rem;
  background: #fff; border: 1px solid var(--line, #e7e1d6);
  border-radius: 12px; cursor: pointer; text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.m-tile:active { background: var(--gold-soft, #fffbeb); }
.m-tile:last-child { grid-column: 1 / -1; }
.m-tile__icon {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: #f6f1e8; color: var(--seal, #7c2d12);
  border-radius: 8px; font-size: 16px; font-weight: 700; margin-bottom: .2rem;
}
.m-tile strong { font-size: 17px; }
.m-tile small { font-size: 12.5px; color: #a8a29e; }

.m-note {
  margin-top: 1.1rem; padding: .8rem .9rem;
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px;
  font-size: 13.5px; line-height: 1.75; color: #57534e;
}
.m-admin { text-align: right; padding: .8rem .2rem 0; }

/* 顶部条 */
.m-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .3rem 0 .2rem; position: sticky; top: 0;
  background: var(--paper, #f7f4ef); z-index: 5;
}
.m-bar__title { font-size: 15px; font-weight: 700; }

/* 文献中心 */
.m-docgroup { margin-bottom: 1.1rem; }
.m-filetabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .5rem; }
.m-tag--on { border-color: var(--seal, #7c2d12); color: var(--seal, #7c2d12); background: #fdf6f1; }
.m-docview { padding-bottom: 1rem; }
/* 登录引导（族人详情属隐私，需登录） */
.m-login { text-align: center; padding: 2.2rem 1rem 1rem; }
.m-login__icon { font-size: 40px; margin-bottom: .6rem; }
.m-login__title { font-size: 20px; font-weight: 700; margin-bottom: .6rem; }
.m-login__desc { font-size: 14px; line-height: 1.9; color: #78716c; margin-bottom: 1.4rem; }
.m-big--login { max-width: 340px; margin: 0 auto 1rem; }
.m-hint--tight { padding: .3rem .3rem 1rem; font-size: 13.5px; text-align: left; }
/* ============================================================
   管理后台控制台布局（左侧竖排菜单 + 右侧内容）
   ------------------------------------------------------------
   页签有 8 个，横排会挤成一排小字；且页面下滚后页签会跟着滚走。
   左菜单在宽屏常驻，窄屏折回横排并横向滚动。
   ============================================================ */
.console { display: flex; gap: 1.1rem; align-items: flex-start; }
.console__side {
  flex: 0 0 168px;
  position: sticky;
  top: .8rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  background: #fff;
  border: 1px solid var(--line, #e7e1d6);
  border-radius: 12px;
  padding: .7rem .55rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.console__title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--seal, #7c2d12);
  padding: .2rem .5rem .6rem;
  border-bottom: 1px solid var(--line, #e7e1d6);
  margin-bottom: .35rem;
}
.console__item {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-align: left;
  width: 100%;
  min-height: 40px;
  padding: .4rem .55rem;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 14.5px;
  color: var(--ink, #1c1917);
  cursor: pointer;
}
.console__item:hover { background: var(--paper-2, #f6f1e8); }
.console__item.is-active {
  background: var(--seal, #7c2d12);
  color: #fff;
  font-weight: 600;
}
.console__ico {
  width: 22px; height: 22px; flex: 0 0 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--paper-3, #f1e9dc);
  color: var(--seal, #7c2d12);
  font-size: 13px;
  font-weight: 700;
}
.console__item.is-active .console__ico { background: rgba(255,255,255,.22); color: #fff; }
.console__foot { margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line, #e7e1d6); }
.console__main { flex: 1; min-width: 0; }

/* 窄屏：菜单折回横排 */
@media (max-width: 860px) {
  .console { flex-direction: column; }
  .console__side {
    position: static;
    flex: none;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: .5rem;
  }
  .console__title, .console__foot { display: none; }
  .console__item { width: auto; white-space: nowrap; }
}