:root {
  --bg: #f5f1e8;
  --panel: #fffdf8;
  --card: #fff;
  --ink: #2a2322;
  --muted: #6b5f58;
  --line: #cbbba8;
  --accent: #8b2e2e;
  --accent-light: #c45c4a;
  --male: #3a5a82;
  --female: #8b3a62;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: "PingFang SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; background: var(--bg); color: var(--ink); }
body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.logo { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: bold; font-size: 18px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; }

.search-box { flex: 1; display: flex; position: relative; max-width: 420px; }
#searchInput { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius) 0 0 var(--radius); font-size: 14px; outline: none; }
#searchBtn { padding: 8px 16px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; }
#searchBtn:hover { background: var(--accent-light); }
.search-results { position: absolute; top: 38px; left: 0; right: 0; max-height: 260px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: none; z-index: 100; }
.search-results .item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f0ebe3; }
.search-results .item:hover, .search-results .item.active { background: #f7f2ea; }
.search-results .item small { color: var(--muted); display: block; margin-top: 2px; }

.branch-select { display: flex; align-items: center; gap: 6px; }
.branch-select label { font-size: 13px; color: var(--muted); }
#branchSelect { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; font-size: 13px; min-width: 140px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { padding: 7px 12px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.actions button:hover { background: #faf5ee; border-color: var(--accent); color: var(--accent); }

/* 主区域 */
.main { flex: 1; display: flex; overflow: hidden; }

/* 左右面板 */
.panel-left, .panel-right { width: 260px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.panel-right { border-right: none; border-left: 1px solid var(--line); }
.panel-header { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; background: #faf6f0; }
.panel-header h3 { margin: 0; font-size: 15px; }
.book-select { position: relative; display: inline-flex; max-width: 62%; }
.book-select-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text); max-width: 100%; }
.book-select-btn:hover { border-color: var(--accent); }
.book-select-btn .caret { font-size: 11px; color: var(--muted); margin-left: 2px; }
#peoplePanelBookName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-select-panel { position: absolute; top: calc(100% + 5px); left: 0; min-width: 260px; max-width: 82vw; max-height: 60vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 150; padding: 8px; }
.book-select-panel .book-row { padding: 8px 10px; }
.book-select-panel .book-row .book-actions { flex-shrink: 0; }
.book-select-panel .book-row .book-name { font-size: 13.5px; }
.book-select-panel .book-row .book-tag { font-size: 10px; }
.book-select-panel .book-row .book-time { display: none; }
.book-select-panel .empty-tip { margin: 6px 0; font-size: 12px; color: var(--muted); }
button.small { padding: 4px 8px; font-size: 12px; border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 4px; cursor: pointer; }
button.small:hover { background: var(--accent); color: #fff; }

.people-list { flex: 1; overflow: auto; padding: 8px; }
.people-list .person-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; margin-bottom: 4px; font-size: 13px; }
.people-list .person-item:hover { background: #f0ebe3; }
.people-list .person-item.active { background: var(--accent); color: #fff; }
.people-list .person-item .gen { color: var(--muted); font-size: 11px; }
.people-list .person-item.active .gen { color: #f0d9d6; }

/* 详情面板 */
.detail-panel { flex: 1; overflow: auto; padding: 14px; font-size: 14px; }
.empty-tip { color: var(--muted); text-align: center; margin-top: 40px; }
.detail-panel h2 { margin: 0 0 8px; font-size: 20px; color: var(--accent); }
.detail-panel .sub { color: var(--muted); margin-bottom: 14px; }
.detail-panel .field { margin-bottom: 10px; line-height: 1.5; }
.detail-panel .field label { color: var(--muted); font-size: 12px; display: block; margin-bottom: 2px; }
.detail-panel .rel-link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.detail-panel .rel-link:hover { opacity: .75; }
.detail-panel .actions { margin-top: 16px; gap: 6px; }

/* 画布 */
.canvas-wrap { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
#treeSvg { width: 100%; height: 100%; cursor: grab; }
#treeSvg:active { cursor: grabbing; }
.zoom-controls { position: absolute; bottom: 16px; right: 16px; display: flex; gap: 6px; }
.zoom-controls button { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 18px; line-height: 1; }
.zoom-controls button:hover { background: #faf5ee; }

/* 树节点 */
.node rect { stroke: var(--line); stroke-width: 1.5px; }
.node.male rect { fill: #eaf2ff; stroke: var(--male); }
.node.female rect { fill: #ffebf3; stroke: var(--female); }
.node.selected rect { stroke: var(--accent); stroke-width: 3px; }
.node text { font-size: 13px; dominant-baseline: middle; pointer-events: none; }
.node .name { font-weight: 600; }
.node .alias { font-size: 11px; fill: var(--muted); }
.node .gen-life { font-size: 10px; fill: #8a6a3a; font-weight: 500; }
.node .collapsed-hint { font-size: 10px; fill: #b23a2e; }
.node .collapse-btn circle { transition: fill .15s; }
.node .collapse-btn:hover circle { fill: #fbeaea; }
.node.dim .gen-life, .node.dim .alias { opacity: 0.5; }
.link, .spouse-link, .spouse-child-link { fill: none; stroke: #b8a89a; stroke-width: 1.5px; }
.link.highlight { stroke: var(--accent); stroke-width: 2.5px; }
.node.dim { opacity: 0.25; }
.node.highlight rect { stroke: var(--accent); stroke-width: 3px; }

/* 右键菜单 */
.context-menu { position: absolute; display: none; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; overflow: hidden; min-width: 120px; }
.context-menu button { padding: 8px 14px; border: none; background: #fff; text-align: left; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f0ebe3; }
.context-menu button:last-child { border-bottom: none; }
.context-menu button:hover { background: #faf5ee; }
.context-menu button.danger { color: var(--accent); }

/* 模态框 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal.open { display: flex !important; }
.modal-body { background: #fff; border-radius: var(--radius); width: 520px; max-width: 92vw; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2); display: block; position: relative; padding: 0 12px; }

.modal-body h3 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); background: #faf6f0; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 300; padding: 20px; }
.modal-mask.open, .modal-mask[style*="flex"] { display: flex !important; }
.modal-mask > .modal-body { display: block; }
.form-modal-close { position: absolute; top: 14px; right: 18px; background: transparent; border: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.form-modal-close:hover { color: var(--accent); }

/* ===== iOS 添加到主屏幕引导浮层 ===== */
.install-guide { background: #fff; border-radius: 14px; max-width: 360px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); animation: guidePop .2s ease; }
@keyframes guidePop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.install-guide .modal-body { padding: 22px 22px 18px; }
.install-guide h3 { margin: 0 0 14px; font-size: 18px; color: var(--accent); text-align: center; }
.install-steps { margin: 0 0 14px; padding-left: 22px; }
.install-steps li { margin: 9px 0; line-height: 1.55; font-size: 14px; color: #333; }
.install-steps b { color: var(--accent); }
.install-note { margin: 0 0 16px; padding: 10px 12px; background: #f6f1e7; border: 1px solid #e6d9bf; border-radius: 8px; font-size: 12.5px; line-height: 1.6; color: #6b5a3a; }
.btn-primary { display: block; width: 100%; padding: 11px 0; border: none; border-radius: 10px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }

/* 族务人员 */
.temple-roles-list { display: flex; flex-direction: column; gap: 8px; }
.temple-role-item { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: rgba(255,255,255,.5); border: 1px solid var(--line); border-radius: 8px; }
.temple-role-item .role-name { font-weight: 700; color: var(--accent); min-width: 90px; }
.temple-role-item .role-person { color: #444; flex: 1; }
.temple-role-item .role-term { color: var(--muted); font-size: 13px; min-width: 130px; text-align: right; }
.temple-role-item .role-actions { display: flex; gap: 6px; }
.temple-role-item button { padding: 3px 10px; font-size: 12px; }

/* 功德碑 */
.temple-merits-list { display: flex; flex-direction: column; gap: 14px; }
.temple-merits-section h4 { margin: 0 0 6px; font-size: 14px; color: var(--accent); display: flex; justify-content: space-between; align-items: baseline; }
.temple-merits-section .section-total { font-size: 13px; color: #c0392b; font-weight: 600; }
.temple-merits-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.temple-merits-table th { background: #faf6f0; padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); font-weight: 600; }
.temple-merits-table td { padding: 6px 10px; border-bottom: 1px solid #f0ebe1; }
.temple-merits-table tr:hover td { background: #fdf9f1; }
.temple-merits-table .amount { text-align: right; font-variant-numeric: tabular-nums; }
.temple-merits-table .actions { white-space: nowrap; }
.temple-merits-table .actions button { padding: 2px 8px; font-size: 11px; margin-right: 4px; }

/* 个人详情 modal（像独立页面） */
.person-detail-mask { position: fixed; inset: 0; background: rgba(20,12,8,0.6); display: none; align-items: flex-start; justify-content: center; z-index: 150; padding: 30px 20px; overflow: auto; }
.person-detail-mask.open { display: flex; }
.person-detail-page { position: relative; width: 800px; max-width: 100%; background: linear-gradient(180deg, #faf6ef 0%, #f3ecdb 100%); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); padding: 30px 36px; }
.pd-close { position: absolute; top: 12px; right: 16px; background: transparent; border: 2px solid var(--accent); color: var(--accent); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 22px; line-height: 28px; }
.pd-close:hover { background: var(--accent); color: #fff; }
.pd-header { display: flex; gap: 24px; align-items: flex-start; padding-bottom: 20px; border-bottom: 2px solid var(--line); margin-bottom: 20px; }
.pd-photo { width: 140px; height: 170px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex-shrink: 0; background: #f5efe2; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; overflow: hidden; }
.pd-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.pd-info { flex: 1; }
.pd-info h2 { margin: 0 0 4px; color: var(--accent); font-size: 28px; font-family: "STKaiti", "KaiTi", "楷体", serif; }
.pd-info .pd-alias { font-size: 15px; color: var(--muted); margin-bottom: 12px; }
.pd-status { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.pd-status.alive { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.pd-status.deceased { background: #f3e5f5; color: #6a1b9a; border: 1px solid #e1bee7; }
.pd-meta { margin-top: 12px; color: #444; font-size: 14px; line-height: 1.9; }
.pd-meta b { color: #7c5a1e; }
.pd-section { margin-top: 18px; padding: 14px 18px; background: rgba(255,255,255,0.6); border-radius: 8px; border: 1px solid var(--line); }
.pd-section h4 { margin: 0 0 8px; color: var(--accent); font-size: 15px; }
.pd-rel-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-rel-chip { display: inline-block; padding: 4px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; font-size: 13px; cursor: pointer; }
.pd-rel-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pd-rel-chip.disabled { cursor: default; opacity: .5; background: transparent; }
.pd-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pd-actions button { padding: 10px 20px; border-radius: 8px; border: 1px solid var(--accent); background: #fff; color: var(--accent); cursor: pointer; font-size: 14px; }
.pd-actions button:hover { background: var(--accent); color: #fff; }
.pd-actions button.primary { background: var(--accent); color: #fff; }
.pd-actions button.primary:hover { background: #5a3e12; }
#personForm { padding: 18px; }
.form-row { margin-bottom: 12px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--accent); }
.parent-row { display: flex; align-items: center; gap: 6px; }
.parent-row select { flex: 1 1 auto; }
.mini-add { flex: 0 0 auto; width: 30px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--accent); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.mini-add:hover { filter: brightness(1.08); }
.quick-parent-input { padding: 8px 10px; border: 1px solid var(--accent); border-radius: 6px; font-size: 14px; }
.children-list { margin-bottom: 6px; }
.children-existing { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.child-chip { background: #f3e9da; color: #5d4037; padding: 3px 10px; border-radius: 12px; font-size: 13px; }
.children-rows { display: flex; flex-direction: column; gap: 8px; }
.child-row { display: flex; gap: 8px; align-items: center; }
.child-row input.child-name { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.child-row select.child-gender { width: 62px; flex: 0 0 auto; padding: 8px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.child-row select.child-living { width: 72px; flex: 0 0 auto; padding: 8px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.child-row .child-del { width: 32px; height: 34px; padding: 0; line-height: 1; background: #fff; border: 1px solid var(--line); border-radius: 6px; color: #c0392b; cursor: pointer; font-size: 16px; }
.child-row .child-del:hover { background: #fff0f0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.form-actions button { padding: 8px 18px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.form-actions .primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.form-actions .primary:hover { background: var(--accent-light); }
.form-actions .secondary { background: #fff; border: 1px solid var(--line); }
.form-actions .secondary:hover { background: #faf5ee; }

/* 资料 / 影像 附件 */
.attach-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attach-tools .small { padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.attach-tools .small:hover { background: #faf5ee; }
.attach-preview { display: flex; gap: 10px; flex-wrap: wrap; min-height: 4px; }
.att-item { position: relative; width: 84px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.att-thumb { width: 84px; height: 64px; object-fit: cover; display: block; background: #efe7db; }
.att-thumb.pdf { display: grid; place-items: center; font-weight: 700; color: var(--accent); background: #f0e7db; }
.att-name { font-size: 11px; color: var(--muted); padding: 3px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-del { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 16px; text-align: center; border: none; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; font-size: 13px; }

/* 图转文 OCR */
.ocr-box { margin-top: 10px; padding: 10px; border: 1px dashed var(--accent); border-radius: 8px; background: #fbf6f2; }
.ocr-progress { font-size: 13px; color: var(--accent); margin-bottom: 6px; }
.ocr-box textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 13px; resize: vertical; }
.ocr-actions { display: flex; gap: 8px; margin-top: 8px; }
.ocr-actions .small { padding: 5px 12px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.ocr-actions .small:hover { background: var(--accent-light); }
.ocr-actions .small.secondary { background: #fff; color: var(--muted); border-color: var(--line); }

/* 影像馆：分类筛选行 + 分类/标签 */
.gallery-filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 4px; }
.gallery-filter-row select, .gallery-filter-row input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: var(--panel); color: var(--ink); }
.gallery-filter-row input { min-width: 220px; flex: 1; max-width: 360px; }
.g-cat { display: inline-block; font-size: 12px; background: var(--accent); color: #fff; padding: 1px 8px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.g-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.g-tag { font-size: 12px; background: #f0e6d8; color: #8a5a2b; border: 1px solid #e0cdaa; padding: 1px 8px; border-radius: 10px; cursor: pointer; transition: background .15s; }
.g-tag:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 手抄本图片批注 + OCR */
.ms-anno-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ms-anno-dot { position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; background: #e23b3b; color: #fff; font-size: 12px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.4); pointer-events: auto; cursor: pointer; }
.ms-anno-panel { width: 90vw; max-width: 1000px; margin-top: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 10px 12px; color: #fff; }
.ms-panel-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; opacity: .92; }
.ms-anno-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow: auto; }
.ms-anno-row { display: flex; align-items: center; gap: 8px; }
.ms-anno-no { width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; background: #e23b3b; color: #fff; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.ms-anno-text { flex: 1; padding: 5px 8px; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; background: rgba(0,0,0,.25); color: #fff; font-size: 13px; }
.ms-anno-text::placeholder { color: rgba(255,255,255,.45); }
.ms-ocr-panel { width: 90vw; max-width: 1000px; margin-top: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 10px 12px; color: #fff; }
.ms-ocr-text { width: 100%; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 8px; font-size: 13px; resize: vertical; background: rgba(0,0,0,.25); color: #fff; }
.ms-ocr-text::placeholder { color: rgba(255,255,255,.45); }
.ms-zoom-btn.active { background: var(--accent); color: #fff; }
.ms-zoom-btn[data-act="annotate"], .ms-zoom-btn[data-act="ocr"], .ms-zoom-btn[data-act="extract"], .ms-zoom-btn[data-act="prev"], .ms-zoom-btn[data-act="next"] { width: auto; padding: 0 12px; font-size: 14px; }
.ms-tool-sep { width: 1px; height: 22px; background: rgba(255,255,255,.3); margin: 0 4px; }
.ms-book-label { color: #fff; font-size: 13px; opacity: .85; }
.ms-book-sel { height: 34px; border: none; border-radius: 8px; background: rgba(255,255,255,.15); color: #fff; font-size: 13px; padding: 0 8px; max-width: 160px; }
.ms-book-sel option { color: #222; }

/* 手抄本卡片状态徽章 */
.ms-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.ms-badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 9px; font-weight: 600; }
.ms-b-ocr { background: #2f7d4f; color: #fff; }
.ms-b-anno { background: #b5532a; color: #fff; }
.ms-b-book { background: #3a5a8a; color: #fff; }
.ms-b-cat { background: #8a6d3a; color: #fff; }
.ms-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.ms-tag { font-size: 12px; background: #f0e6d8; color: #8a5a2b; border: 1px solid #e0cdaa; padding: 1px 8px; border-radius: 10px; cursor: pointer; transition: background .15s; }
.ms-tag:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* 框选裁剪层 */
.ms-crop-box { position: absolute; border: 2px dashed #ffd34d; background: rgba(255,211,77,.18); pointer-events: none; z-index: 20; box-sizing: border-box; }
/* OCR 面板：写入人物 / 新史篇 */
.ocr-person-row { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.ms-ocr-person { height: 30px; border-radius: 6px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.3); color: #fff; font-size: 13px; padding: 0 8px; max-width: 180px; }
.ms-ocr-person option { color: #222; }
#msHitCount { margin-left: 4px; }

/* 摄像头拍照弹窗 */
#captureModal video { background: #000; }
#captureModal .modal-body { background: var(--panel); }

/* 打印 */
@media print {
  .toolbar, .panel-left, .panel-right, .zoom-controls, .context-menu, .topnav, #calendarView,
  #offeringView, #notablesView, #galleryView, #historyView, #chronicleView, #originView, #settingsView,
  .lock-screen, .lightbox { display: none !important; }
  .main { display: block; }
  .canvas-wrap { width: 100vw; height: 100vh; overflow: visible; }
  #treeSvg { width: 100%; height: 100%; }
  body { background: #fff; }
}

/* 顶部主导航 */
.topnav { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: #2a1f1d; color: #f5e9e6; box-shadow: 0 2px 8px rgba(0,0,0,0.18); flex: 0 0 auto; z-index: 10; }
.nav-logo { width: 30px; height: 30px; border-radius: 7px; flex: none; display: block; object-fit: contain; }
.nav-btn { padding: 6px 14px; border: 1px solid transparent; background: transparent; color: #e8d9d4; border-radius: 18px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.nav-btn:hover { background: rgba(255,255,255,0.08); }
.nav-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-lang-select { padding: 6px 10px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); color: #e8d9d4; border-radius: 18px; cursor: pointer; font-size: 13px; outline: none; appearance: none; -webkit-appearance: none; text-align: center; min-width: 44px; }
.nav-lang-select:hover { background: rgba(255,255,255,0.12); }
.nav-lang-select option { background: #2a1f1d; color: #f5e9e6; }
.brand-title { font-size: 18px; font-weight: 700; color: #f5e9e6; white-space: nowrap; letter-spacing: 1px; }
.nav-title { margin-left: auto; font-size: 13px; opacity: 0.7; white-space: nowrap; }

/* 导航分组下拉 */
.nav-group { position: relative; display: inline-flex; flex-direction: column; }
.nav-toggle { display: inline-flex; align-items: center; gap: 4px; touch-action: manipulation; }
/* 用伪元素搭一座「桥」，让鼠标从按钮滑向下拉时不会经过 6px 空隙而丢失 hover */
.nav-group::after {
  content: ''; position: absolute; top: 100%; left: 0; width: 100%; height: 10px;
  background: transparent; pointer-events: auto; z-index: 99;
}
.nav-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 128px;
  display: none; flex-direction: column; gap: 3px;
  background: #2a1f1d; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 7px; box-shadow: 0 8px 22px rgba(0,0,0,0.35);
  z-index: 100;
}
.nav-dropdown .nav-btn { width: 100%; text-align: left; border-radius: 6px; padding: 7px 12px; }
@media (hover: hover) and (pointer: fine) {
  .nav-group:hover .nav-dropdown { display: flex; }
  .nav-group:hover::after { display: block; }
}
.nav-group.open .nav-dropdown { display: flex; }
.nav-group.active > .nav-toggle { background: var(--accent); color: #fff; border-color: var(--accent); }
/* 最右侧分组下拉避免溢出屏幕 */
.nav-group:last-of-type .nav-dropdown { left: auto; right: 0; }

/* 视图容器 */
.view { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; }

/* ===== 万年历 ===== */
.cal-header { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.cal-title { font-size: 18px; font-weight: 600; color: var(--accent); min-width: 190px; }
.cal-nav-btn { width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 18px; line-height: 1; }
.cal-nav-btn:hover { background: #faf5ee; border-color: var(--accent); color: var(--accent); }
.cal-spacer { flex: 1; }
.cal-select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px; }
.cal-today { padding: 6px 14px; border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 6px; cursor: pointer; font-size: 13px; }
.cal-today:hover { background: var(--accent); color: #fff; }

.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: #faf6f0; border-bottom: 1px solid var(--line); }
.cal-weekdays span { text-align: center; padding: 8px 0; font-size: 13px; color: var(--muted); font-weight: 600; }

.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; gap: 1px; background: var(--line); overflow: auto; padding: 1px; }
.cal-cell { background: var(--bg); padding: 6px 8px; min-height: 78px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; position: relative; }
.cal-cell:hover { background: #efe7db; }
.cal-cell.empty { background: #ece6dc; cursor: default; }
.cal-cell .solar { font-size: 16px; font-weight: 600; color: var(--ink); }
.cal-cell .lunar { font-size: 12px; color: var(--muted); }
.cal-cell.today { background: #f8e7e3; }
.cal-cell.today .solar { color: var(--accent); }
.cal-cell.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell .tag { display: inline-block; font-size: 11px; margin-top: 2px; padding: 0 4px; border-radius: 3px; }
.cal-cell .tag.term { background: #e7f0e7; color: #3c6b3c; }
.cal-cell .tag.festival { background: #fbe7df; color: var(--accent); }

.cal-detail { flex: 0 0 auto; max-height: 200px; overflow: auto; padding: 14px 18px; background: var(--panel); border-top: 1px solid var(--line); font-size: 14px; }
.cal-detail h3 { margin: 0 0 10px; font-size: 17px; color: var(--accent); }
.cal-detail .row { margin-bottom: 8px; line-height: 1.5; }
.cal-detail .row label { color: var(--muted); font-size: 12px; display: inline-block; min-width: 64px; }
.cal-detail .big-lunar { font-size: 22px; font-weight: 700; color: var(--accent); }
.cal-detail .gz { color: var(--male); font-weight: 600; }

/* ===== 通用区块头 ===== */
.sec-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sec-header h2 { margin: 0; font-size: 19px; color: var(--accent); }
.gallery-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }

/* ===== 名人卡片墙 ===== */
.cards-grid { flex: 1; overflow: auto; padding: 18px 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; align-content: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; text-align: center; }
.card-photo { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; margin-bottom: 8px; border: 2px solid var(--line); background: #efe7db; display: grid; place-items: center; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-photo.empty { font-size: 36px; color: #b8a89a; font-weight: 700; }
.card-name { font-size: 18px; font-weight: 700; }
.card-alias { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card-bio { font-size: 13px; line-height: 1.6; color: #3a322f; text-align: left; margin-bottom: 10px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* ===== 影像馆 ===== */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.seg-btn { padding: 6px 14px; border: none; background: #fff; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg-btn.active { background: var(--accent); color: #fff; }
.gallery-grid { flex: 1; overflow: auto; padding: 18px 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; align-content: start; }
.g-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.g-media { height: 180px; background: #efe7db; display: grid; place-items: center; overflow: hidden; }
.g-media img, .g-media video { width: 100%; height: 100%; object-fit: cover; }
.g-meta { padding: 8px 10px; display: flex; align-items: center; gap: 8px; }
.g-type { font-size: 11px; background: var(--accent); color: #fff; padding: 1px 7px; border-radius: 10px; }
.g-title { font-size: 14px; font-weight: 600; }
.g-actions { padding: 0 10px 10px; display: flex; gap: 6px; }

/* ===== 史记 ===== */
.doc-list { flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.doc-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.doc-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f0ebe3; padding-bottom: 8px; margin-bottom: 8px; }
.doc-head h3 { margin: 0; font-size: 16px; color: var(--accent); }
.doc-ops { display: flex; gap: 6px; }
.doc-body { font-size: 14px; line-height: 1.8; color: #3a322f; white-space: pre-wrap; }

/* ===== 大事记时间轴 ===== */
.timeline { flex: 1; overflow: auto; padding: 22px 20px 22px 40px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 18px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-dot { position: absolute; left: -28px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.tl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tl-date { font-size: 12px; color: var(--accent); font-weight: 700; }
.tl-title { font-size: 16px; font-weight: 600; margin: 2px 0 4px; }
.tl-desc { font-size: 14px; line-height: 1.7; color: #3a322f; white-space: pre-wrap; }
.tl-ops { margin-top: 8px; display: flex; gap: 6px; }

/* ===== 族源 ===== */
.prose { flex: 1; overflow: auto; padding: 22px 28px; font-size: 15px; line-height: 2; color: #2f2826; white-space: pre-wrap; max-width: 880px; }

/* ===== 祭祀 ===== */
.offer-toolbar { display: flex; align-items: center; gap: 10px; padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.offer-toolbar select { padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; font-size: 13px; min-width: 140px; }
.offer-hint { font-size: 11px; color: var(--muted); }
.offer-stage { flex: 1; min-height: 100%; height: auto; overflow: visible; padding: 8px 16px; display: flex; flex-direction: column; align-items: center; position: relative; background: radial-gradient(ellipse at 50% 30%, #4a2818 0%, #2a1610 70%, #1a0d08 100%); }
.offer-stage-center { margin: 10px 0 auto 0; display: flex; flex-direction: column; align-items: center; gap: 16px; position: relative; z-index: 2; }
@media (min-height: 850px) {
  .offer-stage-center { margin: auto 0; }
}
.stage-bg { position: absolute; inset: 0; background-image: radial-gradient(circle at 20% 30%, rgba(245,215,110,.06) 0, transparent 60%), radial-gradient(circle at 80% 70%, rgba(245,215,110,.04) 0, transparent 60%); pointer-events: none; }
.tablet-selector-bar { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: rgba(0,0,0,.35); border: 1px solid rgba(212,160,23,.35); border-radius: 20px; color: #f5d76e; font-size: 13px; backdrop-filter: blur(2px); }
.tablet-selector-bar label { opacity: .9; }
.tablet-selector-bar select { padding: 4px 8px; border: 1px solid rgba(212,160,23,.5); border-radius: var(--radius); background: rgba(30,15,10,.85); color: #f5d76e; font-size: 13px; min-width: 140px; }
.tablet-selector-bar select:disabled { opacity: .5; }
.tablet-selector-hint { font-size: 11px; opacity: .65; }

/* 中式大号牌位（参考豆包AI中式牌位）：双层黑金边框 + 顶部双如意云纹 + 多层黑色台阶底座 */
/* 中式木牌位（参考中式红木牌位图）：圆弧顶 + 金色如意纹 + 两侧万字纹 + 金色莲花 + 多层木质底座 */
.ancestral-tablet-large { position: relative; width: 220px; padding: 26px 20px 8px; background: linear-gradient(180deg, #8b2828 0%, #6e1414 60%, #4a0e0e 100%); border: 4px solid #4a0e0e; border-radius: 50% 50% 4px 4px / 18% 18% 4px 4px; box-shadow: inset 0 0 0 2px #d4a017, inset 0 0 0 4px #4a0e0e, 0 12px 32px rgba(0,0,0,.7), 0 0 60px rgba(245,215,110,.15); color: #f5d76e; font-family: "STKaiti", "KaiTi", "楷体", "SimSun", serif; text-align: center; user-select: none; }
.at-photo { display: block; width: 70px; height: 90px; object-fit: cover; border: 2px solid #d4a017; border-radius: 3px; margin: 8px auto 4px; box-shadow: 0 0 6px rgba(245,215,110,.3); }
.at-ruyi-svg { position: absolute; top: 10px; left: 0; right: 0; width: 100%; height: 48px; filter: drop-shadow(0 0 6px rgba(245,215,110,.5)); pointer-events: none; }
/* 两侧金色卐万字纹边框（垂直平铺） */
.at-wan-edge { position: absolute; top: 84px; bottom: 72px; width: 14px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path d='M3,2 L8,2 L8,8 L12,8 L12,12 L6,12 L6,6 L3,6 Z M9,2 L11,2 L11,5 L9,5 Z' fill='none' stroke='%23d4a017' stroke-width='1.2' /></svg>"); background-repeat: repeat-y; background-size: 14px 14px; opacity: .85; }
.at-wan-left { left: 6px; }
.at-wan-right { right: 6px; transform: scaleX(-1); }
.at-side { position: absolute; top: 56%; transform: translateY(-50%); writing-mode: vertical-rl; font-size: 14px; color: #f5d76e; letter-spacing: 3px; opacity: .95; text-shadow: 0 1px 2px rgba(0,0,0,.4); z-index: 2; }
.at-side-left { left: 22px; }
.at-side-right { right: 22px; }
.at-name { display: flex; flex-direction: column; align-items: center; font-size: 24px; font-weight: 700; color: #f5d76e; margin: 6px auto 8px; line-height: 1.05; text-shadow: 0 0 12px rgba(245,215,110,.6), 0 2px 4px rgba(0,0,0,.4); max-height: 180px; }
.at-char { display: block; line-height: 1.05; }
.at-lotus-svg { display: block; width: 100%; height: 22px; margin: 4px 0 2px; filter: drop-shadow(0 0 4px rgba(245,215,110,.4)); }
.at-foot { margin-top: 4px; font-size: 10px; color: #d4a017; opacity: .7; letter-spacing: 3px; }

/* 多层木质底座（参考中式红木牌位的 3 层台阶） */
.at-base { position: relative; width: 100%; height: 56px; margin-top: 10px; }
.at-base::before, .at-base::after, .at-base > span:nth-child(1), .at-base > span:nth-child(2) { content: ""; position: absolute; left: 50%; transform: translateX(-50%); background: linear-gradient(180deg, #6e1414 0%, #4a0e0e 100%); border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,.5), inset 0 1px 0 rgba(245,215,110,.15); }
.at-base > span:nth-child(1) { bottom: 0; width: 100%; height: 10px; border-radius: 0 0 4px 4px; }
.at-base > span:nth-child(2) { bottom: 11px; width: 92%; height: 9px; }
.at-base::after { bottom: 21px; width: 84%; height: 8px; }
.at-base::before { bottom: 30px; width: 76%; height: 7px; }
/* 多层黑色台阶底座 */
.at-base { position: relative; width: 100%; height: 26px; margin-top: 6px; }
.at-base::before, .at-base::after, .at-base > span { content: ""; position: absolute; left: 50%; transform: translateX(-50%); background: linear-gradient(#3a2818 0%, #1a0d08 50%, #3a2818 100%); border-radius: 3px; box-shadow: 0 2px 4px rgba(0,0,0,.6); }
.at-base::before { bottom: 0; width: 100%; height: 12px; border-radius: 0 0 6px 6px; }
.at-base::after { bottom: 13px; width: 92%; height: 8px; }
.at-base > span { bottom: 23px; width: 84%; height: 7px; }

/* 中式香炉 */
.incense-burner { position: relative; width: 480px; height: 220px; display: flex; flex-direction: column; align-items: center; }
.incense-shelf { display: flex; gap: 48px; align-items: flex-end; justify-content: center; min-height: 150px; padding: 0 24px 6px; position: relative; z-index: 3; }
.incense-stick { position: relative; width: 14px; height: 200px; display: flex; flex-direction: column; align-items: center; }
/* 白色蜡烛（与香同高 200px，白蜡烛身 + 火焰，无烟） */
.incense-candle { position: relative; width: 14px; height: 200px; display: flex; flex-direction: column; align-items: center; }
.incense-candle-body { width: 12px; height: 184px; background: linear-gradient(180deg, #fbf5e6 0%, #ede4cd 50%, #d8cdb1 100%); border-radius: 6px 6px 0 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.2); }
.incense-candle-tip { width: 14px; height: 18px; background: radial-gradient(circle at 50% 30%, #fff5b0 0%, #ff7700 35%, #aa1100 80%); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; margin-top: -2px; box-shadow: 0 0 14px #ff7700, 0 0 24px rgba(255,120,0,.7); animation: flame-flicker 0.32s ease-in-out infinite alternate; position: relative; z-index: 2; }
.incense-stick-body { width: 12px; height: 180px; background: linear-gradient(#d4b97a 0%, #b8965a 50%, #8c6e34 100%); border-radius: 6px 6px 0 0; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.incense-tip { width: 14px; height: 18px; background: radial-gradient(circle at 50% 30%, #fff5b0 0%, #ff5500 40%, #aa1100 80%); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; margin-top: -2px; box-shadow: 0 0 18px #ff7700, 0 0 28px rgba(255,120,0,.7); animation: flame-flicker 0.32s ease-in-out infinite alternate; position: relative; z-index: 2; }
@keyframes flame-flicker { 0% { transform: scale(1, 1) translateY(0); opacity: .9; box-shadow: 0 0 14px #ff7700, 0 0 22px rgba(255,120,0,.6); } 50% { transform: scale(1.18, 1.25) translateY(-1px); opacity: 1; box-shadow: 0 0 22px #ffaa00, 0 0 36px rgba(255,160,0,.8); } 100% { transform: scale(.95, .9) translateY(0); opacity: .85; box-shadow: 0 0 12px #ff5500, 0 0 18px rgba(255,90,0,.5); } }
.incense-smoke { position: absolute; top: -22px; left: 50%; width: 12px; height: 70px; background: linear-gradient(rgba(200,200,200,0.55), rgba(200,200,200,0)); border-radius: 50%; filter: blur(5px); animation: smoke 2.6s ease-in infinite; transform-origin: bottom center; pointer-events: none; }
.incense-smoke:nth-child(2) { animation-delay: .8s; }
.incense-smoke:nth-child(3) { animation-delay: 1.6s; }
@keyframes smoke { 0% { opacity: 0; transform: translateX(-50%) translateY(0) scaleX(1); } 30% { opacity: .7; } 100% { opacity: 0; transform: translateX(-50%) translateY(-80px) scaleX(2.4); } }
.burner-glow { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); width: 360px; height: 120px; background: radial-gradient(ellipse at center, rgba(255,180,80,.45) 0%, rgba(255,180,80,.12) 40%, transparent 70%); pointer-events: none; animation: burner-pulse 2.6s ease-in-out infinite; }
@keyframes burner-pulse { 0%, 100% { opacity: .6; transform: translateX(-50%) scale(1); } 50% { opacity: 1; transform: translateX(-50%) scale(1.1); } }
.burner-body { width: 320px; height: 90px; background: radial-gradient(circle at 50% 30%, #f5d76e 0%, #d4a017 30%, #b88811 60%, #7c5a1e 90%); border-radius: 50% 50% 35% 35% / 80% 80% 25% 25%; box-shadow: inset 0 -8px 18px rgba(0,0,0,.4), 0 8px 18px rgba(0,0,0,.5); margin-top: -10px; position: relative; display: flex; align-items: center; justify-content: center; z-index: 1; }
.burner-body::before, .burner-body::after { content: ""; position: absolute; bottom: -16px; width: 38px; height: 32px; background: linear-gradient(#7c5a1e, #5a3e12); border-radius: 6px 6px 50% 50%; }
.burner-body::before { left: 28px; }
.burner-body::after { right: 28px; }
.burner-label { color: #4d3818; font-weight: 700; font-size: 22px; letter-spacing: 12px; text-shadow: 0 1px 2px rgba(255,255,255,.3); font-family: "STKaiti", "KaiTi", "楷体", serif; }

/* 香炉 + 供品悬浮布局（无祭台桌子） */
.offer-stage-floating { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 16px 12px; position: relative; z-index: 2; }
/* 香炉在暗背景中居中悬浮（未上香时紧凑，上香后随内容自然撑高） */
.offer-stage-floating .incense-burner { width: 520px; min-height: 150px; height: auto; position: relative; z-index: 3; display: flex; align-items: flex-end; justify-content: center; }
.offer-stage-floating .burner-body { width: 260px; height: 100px; position: relative; display: flex; align-items: center; justify-content: center; z-index: 1; background: transparent; margin: -10px auto 0 auto; }
.offer-stage-floating .burner-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.offer-stage-floating .incense-shelf { position: absolute; bottom: 64%; left: 50%; transform: translateX(-50%); display: flex; gap: 26px; align-items: flex-end; justify-content: center; padding: 0 0 4px; height: 90px; z-index: 5; pointer-events: none; }
.offer-stage-floating .incense-stick { height: 90px; }
/* 长寿香：细长、顶端红色（与传统细香一致），点亮时有火焰 */
.offer-stage-floating .incense-stick-body { width: 4px; height: 74px; background: linear-gradient(180deg, #fce4e4 0%, #d4a85c 30%, #8c6e34 100%); box-shadow: 0 0 6px rgba(245,215,110,.35), 0 1px 2px rgba(0,0,0,.3); border: 1px solid rgba(180,90,60,.45); border-radius: 3px 3px 1px 1px; }
/* 香火焰 */
.offer-stage-floating .incense-tip { display: block !important; width: 12px; height: 22px; background: radial-gradient(ellipse at 50% 70%, #fff5b0 0%, #ffd060 25%, #ff7700 55%, #c01818 85%, transparent 100%); border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%; box-shadow: 0 0 22px #ffaa00, 0 0 40px rgba(255,160,0,.85), 0 0 70px rgba(255,90,0,.45); animation: flame-flicker 0.32s ease-in-out infinite alternate; position: relative; z-index: 4; }
/* 香烟动效保留 */
.offer-stage-floating .incense-smoke { width: 14px; height: 80px; background: linear-gradient(rgba(230,230,230,.75), rgba(230,230,230,0)); filter: blur(6px); }
.offer-stage-floating .burner-glow { width: 320px; height: 150px; top: 26px; left: 50%; transform: translateX(-50%); background: radial-gradient(ellipse at center, rgba(255,180,80,.6) 0%, rgba(255,180,80,.2) 40%, transparent 70%); }
.offer-stage-floating .burner-label { position: absolute; top: 72%; left: 50%; transform: translate(-50%, -50%); font-size: 20px; letter-spacing: 2px; color: #2a1a0a; z-index: 6; text-shadow: 0 1px 2px rgba(255,235,180,.55); font-family: "STKaiti", "KaiTi", "楷体", serif; font-weight: 700; white-space: nowrap; }
.offer-stage-floating .offering-table { margin-top: 6px; padding-top: 6px; width: 100%; position: relative; z-index: 3; border-top: 1px solid rgba(245,215,110,.18); }
/* 香炉两侧烛杯（蜡烛立在杯内，底部被杯壁包裹不外露） */
.offer-stage-floating .candle-stand { position: absolute; bottom: 24px; width: 44px; height: 52px; z-index: 2; pointer-events: none; }
.offer-stage-floating .candle-stand.left { right: 100%; margin-right: -22px; }
.offer-stage-floating .candle-stand.right { left: 100%; margin-left: -22px; }
.offer-stage-floating .candle-stand-base,
.offer-stage-floating .candle-stand-stem { display: none; }
.offer-stage-floating .candle-stand-cup { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 34px; height: 22px; background: radial-gradient(ellipse at 50% 30%, #c9a86c 0%, #8c6e34 45%, #5f4520 75%); border-radius: 50% 50% 35% 35% / 60% 60% 40% 40%; box-shadow: 0 2px 5px rgba(0,0,0,.5), inset 0 -3px 6px rgba(0,0,0,.35); z-index: 4; }
.offer-stage-floating .altar-candle { position: absolute; bottom: 8px; left: 50%; margin-left: -9px; width: 18px; height: 62px; display: flex; flex-direction: column; align-items: center; z-index: 3; animation: stick-flicker 3.6s ease-in-out infinite; animation-delay: .4s; }
.offer-stage-floating .altar-candle-body { width: 16px; height: 50px; background: linear-gradient(90deg, #9a0a0a 0%, #d62020 25%, #ff3a3a 50%, #d62020 75%, #9a0a0a 100%); border-radius: 3px 3px 1px 1px; box-shadow: 0 0 12px rgba(255,60,60,.5), inset 0 0 0 1px rgba(60,5,5,.5); }
.offer-stage-floating .altar-candle-tip { width: 14px; height: 18px; background: radial-gradient(ellipse at 50% 70%, #fff5b0 0%, #ffd060 25%, #ff7700 55%, #c01818 85%, transparent 100%); border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%; box-shadow: 0 0 18px #ff7700, 0 0 34px rgba(255,100,0,.85); animation: flame-flicker 0.32s ease-in-out infinite alternate; position: relative; z-index: 4; margin-bottom: -6px; }
.altar-candle-tip::before { content: ""; position: absolute; top: 3px; left: 50%; transform: translateX(-50%); width: 5px; height: 10px; background: radial-gradient(circle, #8ec5ff 0%, #4a90e2 60%, transparent 100%); border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%; opacity: .9; }

/* 长寿香与红蜡烛漂浮动效（无火纯悬浮已废，改为火焰抖动） */
.offer-stage-floating .incense-stick { animation: stick-flicker 3.2s ease-in-out infinite; }
.offer-stage-floating .incense-candle { animation: stick-flicker 3.6s ease-in-out infinite; animation-delay: .4s; }
@keyframes stick-flicker {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-2px) scaleY(1.005); }
}
/* 跪拜小人（点跪拜时出现在香炉下方） */
.kneel-figure { position: absolute; top: 150px; left: 50%; transform: translateX(-50%); width: 84px; height: 108px; z-index: 10; pointer-events: none; opacity: 0; filter: drop-shadow(0 0 6px rgba(240,207,122,.55)); }
.kneel-figure.show { opacity: 1; }
.kneel-figure svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,.6)); transform-origin: 50% 100%; }
.kneel-figure.kowtow-action svg { animation: kneel-bow 0.6s ease-in-out; }
/* 叩首：背对镜头面朝上方牌位，整身以脚为轴朝牌位（下方香炉/地）俯身低头，而非朝侧歪 */
@keyframes kneel-bow {
  0%   { transform: translateY(0) scaleY(1); }
  45%  { transform: translateY(9px) scaleY(0.86); }
  100% { transform: translateY(0) scaleY(1); }
}

/* 操作按钮与托盘（祭台内暗背景上要明亮） */
.offer-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
/* 跪拜朝向守卫：状态条 + 提示浮层 */
.orient-status { display: none; text-align: center; font-size: 13px; margin: 4px auto 2px; padding: 4px 12px; border-radius: 14px; background: rgba(0,0,0,.35); color: #f0d27a; border: 1px solid rgba(240,210,122,.3); }
.orient-status.ok { color: #9ff0a0; border-color: rgba(120,240,130,.5); }
.orient-status.warn { color: #ffcf6a; border-color: rgba(255,180,80,.5); }
.offer-btn.calibrate { background: #cfe3ff; border-color: #5a8fd0; color: #16335c; }
.offer-hint { position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-8px); max-width: 86%; padding: 10px 16px; border-radius: 12px; font-size: 14px; line-height: 1.4; text-align: center; z-index: 9999; opacity: 0; pointer-events: none; transition: all .25s ease; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.offer-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.offer-hint.warn { background: #5a2a10; color: #ffd9a0; border: 1px solid #b88811; }
.offer-hint.info { background: #16335c; color: #cfe3ff; border: 1px solid #5a8fd0; }
.offer-btn { padding: 8px 18px; border: 2px solid #b88811; background: #f9e8a8; color: #3d2b07; border-radius: 20px; cursor: pointer; font-size: 14px; font-family: inherit; font-weight: 600; transition: all .2s ease; }
.offer-btn:hover { background: #c7950c; color: #1a1002; }
.offer-trays { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
/* 供桌：酒茶香烟鸡肉祭品同一横排（不再分多列） */
.offering-table { display: flex; flex-direction: row; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; max-width: 100%; }
.offer-tray { display: flex; gap: 12px; font-size: 32px; padding: 10px 16px; background: rgba(0,0,0,.35); border: 1px solid #b88811; border-radius: 12px; min-height: 56px; backdrop-filter: blur(4px); align-items: center; }
.cup-row { display: flex; gap: 14px; align-items: center; }
.wine-cup, .tea-cup { animation: pop 0.4s ease; }
.wine-pot { margin-left: 8px; opacity: .9; animation: pop 0.4s ease; }
.cig-stem { animation: pop 0.4s ease; font-size: 30px; }
.offer-big { font-size: 48px; animation: pop 0.4s ease; }
.food-tray { padding: 10px 14px; }
.food-row { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.food-dish { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 12px; background: rgba(0,0,0,.3); border: 1px solid #d4a017; border-radius: 10px; min-width: 64px; }
.food-dish .dish-emoji { font-size: 30px; line-height: 1.2; }
.food-dish .dish-label { font-size: 11px; color: #f5d76e; letter-spacing: 1px; }
.fruit-tray { display: flex; gap: 18px; font-size: 44px; padding: 16px 24px; background: rgba(0,0,0,.3); border: 2px solid #b88811; border-radius: 14px; min-height: 30px; backdrop-filter: blur(4px); }


/* ===== 设置 ===== */
.settings-wrap { flex: 1; overflow: auto; padding: 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-content: start; }
.setting-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.setting-card h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.setting-card .muted { font-size: 13px; margin-bottom: 12px; }
.setting-card .form-row { margin-bottom: 10px; }
.changelog { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.8; color: #3a322f; }

/* ===== 用户管理（超级用户） ===== */
.admin-user-list { margin-top: 8px; }
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line, #e6ddd6); border-radius: 8px; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
.admin-table th, .admin-table td { border: 1px solid var(--line, #e6ddd6); padding: 8px 10px; text-align: left; white-space: nowrap; }
.admin-table th { background: var(--accent, #a0301f); color: #fff; font-weight: 600; }
.admin-table tr:nth-child(even) td { background: #faf6f2; }
.admin-reset { background: var(--accent, #a0301f); color: #fff; border: none; }
@media (max-width: 640px) {
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 6px 7px; }
  .admin-table .small { padding: 4px 7px; font-size: 11px; }
  .admin-table select { font-size: 12px; padding: 3px 4px; }
}

/* ===== 密码锁屏 ===== */
.lock-screen { position: fixed; inset: 0; background: #2a1f1d; display: flex; align-items: center; justify-content: center; z-index: 500; }
.lock-box { background: #fff; border-radius: 14px; padding: 30px 34px; width: 320px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.lock-logo { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: bold; margin: 0 auto 12px; }
.lock-box h2 { margin: 0 0 6px; font-size: 20px; }
.lock-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; margin-top: 8px; }
.lock-box .primary { padding: 10px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px; cursor: pointer; font-size: 15px; }
.lock-err { color: var(--accent); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ===== 灯箱 ===== */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.82); display: none; align-items: center; justify-content: center; z-index: 400; }
.lightbox-close { position: absolute; top: 18px; right: 26px; color: #fff; font-size: 34px; cursor: pointer; line-height: 1; }
.lightbox-content img, .lightbox-content video { border-radius: 6px; }

/* 手抄本图片查看器：缩放 + 平移 */
.ms-img-viewer { display: flex; flex-direction: column; align-items: center; max-width: 94vw; }
.ms-img-toolbar { display: flex; align-items: center; gap: 8px; color: #fff; margin-bottom: 10px; }
.ms-zoom-btn { width: 34px; height: 34px; border: none; border-radius: 8px; background: rgba(255,255,255,0.15); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.ms-zoom-btn:hover { background: rgba(255,255,255,0.32); }
.ms-zoom-reset { width: auto; padding: 0 12px; font-size: 14px; }
.ms-zoom-val { min-width: 54px; text-align: center; font-size: 14px; }
.ms-zoom-hint { font-size: 12px; opacity: 0.7; margin-left: 6px; }
.ms-img-stage { position: relative; width: 90vw; max-width: 1000px; height: 76vh; overflow: hidden; border-radius: 8px; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; touch-action: none; }
.ms-img { transform-origin: center center; cursor: grab; max-width: 100%; max-height: 100%; user-select: none; -webkit-user-drag: none; position: relative; }
.ms-img-el { display: block; max-width: 100%; max-height: 100%; -webkit-user-drag: none; }

/* ===== 相片 / 媒体辅助 ===== */
.person-photo-row { display: flex; align-items: center; gap: 14px; }
.photo-preview { width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #efe7db; display: grid; place-items: center; flex: 0 0 auto; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-ph { color: #8a6a4a; font-size: 32px; font-weight: 700; }
.media-preview { margin-bottom: 8px; min-height: 30px; }
.media-preview img, .media-preview video { border-radius: 6px; border: 1px solid var(--line); }
.detail-photo { width: 96px; height: 96px; border-radius: 8px; overflow: hidden; margin-bottom: 10px; border: 1px solid var(--line); background: #efe7db; display: grid; place-items: center; }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-photo.empty { color: #8a6a4a; font-size: 42px; font-weight: 700; background: linear-gradient(135deg, #f5e9d8, #e8d6c0); border-color: #d8c4a0; }
.badge-notable { display: inline-block; font-size: 11px; background: #e8b84b; color: #5a3d00; padding: 1px 8px; border-radius: 10px; vertical-align: middle; margin-left: 6px; font-weight: 600; }
.checkbox-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.checkbox-row input { width: auto; }

/* ===== 身份证 ===== */
.idcard-preview { margin: 8px 0; min-height: 28px; }
.idcard-preview img { max-height: 150px; max-width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.idcard-fields { display: flex; flex-direction: column; gap: 8px; }
.idcard-row { display: flex; align-items: center; gap: 8px; }
.idcard-row > label { flex: 0 0 96px; font-size: 13px; color: #6b5f58; }
.idcard-row > input, .idcard-row > select { flex: 1; }
.idcard-2col { display: flex; gap: 12px; }
.idcard-2col > div { flex: 1; }
.idcard-row .hint { flex: 0 0 auto; font-size: 12px; color: var(--accent); }
.idcard-derived { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 2px 104px; }
.tag { display: inline-block; font-size: 12px; background: #f0e6d6; color: #7a5a2e; border: 1px solid #e0d0b4; padding: 2px 9px; border-radius: 10px; }
.detail-idcard { margin-top: 4px; }
.detail-idphoto { width: 160px; max-width: 100%; border-radius: 6px; overflow: hidden; margin-bottom: 8px; border: 1px solid var(--line); background: #efe7db; }
.detail-idphoto img { width: 100%; display: block; }

/* ===== 学习视频 / 文档页 ===== */
#studyView { flex-direction: column; padding: 18px 20px; overflow: hidden; }
#studyView .sec-header { flex: none; margin-bottom: 12px; }
.study-wrap { display: flex; flex: 1; gap: 16px; min-height: 0; overflow: hidden; }
.study-tree { width: 260px; flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; }
.study-tree-item { margin: 2px 0; }
.study-tree-btn { width: 100%; text-align: left; padding: 8px 10px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-tree-btn:hover { background: rgba(139,46,46,.08); }
.study-tree-btn.active { background: var(--accent); color: #fff; }
.study-tree-btn:disabled { opacity: .5; cursor: default; }
.study-count { float: right; font-size: 12px; background: rgba(139,46,46,.12); color: var(--accent); padding: 1px 6px; border-radius: 10px; }
.study-tree-btn.active .study-count { background: rgba(255,255,255,.25); color: #fff; }
.study-files { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow: auto; }
.study-breadcrumb { font-size: 15px; font-weight: 600; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.study-breadcrumb span { font-weight: normal; font-size: 13px; margin-left: 8px; }
.study-file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.study-file-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; transition: transform .12s, box-shadow .12s; text-align: center; }
.study-file-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.study-file-card.disabled { opacity: .6; cursor: not-allowed; }
.study-file-thumb { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: linear-gradient(180deg, var(--accent-light), var(--accent)); color: #fff; display: grid; place-items: center; font-size: 22px; }
.study-file-info { text-align: left; }
.study-file-name { font-size: 13px; line-height: 1.4; max-height: 2.8em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.study-file-size { font-size: 12px; margin-top: 4px; }
.study-player { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.study-player-mask { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.study-player-body { position: relative; width: min(92vw, 1100px); max-height: 90vh; background: #000; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.study-player-titlebar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #1a1a1a; color: #fff; }
.study-player-titlebar span { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90%; }
.study-close { background: transparent; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 4px 8px; }
#studyVideo { width: 100%; max-height: 78vh; display: block; background: #000; }
.study-text { flex: 1; margin: 0; padding: 18px 22px; background: #fff; color: #222; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 78vh; }
.study-encoding-bar { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: #1a1a1a; color: #ccc; font-size: 13px; border-bottom: 1px solid #333; }
.study-encoding-bar span { margin-right: 4px; }
.study-encoding-bar button { background: #2a2a2a; border: 1px solid #444; color: #ddd; border-radius: 4px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.study-encoding-bar button.active { background: #c9a227; border-color: #c9a227; color: #222; font-weight: 600; }
.study-encoding-bar button:hover { background: #3a3a3a; }
.study-tauri-hint { color: #fff; background: rgba(0,0,0,.6); margin: 0; padding: 10px 14px; font-size: 13px; }

/* ===== 泡酒（岭南安全泡酒药材百科） ===== */
.paojiu-view .sec-header p.muted { font-size: 13px; }
.paojiu-inner { max-width: 1000px; margin: 0 auto; padding: 18px 22px 40px; }
.paojiu-hero { margin: 0 0 16px; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.paojiu-hero img { width: 100%; display: block; max-height: 320px; object-fit: cover; object-position: center; }
.paojiu-disclaimer { background: #fff7e6; border: 1px solid #ffd591; color: #874d00; border-radius: 10px; padding: 12px 16px; font-size: 13px; line-height: 1.7; margin-bottom: 18px; }
.paojiu-disclaimer b { color: #ad4e00; }
.paojiu-block { margin-bottom: 22px; }
.paojiu-block h3 { font-size: 17px; color: var(--accent, #8a5a18); border-left: 4px solid var(--accent, #c9a227); padding-left: 10px; margin: 0 0 12px; }
.paojiu-rules { margin: 0; padding-left: 22px; line-height: 1.9; font-size: 14px; }
.paojiu-rules li { margin-bottom: 4px; }
.paojiu-note { background: #eef5ff; border: 1px solid #b8d4ff; color: #1d4e89; border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.7; }
.paojiu-warn { background: #fff1f0; border: 1px solid #ffccc7; color: #a8071a; border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.7; margin-top: 10px; }
.paojiu-danger { background: #fff5f5; border: 1px solid #ffa39e; border-radius: 12px; padding: 14px 18px; }
.paojiu-danger h3 { color: #cf1322; border-left-color: #cf1322; }
.paojiu-compare { list-style: none; margin: 8px 0; padding: 0; }
.paojiu-compare li { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.paojiu-compare li.safe { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
.paojiu-compare li.danger { background: #fff1f0; border: 1px solid #ffa39e; color: #a8071a; }
.paojiu-herb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.paojiu-herb-card { background: var(--panel, #fff); border: 1px solid var(--line, #e6e0d2); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.paojiu-herb-card img { width: 100%; height: 180px; object-fit: contain; background: #faf7f0; padding: 10px; }
.paojiu-herb-body { padding: 12px 16px 16px; }
.paojiu-herb-body h4 { margin: 0 0 8px; font-size: 15px; color: #333; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.paojiu-herb-body .alias { font-size: 12px; font-weight: 400; color: #999; }
.paojiu-herb-body .tag { font-size: 11px; background: #cf1322; color: #fff; border-radius: 4px; padding: 1px 6px; font-weight: 400; }
.paojiu-herb-body p { margin: 0 0 6px; font-size: 13px; line-height: 1.7; color: #444; }
.paojiu-herb-card.mini { flex-direction: column; }
.paojiu-animal-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.paojiu-animal-card { display: flex; gap: 10px; align-items: flex-start; background: var(--panel, #fff); border: 1px solid var(--line, #e6e0d2); border-radius: 10px; padding: 14px; font-size: 13px; line-height: 1.7; color: #444; }
.paojiu-animal-card .ico { font-size: 24px; line-height: 1; }
.paojiu-recipe { background: #fbf7ef; border: 1px solid #ecd9b0; border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; }
.paojiu-recipe h4 { margin: 0 0 8px; font-size: 14px; color: #8a5a18; }
.paojiu-recipe p { margin: 0 0 5px; font-size: 13px; line-height: 1.7; color: #444; }
.paojiu-footer { text-align: center; font-size: 12px; margin-top: 8px; }

@media (max-width: 820px) {
  .study-wrap { flex-direction: column; }
  .study-tree { width: 100%; max-height: 38vh; }
  .study-files { min-height: 38vh; }
  .study-file-grid { grid-template-columns: 1fr 1fr; }
  #studyVideo { max-height: 56vh; }
  .study-text { max-height: 56vh; }
  .paojiu-herb-grid { grid-template-columns: 1fr; }
  .paojiu-animal-grid { grid-template-columns: 1fr; }
  .paojiu-hero img { max-height: 180px; }
}

/* ===== 移动端适配（手机 / 平板竖屏） ===== */
@media (max-width: 820px) {
  /* 顶部导航：横向滚动，避免窄屏溢出 */
  .topnav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .nav-logo, .nav-btn { flex: 0 0 auto; }
  .nav-btn { white-space: nowrap; }
  .nav-title { display: none; }
  .brand-title { font-size: 15px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }

  /* 触摸目标加高，便于手指点按 */
  .nav-btn, .cal-nav-btn, .cal-today, .cal-select, .offer-btn, .seg-btn,
  .modal .primary, .lock-box .primary, .ocr-actions .small { min-height: 40px; }

  /* 锁屏框与模态在手机上更贴近全屏 */
  .lock-box { width: auto; max-width: 92vw; }
  .modal-body { width: auto; max-width: 96vw; }

  /* 日历格子紧凑化 */
  .cal-cell { min-height: 56px; padding: 4px 5px; }
  .cal-cell .solar { font-size: 14px; }
  .cal-cell .lunar { font-size: 10px; }
  .cal-title { min-width: auto; font-size: 16px; }

  /* 各类工具栏折行 */
  .cal-header, .offer-toolbar, .sec-header, .gallery-tools { flex-wrap: wrap; }
  .offer-toolbar select, .cal-select, .cal-today { min-width: 120px; }

  /* 家谱树容器允许横向滚动 / 双指缩放 */
  .canvas-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }

  /* 身份证 / 表单：标签与输入纵向排列 */
  .idcard-row { flex-direction: column; align-items: stretch; gap: 3px; }
  .idcard-row > label { flex: none; }
  .idcard-2col { flex-direction: column; }

  /* 设置卡片单列 */
  .settings-wrap { grid-template-columns: 1fr; }

  /* 文本类视图左右留白收紧 */
  .doc-list, .timeline, .prose { padding-left: 16px; padding-right: 16px; }

  /* 祭祀页手机紧凑（大牌位+香炉+按钮） */
  .offer-stage-center { gap: 8px; width: 100%; }
  .tablet-selector-bar { flex-wrap: wrap; justify-content: center; gap: 4px 8px; padding: 5px 10px; font-size: 12px; }
  .tablet-selector-bar select { min-width: 120px; font-size: 12px; }
  .tablet-selector-hint { display: none; }
  .ancestral-tablet-large { width: 190px; padding: 36px 14px 10px; }
  .at-name { font-size: 24px; }
  .offer-stage-floating { width: 100%; }
  .offer-stage-floating .incense-burner { width: 100%; max-width: 320px; min-height: 160px; }
  .offer-stage-floating .burner-body { width: 240px; height: 100px; }
  .offer-stage-floating .burner-glow { width: 280px; height: 140px; }
  .offer-stage-floating .burner-label { font-size: 18px; letter-spacing: 8px; }
  .offer-stage-floating .incense-shelf { height: 80px; gap: 16px; }
  .offer-stage-floating .incense-stick { height: 80px; }
  .offer-stage-floating .incense-stick-body { height: 64px; }
  .offer-stage-floating .candle-stand { width: 34px; height: 40px; bottom: 22px; }
  .offer-stage-floating .candle-stand.left { margin-right: -16px; }
  .offer-stage-floating .candle-stand.right { margin-left: -16px; }
  .offer-stage-floating .candle-stand-base,
  .offer-stage-floating .candle-stand-stem { display: none; }
  .offer-stage-floating .candle-stand-cup { width: 26px; height: 16px; bottom: 0; }
  .offer-stage-floating .altar-candle { width: 14px; height: 48px; bottom: 6px; margin-left: -7px; }
  .offer-stage-floating .altar-candle-body { height: 36px; width: 12px; }
  .offer-stage-floating .altar-candle-tip { width: 10px; height: 14px; margin-bottom: -2px; }
  .offer-actions { gap: 8px; }
  .offer-btn { padding: 10px 18px; font-size: 14px; }
}

/* ===================== 新增模块样式 ===================== */
.form-section-title { font-weight: 700; color: var(--accent); margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px dashed var(--line); }
.chk-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-top: 6px; color: var(--text); font-weight: 400; }
.album-grid, .video-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.album-thumb, .video-thumb { width: 84px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #efe7db; cursor: pointer; text-align: center; }
.album-thumb img, .video-thumb { width: 100%; height: 64px; object-fit: cover; display: block; }
.video-thumb { display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--accent); }
.album-thumb em, .video-thumb em { display: block; font-size: 10px; color: var(--muted); padding: 2px; font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 牌位 / 祭台 */
.altar-music-bar { display: flex; align-items: center; gap: 8px; padding: 5px 16px; background: #f0e7d8; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.altar-music-bar select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 12px; }
.altar-music-info { padding: 4px 16px; background: #faf6f0; border-bottom: 1px solid var(--line); font-size: 11px; }
.altar-section { padding: 16px; }
.altar-tablets { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; justify-content: center; }
.altar-generation { width: 100%; margin: 14px 0 4px; padding: 6px 12px; border-bottom: 2px solid #b9893f; color: #7c5a1e; font-weight: 700; font-size: 15px; }
.altar-generation:first-child { margin-top: 0; }
.altar-all { display: none; }
.altar-toggle { font-size: 13px; color: var(--accent); cursor: pointer; text-align: right; margin-top: 6px; user-select: none; }
.tablet-item { text-align: center; cursor: pointer; transition: transform .15s ease; width: 130px; }
.tablet-item:hover { transform: translateY(-2px); }
/* 中式牌位（参考淘宝中式神龛牌位）：红底金边祥云 */
.tablet-frame { width: 130px; height: 220px; padding: 24px 8px 12px; background: linear-gradient(135deg, #a82424 0%, #8a1c1c 50%, #6e1414 100%); border: 3px solid #0a0604; outline: 1px solid #d4a017; outline-offset: -2px; box-shadow: inset 0 0 0 2px #d4a017, 0 4px 10px rgba(0,0,0,.4); border-radius: 4px; color: #f5d76e; font-family: "STKaiti", "KaiTi", "楷体", serif; position: relative; user-select: none; }
.tablet-frame::before { content: ""; position: absolute; top: 4px; left: 0; right: 0; height: 18px; background: radial-gradient(ellipse at 50% 0%, rgba(245,215,110,.4), transparent 70%); pointer-events: none; }
.tablet-frame::after { content: "☁☁"; position: absolute; top: -2px; left: 0; right: 0; text-align: center; color: #d4a017; font-size: 12px; letter-spacing: 6px; opacity: .8; text-shadow: 0 0 4px rgba(245,215,110,.5); }
.tablet-top { font-size: 14px; color: #d4a017; opacity: .9; letter-spacing: 2px; }
.tablet-name { font-size: 20px; font-weight: 700; color: #f5d76e; letter-spacing: 3px; margin-top: 6px; text-shadow: 0 0 6px rgba(245,215,110,.4), 0 1px 2px rgba(0,0,0,.3); word-break: break-all; }
.tablet-alias { font-size: 11px; color: #d4a017; opacity: .8; margin-top: 2px; letter-spacing: 1px; }
.tablet-photo { width: 100%; max-height: 70px; object-fit: cover; border-radius: 3px; margin-top: 6px; border: 1px solid #d4a017; }
.tablet-meta { font-size: 11px; color: var(--muted); margin: 6px 0; }
.tablet-btns { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }

/* 中式大图牌位 modal：红底金边祥云 */
.cnt-tablet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.cnt-tablet-mask.open { display: flex; }
.cnt-tablet { position: relative; width: 360px; max-width: 100%; padding: 30px 22px; background: linear-gradient(135deg, #a82424 0%, #8a1c1c 50%, #6e1414 100%); border: 6px solid; border-color: #d4a017 #b88811 #b88811 #d4a017; border-radius: 6px 6px 0 0; box-shadow: 0 0 0 3px #7c5a1e, 0 12px 40px rgba(0,0,0,.6); color: #f5d76e; font-family: "STKaiti", "KaiTi", "楷体", "SimSun", serif; text-align: center; user-select: none; }
.cnt-tablet::before { content: "☁☁☁"; position: absolute; top: 8px; left: 0; right: 0; text-align: center; color: #f5d76e; font-size: 22px; letter-spacing: 8px; opacity: .8; text-shadow: 0 0 4px rgba(245,215,110,.4); }
.cnt-tablet-title { margin-top: 30px; font-size: 16px; font-weight: 600; color: #f5d76e; letter-spacing: 6px; }
.cnt-tablet-name { font-size: 38px; font-weight: 700; color: #f5d76e; letter-spacing: 12px; margin: 24px 0; line-height: 1.2; text-shadow: 0 0 8px rgba(245,215,110,.5), 0 2px 3px rgba(0,0,0,.3); }
.cnt-tablet-year { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; font-size: 14px; color: #f5d76e; letter-spacing: 3px; opacity: .85; }
.cnt-tablet-by { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; font-size: 14px; color: #f5d76e; letter-spacing: 3px; opacity: .85; }
.cnt-tablet-photo { width: 110px; height: 130px; object-fit: cover; border: 3px solid #f5d76e; margin: 10px auto 0; display: block; border-radius: 4px; box-shadow: 0 0 12px rgba(245,215,110,.3); }
.cnt-tablet-close { position: absolute; top: 10px; right: 14px; background: transparent; border: 1px solid #f5d76e; color: #f5d76e; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 24px; }
.cnt-tablet-close:hover { background: #f5d76e; color: #6e1414; }
.cnt-tablet-foot { margin-top: 16px; font-size: 12px; color: #d4a017; opacity: .7; letter-spacing: 2px; }
.cnt-tablet-base { width: 90%; height: 14px; background: linear-gradient(#2a1c08, #4d3818); margin: 0 auto; border-radius: 2px 2px 6px 6px; box-shadow: 0 4px 8px rgba(0,0,0,.4); }

/* 详情牌位卡 */
.tablet-field .tablet-card { border: 1px solid #b9893f; background: #f7efdf; border-radius: 10px; padding: 12px; }
.tablet-card .tablet-name { color: #7c5a1e; font-weight: 700; }
.tablet-card .tablet-sub { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.tablet-card .tablet-photo { width: 64px; border-radius: 6px; margin-bottom: 8px; }
.btn-memorial { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; }

/* 关系视图 */
.rel-header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.rel-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rel-tree { padding: 14px 16px; }
.rel-gen { margin-bottom: 10px; }
.rel-gen-title { font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.rel-gen-list { display: flex; flex-wrap: wrap; gap: 6px; }
.rel-chip { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.rel-chip.dead { opacity: .65; background: #f0e7d8; }
.rel-calc { padding: 14px 16px; border-top: 1px solid var(--line); }
.rel-calc select { margin-right: 8px; }
.rel-result { margin-top: 10px; line-height: 1.7; }

/* 忌日提醒 */
.rem-header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.rem-list { padding: 14px 16px; display: grid; gap: 12px; }
.rem-card { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; }
.rem-name { font-weight: 700; font-size: 16px; }
.rem-date { color: var(--muted); font-size: 13px; margin: 4px 0; }
.rem-notify { font-size: 13px; }
.tag-notify { background: #f6d9a8; color: #7c5a1e; border-radius: 10px; padding: 1px 8px; font-size: 12px; margin-right: 6px; }

/* 祠堂 */
.temples-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.temple-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.temple-photo img { width: 100%; height: 160px; object-fit: cover; }
.temple-body { padding: 12px 14px; flex: 1; }
.temple-body h3 { margin: 0 0 4px; }
.temple-hist { font-size: 13px; color: #5b4f47; line-height: 1.6; margin: 8px 0; white-space: pre-wrap; }

/* 杂录 */
.doc-list { padding: 16px; display: grid; gap: 14px; }
.doc-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.doc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tag { background: #f0e7d8; color: var(--accent); border-radius: 10px; padding: 1px 8px; font-size: 12px; }

/* 通讯录 */
.contacts-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.contact-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.contact-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.contact-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.ct-call, .ct-wx { text-decoration: none; }
.ct-row { display: flex; gap: 8px; font-size: 13px; }
.ct-row span { color: var(--muted); min-width: 36px; }

/* 账号 / 同步 */
.accounts-wrap { background: #faf6ee; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.login-ext { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.wechat-cfg { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.ext-sep { border: none; border-top: 1px dashed var(--line); margin: 10px 0; }
.ext-btn { border: 1px solid var(--accent); background: #fff; color: var(--accent); }

/* AI 助手 */
.ai-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 82%; padding: 9px 13px; border-radius: 12px; line-height: 1.65; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.ai-msg.me { align-self: flex-end; background: var(--accent); color: #fff; }
.ai-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.ai-msg.tool { align-self: flex-start; background: #eef3ff; border: 1px dashed #9bb; font-size: 12px; max-width: 92%; }
.ai-settings { padding: 12px 16px; background: #faf6ee; border-radius: 10px; margin: 0 12px 8px; }
.accounts-wrap { padding: 6px 0; }
.login-ext { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ext-btn { border: 1px dashed var(--line); }
.sync-note { margin-top: 12px; background: #f7f2e8; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #5b4f47; }
.sync-note ul { margin: 6px 0 0; padding-left: 18px; }
.sync-note li { margin: 4px 0; }

/* ===================== LOGO ===================== */
.nav-logo { width: 30px; height: 30px; border-radius: 7px; flex: none; display: block; object-fit: contain; }
.logo-inline { width: 32px; height: 32px; border-radius: 8px; flex: none; display: block; object-fit: contain; }

/* ===================== 聊天（本地留言板） ===================== */
#chatView { flex-direction: column; height: 100%; }
#chatView .sec-header { flex: none; }
.chat-list { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #faf6ee; }
.chat-msg { max-width: 76%; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.chat-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-color: var(--accent); }
.chat-meta { font-size: 11px; margin-bottom: 3px; opacity: .85; display: flex; gap: 8px; }
.chat-text { white-space: pre-wrap; line-height: 1.5; word-break: break-word; }
.chat-input-bar { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.chat-input-bar input[type=text] { flex: 1; min-width: 0; }

/* ===================== 免责声明 ===================== */
.disclaim { background: #fff4e6; border: 1px solid #f0c98a; color: #8a5a00; border-radius: 8px; padding: 8px 12px; font-size: 12.5px; margin: 10px 14px; }




/* ===== 打赏支持 ===== */
.donate-row { display: flex; gap: 16px; flex-wrap: nowrap; justify-content: center; align-items: flex-start; margin-top: 10px; }
.donate-col { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.donate-label { font-size: 13px; color: var(--muted); }
.donate-qr { width: 132px; height: 132px; border: 1px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fff; }
.donate-qr img { width: 100%; height: 100%; object-fit: contain; }

/* ===== 意见反馈 ===== */
.fb-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.fb-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.fb-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.fb-contact { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fb-content { font-size: 13px; line-height: 1.7; margin-top: 6px; white-space: pre-wrap; }

/* ===== AI 注册引导卡 ===== */
.ai-guide { margin-top: 10px; padding: 12px 14px; background: #f8f4ed; border: 1px solid #e8d9b8; border-radius: 8px; }
.ai-guide-title { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.ai-guide-body { font-size: 12.5px; line-height: 1.7; color: #3a322f; }
.ai-guide-body code { background: #efe7d5; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.ai-guide-body b { color: var(--accent); }
.ai-guide-card:empty { display: none; }
/* ===== 祭祀活动（按年份） ===== */
.worship-events-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; padding: 14px 20px; }
.worship-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.worship-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 6px; padding: 8px 10px 0; }
.worship-thumb { position: relative; width: 100%; aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #efe7db; cursor: pointer; }
.worship-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.worship-thumb:hover img { transform: scale(1.06); }
.worship-thumb em { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; color: #fff; background: rgba(0,0,0,.5); padding: 2px 3px; font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worship-thumb.video { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #3a322f, #5a4d44); }
.worship-thumb.video .play-ico { font-size: 22px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.worship-empty { padding: 10px 12px; font-size: 12px; }
.worship-body { padding: 10px 12px; }
.worship-body h4 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
.worship-body p { margin: 4px 0; font-size: 12px; line-height: 1.6; color: #3a322f; }
.worship-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.worship-tools .we-up { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); background: #fff; border-radius: 16px; font-size: 12px; cursor: pointer; }
/* ===== 历史（中国朝代/近代/共和国）===== */
.history-tabs { display: flex; gap: 8px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.history-tab { padding: 6px 14px; border: 1px solid var(--line); background: #fff; border-radius: 18px; cursor: pointer; font-size: 13px; }
.history-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.history-pane { padding: 14px 18px; }
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.history-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; gap: 12px; }
.history-year { width: 64px; flex: none; font-size: 18px; font-weight: 700; color: var(--accent); text-align: center; padding-top: 6px; border-right: 1px solid var(--line); padding-right: 10px; }
.history-body h4 { margin: 0 0 6px; font-size: 14px; }
.history-body p { margin: 4px 0; font-size: 12px; line-height: 1.7; }
.history-timeline { display: flex; flex-direction: column; gap: 12px; max-width: 760px; margin: 0 auto; }
.history-tl-item { display: flex; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); }
.history-tl-year { width: 90px; flex: none; font-weight: 700; color: var(--accent); padding-top: 4px; }
.history-tl-body h4 { margin: 0 0 4px; font-size: 14px; }
.history-tl-body p { margin: 0; font-size: 12.5px; line-height: 1.7; color: #3a322f; }

/* ===== 艾灸养生 ===== */
.moxa-wrap { padding: 18px 20px; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.moxa-wrap .card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); text-align: left; align-items: flex-start; }
.moxa-wrap h3 { margin: 0 0 10px; font-size: 16px; color: var(--accent); }
.moxa-wrap p, .moxa-wrap li { font-size: 13.5px; line-height: 1.8; color: #3a322f; margin: 6px 0; }
.moxa-wrap ul { padding-left: 18px; margin: 0; }
.moxa-wrap li b { color: var(--accent); }
.moxa-svg-wrap { display: flex; justify-content: center; padding: 8px 0; }
.moxa-body { width: 260px; max-width: 100%; height: auto; }
.moxa-legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 6px; font-size: 12px; }
.moxa-legend span { display: inline-flex; align-items: center; gap: 5px; }
.moxa-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.moxa-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
.moxa-table th, .moxa-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.moxa-table th { background: var(--panel); color: var(--accent); }
.moxa-table tr:nth-child(even) { background: #faf8f4; }

/* ===== 民俗资料视图（红白喜事 / 碑文对联 / 亲戚称谓） ===== */
.folk-doc { padding: 18px 20px; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.folk-doc .card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); text-align: left; align-items: flex-start; }
.folk-doc h3 { margin: 0 0 10px; font-size: 16px; color: var(--accent); }
.folk-doc p, .folk-doc li { font-size: 13.5px; line-height: 1.9; color: #3a322f; margin: 6px 0; }
.folk-doc .card b { color: var(--accent); }
.folk-steps { padding-left: 22px; margin: 0; }
.folk-steps li { margin: 8px 0; }
.folk-steps li b { color: var(--accent); }

/* ===== 手机版补充适配（窄屏 ≤820px，叠加于上方媒体查询，不影响桌面） ===== */
@media (max-width: 820px) {
  /* 整体允许滚动（移动端无桌面固定视口概念，避免内容被裁切） */
  html, body { height: auto; min-height: 100dvh; overflow: auto; }
  #app { height: auto; min-height: 100dvh; }

  /* 工具栏换行：品牌 + 分支选择 + 操作按钮一行，搜索框整行置底 */
  .toolbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .brand { min-width: 0; }
  .search-box { flex: 1 1 100%; max-width: none; order: 5; }
  .branch-select { flex: 1 1 auto; }
  .actions { width: 100%; }
  .actions button { flex: 1 1 auto; }

  /* 主区域三栏（人列表 / 画布 / 详情）由横排改为上下堆叠 */
  .main { flex-direction: column; overflow: auto; }
  .panel-left, .panel-right { width: 100%; max-height: 36vh; border-right: none; border-bottom: 1px solid var(--line); }
  .panel-right { border-left: none; }
  .canvas-wrap { min-height: 54vh; flex: none; }
  .detail-panel { width: 100%; }

  /* 移动端下拉菜单：改成醒目的白色卡片浮层 + 遮罩，彻底解决「看不见/误触」问题 */
  .nav-dropdown { min-width: 0; }
  .nav-group.open .nav-dropdown {
    position: fixed; top: 52px; left: 0; right: 0;
    display: flex; flex-direction: column;
    background: #fffbf5 !important; color: #3e2723 !important;
    border: none; border-radius: 0 0 16px 16px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.45);
    opacity: 1 !important; visibility: visible !important;
    padding: 8px 16px 16px;
    z-index: 101;
    max-height: 70vh; overflow: auto;
  }
  .nav-group.open .nav-dropdown::before {
    content: '请选择'; display: block; font-size: 12px; color: #8d6e63;
    padding: 6px 4px 8px; margin-bottom: 4px; border-bottom: 1px solid #efe6d8;
    letter-spacing: 1px;
  }
  .nav-group.open .nav-dropdown .nav-btn {
    background: transparent; color: #3e2723 !important;
    border-bottom: 1px solid #f0e8dc;
    padding: 14px 12px; font-size: 16px; text-align: center;
  }
  .nav-group.open .nav-dropdown .nav-btn:last-child { border-bottom: none; }
  .nav-group.open .nav-dropdown .nav-btn:active { background: #f3e9da; }

  /* 表单控件触控友好 + 防止 iOS 输入框自动放大 */
  input, select, textarea { font-size: 16px; min-height: 40px; max-width: 100%; box-sizing: border-box; }
  .modal-body input, .modal-body select, .modal-body textarea { width: 100%; }
  .modal-body .form-actions, .modal-body form > .actions { padding: 14px; }

  /* 表格横向滚动 */
  .temple-merits-table { overflow-x: auto; }

  /* 各种网格在手机上单列 */
  [class*="-grid"] { grid-template-columns: 1fr !important; }
  .history-list { grid-template-columns: 1fr; }
  .album-grid, .video-grid { gap: 6px; }
  .album-thumb, .video-thumb { width: calc((100% - 12px) / 3); }

  /* 人物大详情页紧凑化 */
  .person-detail-page { padding: 20px 16px; }

  /* 祭祀 / 牌位区域在窄屏不溢出 */
  .offering-table { gap: 8px; }
  .food-dish { min-width: 56px; padding: 6px 8px; }
}

/* ===== 首页 landing（公开：功能介绍 + 操作方法） ===== */
.landing { display: block; overflow: auto; padding: 0 0 40px; background: linear-gradient(180deg, #fbf4ec 0%, #f6ede1 100%); }
.landing-hero { text-align: center; padding: 56px 20px 36px; background: radial-gradient(ellipse at 50% 0%, #fff7ec 0%, #fbf4ec 60%, transparent 100%); }
.landing-logo { width: 72px; height: 72px; border-radius: 16px; box-shadow: 0 6px 18px rgba(124,90,30,.18); }
.landing-hero h1 { margin: 16px 0 8px; font-size: 30px; color: #5a3e12; letter-spacing: 2px; }
.landing-sub { margin: 0 auto; max-width: 560px; color: #8a7257; font-size: 15px; line-height: 1.7; }
.landing-cta { margin-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
@media (min-width: 520px) { .landing-cta { flex-direction: row; flex-wrap: wrap; justify-content: center; } .landing-cta .btn-primary, .landing-cta .btn-ghost, .landing-cta .landing-help-link { margin: 0 4px; } }
.landing-cta .btn-primary { display: inline-block; width: auto; padding: 12px 34px; border: none; border-radius: 26px; background: linear-gradient(180deg, #b88811, #8c6e34); color: #fff; font-size: 16px; cursor: pointer; box-shadow: 0 6px 16px rgba(140,110,52,.3); }
.landing-cta .btn-primary:hover { filter: brightness(1.05); }
.landing-cta .landing-help-link { display: inline-block; width: auto; padding: 10px 20px; border: 1.5px solid #b88811; border-radius: 26px; background: transparent; color: #8c6e34; font-size: 14px; cursor: pointer; transition: all .15s; }
.landing-cta .landing-help-link:hover { background: rgba(184,136,17,.08); }
.landing-cta .btn-ghost { padding: 10px 28px; border: 1.5px solid #b88811; border-radius: 26px; background: transparent; color: #8c6e34; font-size: 15px; cursor: pointer; transition: all .15s; }
.landing-cta .btn-ghost:hover { background: rgba(184,136,17,.08); }
/* 轻提示（分享等） */
.toast { position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%) translateY(16px); background: rgba(40,28,12,.92); color: #fff; padding: 11px 22px; border-radius: 22px; font-size: 14px; z-index: 9999; opacity: 0; pointer-events: none; transition: all .25s ease; max-width: 86vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.landing-hint { font-size: 13px; color: #a08a6c; }
.landing-section { max-width: 1040px; margin: 0 auto; padding: 18px 20px; }
.landing-h2 { text-align: center; font-size: 22px; color: #5a3e12; margin: 18px 0 22px; position: relative; }
.landing-h2::after { content: ''; display: block; width: 48px; height: 3px; border-radius: 2px; background: var(--accent); margin: 10px auto 0; }
.landing-feats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.feat-card { background: #fff; border: 1px solid #ecdfca; border-radius: 14px; padding: 20px 18px; box-shadow: 0 4px 14px rgba(124,90,30,.06); transition: transform .15s, box-shadow .15s; }
.feat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(124,90,30,.14); }
.feat-ico { font-size: 30px; }
.feat-card h3 { margin: 10px 0 6px; font-size: 16px; color: #5a3e12; }
.feat-card p { margin: 0; font-size: 13px; line-height: 1.7; color: #7a6650; }
.landing-guide { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid #ecdfca; border-radius: 14px; padding: 22px 28px; box-shadow: 0 4px 14px rgba(124,90,30,.06); }
.landing-guide li { margin: 12px 0; font-size: 14px; line-height: 1.8; color: #4f4030; }
.landing-guide b { color: #8c6e34; }
.landing-foot { text-align: center; margin-top: 30px; font-size: 12px; color: #b09a7c; }

/* 微信打开提示（首页固定说明） */
.landing-notice { max-width: 1040px; margin: 18px auto 0; padding: 16px 18px; display: flex; gap: 12px; align-items: flex-start; background: #fff7e6; border: 1px solid #f0d59a; border-left: 4px solid #e0a83a; border-radius: 12px; box-shadow: 0 4px 14px rgba(124,90,30,.06); }
.ln-ico { font-size: 22px; line-height: 1.3; }
.ln-body { flex: 1; }
.ln-body > b { display: block; font-size: 15px; color: #9a5b0d; margin-bottom: 4px; }
.ln-body p { margin: 0; font-size: 13px; line-height: 1.75; color: #6f5a3c; }
.ln-body p strong { color: #9a5b0d; }
.ln-btn { margin-top: 10px; padding: 8px 16px; font-size: 13px; border: none; border-radius: 8px; background: #e0a83a; color: #fff; cursor: pointer; }
.ln-btn:hover { background: #cf962a; }

/* 微信内置浏览器提示条（置顶、不遮挡页面、可关闭） */
.wx-banner { display: flex; align-items: center; gap: 10px; padding: 9px 40px 9px 14px; background: #fff3d6; border-bottom: 1px solid #f0d59a; font-size: 13px; line-height: 1.5; color: #6f4e12; position: relative; }
.wx-banner b { color: #9a5b0d; margin-right: 2px; }
.wx-banner strong { color: #9a5b0d; }
.wx-b-close { position: absolute; top: 3px; right: 7px; width: 26px; height: 26px; line-height: 24px; text-align: center; font-size: 20px; color: #b08a3c; cursor: pointer; border-radius: 50%; }
.wx-b-close:hover { background: rgba(0,0,0,.06); }
.wx-b-copy { flex: 0 0 auto; padding: 6px 12px; font-size: 12px; border: none; border-radius: 7px; background: #e0a83a; color: #fff; cursor: pointer; }
.wx-b-copy:hover { background: #cf962a; }
@media (max-width: 520px) { .landing-notice { margin: 14px 14px 0; } .landing-notice p { font-size: 12.5px; } .wx-banner { font-size: 12px; padding-right: 38px; } }

/* ===== 登录 / 注册 弹窗 ===== */
.nav-auth { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.auth-login-btn { border: 1px solid rgba(255,255,255,.35); color: #fff; }
.auth-user { font-size: 13px; color: #f3e6dd; white-space: nowrap; }
.auth-logout { border: 1px solid rgba(255,255,255,.3); color: #f3e6dd; }
.auth-body { max-width: 420px; position: relative; }
.auth-title { margin: 0 0 4px; text-align: center; color: #5a3e12; }
.auth-tabs { display: flex; gap: 8px; justify-content: center; margin: 12px 0 6px; }
.auth-tab { padding: 6px 22px; border: 1px solid var(--line); background: #fff; border-radius: 18px; cursor: pointer; font-size: 14px; color: #7a6650; }
.auth-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.auth-msg { min-height: 18px; font-size: 13px; text-align: center; margin: 8px 0; }
.auth-msg-warn { color: #b8860b; }
.auth-msg-err { color: #b03a3a; }
.auth-pane .form-row { margin-bottom: 12px; }
.auth-submit { width: 100%; margin-top: 6px; padding: 11px; border: none; border-radius: 8px; background: linear-gradient(180deg, #b88811, #8c6e34); color: #fff; font-size: 15px; cursor: pointer; }
.auth-submit:hover { filter: brightness(1.05); }

/* 手机端 landing 紧凑化 */
@media (max-width: 820px) {
  .landing-hero { padding: 40px 16px 28px; }
  .landing-hero h1 { font-size: 24px; }
  .landing-feats { grid-template-columns: 1fr 1fr; }
  .feat-card { padding: 16px 14px; }
  .landing-guide { padding: 18px 20px; }
}

/* ============================================================
   打印族谱书：A4 竖版中式仿古单页，一人一页，统一版式
   ============================================================ */
.print-book { display: none; }

.book-page {
  width: 210mm; min-height: 297mm; box-sizing: border-box;
  margin: 0 auto 10mm; padding: 14mm 16mm;
  background: #fcf9f2; color: #2b2018;
  border: 3px double #6b4a2b;
  font-family: "Songti SC", "STSong", "SimSun", "宋体", "Noto Serif CJK SC", serif;
  position: relative;
}
.book-page .bp-head { text-align: center; margin-bottom: 6px; }
.book-page .bp-name { font-size: 30pt; font-weight: 700; letter-spacing: 6px; }
.book-page .bp-sub { font-size: 12pt; color: #6b4a2b; margin-top: 6px; letter-spacing: 1px; }
.book-page .bp-rule { border: none; border-top: 1.5px solid #6b4a2b; margin: 10px 0 12px; }
.book-page .bp-info { width: 100%; border-collapse: collapse; font-size: 11pt; }
.book-page .bp-info th, .book-page .bp-info td {
  border: 1px solid #c9b48f; padding: 7px 10px; vertical-align: top; text-align: left;
}
.book-page .bp-info th { width: 64px; background: #f3ead8; color: #6b4a2b; font-weight: 600; white-space: nowrap; }
.book-page .bp-info td { width: auto; }
.book-page .bp-bio { margin-top: 12px; font-size: 11pt; line-height: 1.9; text-align: justify; }
.book-page .bp-bio .bp-bio-t { color: #6b4a2b; font-weight: 600; margin-right: 6px; }
.book-page .bp-tree-title { text-align: center; font-size: 11pt; color: #6b4a2b; margin: 14px 0 4px; letter-spacing: 2px; }
.book-page .bp-tree { display: block; width: 100%; }
.book-page .bp-tree svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.book-page .bp-bazi-title { text-align: center; font-size: 13pt; color: #6b4a2b; margin: 16px 0 10px; letter-spacing: 2px; font-weight: 600; }
.book-page .bp-bazi-report { width: 100%; margin-top: 8px; }
.book-page .bp-bazi-report .bzr-wrap { font-size: 10pt; line-height: 1.75; color: #2b2018; }
.book-page .bp-bazi-report .bzr-wrap h2 { font-size: 15pt; color: #8b2e2e; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1.5px solid #d8c9a8; }
.book-page .bp-bazi-report .bzr-wrap h3 { font-size: 11.5pt; color: #6b4a2b; margin: 12px 0 6px; }
.book-page .bp-bazi-report .bzr-wrap h4 { font-size: 10.5pt; color: #5a4539; margin: 10px 0 6px; }
.book-page .bp-bazi-report .bzr-header { background: #f9f6ef; border: 1px solid #e3dac6; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
.book-page .bp-bazi-report .bzr-pillars { gap: 6px; margin: 10px 0; }
.book-page .bp-bazi-report .bzr-pillar { min-width: 90px; padding: 6px 4px; border: 1px solid #e3dac6; }
.book-page .bp-bazi-report .bzr-gz { font-size: 15pt; }
.book-page .bp-bazi-report .bzr-cang { font-size: 9pt; }
.book-page .bp-bazi-report .bzr-list { padding-left: 16px; }
.book-page .bp-bazi-report .bzr-list li { margin-bottom: 4px; }
.book-page .bp-bazi-report .bzr-disclaimer { color: #8a7a63; font-size: 9pt; border-top: 1px dashed #d8c9a8; margin-top: 10px; padding-top: 6px; }
.book-page .bp-lineage-list { list-style: none; padding: 0; margin: 0; width: 100%; }
.book-page .bp-lineage-list li { display: flex; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px dotted #d8c9a8; font-size: 11pt; }
.book-page .bp-lineage-list li:last-child { border-bottom: none; }
.book-page .bp-lineage-list .bp-lineage-gen { flex: 0 0 56px; color: #7a1f1f; font-weight: 600; font-size: 10.5pt; }
.book-page .bp-lineage-list .bp-lineage-name { flex: 0 0 100px; font-weight: 700; color: #2b2018; }
.book-page .bp-lineage-list .bp-lineage-life { flex: 1; color: #6b4a2b; font-size: 10.5pt; }
.book-page .bp-lineage-list .bp-lineage-self { background: #f3ead8; border-radius: 4px; padding-left: 8px; padding-right: 8px; margin-left: -8px; margin-right: -8px; }
.book-page .bp-lineage-children { margin-top: 10px; padding-top: 8px; border-top: 1px dashed #d8c9a8; font-size: 10.5pt; color: #4a3b2a; }
.book-page .bp-lineage-children .bp-lineage-children-t { color: #6b4a2b; font-weight: 600; }
.book-page .bp-empty { text-align: center; color: #8a7a63; padding: 40px; font-size: 13pt; }
.book-page .bp-page-no {
  position: absolute;
  bottom: 8mm;
  left: 0; right: 0;
  text-align: center;
  font-size: 10pt;
  color: #6b4a2b;
  letter-spacing: 1px;
}

/* 谱书编辑模式视觉提示 */
.pedigree-book[contenteditable="true"] {
  border: 2px dashed var(--accent);
  padding: 16px;
  background: #fffefc;
  border-radius: 8px;
}

/* 打印时只输出族谱书，每页一张 A4 */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  @page pg-tree-chart-page { size: A4 landscape; margin: 8mm; }
  @page pg-tree-chart-page-p { size: A4 portrait; margin: 8mm; }
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }

  /* —— 模式 A：A4 仿古单页（#printBook 容器） —— */
  /* 用最高优先级直接显示，不依赖「先 body>* 隐藏再放出」的脆弱机制 */
  body.folk-print #printBook.print-book,
  body.folk-print #printBook {
    display: block !important;
    position: static !important;
    left: auto !important; top: auto !important; width: auto !important; height: auto !important;
    overflow: visible !important; z-index: auto !important;
  }
  body.folk-print .book-page {
    width: 100%; min-height: calc(297mm - 20mm); margin: 0; border: 3px double #6b4a2b;
    page-break-after: always; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  body.folk-print .book-page:last-child { page-break-after: auto; }
  body.folk-print .bp-bazi-report .bzr-wrap { color: #2b2018 !important; }
  body.folk-print .bp-bazi-report .bzr-header,
  body.folk-print .bp-bazi-report .bzr-pillar,
  body.folk-print .bp-bazi-report .bzr-list li,
  body.folk-print .bp-bazi-report .bzr-disclaimer { page-break-inside: avoid; }
  body.folk-print .bp-bazi-report .bzr-level,
  body.folk-print .bp-bazi-report .bzr-pillar,
  body.folk-print .bp-bazi-report .bzr-header { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* —— 模式 B：标准谱书（#pedigreeView 内的 #pedigreeBook） —— */
  body.std-print #pedigreeView,
  body.std-print #pedigreeView.folk-doc,
  body.std-print #pedigreeView .folk-doc,
  body.std-print #pedigreeBook {
    display: block !important;
    position: static !important;
    left: auto !important; top: auto !important; width: auto !important; height: auto !important;
    overflow: visible !important; z-index: auto !important;
  }
  body.std-print .topnav,
  body.std-print .ledger-head,
  body.std-print .no-print { display: none !important; }
  body.std-print #pedigreeBook { box-shadow: none !important; border: none !important; padding: 0; }
  body.std-print .pg-cover { min-height: calc(100vh - 20mm); page-break-after: always; }
  body.std-print .pg-gen, body.std-print .pg-section { page-break-inside: avoid; }

  /* 世系总图单独一页 A4 横版（默认）/ A4 竖版（data-orient=portrait） */
  body.std-print .pg-tree-chart-section { page: pg-tree-chart-page; page-break-before: always; page-break-after: always; margin: 0; }
  body.std-print .pg-tree-chart-section[data-orient="portrait"] { page: pg-tree-chart-page-p; }
  body.std-print .pg-tree-chart { border: none; background: transparent; min-height: auto; padding: 0; }
  body.std-print .pg-tree-chart-img { max-width: 100%; max-height: calc(297mm - 16mm); width: auto; height: auto; }
  body.std-print .pg-tree-chart-note { display: none; }

  /* 兜底：若上述 class 机制因故未触发，至少保证两个打印容器可见 */
  #printBook:not([style*="display: none"]),
  #pedigreeBook:not([style*="display: none"]) { display: block !important; }
}

/* ============ 宗族账簿 ============ */
.nav-btn.nav-ledger { color: var(--accent); font-weight: 600; }
.ledger-wrap { padding: 18px 20px; max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.ledger-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ledger-head h2 { margin: 0; font-size: 20px; letter-spacing: 1px; }
.ledger-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pg-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: #f9f6f0; border: 1px dashed #d8c9a8; border-radius: 8px; }
.pg-split-hint { font-size: 12px; color: #8a7a63; }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 7px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 7px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { background: rgba(160,30,30,.08); }
.ledger-tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border, #e3d9c6); }
.ledger-tab { background: none; border: none; padding: 9px 16px; font-size: 14px; cursor: pointer; color: var(--muted,#8a7a63); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.ledger-tab.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.ledger-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: var(--card,#fbf6ec); border: 1px solid var(--border,#e3d9c6); border-radius: 10px; padding: 14px 16px; text-align: center; }
.stat-num { font-size: 20px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted,#8a7a63); margin-top: 4px; }
.ledger-card { background: var(--card,#fbf6ec); border: 1px solid var(--border,#e3d9c6); border-radius: 10px; padding: 14px 16px; }
.ledger-card h3 { margin: 0 0 10px; font-size: 15px; color: var(--accent); border-left: 3px solid var(--accent); padding-left: 8px; }
.ledger-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ledger-table th, .ledger-table td { padding: 8px 10px; border-bottom: 1px solid var(--border,#e3d9c6); text-align: left; }
.ledger-table th { color: var(--muted,#8a7a63); font-weight: 600; background: rgba(160,30,30,.04); }
.ledger-table .amount { text-align: right; font-variant-numeric: tabular-nums; }
.ledger-table td.actions { white-space: nowrap; }
.dn-name { font-weight: 500; }
.type-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.type-tag.donation { background: #fff0e0; color: #b5651d; }
.type-tag.income { background: #e6f4ea; color: #1a7f37; }
.type-tag.expense { background: #fdeaea; color: #b03a3a; }
.amt-in { color: #1a7f37; font-weight: 600; }
.amt-out { color: #b03a3a; font-weight: 600; }
.rank-badge { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 12px; }
.rank-badge.r1 { background: linear-gradient(135deg,#f6c64b,#d4a017); }
.rank-badge.r2 { background: linear-gradient(135deg,#d8d8d8,#a8a8a8); }
.rank-badge.r3 { background: linear-gradient(135deg,#e0a96d,#b5793d); }
.rank-num { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; color: var(--muted,#8a7a63); font-weight: 600; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-pill { background: rgba(160,30,30,.08); color: var(--accent); border-radius: 14px; padding: 5px 12px; font-size: 12.5px; }
.vu-count { font-size: 11px; color: var(--muted,#8a7a63); margin-left: 4px; }
.voucher-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.voucher-chip { position: relative; display: inline-block; }
.voucher-chip img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border,#e3d9c6); }
.voucher-x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: #b03a3a; color: #fff; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; }
.ledger-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.archive-list { display: flex; flex-direction: column; gap: 10px; }
.archive-card { background: var(--card,#fbf6ec); border: 1px solid var(--border,#e3d9c6); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.archive-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.archive-main b { font-size: 15px; color: var(--accent); }
.archive-sum { font-size: 13px; color: var(--muted,#8a7a63); }
.archive-actions { display: flex; gap: 8px; }
@media (max-width: 640px) {
  .ledger-stats { grid-template-columns: repeat(2, 1fr); }
  .ledger-head { flex-direction: column; align-items: flex-start; }
}

/* ============ 谱牒模块（寻根/谱书/家训/祖墓祠堂/清明登记） ============ */
.mini-btn { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.mini-btn:hover { background: rgba(160,30,30,.06); }
.mini-btn.danger { color: #b03a3a; border-color: #e8c4c4; }
.mini-btn.danger:hover { background: rgba(176,58,58,.08); }
.card-actions { display: inline-flex; gap: 6px; margin-left: auto; }

/* 寻根检索 */
.root-search-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.root-search-bar input { flex: 1 1 160px; min-width: 120px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13.5px; }
.root-results { display: flex; flex-direction: column; gap: 8px; }
.root-card { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: box-shadow .15s; }
.root-card:hover { box-shadow: 0 2px 10px rgba(160,30,30,.12); }
.root-photo { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; overflow: hidden; flex: 0 0 auto; }
.root-photo img { width: 100%; height: 100%; object-fit: cover; }
.root-info { flex: 1; }
.root-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.root-gen { font-size: 11px; color: var(--accent); background: rgba(160,30,30,.08); border-radius: 10px; padding: 1px 8px; font-weight: 500; }
.root-deceased { font-size: 11px; color: #8a7a63; background: rgba(0,0,0,.05); border-radius: 10px; padding: 1px 8px; }
.root-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* 谱书 */
.pedigree-book { background: #fffdf8; border: 1px solid var(--line); border-radius: 8px; padding: 36px 40px; color: #2a2018; font-family: "Songti SC", "SimSun", "STSong", serif; line-height: 1.9; }
.pg-cover { text-align: center; padding: 90px 0 80px; border-bottom: 2px solid #c9a96a; margin-bottom: 28px; page-break-after: always; min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.pg-cover-inner { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.pg-cover-surname { width: 240px; height: 240px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 8px double #7a1f1f; background: #fff8f0; font-size: 180px; font-weight: 800; color: #7a1f1f; letter-spacing: 0; text-shadow: 3px 3px 0 rgba(122,31,31,.12); box-shadow: 0 10px 36px rgba(122,31,31,.18); font-variant-east-asian: simplified !important; font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif !important; }
.pg-cover-title { font-size: 56px; letter-spacing: 12px; margin: 14px 0 8px; }
.pg-cover-sub { display: none; }
.pg-cover-date { margin-top: 18px; font-size: 13px; color: #8a7a63; }
.pg-section { margin-bottom: 26px; }
.pg-section h2 { font-size: 22px; color: #7a1f1f; border-left: 5px solid #c9a96a; padding-left: 12px; margin: 0 0 12px; }
.pg-pre { white-space: pre-wrap; font-size: 14.5px; }
.pg-gen { margin-bottom: 18px; }
.pg-gen h3 { font-size: 17px; color: #7a1f1f; margin: 0 0 8px; }
.pg-gen-list { display: flex; flex-direction: column; gap: 7px; }
.pg-gen-row { display: flex; align-items: baseline; gap: 12px; line-height: 1.8; }
.pg-gen-no { flex: 0 0 70px; font-weight: 600; color: #7a1f1f; font-size: 14px; }
.pg-gen-names { flex: 1; font-size: 14px; color: #2b2b2b; }
.pg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pg-table th, .pg-table td { border: 1px solid #d8c9a8; padding: 5px 8px; text-align: left; }
.pg-table th { background: #f3ead4; color: #6b4423; font-weight: 600; }
/* 八字（立命）列：紧凑、不换行、竖排感配色 */
.pg-table td.pg-bz { white-space: nowrap; font-size: 12px; letter-spacing: 1px; color: #7a1f1f; font-family: "STKaiti", "KaiTi", "楷体", serif; }
.pg-empty, .pg-footer { color: #8a7a63; font-size: 13px; }
.pg-footer { margin-top: 24px; padding-top: 14px; border-top: 1px dashed #d8c9a8; text-align: center; font-size: 12px; }

/* 世系总图（谱书内嵌） */
.pg-tree-chart-section { margin-bottom: 26px; }
.pg-tree-chart { width: 100%; min-height: 260px; background: #f5f1e8; border: 1px dashed #d8c9a8; border-radius: 6px; display: flex; align-items: center; justify-content: center; padding: 10px; }
.pg-tree-chart-loading { color: #8a7a63; font-size: 13px; padding: 40px; text-align: center; }
.pg-tree-chart-img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.pg-tree-chart-note { color: #8a7a63; font-size: 12px; margin-top: 8px; }
.pg-tree-chart-host { width: 100%; }
.pg-tree-tile-wrap { background: #f5f1e8; }
.pg-tree-tile-img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
/* 谱书工具栏：世系总图拆分选择器 */
.pg-split-label { font-size: 13px; color: #5b4636; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.pg-split-label select { font-size: 13px; padding: 5px 8px; border: 1px solid #d8c9a8; border-radius: 6px; background: #fffdf8; color: #3e2723; }

/* 家训族规 */
.precept-list { display: flex; flex-direction: column; gap: 12px; }
.precept-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.precept-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.precept-head b { color: var(--accent); }
.precept-head .muted { font-size: 12px; }
.precept-body { margin-top: 8px; white-space: pre-wrap; font-size: 14px; line-height: 1.9; color: #3a322a; border-left: 3px solid var(--accent); padding-left: 10px; }

/* 祖墓祠堂档案 */
.site-list { display: flex; flex-direction: column; gap: 14px; }
.site-card { display: flex; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.site-photo { width: 88px; height: 88px; border-radius: 8px; background: rgba(160,30,30,.06); display: flex; align-items: center; justify-content: center; font-size: 34px; overflow: hidden; flex: 0 0 auto; position: relative; }
.site-photo img { width: 100%; height: 100%; object-fit: cover; }
.site-photo-badge { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.site-photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.site-photo-thumb { width: 90px; height: 90px; border-radius: 6px; overflow: hidden; position: relative; border: 1px solid var(--line); }
.site-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.site-photo-thumb .photo-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0; line-height: 22px; text-align: center; border-radius: 50%; font-size: 14px; }
.site-info { flex: 1; min-width: 0; }
.site-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-head b { font-size: 15px; color: var(--accent); }
.site-loc { font-size: 13px; color: var(--muted); margin: 4px 0; }
.site-epitaph, .site-map, .site-note { font-size: 13px; margin: 4px 0; line-height: 1.8; }
.site-epitaph .lbl, .site-map .lbl, .site-reno .lbl { color: var(--accent); font-weight: 600; margin-right: 4px; }
.site-reno ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.site-reno li { margin: 2px 0; }
.reno-row { display: flex; gap: 6px; margin: 4px 0; align-items: center; }
.reno-row .reno-date { flex: 0 0 110px; }
.reno-row input { flex: 1; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }

/* 人物生卒时间（年月日时分 + 农历/新历切换 + 日历） */
.life-date-row { display: flex; flex-direction: column; gap: 8px; }
.life-date-calendar-toggle { display: flex; gap: 14px; font-size: 13px; }
.life-date-calendar-toggle .radio-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #5c5348; }
.life-date-calendar-toggle input[type="radio"] { margin: 0; }
.life-date-inputs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.life-date-inputs input { padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; text-align: center; }
.life-date-inputs .life-year { width: 72px; }
.life-date-inputs .life-month, .life-date-inputs .life-day { width: 48px; }
.life-date-inputs .life-hour { width: 78px; }
.life-date-inputs .life-minute { width: 42px; }
.life-date-inputs .life-calendar-btn { padding: 6px 8px; font-size: 15px; line-height: 1; }
.date-picker-panel { position: absolute; z-index: 1200; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 10px; min-width: 260px; }
.date-picker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.date-picker-header select { padding: 4px 6px; border-radius: 4px; border: 1px solid var(--line); font-size: 13px; }
.date-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 12px; }
.date-picker-grid .dp-weekday { color: var(--muted); font-weight: 600; padding: 4px 0; }
.date-picker-grid .dp-day { padding: 5px 0; border-radius: 4px; cursor: pointer; }
.date-picker-grid .dp-day:hover { background: rgba(160,30,30,.08); }
.date-picker-grid .dp-day.selected { background: var(--accent); color: #fff; }
.date-picker-grid .dp-day.other-month { color: #bbb; }
.date-picker-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.date-picker-lunar { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.date-picker-lunar select { padding: 5px 6px; border-radius: 4px; border: 1px solid var(--line); font-size: 13px; }

/* 清明登记 */
.wr-list { display: flex; flex-direction: column; gap: 16px; }
.wr-year h3 { font-size: 15px; color: var(--accent); margin: 0 0 8px; border-left: 3px solid var(--accent); padding-left: 8px; }

@media (max-width: 640px) {
  .root-search-bar input { flex-basis: 100%; }
  .site-card { flex-direction: column; }
  .pg-table { font-size: 11px; }
  .pg-table td.pg-bz { font-size: 10px; letter-spacing: 0; }
  .pedigree-book { padding: 20px 16px; }
  .pg-cover { padding: 40px 0; }
  .pg-cover-surname { width: 160px; height: 160px; font-size: 120px; }
  .pg-cover-title { font-size: 40px; letter-spacing: 8px; }
}

/* 谱书打印：仅显示谱书内容；恢复 10mm 页边距让浏览器默认页脚页码显示 */
@media print {
  @page pg-tree-chart-page { size: A4 landscape; margin: 8mm; }
  @page pg-tree-chart-page-p { size: A4 portrait; margin: 8mm; }
  body { background: #fff !important; margin: 0; }
  .topnav, .ledger-head, .no-print { display: none !important; }
  .view { display: none !important; }
  #pedigreeView { display: block !important; }
  #pedigreeView .folk-doc { max-width: none; padding: 0; margin: 0; }
  #pedigreeBook { box-shadow: none !important; border: none !important; padding: 0; }
  /* 封面撑满整页：父 #pedigreeBook 无内边距，100vh = 内容区高度，正好一页 */
  .pg-cover { border-bottom: none; min-height: 100vh; padding: 0; margin: 0; page-break-after: always; }
  /* 世系总图单独 A4 横版（默认）/ A4 竖版（data-orient=portrait）一页 */
  .pg-tree-chart-section { page: pg-tree-chart-page; page-break-before: always; page-break-after: always; margin: 0; }
  .pg-tree-chart-section[data-orient="portrait"] { page: pg-tree-chart-page-p; }
  .pg-tree-chart { border: none; background: transparent; min-height: auto; padding: 0; }
  .pg-tree-chart-img { max-width: 100%; max-height: calc(297mm - 16mm); width: auto; height: auto; }
  .pg-tree-chart-note { display: none; }
  .pg-cover-surname { width: 280px; height: 280px; font-size: 220px; border-width: 10px; }
  .pg-cover-surname-img { width: 280px; height: 280px; }
  .pg-cover-title { font-size: 72px; letter-spacing: 14px; }
  .pg-cover-title-img { max-height: 110px; }
  .pg-cover-seal { width: 160px; height: 160px; right: 50px; bottom: 60px; }
  .pg-cover-seal-img { width: 100%; height: 100%; }
  .pg-gen, .pg-section { page-break-inside: avoid; }
}

/* ============ 罗盘 · iOS 地磁定向提示 ============ */
.ios-sensor-tip { display: flex; gap: 10px; align-items: flex-start; background: #fff1f0; border: 2px solid #e0635f; border-radius: 10px; padding: 12px 14px; margin: 10px 14px; box-shadow: 0 2px 10px rgba(224,99,95,.18); animation: iosTipPulse 1.8s ease-in-out infinite; }
@keyframes iosTipPulse { 0%,100% { border-color: #e0635f; } 50% { border-color: #ff9a96; } }
.ios-sensor-tip .tip-icon { font-size: 22px; line-height: 1.2; flex: 0 0 auto; }
.ios-sensor-tip .tip-body { flex: 1; font-size: 13.5px; line-height: 1.85; color: #7a2b28; }
.ios-sensor-tip .tip-body strong { color: #c0392b; }
.ios-sensor-tip .tip-close { margin-top: 8px; background: #c0392b; color: #fff; border: none; border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.ios-sensor-tip .tip-close:hover { filter: brightness(1.08); }
/* iOS 上高亮「地磁定向」按钮，引导用户手动点击 */
.sensor-btn-ios { border: 2px solid #e0635f !important; box-shadow: 0 0 0 4px rgba(224,99,95,.22); animation: sensorBtnPulse 1.6s ease-in-out infinite; }
@keyframes sensorBtnPulse { 0%,100% { box-shadow: 0 0 0 4px rgba(224,99,95,.22); } 50% { box-shadow: 0 0 0 8px rgba(224,99,95,.08); } }

/* ============ 关于 · 特别鸣谢（下拉名单框） ============ */
.thanks-dropbox { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; background: rgba(160,30,30,.03); min-height: 60px; }
.thanks-list { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.95; }
.thanks-list li { margin: 6px 0; }
.thanks-list b { color: var(--accent); }
.donor-note { margin-top: 8px; padding: 8px 12px; border: 1px dashed var(--accent); border-radius: 8px; background: rgba(160,30,30,.04); font-size: 12.5px; line-height: 1.7; color: var(--text); }

/* ===== 我的族谱（多谱体系） ===== */
.my-books-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.book-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); }
.book-row.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: rgba(160,30,30,.06); }
.book-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.book-name { font-weight: 600; font-size: 14.5px; }
.book-tag { font-size: 11px; padding: 1px 8px; border-radius: 10px; color: #fff; }
.tag-zong { background: #8a5a2b; }
.tag-zhi { background: #2b6e8a; }
.tag-custom { background: #555; }
.book-cur { font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 10px; padding: 1px 8px; }
.book-time { font-size: 11px; }
.book-from { font-size: 11px; color: var(--muted); white-space: nowrap; }
.book-actions { display: flex; gap: 6px; flex-shrink: 0; }
.book-open.disabled, .book-open:disabled { opacity: .55; cursor: not-allowed; background: #c9c1b6; color: #fff; border-color: transparent; }
.derive-from-name { font-weight: 600; color: var(--accent); }

/* ===== 意见反馈增强：回复/点赞/删除/黑名单 ===== */
.fb-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.fb-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; }
.fb-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.fb-contact { font-size: 12px; color: #888; margin: 2px 0; }
.fb-content { margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.fb-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.fb-like.on { background: var(--accent); color: #fff; }
.fb-reply-form { display: flex; gap: 6px; margin-top: 6px; }
.fb-reply-form input { flex: 1; }
.fb-replies { margin-top: 8px; border-left: 3px solid var(--line); padding-left: 8px; display: flex; flex-direction: column; gap: 4px; }
.fb-reply-item { font-size: 13px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.fb-reply-item .muted { font-size: 11px; }
.fb-reply-text { white-space: pre-wrap; word-break: break-word; flex: 1; min-width: 120px; }
.fb-del { background: #c0392b; color: #fff; }
.fb-reply-del { border: none; background: transparent; color: #c0392b; cursor: pointer; font-size: 12px; padding: 0 4px; }
.blk-row { margin: 6px 0; font-size: 13px; }
.blk-tag { display: inline-flex; align-items: center; gap: 2px; background: #f3f3f3; border-radius: 10px; padding: 1px 6px; margin: 2px; }
.blk-del { border: none; background: transparent; color: #c0392b; cursor: pointer; font-size: 14px; line-height: 1; }

/* ===== 本期新增样式补丁 ===== */

/* 工具栏下拉：族谱 / 分享码 */
.toolbar-dropdown { position: relative; display: inline-flex; }
.toolbar-dropdown-panel {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 320px; max-width: 90vw; max-height: 70vh; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 200; padding: 10px;
}
.toolbar-dropdown.open .toolbar-dropdown-panel { display: block; }
.toolbar-dropdown-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0; align-items: center; }
.toolbar-dropdown-actions button.small { white-space: nowrap; }
.toolbar-dropdown-actions input { flex: 1; min-width: 160px; }

/* 封面 canvas 预渲染图片 */
.pg-cover { position: relative; }
.pg-cover-surname-img { width: 100%; height: 100%; object-fit: contain; }
.pg-cover-title-img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.pg-cover-seal { position: absolute; right: 40px; bottom: 50px; width: 140px; height: 140px; }
.pg-cover-seal-img { width: 100%; height: 100%; object-fit: contain; }

/* 杂录图片 */
.doc-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.doc-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.misc-img-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.misc-thumb { position: relative; width: 80px; height: 80px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.misc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.misc-thumb-del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: none; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.misc-thumb-del:hover { background: rgba(0,0,0,.75); }

/* ===== 八字命盘卡片 ===== */
.bz-card { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(180deg, #fbf6ee, #f6efe2); }
.bz-title { font-weight: 700; color: #7a1f1f; font-size: 15px; margin-bottom: 8px; }
.bz-sub { font-weight: 400; font-size: 12px; color: #9a8c7a; }
.bz-pillars { display: flex; gap: 8px; flex-wrap: wrap; }
.bz-pillar { flex: 1; min-width: 56px; text-align: center; background: #fff; border: 1px solid #e7dcc7; border-radius: 8px; padding: 8px 4px; }
.bz-pillar.bz-empty { opacity: .5; }
.bz-p-name { font-size: 12px; color: #9a8c7a; margin-bottom: 4px; }
.bz-pz { display: flex; justify-content: center; gap: 4px; font-size: 22px; font-weight: 700; line-height: 1.1; }
.bz-g { color: #b3402f; }
.bz-z { color: #2b6a8f; }
.bz-row { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 13px; flex-wrap: wrap; }
.bz-label { color: #9a8c7a; min-width: 34px; }
.bz-wx { margin-right: 6px; padding: 1px 7px; border-radius: 10px; background: #fff; border: 1px solid #e7dcc7; font-size: 12px; }
.bz-wx b { color: #7a1f1f; }
.bz-mg { font-weight: 700; color: #5a3d8a; }
.bz-solar { color: #888; font-size: 12px; }
.bz-dy-note { color: #5a3d8a; font-weight: 600; }
.bz-dy-list { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; width: 100%; }
.bz-dy { padding: 1px 6px; border-radius: 6px; background: #f0e6d2; border: 1px solid #e0d2b6; font-size: 12px; }
.bz-dy-sep { color: #c9b896; }
.bz-preview-empty { color: #aaa; font-size: 12px; font-style: italic; }
.bazi-preview { margin: 4px 0 2px; }
.bz-corrected { margin-left: 8px; font-size: 11px; font-weight: 600; color: #2b6a8f; background: #e3f0f7; border: 1px solid #b9dceb; border-radius: 8px; padding: 0 6px; }
.bz-ov-mark { margin-left: 8px; font-size: 11px; color: #2b6a8f; background: #e3f0f7; border: 1px solid #b9dceb; border-radius: 8px; padding: 0 6px; }
.bz-override-box { margin: 10px 0 4px; padding: 10px 12px; border: 1px dashed #c9a26a; border-radius: 10px; background: #fffaf0; }
.bz-ov-title { font-size: 13px; font-weight: 700; color: #7a1f1f; margin-bottom: 8px; }
.bz-ov-grid { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1.1fr; align-items: center; gap: 6px 8px; }
.bz-ov-grid label { font-size: 12px; color: #8a7a66; white-space: nowrap; }
.bz-ov-grid input, .bz-ov-grid select { padding: 5px 7px; border: 1px solid #d8c9ad; border-radius: 6px; font-size: 13px; width: 100%; }
.bz-ov-grid2 { grid-template-columns: auto 1fr; margin-top: 8px; }
.bz-ov-tip { margin-top: 8px; font-size: 11px; color: #9a8c7a; line-height: 1.5; }
@media print { .bz-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; } .bz-override-box { display: none; } }

/* ===== 丧葬档案 ===== */
.fn-field .fn-empty { font-size: 13px; color: #8a7a66; }
.fn-card { background: #fffaf2; border: 1px solid #e6d8bf; border-radius: 10px; padding: 12px 14px; }
.fn-row { display: flex; gap: 10px; padding: 4px 0; align-items: flex-start; }
.fn-k { flex: 0 0 96px; color: #7a1f1f; font-weight: 600; font-size: 13px; }
.fn-v { flex: 1; color: #3a2f28; font-size: 13px; line-height: 1.6; }
.fn-slot { padding: 2px 0; }
.fn-slot-no { display: inline-block; background: #7a1f1f; color: #fff; border-radius: 4px; font-size: 11px; padding: 1px 6px; margin-right: 6px; }
.fn-none { color: #9a8c7a; font-size: 13px; }
.fn-jz { padding: 2px 0; font-size: 13px; }
.fn-jz.on { color: #7a1f1f; font-weight: 600; }
.fn-jz b { color: #b8860b; }
.fn-chong { color: #c0392b; font-weight: 700; font-size: 12px; }
.fn-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fn-photos img, .fn-photo-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid #e0d2b8; }
.fn-actions { margin-top: 10px; }
/* 编辑弹窗 */
.fn-slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.fn-slot-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: 12px; background: #fbf6ec; border: 1px solid #ecdfc4; border-radius: 8px; padding: 6px 8px; }
.fn-slot-cal { display: flex; gap: 8px; }
.fn-slot-row input { width: 52px; padding: 4px 5px; border: 1px solid #d8c9ad; border-radius: 5px; font-size: 12px; }
.fn-slot-row .fn-snote { width: 110px; }
.fn-slot-row .fn-slot-del { color: #8b2e2e; }
.fn-jz-box { display: flex; flex-direction: column; gap: 5px; max-height: 200px; overflow-y: auto; background: #fbf6ec; border: 1px solid #ecdfc4; border-radius: 8px; padding: 8px 10px; }
.fn-jz-opt { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.fn-jz-opt.on { color: #7a1f1f; font-weight: 600; }
.fn-photos-edit { display: flex; flex-wrap: wrap; gap: 8px; }
.fn-photo-thumb { position: relative; }
.fn-photo-thumb .fn-photo-del { position: absolute; top: -6px; right: -6px; background: #8b2e2e; color: #fff; border: none; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; cursor: pointer; line-height: 1; }

/* ===== 帮助页 iframe 全高修复 ===== */
#helpView {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.help-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}



/* 八字全盘详解 */
.bz-report-actions { margin-top: 10px; }
.bz-full-report-btn { background: var(--primary); color: #fff; border: none; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.bazi-report-body { max-width: 760px; width: 92vw; max-height: 86vh; overflow: auto; background: var(--card); border-radius: 12px; padding: 20px 24px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.bzr-close-wrap { text-align: right; margin-bottom: 8px; }
.bzr-close { background: #f0f0f0; border: none; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.bzr-wrap { color: var(--ink); line-height: 1.8; font-size: 15px; }
.bzr-wrap h2 { margin: 0 0 12px; font-size: 20px; color: #8b2e2e; border-bottom: 2px solid #d8cfc4; padding-bottom: 8px; }
.bzr-wrap h3 { margin: 18px 0 10px; font-size: 17px; color: #6b4c3a; }
.bzr-wrap h4 { margin: 14px 0 8px; font-size: 15px; color: #5a4539; }
.bzr-header { background: #faf8f3; border: 1px solid #e8e0d4; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.bzr-zao { font-size: 18px; margin-bottom: 6px; }
.bzr-main-gz { letter-spacing: 2px; }
.bzr-rizhu { font-size: 16px; margin-bottom: 4px; }
.bzr-solar, .bzr-info { color: #666; font-size: 14px; }
.bzr-wx-row { margin-top: 6px; }
.bzr-wx { display: inline-block; margin-right: 10px; font-size: 14px; }
.bzr-wx b { color: #8b2e2e; margin-left: 3px; }
.bzr-pillars { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.bzr-pillar { flex: 1; min-width: 120px; background: #fff; border: 1px solid #e8e0d4; border-radius: 8px; padding: 10px; text-align: center; }
.bzr-p-name { color: #888; font-size: 13px; margin-bottom: 4px; }
.bzr-gz { font-size: 22px; font-weight: bold; color: #8b2e2e; letter-spacing: 2px; }
.bzr-shishen { color: #6b4c3a; font-size: 13px; margin-top: 2px; }
.bzr-cang { color: #999; font-size: 12px; margin-top: 4px; }
.bzr-wrap ul, .bzr-wrap ol { padding-left: 20px; margin: 8px 0; }
.bzr-wrap li { margin-bottom: 8px; }
.bzr-wrap blockquote { margin: 10px 0; padding: 10px 14px; background: #faf8f3; border-left: 4px solid #c9a87c; color: #5a4539; }
.bzr-disclaimer { color: #999; font-size: 13px; margin-top: 16px; padding-top: 10px; border-top: 1px dashed #ddd; }
/* 大运吉凶徽章 + 得失守攻标注 */
.bzr-level { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.bzr-lv-ji { background: #e7f4e9; color: #2f7d3a; border: 1px solid #b7dcbd; }
.bzr-lv-shou { background: #fbeaea; color: #b23a3a; border: 1px solid #e7b7b7; }
.bzr-lv-ping { background: #f3efe6; color: #8a6a2e; border: 1px solid #ddd0b8; }
.bzr-ddsg { display: inline-block; margin-left: 6px; font-size: 12px; color: #8a6a4a; opacity: 0.85; }
.bzr-sub { color: #999; font-size: 13px; margin: 4px 0 0; }
/* 五行加权得分 + 雷达图 */
.bzr-wx-score-row { margin-top: 2px; }
.bzr-wxs { display: inline-block; margin-right: 10px; font-size: 14px; color: #6b4c3a; }
.bzr-wxs b { color: #b22222; margin-left: 3px; }
.bzr-radar-wrap { text-align: center; margin: 8px 0 4px; }
.bzr-radar { display: inline-block; width: 360px; max-width: 100%; height: auto; aspect-ratio: 360 / 320; background: #fcfaf5; border: 1px solid #ece3d2; border-radius: 8px; }
.bzr-radar-cap { color: #999; font-size: 12px; margin-top: 2px; }
/* 四柱十神单字标注 */
.bzr-ss-mark { font-size: 13px; color: #b22222; letter-spacing: 2px; margin-top: 2px; }
/* 近十六年流年表 */
.bzr-ln-table { width: 100%; border-collapse: collapse; margin: 6px 0 4px; font-size: 13px; }
.bzr-ln-table th, .bzr-ln-table td { border: 1px solid #e3d8c4; padding: 4px 8px; text-align: center; }
.bzr-ln-table th { background: #f3ead9; color: #6b4c3a; }
.bzr-ln-table .bzr-ln-gz { font-weight: 700; color: #6b4c3a; }
.bzr-ln-table .bzr-ln-mark { color: #8a6a2e; font-size: 12px; }
.bzr-ln-flag { display: inline-block; width: 18px; height: 18px; line-height: 18px; border-radius: 50%; font-size: 12px; font-weight: 700; }
.bzr-ln-ji .bzr-ln-flag { background: #e7f4e9; color: #2f7d3a; }
.bzr-ln-ji { background: #f3fbf4; }
.bzr-ln-table tr.bzr-ln-忌 .bzr-ln-flag { background: #fbeaea; color: #b23a3a; }
.bzr-ln-table tr.bzr-ln-忌 { background: #fdf5f5; }
.bzr-ln-table tr.bzr-ln-平 .bzr-ln-flag { background: #f3efe6; color: #8a6a2e; }
/* 传统「批命纸」打印/视图样式：红纸、竖排味、圈点神煞 */
@media print {
  body.bzr-paper-mode * { visibility: hidden; }
  body.bzr-paper-mode #baziReportModal,
  body.bzr-paper-mode #baziReportModal * { visibility: visible; }
  body.bzr-paper-mode #baziReportModal { position: absolute; left: 0; top: 0; width: 100%; background: #fff7ef; }
  body.bzr-paper-mode .bzr-close-wrap,
  body.bzr-paper-mode .bzr-disclaimer { display: none !important; }
}
body.bzr-paper-mode .bazi-report-body {
  background: #fff7ef;
  border: 2px solid #c0392b;
  border-radius: 0;
  box-shadow: none;
  color: #3a2a20;
}
body.bzr-paper-mode .bzr-title {
  color: #c0392b;
  text-align: center;
  border-bottom: 2px double #c0392b;
  padding-bottom: 8px;
  letter-spacing: 4px;
}
body.bzr-paper-mode .bzr-main-gz {
  color: #c0392b;
  font-size: 20px;
  letter-spacing: 3px;
}
body.bzr-paper-mode .bzr-pillars { border-top: 1px solid #d9b8a0; border-bottom: 1px solid #d9b8a0; padding: 8px 0; }
body.bzr-paper-mode .bzr-pillar { border: 1px solid #e0c5b3; background: #fffaf3; }
body.bzr-paper-mode .bzr-ss-mark { color: #c0392b; }
body.bzr-paper-mode .bzr-radar { background: #fffaf3; border-color: #e0c5b3; }
body.bzr-paper-mode .bzr-ln-table th { background: #f6e6d8; }
body.bzr-paper-mode .bzr-ln-table, body.bzr-paper-mode .bzr-ln-table th, body.bzr-paper-mode .bzr-ln-table td { border-color: #e0c5b3; }
.bzr-paper-btn { margin-left: 10px; padding: 4px 12px; border: 1px solid #c0392b; background: #c0392b; color: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }

/* 手抄本馆 */
#manuscriptsView { flex-direction: column; }
#manuscriptsView .sec-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
#manuscriptsView .hint-text { color: #888; font-size: 13px; margin-left: 8px; }
.ms-item { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: box-shadow .2s, transform .1s; display: flex; flex-direction: column; }
.ms-item:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-2px); }
.ms-thumb { height: 140px; background: #f7f4ef; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ms-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ms-file { flex-direction: column; gap: 6px; }
/* 手抄本文件类型徽章（替代 emoji，跨设备一致） */
.ms-type-badge { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; }
.ms-type-ext { font-size: 28px; font-weight: 800; letter-spacing: 1px; color: #fff; background: #888; border-radius: 8px; padding: 6px 12px; line-height: 1; }
.ms-type-label { font-size: 13px; color: #555; }
.ms-type-badge.ms-big .ms-type-ext { font-size: 46px; padding: 14px 22px; }
.ms-type-badge.ms-big .ms-type-label { font-size: 16px; margin-top: 8px; }
.ms-k-img   .ms-type-ext { background: #2e8b57; }
.ms-k-pdf   .ms-type-ext { background: #c0392b; }
.ms-k-doc   .ms-type-ext { background: #2b6cb0; }
.ms-k-txt   .ms-type-ext { background: #6b7280; }
.ms-k-zip   .ms-type-ext { background: #d68910; }
.ms-k-other .ms-type-ext { background: #777; }
.ms-meta { padding: 10px 12px; flex: 1; }
.ms-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.ms-size { font-size: 12px; color: #888; margin-top: 4px; }
.ms-actions { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--border); }
.ms-actions .small { flex: 1; }
.ms-download-card { background: var(--card); border-radius: 12px; padding: 30px 40px; text-align: center; }
.ms-ico-big { font-size: 64px; }
.ms-dn-name { font-size: 18px; margin: 12px 0 4px; color: var(--ink); }
.ms-dn-size { color: #888; margin-bottom: 16px; }

/* 八字仅年柱提示 */
.bz-partial-tip { color: #999; font-size: 13px; font-style: italic; }

/* ===== 八字全盘详解页（白名单自填推算） ===== */
.bazi-page { max-width: 960px; margin: 0 auto 48px; padding: 18px 20px; }
.bazi-page-head h2 { font-size: 22px; color: var(--accent); margin: 0 0 6px; }
.bazi-page-desc { color: var(--sub); font-size: 14px; line-height: 1.75; margin: 0 0 18px; }
.bazi-page-desc b { color: var(--ink); }
.bazi-form { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.bf-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.bf-row label { display: flex; flex-direction: column; font-size: 13px; color: var(--sub); gap: 5px; flex: 1; min-width: 120px; }
.bf-row input, .bf-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; background: var(--bg); color: var(--ink); }
.bf-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.bazi-form button { background: var(--bg); border: 1px solid var(--border); padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 15px; color: var(--ink); transition: background .15s, opacity .15s; }
.bazi-form button:hover { background: var(--hover); }
.bazi-form .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.bazi-form .primary:hover { opacity: .9; }
.bz-warn { color: #b23a3a; background: #fbeaea; border: 1px solid #e7b7b7; padding: 10px 14px; border-radius: 8px; margin-top: 14px; }
.bazi-result { margin-top: 18px; }
.bazi-result .bzr-name-badge { font-size: 14px; color: var(--accent); margin-bottom: 10px; font-weight: 600; }
.bazi-whitelist { margin-top: 28px; }
.bazi-whitelist h3 { font-size: 16px; color: var(--accent); margin: 0 0 10px; }
.bz-wl-list { display: flex; flex-direction: column; gap: 8px; }
.bz-wl-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.bz-wl-info { font-size: 14px; }
.bz-wl-info b { color: var(--ink); }
.bz-wl-info .meta { color: var(--sub); font-size: 12px; margin-left: 8px; }
.bz-wl-actions { display: flex; gap: 8px; flex-shrink: 0; }
.bz-wl-actions button { font-size: 13px; padding: 5px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; color: var(--ink); }
.bz-wl-actions .bz-wl-load { background: var(--accent); color: #fff; border-color: var(--accent); }
.bz-wl-empty { color: var(--sub); font-size: 13px; }
@media (max-width: 720px) {
  .bf-row label { min-width: 44%; }
  .bz-wl-item { flex-direction: column; align-items: flex-start; }
  .bz-wl-actions { width: 100%; }
  .bz-wl-actions button { flex: 1; }
}

/* ===== 导出范围（族谱分图）弹窗 ===== */
#exportScopeModal .form-row { margin: 8px 0; font-size: 14px; color: var(--ink); }
#exportScopeModal .form-row label { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
#exportScopeModal input[type="radio"] { width: auto; margin: 0; }
#exportScopeModal #expGenBox, #exportScopeModal #expBranchBox { padding-left: 4px; border-left: 2px solid var(--border); }
#exportScopeModal .expGenRow, #exportScopeModal .expBranchRow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 6px 0; font-size: 13px; color: var(--sub); }
#exportScopeModal .expGenRow input, #exportScopeModal .expBranchRow input, #exportScopeModal .expBranchRow select {
  width: auto; padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--bg); color: var(--ink);
}
#exportScopeModal .expGenRow .expGenFrom, #exportScopeModal .expGenRow .expGenTo { width: 56px; }
#exportScopeModal .expGenRow button, #exportScopeModal .expBranchRow button {
  width: 26px; height: 26px; border: 1px solid var(--border); background: var(--bg); border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1; color: var(--ink);
}
#exportScopeModal .expGenRow .expGenAdd { color: var(--accent); }
#exportScopeModal .expBranchRow .expBranchFocus { min-width: 130px; }
#exportScopeModal hr { border: none; border-top: 1px solid var(--border); }
#exportScopeModal .form-actions .btn { background: var(--bg); border: 1px solid var(--border); padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--ink); }
#exportScopeModal .form-actions .btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
