: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; }
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 .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); }
.link, .spouse-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; }
.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); }

/* 族务人员 */
.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); }
.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); }

/* 摄像头拍照弹窗 */
#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-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; }
/* 用伪元素搭一座「桥」，让鼠标从按钮滑向下拉时不会经过 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; }

/* 中式大号牌位（参考豆包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; }

/* ===== 密码锁屏 ===== */
.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; }

/* ===== 相片 / 媒体辅助 ===== */
.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; }

  /* 触摸目标加高，便于手指点按 */
  .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%; }
  .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; }

/* ===== 手机版补充适配（窄屏 ≤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: 8px; right: 8px; max-height: 62vh; overflow: auto; box-shadow: 0 8px 22px rgba(0,0,0,0.35); }

  /* 表单控件触控友好 + 防止 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; }
.btn-primary { 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); }
.btn-primary:hover { filter: brightness(1.05); }
.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; }
.btn-ghost:hover { background: rgba(184,136,17,.08); }
.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; }

/* ===== 登录 / 注册 弹窗 ===== */
.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; }
}
