
/* ============================================================
   晚晴计划 v2 前端 —— 小程序风格 · 适老化 · 五模块
   数据唯一源：后端 API（localStorage 仅存登录 token）
   适老化：字号≥20px / 按钮高≥48px / 点击区≥44px / 对比度≥4.5:1
   ============================================================ */
:root {
  /* 对比度已按 WCAG 2.1 AA 校核（正文 ≥4.5:1，见 test/a11y.test.js 自动校验）
     --accent 由 #c96a22 调整为 #a8531a：白字按钮对比度 3.76:1 → 5.37:1 */
  --primary: #1a3a5c; --accent: #a8531a; --green: #177a40;
  --bg: #f5f0e8; --card: #fff; --text: #2b2b2b; --sub: #57534e;
  --danger: #b03a2e; --line: #cfc7b8; --line-strong: #8f8677; --tab: #5f5a51;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 20px; line-height: 1.6; color: var(--text); background: var(--bg); }
.app { max-width: 480px; height: 100%; margin: 0 auto; position: relative; overflow: hidden; background: var(--bg); box-shadow: 0 0 24px rgba(0,0,0,.12); }
.view { position: absolute; inset: 0; display: none; flex-direction: column; }
.view.active { display: flex; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card { background: var(--card); border-radius: 16px; padding: 20px; margin: 12px 16px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.btn { display: block; width: 100%; min-height: 52px; border: none; border-radius: 12px; font-size: 21px; font-weight: 600; color: #fff; background: var(--primary); cursor: pointer; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); opacity: .85; }
.btn.accent { background: var(--accent); }
.btn.green { background: var(--green); }
.btn.ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn.sm { min-height: 48px; font-size: 18px; width: auto; }
input[type="text"], input[type="password"], input[type="number"], input[type="tel"], textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; font-size: 20px;
  border: 2px solid var(--line-strong); border-radius: 12px; background: #fff;
  transition: border-color .2s, transform .2s, box-shadow .2s; font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,58,92,.18); transform: scale(1.02); }
label.field { display: block; font-size: 18px; color: var(--sub); margin: 12px 0 6px; }
.error-text { color: var(--danger); font-size: 20px; font-weight: 700; margin-top: 8px; min-height: 28px; }
.muted { color: var(--sub); font-size: 18px; }
.title-lg { font-size: 24px; font-weight: 700; }
.center { text-align: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* 无障碍：动效降级（偏好减少动态效果时停用呼吸动画与过渡） */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
/* 大字体模式（适老化增强）：整体放大 2px */
body.font-lg { font-size: 22px; }
body.font-lg .muted { font-size: 20px; }
body.font-lg .desc { font-size: 17px; }
body.font-lg .module-card span { font-size: 22px; }
body.font-lg .tab-item { font-size: 17px; }
body.font-lg .wi-d { font-size: 17px; }
body.font-lg .type-badge { font-size: 17px; }
body.font-lg .law { font-size: 17px; }
body.font-lg .lbl { font-size: 17px; }
body.font-lg .record-tab { font-size: 19px; }
/* 聊天"正在输入"指示器（P0-2） */
.typing-dots { color: var(--sub); font-style: italic; }
.typing-dots::after { content: '…'; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
/* 记录类型徽标（替代 emoji：语义化颜色区分） */
.type-badge {
  display: inline-block; min-width: 48px; padding: 2px 10px; border-radius: 8px;
  font-size: 16px; font-weight: 700; color: #fff; text-align: center; margin-right: 8px;
}
.type-badge.photo { background: var(--primary); }
.type-badge.video { background: var(--accent); }
.type-badge.text { background: var(--green); }
.lock-mark { color: var(--danger); font-weight: 700; margin-left: 6px; }

/* 登录 */
#view-login { justify-content: center; padding: 30px 26px; background: linear-gradient(160deg, var(--primary) 0%, #2a5078 55%, var(--bg) 55.2%); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { font-size: 34px; color: #fff; letter-spacing: 4px; }
.login-logo p { color: rgba(255,255,255,.9); font-size: 18px; margin-top: 6px; }
.login-card { background: #fff; border-radius: 20px; padding: 26px 22px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 74px; }
.pwd-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); min-width: 60px; min-height: 48px; background: none; border: none; font-size: 18px; color: var(--primary); cursor: pointer; }
.link-btn { background: none; border: none; color: var(--primary); font-size: 19px; text-decoration: underline; cursor: pointer; margin-top: 12px; }

/* 主页 */
.home-main { flex: 1; overflow-y: auto; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .3s ease; }
.welcome { background: var(--primary); color: #fff; border-radius: 0 0 24px 24px; padding: 26px 20px 32px; }
.welcome .greet { font-size: 17px; opacity: .9; }
.welcome h2 { font-size: 28px; margin: 4px 0 8px; }
.module-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px; }
.module-card { background: #fff; border-radius: 16px; padding: 18px 12px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.06); cursor: pointer; min-height: 118px; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .12s; border-top: 5px solid var(--primary); }
.module-card:nth-child(2) { border-top-color: var(--accent); }
.module-card:nth-child(3) { border-top-color: var(--green); }
.module-card:nth-child(4) { border-top-color: var(--accent); }
.module-card:nth-child(5) { border-top-color: var(--primary); }
.module-card:active { transform: scale(.96); }
.module-card .ic { margin-bottom: 6px; }
.module-card .ic svg { width: 30px; height: 30px; fill: var(--primary); }
.module-card:nth-child(2) .ic svg { fill: var(--accent); }
.module-card:nth-child(3) .ic svg { fill: var(--green); }
.module-card:nth-child(4) .ic svg { fill: var(--accent); }
.module-card:nth-child(5) .ic svg { fill: var(--primary); }
.module-card span { font-size: 20px; font-weight: 600; }
.module-card .desc { font-size: 16px; color: var(--sub); margin-top: 2px; }

/* 密录 */
.will-item { background: #fff; border-radius: 16px; padding: 16px; margin: 12px 16px; box-shadow: 0 2px 6px rgba(0,0,0,.05); border-left: 6px solid var(--accent); }
.will-item .wi-t { font-size: 20px; font-weight: 600; }
.will-item .wi-d { font-size: 16px; color: var(--sub); margin-top: 2px; white-space: pre-wrap; }
.will-item .ops { display: flex; gap: 10px; margin-top: 10px; }
.will-item .ops .btn { flex: 1; min-height: 48px; font-size: 18px; margin: 0; }
.record-tabs { display: flex; gap: 8px; margin: 12px 16px 0; }
.record-tab { flex: 1; min-height: 48px; border: 2px solid var(--line-strong); border-radius: 12px; font-size: 18px; background: #efe9dd; color: var(--sub); cursor: pointer; }
.record-tab.active { background: var(--primary); color: #fff; font-weight: 700; }

/* AI 对话 */
.chat-box { height: 42vh; min-height: 280px; overflow-y: auto; padding: 14px; background: var(--card); border-radius: 16px; margin: 12px 16px; }
.msg { margin-bottom: 13px; display: flex; }
.msg .bubble { max-width: 82%; padding: 12px 16px; border-radius: 14px; font-size: 19px; line-height: 1.5; white-space: pre-wrap; }
.msg.ai { justify-content: flex-start; }
.msg.ai .bubble { background: #e9eef5; border-top-left-radius: 4px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.chat-input-wrap { display: flex; gap: 10px; padding: 0 16px; }
.chat-input-wrap input { flex: 1; }
.icon-btn { min-width: 52px; min-height: 52px; border: none; border-radius: 12px; background: var(--accent); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 26px; height: 26px; fill: #fff; }
.chat-mode-tabs { display: flex; gap: 8px; margin: 12px 16px 0; }

/* 介绍/遗嘱指引 */
.value-card { background: #fff; border-radius: 16px; padding: 20px; margin: 12px 16px; border-top: 5px solid var(--primary); }
.value-card h3 { font-size: 21px; color: var(--primary); margin-bottom: 6px; }
.form-card { background: #fff; border-radius: 16px; padding: 18px; margin: 12px 16px; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.form-card h4 { font-size: 20px; color: var(--primary); }
.form-card .law { font-size: 16px; color: var(--sub); }
.tip-card { border-left: 5px solid var(--danger); }

/* 我的 */
.avatar { width: 92px; height: 92px; border-radius: 50%; margin: 18px auto 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 38px; font-weight: 700; }
.profile-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 20px; }
.profile-row .k { color: var(--sub); }
.admin-entry { margin-top: 24px; border-top: 2px dashed #c8c2b8; padding-top: 16px; text-align: center; }

/* 底部导航 */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; height: 70px; background: #fff; border-top: 1px solid var(--line); display: flex; align-items: stretch; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
.tab-item { flex: 1; background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--tab); font-size: 17px; min-height: 48px; }
.tab-item svg { width: 24px; height: 24px; fill: currentColor; }
.tab-item.active { color: var(--primary); font-weight: 700; }
.tab-enter { flex: 0 0 84px; position: relative; background: none; border: none; cursor: pointer; }
.tab-enter .circle { position: absolute; left: 50%; top: -22px; transform: translateX(-50%); width: 60px; height: 60px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 700; letter-spacing: 2px; box-shadow: 0 6px 16px rgba(39,174,96,.4); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: translateX(-50%) scale(1); box-shadow: 0 6px 16px rgba(39,174,96,.4); } 50% { transform: translateX(-50%) scale(1.08); box-shadow: 0 8px 24px rgba(39,174,96,.55); } }

/* 管理员 */
.admin-head { background: var(--primary); color: #fff; padding: 18px; display: flex; justify-content: space-between; align-items: center; padding-right: 205px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 16px; }
.stat-card { background: #fff; border-radius: 16px; padding: 16px 10px; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.stat-card .num { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-card .lbl { font-size: 16px; color: var(--sub); }
.table-wrap { background: #fff; border-radius: 16px; margin: 12px 16px; padding: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 17px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #eee; }
th { color: var(--sub); font-size: 16px; }

/* 弹窗 */
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 20px; width: 86%; max-height: 80%; overflow-y: auto; padding: 24px 20px; animation: fadeIn .25s ease; }
.modal h3 { font-size: 23px; margin-bottom: 12px; padding-right: 44px; }

/* ============================================================
   响应式：桌面端（≥768px）—— 手机 App 容器居中呈现
   设计原则：以手机为第一目标，桌面端呈现"手机容器"（居中+投影圆角）
   ============================================================ */
@media (min-width: 768px) {
  /* 桌面背景：暖灰渐变，衬托手机容器 */
  body { display: flex; align-items: center; justify-content: center; padding: 24px 0; background: linear-gradient(160deg, #e9edf3 0%, #f0eadf 60%, #f5f0e8 100%); }
  /* 手机容器：480px 恒定 + 圆角投影（模拟手机设备） */
  .app { max-width: 480px; width: 480px; height: calc(100vh - 48px); border-radius: 32px; box-shadow: 0 24px 60px rgba(26,58,92,.22), 0 4px 16px rgba(26,58,92,.12); }

  /* 弹窗：容器内保持手机比例 */
  .modal { width: 86%; }
}

/* ============================================================
   吸顶工具条：模式切换 / 通知 / 无障碍
   统一顶部条带定位（不再绝对定位散落），内容自动避让（padding-top）
   ============================================================ */
.top-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  height: 52px; display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 0 10px;
  background: linear-gradient(180deg, rgba(26,58,92,.18) 0%, rgba(26,58,92,0) 100%);
  pointer-events: none;   /* 条带本身不拦截点击，仅按钮可点 */
}
.top-bar button { pointer-events: auto; }

.mode-switch {
  min-height: 36px; padding: 4px 16px; border-radius: 18px;
  background: #fff; color: var(--primary); border: 2px solid var(--primary);
  font-size: 15px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  transition: transform .1s, opacity .2s;
}
.mode-switch:active { transform: scale(.95); }
/* 标准版下按钮反色（深底白字，与浅色内容区形成反差） */
body.std .mode-switch { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 通知铃铛 */
.bell-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.bell-btn svg { width: 20px; height: 20px; fill: var(--primary); }
body.std .bell-btn { background: var(--primary); }
body.std .bell-btn svg { fill: #fff; }
.bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.bell-btn:active { transform: scale(.94); }

/* 无障碍按钮（文字版：与模式切换按钮同款胶囊） */
.a11y-btn {
  min-height: 36px; padding: 4px 16px; border-radius: 18px;
  background: #fff; color: var(--primary); border: 2px solid var(--primary);
  font-size: 15px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  transition: transform .1s, opacity .2s;
}
body.std .a11y-btn { background: var(--primary); color: #fff; border-color: var(--primary); }
.a11y-btn:active { transform: scale(.94); }

/* 内容避让：各视图顶部为工具条让出 52px 安全区 */
.home-main { padding-top: 52px; scroll-padding-top: 56px; }
#view-login { padding-top: 78px; }
.admin-head { padding-top: 64px; padding-right: 18px; }
/* 注意：必须保留 padding-top，否则返回/列表按钮会被顶部工具条压住导致点不到 */
.gen-head { padding-top: 64px; }

/* 轻提示（独立图层，不占用弹窗容器）：校验类提示不再清空表单 */
.toast-layer {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(12px);
  max-width: min(86vw, 420px); padding: 14px 20px; border-radius: 14px;
  background: rgba(26,58,92,.94); color: #fff; font-size: 18px; line-height: 1.5;
  text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  z-index: 400; word-break: break-word;
}
.toast-layer.show { opacity: 1; transform: translateX(-50%) translateY(0); }
body.std .toast-layer { font-size: 15px; padding: 10px 16px; bottom: 76px; }

/* 弹窗关闭按钮：所有弹窗均可关闭（键盘/读屏用户不再被困住） */
.modal { position: relative; }
.modal-close {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px;
  border: none; border-radius: 50%; background: #f1ece2; color: var(--primary);
  font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer;
}
.modal-close:active { transform: scale(.94); }
.modal-body { padding-top: 4px; }

/* ============================================================
   无障碍基础设施：读屏专用文本 / 跳转链接 / 关怀模式开关 / 录音态
   ============================================================ */
/* 视觉隐藏但对读屏可见（h1、实时播报区） */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* 键盘用户按 Tab 第一个就能跳过工具条直达正文 */
.skip-link {
  position: absolute; left: 50%; top: -60px; transform: translateX(-50%);
  z-index: 500; padding: 10px 18px; border-radius: 0 0 12px 12px;
  background: var(--primary); color: #fff; font-size: 17px; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; outline: 3px solid var(--accent); outline-offset: 2px; }
/* 关怀模式总开关（顶部工具条最左侧，老人一眼可见） */
.care-btn {
  min-height: 36px; padding: 4px 14px; margin-right: auto; border-radius: 18px;
  background: #fff; color: var(--primary); border: 2px solid var(--primary);
  font-size: 15px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.care-btn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.care-btn:active { transform: scale(.94); }
body.std .care-btn { background: var(--primary); color: #fff; }
body.std .care-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

/* 朗读逐句高亮：与服务端合成的分段一一对应（原文本不变，可复制、可被读屏读取） */
.tts-seg { border-radius: 6px; transition: background-color .15s ease, color .15s ease; }
.tts-seg.tts-speaking { background: rgba(168, 83, 26, .22); box-shadow: 0 0 0 2px rgba(168, 83, 26, .22); }
body.hc .tts-seg.tts-speaking { background: #000; color: #fff; }
.msg.user .bubble .tts-seg.tts-speaking { background: rgba(255,255,255,.28); color: #fff; }


/* 本条音频不可用标记（只标注，不影响文字与其它功能） */
.tts-unavailable {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 8px;
  font-size: 13px; color: var(--sub); background: #eee7db; border: 1px solid var(--line-strong);
}
.speak-mini.tts-off { opacity: .6; border-style: dashed; }
body.hc .tts-unavailable { background: #fff; color: #000; border: 1px solid #000; }

/* 语音输入录音中：按钮高亮 + 呼吸提示 */
.icon-btn.recording { background: var(--danger); animation: recPulse 1.2s ease-in-out infinite; }
@keyframes recPulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
/* 高对比度模式下确保按钮/焦点仍清晰可辨 */
body.hc .care-btn { border-color: #000; background: #000; color: #fff; }
body.hc .care-btn[aria-pressed="true"] { background: #fff; color: #000; }
body.hc .toast-layer { background: #000; border: 2px solid #fff; }
body.hc .skip-link { background: #000; color: #fff; }
/* 系统级"增强对比度"偏好 */
@media (prefers-contrast: more) {
  :root { --sub: #3f3b36; --line: #8a8478; --tab: #3f3b36; }
  .btn.ghost { border-width: 3px; }
}

/* 朗读小按钮（AI 消息/档案弹窗内） */
.speak-mini {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px; padding: 2px 12px; margin-left: 8px;
  border: 1.5px solid var(--primary); border-radius: 16px;
  background: #fff; color: var(--primary); font-size: 13px; font-weight: 600; cursor: pointer;
}
.speak-mini:active { transform: scale(.96); }
body.std .speak-mini { min-height: 26px; font-size: 12px; }
.speak-mini.speaking { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 高对比度模式（body.hc）：视障增强，黑白高对比 */
body.hc {
  --primary: #000; --accent: #000; --green: #000; --danger: #000;
  --bg: #fff; --card: #fff; --text: #000; --sub: #1a1a1a;
  --line: #000; --line-strong: #000; --tab: #000;
}
body.hc .welcome { background: #000; }
body.hc .type-badge { background: #000; }
body.hc .welcome .greet { opacity: 1; }
body.hc .mode-switch { border-width: 2px; box-shadow: none; }
body.hc .tabbar { border-top-width: 2px; }

/* 功能中心（我的页）：网格入口 */
.func-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.func-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 72px; padding: 10px 6px; border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: #fbfaf6; cursor: pointer; transition: transform .1s, border-color .2s;
}
.func-btn b { font-size: 16px; color: var(--primary); }
.func-btn span { font-size: 12px; color: var(--sub); }
.func-btn:active { transform: scale(.96); }
.func-btn:hover { border-color: var(--primary); }
body.std .func-btn b { font-size: 14px; }
body.std .func-btn span { font-size: 11px; }
body.std .func-btn { min-height: 60px; }
@media (min-width: 768px) { .func-grid { grid-template-columns: repeat(3, 1fr); max-width: 900px; } }

/* 家系图（家族树）：辈分纵向、同辈横向、连线连接父子 */
.gtree { overflow-x: auto; padding: 14px 4px 6px; }
.gtree-root { display: flex; flex-direction: column; align-items: center; margin: 0 auto; }
.gtree-node {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 96px; padding: 8px 12px; border-radius: 12px;
  background: #fbfaf6; border: 1.5px solid var(--primary); position: relative;
}
.gtree-node .gn-name { font-size: 16px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.gtree-node .gn-life { font-size: 12px; color: var(--sub); }
.gtree-node .gn-note { font-size: 12px; color: var(--sub); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.std .gtree-node { min-width: 84px; padding: 6px 10px; }
body.std .gtree-node .gn-name { font-size: 14px; }
body.std .gtree-node .gn-life, body.std .gtree-node .gn-note { font-size: 11px; }
.gtree-children { display: flex; justify-content: center; gap: 18px; position: relative; margin-top: 16px; padding: 0 4px; }
/* 横线：连接所有子节点 */
.gtree-children::before { content: ''; position: absolute; top: -8px; left: 4%; right: 4%; height: 2px; background: #c8c2b8; }
/* 竖线：父节点下方到横线 */
.gtree-root > .gtree-node::after { content: ''; position: absolute; top: 100%; left: 50%; width: 2px; height: 8px; background: #c8c2b8; }
/* 竖线：横线到子节点 */
.gtree-item { position: relative; display: flex; flex-direction: column; align-items: center; }
.gtree-item::before { content: ''; position: absolute; top: -8px; left: 50%; width: 2px; height: 8px; background: #c8c2b8; }
/* 第一个子节点左侧到横线起点的短横（补全连接） */
.gtree-item:first-child::after { content: ''; position: absolute; top: -8px; right: 50%; width: 50%; height: 2px; background: #c8c2b8; }
.gtree-item:last-child::after { content: ''; position: absolute; top: -8px; left: 50%; width: 50%; height: 2px; background: #c8c2b8; }
/* 始祖（无父）节点 */
.gtree-root > .gtree-item:first-child::before { display: none; }
.gtree-empty { text-align: center; color: var(--sub); font-size: 15px; padding: 20px 0; }

/* ============================================================
   家系族谱全屏视图：暖色背景 + 精致树形 + 顶部返回
   ============================================================ */
#view-genealogy { background: linear-gradient(180deg, #f6f0e4 0%, #fdfbf6 45%, #f9f4ea 100%); }
.gen-head {
  background: linear-gradient(135deg, var(--primary) 0%, #2a5078 100%);
  color: #fff; padding: 64px 14px 14px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 14px rgba(26,58,92,.18);
  padding-right: 80px;   /* 避开右上角悬浮三按钮 */
}
.gen-main { flex: 1; overflow-y: auto; position: relative; scroll-padding-top: 56px; }
.gen-legend {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 12px; font-size: 13px; color: var(--sub);
  background: rgba(255,255,255,.75); border-bottom: 1px solid rgba(216,203,180,.5);
}
.gen-legend span { display: inline-flex; align-items: center; gap: 5px; }
.gen-legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.gen-scroll { padding: 18px 14px 90px; }
.gen-actions {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px 16px;
  background: linear-gradient(180deg, rgba(249,244,234,0), #f9f4ea 40%);
}
/* 节点美化：渐变卡 + 顶部色条 + 辈分徽章 */
.gtree-node {
  background: linear-gradient(180deg, #ffffff 0%, #fdf9f1 100%);
  border: 1.5px solid var(--line-strong);
  border-top: 4px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(26,58,92,.10);
  padding: 8px 12px 6px;
}
.gtree-node.gen2 { border-top-color: var(--accent); }
.gtree-node.gen3 { border-top-color: var(--green); }
.gtree-node .gn-badge {
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--primary); border-radius: 8px; padding: 1px 7px; margin-bottom: 3px;
  letter-spacing: 1px;
}
.gtree-node.gen2 .gn-badge { background: var(--accent); }
.gtree-node.gen3 .gn-badge { background: var(--green); }
.gtree-node .gn-name { font-size: 16px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.gtree-node .gn-life { font-size: 12px; color: var(--sub); }
.gtree-node .gn-note { font-size: 12px; color: var(--sub); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.std .gtree-node { min-width: 84px; padding: 6px 10px; }
body.std .gtree-node .gn-name { font-size: 14px; }
body.std .gtree-node .gn-life, body.std .gtree-node .gn-note { font-size: 11px; }
/* 连线精致化：暖棕 + 圆点 */
.gtree-children::before { background: #cbb99a; }
.gtree-root > .gtree-node::after { background: #cbb99a; }
.gtree-item::before { background: #cbb99a; }
.gtree-item:first-child::after, .gtree-item:last-child::after { background: #cbb99a; }

/* ---------- 标准版（body.std）：全套页面 ---------- */
body.std { font-size: 15px; }

/* 登录 */
body.std #view-login { padding: 40px 20px; background: var(--bg); }
body.std .login-logo { margin-bottom: 16px; }
body.std .login-logo h1 { font-size: 26px; color: var(--primary); letter-spacing: 2px; }
body.std .login-logo p { color: var(--sub); font-size: 14px; }
body.std .login-card { max-width: 400px; margin: 0 auto; padding: 20px; border-radius: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.08); }

/* 卡片 / 按钮 / 表单 */
body.std .card { padding: 14px 16px; margin: 8px 12px; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
body.std .btn { min-height: 42px; font-size: 15px; border-radius: 8px; }
body.std .btn.sm { min-height: 36px; font-size: 14px; }
body.std .btn.ghost { border-width: 1.5px; }
body.std input[type="text"], body.std input[type="password"], body.std input[type="number"], body.std input[type="tel"], body.std textarea {
  min-height: 42px; padding: 8px 12px; font-size: 15px; border-radius: 8px; border-width: 1.5px;
}
body.std label.field { font-size: 13px; margin: 8px 0 4px; }
body.std .muted { font-size: 13px; }
body.std .title-lg { font-size: 19px; }
body.std .error-text { font-size: 15px; }

/* 欢迎区 */
body.std .welcome { padding: 18px 20px 22px; border-radius: 0 0 16px 16px; }
body.std .welcome h2 { font-size: 22px; margin: 2px 0 4px; }
body.std .welcome .greet { font-size: 13px; }

/* 首页模块网格：3 列紧凑（桌面 5 列） */
body.std .module-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 12px; }
body.std .module-card { min-height: 88px; padding: 12px 8px; border-radius: 12px; border-top-width: 3px; }
body.std .module-card span { font-size: 15px; }
body.std .module-card .desc { font-size: 12px; }
body.std .module-card .ic { margin-bottom: 4px; }
body.std .module-card .ic svg { width: 22px; height: 22px; }

/* 密录 */
body.std .will-item { padding: 12px 14px; margin: 8px 12px; border-radius: 12px; border-left-width: 4px; }
body.std .will-item .wi-t { font-size: 15px; }
body.std .will-item .wi-d { font-size: 13px; }
body.std .will-item .ops { gap: 8px; margin-top: 8px; }
body.std .will-item .ops .btn { min-height: 36px; font-size: 14px; }
body.std .record-tab { min-height: 38px; font-size: 14px; border-radius: 8px; }
body.std .type-badge { font-size: 12px; min-width: 38px; padding: 1px 8px; margin-right: 6px; }

/* AI 对话 */
body.std .chat-box { height: 45vh; min-height: 240px; border-radius: 12px; margin: 8px 12px; padding: 10px; }
body.std .msg { margin-bottom: 8px; }
body.std .msg .bubble { font-size: 15px; padding: 8px 12px; border-radius: 10px; }
body.std .chat-input-wrap { padding: 0 12px; gap: 8px; }
body.std .chat-input-wrap input { flex: 1; }
body.std .icon-btn { min-width: 42px; min-height: 42px; border-radius: 8px; }
body.std .chat-mode-tabs { margin: 8px 12px 0; }

/* 介绍 / 表单 */
body.std .value-card { padding: 14px 16px; margin: 8px 12px; border-radius: 12px; border-top-width: 3px; }
body.std .value-card h3 { font-size: 17px; }
body.std .form-card { padding: 12px 14px; margin: 8px 12px; border-radius: 10px; }
body.std .form-card h4 { font-size: 16px; }
body.std .form-card .law { font-size: 13px; }

/* 我的 */
body.std .avatar { width: 64px; height: 64px; font-size: 26px; margin: 12px auto 6px; }
body.std .profile-row { font-size: 15px; padding: 10px 0; }

/* 底部导航：更窄更高密度 */
body.std .tabbar { height: 54px; }
body.std .tab-item { font-size: 12px; min-height: 40px; gap: 1px; }
body.std .tab-item svg { width: 20px; height: 20px; }
body.std .tab-enter .circle { width: 46px; height: 46px; font-size: 14px; top: -16px; }

/* 管理员 */
body.std .stat-grid { gap: 8px; margin: 10px 12px; }
body.std .stat-card { padding: 12px 8px; border-radius: 12px; }
body.std .stat-card .num { font-size: 24px; }
body.std .stat-card .lbl { font-size: 12px; }
body.std table { font-size: 13px; }
body.std th { font-size: 12px; }
body.std .table-wrap { margin: 8px 12px; border-radius: 12px; }

/* 弹窗：更窄更紧凑 */
body.std .modal { width: 92%; max-width: 560px; border-radius: 14px; padding: 18px 16px; }
body.std .modal h3 { font-size: 18px; }
body.std .modal .btn { min-height: 38px; font-size: 14px; }
body.std .modal input, body.std .modal textarea { min-height: 38px; font-size: 14px; padding: 6px 10px; }
body.std .modal .field { font-size: 13px; }

/* 标准版桌面端：同样为手机容器内布局（容器居中由全局规则处理） */
@media (min-width: 768px) {
  body.std .func-grid { max-width: 100%; }
}
