﻿/* ============================================================================
   慢慢讲 · 长辈视觉系统（v1.0）
   ----------------------------------------------------------------------------
   设计前提：主用户 60–95 岁，老花眼、手抖、不熟悉智能手机，只用手机竖屏、
   家里光线可能很亮。他们打开网页只会做一件事——看见大按钮，按下去说话。
   所以：单屏、一个字都不能小、状态必须"图标 + 文字 + 形态"三重表达，
   不靠颜色区分类别，不出现需要滑动的长列表，所有可点区域 ≥56px。

   调色（对比度按 WCAG 2.1 实算，详见文末自检表）：
     暖纸底 #FBF6EC · 深墨字 #241F19（15.2:1）
     温红行动色 #9C2A20（白字 7.6:1，红字印在纸底 7.1:1）
     深绿成功色 #1F5B3A（纸底 7.5:1）
   不使用任何外部字体 / CDN：国内加载快、断网也能看，PWA 离线可用。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计变量
   -------------------------------------------------------------------------- */
:root {
  /* 纸与墨 */
  --paper: #FBF6EC;          /* 暖纸底 */
  --paper-2: #F3E9D7;        /* 略深的纸，用于分区/选中 */
  --card: #FFFCF6;           /* 卡片，比纸面更亮一点 */
  --ink: #241F19;            /* 深墨正文 */
  --ink-2: #4A4238;          /* 次要文字（纸底 9.2:1，仍远高于 7:1） */

  /* 行动色：加深到 #9C2A20，保证白字与红字两个方向都 ≥7:1 */
  --red: #9C2A20;
  --red-deep: #7C1F17;
  --red-warm: #B3352B;       /* 只用于装饰描边，不承载小字 */
  --red-wash: #F6E2DC;

  /* 成功 / 提示 */
  --green: #1F5B3A;          /* 纸底 7.5:1，白字 8.0:1 */
  --green-wash: #E1EDE3;

  /* 线与焦点 */
  --line: #D9CCB6;           /* 纯装饰分隔线 */
  --line-strong: #8C7A5E;    /* 交互控件边框（纸底 3.9:1 ≥ 3:1） */
  --focus: #12496E;          /* 焦点环，深蓝与暖色系区分明显 */

  /* 圆角 / 间距 */
  --r-lg: 1.4rem;
  --r-md: 1rem;
  --r-sm: .6rem;

  /* 字体栈：全国产系统字体，离线可用，无 CDN */
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Noto Sans CJK SC", system-ui, sans-serif;
  /* 标题用宋体，有回忆录的书卷气；安卓无宋体时回落到系统黑体，不影响可读性 */
  --font-title: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC",
                "Source Han Serif SC", var(--font);

  color-scheme: light;
  accent-color: var(--green);
}

/* --------------------------------------------------------------------------
   2. 基础重置与排版
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

/* 用 125% 而不是写死 20px：系统字号放大时（无障碍设置）整页仍然等比放大 */
html {
  font-size: 125%;                 /* 16 × 1.25 = 20px 正文 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 1rem;                 /* 20px */
  line-height: 1.6;                /* 行高 ≥1.6 */
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* JS 用 hidden 属性切屏；这条必须放在所有 display 规则之后也不被覆盖 */
[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: .01em; text-wrap: balance; }
p, ol, ul, dl, dd, figure { margin: 0; }
button, input, select, textarea { font-family: inherit; }
svg { overflow: visible; }
audio { display: none; }

/* 纯给读屏器看的说明 */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   3. 应用外壳：一个屏幕、不滚动、适配安全区
   -------------------------------------------------------------------------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;                  /* 手机地址栏收放不跳动 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

/* 屏幕：默认全部关闭；由 #app[data-screen] 兜底，JS 再用 hidden 精确切换。
   两套机制同时生效 = 首屏不会闪出五个屏幕叠在一起。 */
.screen {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;                /* 正常字号下内容放得下，不会出现滚动 */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#app[data-screen="welcome"] #screen-welcome,
#app[data-screen="talk"]    #screen-talk,
#app[data-screen="review"]  #screen-review,
#app[data-screen="rest"]    #screen-rest,
#app[data-screen="family"]  #screen-family { display: flex; }

/* 家人区是唯一允许滚动的屏幕，滚动条要看得见（长辈用指针设备时是重要线索） */
.screen-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.screen-scroll::-webkit-scrollbar { width: 12px; }
.screen-scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 12px;
  border: 3px solid var(--paper);
}

/* --------------------------------------------------------------------------
   4. 通用按钮：所有文字 ≥26px，可点区 ≥56px，状态不靠颜色
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: max(3rem, 60px);             /* 60px ≥ 56；px 兜底，防止窄屏 rem 被缩小时掉到 56 以下 */
  padding: .55rem 1.25rem;
  border: 2.5px solid transparent;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.3rem;                      /* 26px */
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease,
              background-color .12s ease, border-color .12s ease;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn:disabled { opacity: .62; cursor: progress; }
.btn:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

/* 主行动：暖红实心 + 底部厚度，按下"陷下去"的物理反馈 */
.btn-primary {
  background: var(--red);
  color: #FFF8F0;                         /* 对 #9C2A20 为 7.6:1 */
  border-color: var(--red);
  box-shadow: 0 5px 0 var(--red-deep), 0 10px 22px rgba(124, 31, 23, .22);
}
.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--red-deep), 0 4px 10px rgba(124, 31, 23, .2);
}

/* 次行动：白底红描边红字（红字纸底 7.1:1），形状与主按钮明显不同 */
.btn-secondary {
  background: var(--card);
  color: var(--red-deep);
  border-color: var(--red);
  box-shadow: 0 3px 0 rgba(124, 31, 23, .18);
}
.btn-secondary:active { transform: translateY(3px); box-shadow: none; }

/* 文字按钮：下划线是"可点"的非颜色线索 */
.btn-text {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  text-decoration: underline;
  text-decoration-thickness: 2.5px;
  text-underline-offset: 5px;
  text-decoration-color: var(--line-strong);
}
.btn-text:active { text-decoration-color: var(--red); }

/* 静默按钮（歇会儿 / 返回）：细描边，绝不抢主按钮视线 */
.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line-strong);
  border-width: 2px;
}

.btn-small {
  min-height: max(3.5rem, 56px);           /* 56px 底线，px 兜底 */
  padding: .35rem .9rem;
  font-size: 1.3rem;
}

.btn-big {
  width: 100%;
  min-height: 3.8rem;                     /* 76px */
  font-size: 1.35rem;                     /* 27px */
}

.btn-hero {
  width: 100%;
  max-width: 26rem;
  min-height: 4.4rem;                     /* 88px：欢迎屏唯一的目标 */
  font-size: 1.45rem;                     /* 29px */
}

/* 按钮里的图标：随字号缩放，不单独写死 px */
.ico {
  width: 1.3em;
  height: 1.3em;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   5. 欢迎屏
   -------------------------------------------------------------------------- */
.welcome-wrap {
  margin: auto;
  width: 100%;
  max-width: 30rem;
  padding: clamp(1rem, 5vh, 3rem) 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .85rem;
}

.welcome-title {
  font-family: var(--font-title);
  font-size: clamp(3rem, 12vw, 4rem);     /* 60–80px */
  line-height: 1.12;
  letter-spacing: .14em;
  text-indent: .14em;                     /* 抵消字距造成的视觉偏心 */
  color: var(--ink);
}

/* 本机账号：安静的一行"这是谁的回忆录"，比副标题弱、但比小字显眼 */
.welcome-owner {
  font-size: clamp(22px, 1.02rem + .35vw, 24px);   /* 22–24px */
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: balance;
  margin-top: -.15rem;
}

.welcome-lead {
  font-size: 1.25rem;                     /* 25px */
  line-height: 1.8;
  color: var(--ink);
}

.welcome-note {
  font-size: 1rem;                        /* 20px */
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 22rem;
}

#btn-start { margin-top: .5rem; }

.welcome-foot {
  font-size: 1rem;                        /* 20px：说明性文字也按正文标准 */
  color: var(--ink-2);
  margin-top: .1rem;
}

#btn-welcome-continue {
  margin-top: -.2rem;
  text-decoration-color: var(--line-strong);
}

/* --------------------------------------------------------------------------
   6. 说话屏（核心）
   -------------------------------------------------------------------------- */
.talk-wrap {
  width: 100%;
  max-width: 42rem;
  margin-inline: auto;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .5rem clamp(.9rem, 4vw, 1.5rem) .6rem;
}
/* 说话屏里的每一块都不许被压扁：问题再长，也只会让屏幕整体略高一截，
   不会出现"顶栏被压成一条、文字叠在一起"这种吓人的场面 */
.talk-wrap > * { flex: 0 0 auto; }

.talk-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 3.5rem;
}

.prompt-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .9rem;                       /* 18px 标签 */
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--ink-2);
}
/* 小圆点只是"这是提示语"的装饰，不承载任何状态信息 */
.prompt-label::before {
  content: "";
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--red);
  flex: 0 0 auto;
}

.question {
  margin-top: .15rem;
  font-size: clamp(2rem, 1.72rem + .9vw, 2.4rem);   /* 40–48px，≥32 要求 */
  line-height: 1.45;
  font-weight: 700;
  color: var(--ink);
  text-wrap: balance;
}

.hint {
  margin-top: .35rem;
  min-height: 1.6em;                      /* 预留一行，换文案时不跳动 */
  font-size: 1rem;                        /* 20px */
  line-height: 1.6;
  color: var(--ink-2);
}

/* 录音区：按钮居中，按钮下方文字与计时共用同一格，切换时不跳版 */
.record-zone {
  margin-top: auto;
  margin-bottom: auto;
  padding-top: .3rem;
  display: grid;
  grid-template-rows: auto 2rem;
  justify-items: center;
  align-items: center;
  row-gap: .25rem;
  position: relative;
}

.record-hint,
#recording-time {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  align-self: start;
}

.record-hint {
  font-size: 1rem;                        /* 20px：说明也要看得清 */
  line-height: 1.5;
  color: var(--ink-2);
  text-align: center;
  max-width: 18rem;
}

#recording-time {
  font-size: 1.15rem;                     /* 23px */
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  color: var(--red-deep);
}

/* 主录音按钮：圆形，≥180px，三态（idle / recording / busy）形态可辨 */
.btn-record {
  position: relative;
  width: clamp(180px, 46vmin, 210px);
  height: clamp(180px, 46vmin, 210px);
  padding: 1rem;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: #FFF8F0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  font-family: inherit;
  font-size: 1.3rem;                      /* 26px */
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 6px 0 var(--red-deep),
    0 12px 26px rgba(124, 31, 23, .26),
    inset 0 0 0 5px rgba(255, 248, 240, .24);
  transition: transform .14s ease, box-shadow .14s ease,
              background-color .14s ease, color .14s ease;
}
.btn-record .ico { width: 2.1rem; height: 2.1rem; }
#record-label {
  display: block;
  max-width: 88%;
  font-size: 1.3rem;
}
.btn-record:active { transform: scale(.965); }
.btn-record:focus-visible { outline: 5px solid var(--focus); outline-offset: 6px; }

/* 脉搏环：录音中的"我还在听"= 扩散的描边，不是颜色变化 */
.btn-record::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 3.5px solid var(--red-warm);
  opacity: 0;
  pointer-events: none;
}

body[data-state="listening"] .btn-record::before {
  animation: pulse-ring 2.4s cubic-bezier(.2, .6, .3, 1) infinite;
}

@keyframes pulse-ring {
  0%   { opacity: .7; transform: scale(.94); }
  70%  { opacity: 0;  transform: scale(1.16); }
  100% { opacity: 0;  transform: scale(1.16); }
}

/* 录音中：底色加深 + 外圈实描边 + 文字变成"说完了"，三重可辨 */
.btn-record[data-mode="recording"] {
  background: var(--red-deep);
  box-shadow:
    0 0 0 6px var(--paper),
    0 0 0 10px var(--red),
    0 6px 0 #5C150F,
    0 12px 26px rgba(124, 31, 23, .3);
  transform: scale(1.01);
}

/* 处理中：绿灰底 + 旋转细环 + 文字由 JS 换掉；没有颜色也认得出 */
.btn-record[data-mode="busy"] {
  background: #6B6154;
  color: #FFF8F0;
  cursor: progress;
  box-shadow: 0 4px 0 #4E463C, 0 10px 20px rgba(36, 31, 25, .28);
}
.btn-record[data-mode="busy"]::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 6px solid rgba(255, 248, 240, .26);
  border-top-color: #FFF8F0;
  animation: spin 1.15s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 播放中（助手在说话）：大按钮变成"按下就打断"的浅底红环形态 */
body[data-state="speaking"] .btn-record {
  background: var(--paper);
  color: var(--red-deep);
  box-shadow:
    inset 0 0 0 7px var(--red),
    0 5px 0 rgba(124, 31, 23, .22),
    0 10px 22px rgba(124, 31, 23, .18);
}

/* 实时转写：有字才出现，最多两行，超出裁掉（不出小滚动条，完整内容在核对屏看）。
   flex 不收缩：小屏上宁可整块内容收紧，也不能把这一行压成"半行" */
.live-text {
  flex: 0 0 auto;
  margin-top: .4rem;
  font-size: 1.1rem;                      /* 22px */
  line-height: 1.7;
  color: var(--ink);
  max-height: 5.4rem;
  overflow: hidden;                       /* 不出小滚动条：最多两行，完整内容在核对屏看 */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: break-word;
}
.live-text:not(:empty) {
  padding: .55rem .85rem;
  background: var(--card);
  border-left: 5px solid var(--red);
  border-radius: .3rem .9rem .9rem .3rem;
}

.talk-actions {
  position: sticky;                 /* 问题特别长、屏幕特别矮时，这两个按钮也不许滑出屏幕 */
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .5rem .7rem;
  padding-top: .3rem;
  padding-bottom: calc(.15rem + env(safe-area-inset-bottom));
  background: var(--paper);
  box-shadow: 0 -14px 16px -16px rgba(36, 31, 25, .45);
}

/* 底部两个次要按钮尽量并排一行：多占一行就会把录音键挤小、把屏幕撑高 */
.talk-actions .btn { padding-inline: clamp(.5rem, 2.6vw, 1rem); }
.talk-actions .ico { width: 1.2em; height: 1.2em; }

/* 播放中给"再听一遍"一个明确的进行中形态（绿环 + 文字由 JS 改） */
body[data-state="speaking"] #btn-replay {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 0 4px var(--green-wash);
}

.net-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 2.6rem;
  padding: .15rem .8rem;
  border-radius: 999px;
  background: var(--ink);
  color: #FFF9EE;
  font-size: .95rem;                      /* 19px */
  font-weight: 700;
  white-space: nowrap;
}
/* 感叹号图标 + 文字，不只用颜色表达"没联网" */
.net-badge::before {
  content: "!";
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #F2B33D;
  color: var(--ink);
  font-size: .85rem;
  font-weight: 900;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   7. 核对屏
   -------------------------------------------------------------------------- */
.review-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 40rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: .6rem clamp(.9rem, 4vw, 1.5rem) .8rem;
}

.review-title {
  font-size: clamp(1.7rem, 1.45rem + .9vw, 2.1rem);   /* 34–42px */
  line-height: 1.45;
}

.review-text {
  flex: 0 1 auto;
  min-height: 5rem;
  max-height: 42dvh;
  overflow-y: auto;
  padding: .9rem 1rem;
  background: var(--card);
  border: 2.5px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: 1.15rem;                     /* 23px */
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  /* 底部淡淡淡出：暗示"下面还有，可以往下滑"，而不是硬生生把一行字切一半 */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.9rem), rgba(0, 0, 0, .15));
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1.9rem), rgba(0, 0, 0, .15));
}
.review-text p { margin: 0 0 .6em; }
.review-text p:last-child { margin-bottom: 0; }

.review-edit-zone { margin-top: .2rem; }

.review-edit {
  width: 100%;
  min-height: 9rem;
  padding: .65rem .8rem;
  font-size: 1.15rem;                     /* 23px */
  line-height: 1.7;
  color: var(--ink);
  background: #FFFDF8;
  border: 3px solid var(--line-strong);
  border-radius: var(--r-md);
  resize: vertical;
}
.review-edit:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}

.review-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding-top: .4rem;
}
.review-actions .btn-small { align-self: center; }

/* --------------------------------------------------------------------------
   8. 休息屏
   -------------------------------------------------------------------------- */
.rest-wrap {
  flex: 1 1 auto;
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
  padding: clamp(.8rem, 4vh, 2.2rem) 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .8rem;
}

.rest-title {
  font-family: var(--font-title);
  font-size: clamp(2rem, 1.6rem + 1.2vw, 2.6rem);     /* 40–52px */
  line-height: 1.3;
  letter-spacing: .04em;
}

.rest-lead {
  font-size: 1.15rem;                     /* 23px */
  line-height: 1.75;
  color: var(--ink-2);
}

/* 今天的成果：绿字 + 对勾图标 + 数字，不靠颜色单独表达"成功" */
.rest-stats {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  max-width: 100%;
  padding: .55rem 1rem;
  background: var(--card);
  border: 2.5px solid #BFD8C4;
  border-radius: 999px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green);
  text-align: left;
}
.rest-stats:not(:empty)::before {
  content: "✓";
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: var(--green);
  color: #FFF8F0;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

/* 「家人辅助区」入口：有富余空间时贴到屏幕最下方，不占老人视线中心 */
#btn-family { margin-top: auto; }

/* --------------------------------------------------------------------------
   9. 家人辅助区（信息密度更高，但同样大字、不花哨）
   -------------------------------------------------------------------------- */
.family-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .55rem clamp(.9rem, 4vw, 1.5rem);
  background: var(--paper);
  border-bottom: 2px solid var(--line);
  flex: 0 0 auto;
}

.family-title {
  font-size: 1.4rem;                      /* 28px */
  line-height: 1.3;
}

.family-panel {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  width: 100%;
  max-width: 46rem;
  margin-inline: auto;
  padding: .9rem clamp(.9rem, 4vw, 1.5rem) 2.4rem;
}

/* 分段卡片：家人区用卡片分组，不靠标题层级层层嵌套 */
#family-panel > section,
#family-panel > .family-card,
#family-panel fieldset {
  margin: 0;
  padding: 1rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
}
#family-panel fieldset { min-width: 0; }

/* family.mjs 自带一套很淡的内联样式（.mmj-*），这里统一收进设计系统：
   卡片更厚实、字号更大，长辈家里人看着不费劲 */
#family-panel .mmj-family-zone { gap: .9rem; padding-bottom: 2rem; }
#family-panel .mmj-family-card {
  padding: 1rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
}
#family-panel .mmj-family-lead { font-size: 1rem; color: var(--ink-2); }
#family-panel .mmj-family-meta { font-size: .95rem; color: var(--ink-2); }
#family-panel .mmj-family-warn { font-size: 1rem; }
#family-panel .mmj-family-turn { border-top: 2px solid var(--line); }
#family-panel .mmj-family-turn-text { font-size: 1rem; }
#family-panel .mmj-family-story { border: 2px dashed var(--line-strong); background: var(--card); }

#family-panel h3 {
  font-size: 1.25rem;                     /* 25px */
  line-height: 1.4;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
/* 卡片标题前的红色竖条：纯装饰的视觉锚点 */
#family-panel h3::before {
  content: "";
  flex: 0 0 auto;
  width: .35rem;
  height: 1.15rem;
  border-radius: 2px;
  background: var(--red);
}
#family-panel h4 { font-size: 1.1rem; margin: .8rem 0 .35rem; }

#family-panel p {
  font-size: 1rem;                        /* 20px */
  line-height: 1.7;
  color: var(--ink-2);
}
#family-panel p + p { margin-top: .4rem; }
#family-panel strong { color: var(--ink); }
#family-panel hr {
  border: 0;
  border-top: 2px solid var(--line);
  margin: .8rem 0;
}

#family-panel ul, #family-panel ol {
  padding-left: 1.3rem;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--ink-2);
}
#family-panel li + li { margin-top: .25rem; }

/* 表单：字号 20px、控件高度 ≥48px、触屏友好 */
#family-panel label {
  display: block;
  font-size: .95rem;                      /* 19px */
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .25rem;
}
#family-panel input[type="text"],
#family-panel input[type="number"],
#family-panel input[type="search"],
#family-panel input[type="tel"],
#family-panel select,
#family-panel textarea {
  width: 100%;
  min-height: max(3rem, 56px);            /* 60px；窄屏 rem 缩水时用 px 兜住 56 底线 */
  padding: .35rem .7rem;
  font-family: inherit;
  font-size: max(1.05rem, 20px);          /* 21px；窄屏也不低于 20px */
  line-height: 1.5;
  color: var(--ink);
  background: #FFFDF8;
  border: 2.5px solid var(--line-strong);
  border-radius: .7rem;
}
#family-panel textarea { min-height: 7rem; line-height: 1.6; resize: vertical; }
/* 语速滑杆：family.mjs 里写了内联 min-width:180px / height:48px，
   窄屏与 200% 缩放下会顶出右边界，这里用 !important 收回来并托到 56px */
#family-speed {
  min-width: 0 !important;
  flex: 1 1 6rem;
  max-width: 100%;
  min-height: max(3rem, 56px);
}
#family-panel input:focus-visible,
#family-panel select:focus-visible,
#family-panel textarea:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}
/* 勾选类控件：老人手抖，勾选框本身就要大（48px），整行也可点。
   family.mjs 里给 #family-save-audio 写了内联 width/height:24px，
   这里用 !important 兜底触控尺寸（建议那边改成 class 后去掉内联样式）。 */
#family-panel input[type="checkbox"],
#family-panel input[type="radio"] {
  width: max(2.4rem, 48px) !important;     /* 48px 起（窄屏 html 字号变小时用 px 兜底） */
  height: max(2.4rem, 48px) !important;
  flex: 0 0 auto;
  accent-color: var(--red);
}
#family-panel label:has(> input[type="checkbox"]),
#family-panel label:has(> input[type="radio"]) {
  display: flex;
  flex-wrap: nowrap;                      /* 勾选框和说明文字并排，别把框挤到上一行 */
  align-items: center;
  gap: .6rem;
  min-height: 3rem;                       /* 60px 的行高，整行都能点 */
  margin-bottom: .3rem;
  cursor: pointer;
}
#family-panel label:has(> input[type="checkbox"]) > span,
#family-panel label:has(> input[type="radio"]) > span {
  flex: 1 1 auto;
  min-width: 0;                           /* 让长句子在文字一侧自然换行 */
  line-height: 1.5;
}

/* 家人区按钮：默认样式（.btn 自带样式优先，这里只兜底裸 <button>） */
#family-panel button:not(.btn) {
  min-height: max(3rem, 56px);            /* 56px 底线 */
  padding: .45rem 1rem;
  font-family: inherit;
  font-size: 1.05rem;                     /* 21px */
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2.5px solid var(--line-strong);
  border-radius: .8rem;
  cursor: pointer;
  touch-action: manipulation;
}
#family-panel button:not(.btn):focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}
#family-panel button:disabled { opacity: .6; cursor: progress; }

/* 家人区的 .btn 尺寸：比长辈端略紧凑，但文字仍 ≥22px */
#family-panel .btn {
  min-height: max(3rem, 56px);
  font-size: 1.1rem;
  padding: .4rem 1rem;
  border-radius: .8rem;
}
#family-panel .btn-big { width: 100%; min-height: 3.4rem; }

/* 危险操作：红色 + 明确动词，并且要求二次确认（由 #confirm-sheet 承担） */
#family-panel .danger,
#family-panel button.danger,
#family-panel .btn-danger {
  color: #8E1B12;
  border-color: #8E1B12;
  background: #FFF3F0;
}

/* ---- 本机账号卡（family.mjs 渲染的 [data-section="account"]） ----
   设备即账号：没有密码，所以文案要把「只在本机 / 换手机先导出 / 谁拿到手机都能看」说清楚。 */
#family-panel [data-section="account"] {
  /* 卡片本身沿用 #family-panel > section 的卡片样式，这里只强调它是第一张 */
  border-color: var(--line-strong);
}
#family-panel [data-section="account"] > p {
  font-size: 1rem;                        /* 20px */
  line-height: 1.7;
}
/* 保存名字是这张卡里的主操作：尺寸给足（和家里其它按钮保持同一套白底描边风格） */
#family-account-name {
  min-height: max(3.5rem, 56px);          /* 70px；320 宽 rem 缩水也保 56 */
  font-size: max(1.1rem, 20px);
}
#family-panel #family-account-save {
  min-height: max(3rem, 56px);
  padding: .45rem 1.2rem;
  font-size: max(1.1rem, 20px);           /* 22px */
  font-weight: 700;
}
#family-panel #family-account-save:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}
/* 账号码：看起来像"码"，读得清、报得出来 */
#family-account-code {
  font-family: "SFMono-Regular", Consolas, "Courier New", ui-monospace, monospace;
  font-size: 1.15rem;                     /* 23px */
  letter-spacing: .12em;
  color: var(--ink);
  background: var(--paper-2);
  padding: .05rem .45rem .05rem .55rem;
  border-radius: .4rem;
  white-space: nowrap;
}
/* 状态行由 family.mjs 填；空着的时候不占位 */
#family-account-status { font-size: 1rem; color: var(--ink-2); }
#family-account-status:empty { display: none; }

/* ---- 云端文字备份卡（family.mjs 渲染的 [data-section="cloud"]） ----
   规矩：语音永不上云，只把「整理出来的文字」存到云上；开关都在家人区，
   长辈端不出现任何云端相关字眼。 */
#family-panel [data-section="cloud"] {
  border-color: var(--line-strong);       /* 和账号卡一样：是"家里人要动手"的卡 */
}
#family-panel [data-section="cloud"] > p {
  font-size: 1rem;                        /* 20px */
  line-height: 1.7;
}
/* 手机号、取回码输入：沿用家人区 input 规范，另把取回码做成"码"的样子 */
#family-panel #cloud-phone,
#family-panel #cloud-recover-phone,
#family-panel #cloud-recover-code {
  font-variant-numeric: tabular-nums;
}
#family-panel #cloud-recover-code {
  font-family: "SFMono-Regular", Consolas, "Courier New", ui-monospace, monospace;
  letter-spacing: .1em;
}
/* 取回码：家人要"读给另一台手机听 / 拍照存下来"，必须等宽大字。
   320 宽和 200% 缩放下允许折行，绝不顶出右边。 */
#family-panel #cloud-recovery-code {
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  padding: .2rem .6rem;
  font-family: "SFMono-Regular", Consolas, "Courier New", ui-monospace, monospace;
  font-size: clamp(24px, 1.35rem + .9vw, 30px);   /* 24–30px，窄屏也不低于 24 */
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
  color: var(--ink);
  background: var(--paper-2);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;                /* 200% 缩放时折行而不是溢出 */
}
/* 状态行：次要色；出错只改字色 + 加粗（不铺红底、不靠颜色单独传达） */
#family-panel #cloud-status {
  font-size: 1rem;                        /* 20px */
  line-height: 1.65;
  color: var(--ink-2);
}
#family-panel #cloud-status:empty { display: none; }
#family-panel [data-cloud-state="error"] #cloud-status,
#family-panel #cloud-status[data-cloud-state="error"] {
  color: #8E1B12;
  font-weight: 700;
}
#family-panel [data-cloud-state="ok"] #cloud-status {
  color: var(--green);
}
/* 取回码和旁边的「复制」按钮排成一行：码和按钮都不许被压扁，实在放不下才换行 */
#family-panel [data-section="cloud"] .mmj-family-row:has(#cloud-recovery-code) {
  flex-wrap: wrap;
  gap: .5rem .6rem;
  align-items: center;
}
#family-panel [data-section="cloud"] .mmj-family-row:has(#cloud-recovery-code) > #cloud-recovery-code {
  flex: 0 1 auto;
}
#family-panel [data-section="cloud"] .mmj-family-row:has(#cloud-recovery-code) > button {
  flex: 0 0 auto;
  white-space: nowrap;
}
/* 万一 webapp 把码和按钮直接放在 <p> 里，也照样排成一行 */
#family-panel [data-section="cloud"] p:has(> #cloud-recovery-code) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .6rem;
}
#family-panel [data-section="cloud"] p:has(> #cloud-recovery-code) > #cloud-recovery-code {
  flex: 0 1 auto;
}
#family-panel [data-section="cloud"] p:has(> #cloud-recovery-code) > button {
  flex: 0 0 auto;
  white-space: nowrap;
}
/* 「关闭并删除云端文字」= 危险操作：红色描边，白/粉底，不做实心红，不抢主操作视觉 */
#family-panel #cloud-erase {
  min-height: max(3rem, 56px);
  padding: .45rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #8E1B12;
  background: #FFF3F0;
  border: 2.5px solid #8E1B12;
  border-radius: .8rem;
  cursor: pointer;
}
#family-panel #cloud-erase:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}


.family-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}
.family-row > * { flex: 1 1 10rem; }
.family-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: .7rem;
}
.family-actions > .btn,
.family-actions > button { flex: 1 1 10rem; }

.family-grid {
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.family-note {
  font-size: .9rem;                       /* 18px */
  line-height: 1.65;
  color: var(--ink-2);
}

.family-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .8rem;
  padding: .35rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 1rem;
}
.family-stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

#family-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
#family-panel th, #family-panel td {
  padding: .45rem .3rem;
  border-bottom: 2px solid var(--line);
  text-align: left;
  vertical-align: top;
}
#family-panel th { font-weight: 700; color: var(--ink); }

#family-panel details {
  border: 2px solid var(--line);
  border-radius: .8rem;
  padding: .6rem .8rem;
  background: var(--card);
}
#family-panel summary {
  min-height: 2.8rem;
  display: flex;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
#family-panel summary:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

#family-panel progress {
  width: 100%;
  height: 1.1rem;
  accent-color: var(--green);
}

/* --------------------------------------------------------------------------
   10. 说明层 / 确认层（对话框）
   -------------------------------------------------------------------------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;         /* 老浏览器不认下一行的 safe 时退回顶部对齐 */
  align-items: safe center;        /* 装得下就居中，装不下（safe）就退回顶部对齐，标题永不被顶出屏幕 */
  justify-content: center;
  padding: calc(10px + env(safe-area-inset-top)) .55rem calc(.55rem + env(safe-area-inset-bottom));
  background: rgba(28, 23, 18, .6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  overflow-y: auto;                 /* 极端矮屏：整层可滚，信息绝不裁掉 */
  overscroll-behavior: contain;
  animation: sheet-fade .18s ease-out;
}
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-card {
  width: 100%;
  max-width: 36rem;
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 1.15rem 1.1rem 0;        /* 底部留白交给 sticky 按钮区，避免按钮被裁 */
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 -6px 34px rgba(0, 0, 0, .24);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet-card > * { flex: 0 0 auto; }
.sheet-card > .sheet-actions { margin-top: auto; }

.sheet-title {
  font-size: clamp(1.5rem, 1.3rem + .7vw, 1.8rem);    /* 30–36px */
  line-height: 1.42;
  color: var(--ink);
}

.consent-list {
  list-style: none;
  margin: .8rem 0 .75rem;                 /* 下留 15px：末行不会贴着按钮条 */
  padding: 0;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.consent-list li {
  position: relative;
  padding-left: 2.6rem;
  font-size: 1.02rem;                     /* 20px */
  line-height: 1.7;
  color: var(--ink-2);
}
.consent-list li strong {
  display: block;
  margin-bottom: .1rem;
  font-size: 1.08rem;                     /* 22px */
  color: var(--ink);
}
/* 第 3 条里"文字会存到云上备份"是这次新加的关键点：行内加深，不另起一行 */
.consent-list li .consent-key {
  font-weight: 700;
  color: var(--ink);
}
/* 序号是"三步说明"的结构线索，比单纯的圆点好读 */
.consent-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: .1rem;
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 50%;
  background: var(--red);
  color: #FFF8F0;
  font-size: .95rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.consent-more {
  margin-top: .9rem;
  padding: .75rem .85rem;
  background: var(--paper-2);
  border-left: 5px solid var(--red-warm);
  border-radius: .3rem .8rem .8rem .3rem;
  font-size: 1rem;                        /* 20px：正文标准 */
  line-height: 1.65;
  color: var(--ink-2);
}

.sheet-actions {
  position: sticky;                 /* 内容再长，按钮区也钉在面板底部：老人不用找、不用滚 */
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-top: 1rem;
  padding: .7rem 0 calc(.85rem + env(safe-area-inset-bottom));
  background: var(--card);
  box-shadow: 0 -10px 14px -10px rgba(36, 31, 25, .35);
}
.sheet-actions .btn { width: 100%; }
.sheet-actions .btn-text { align-self: center; }
.sheet-actions .btn-text.btn-small { width: auto; }

.confirm-body {
  margin-top: .5rem;
  font-size: 1.05rem;                     /* 21px */
  line-height: 1.75;
  color: var(--ink-2);
  white-space: pre-wrap;
}

/* 矮屏（390×640、320×568 这类）：说明层必须一屏装下「标题 + 三条 + 三个按钮」。
   这是老人第一个动作，任何一个按钮被挤出屏幕都可能让他停住。 */
@media (max-height: 700px) {
  .sheet { padding-top: calc(8px + env(safe-area-inset-top)); }
  .sheet-card { max-height: calc(100dvh - 16px); padding: .8rem .95rem 0; }
  .sheet-title { font-size: 1.28rem; line-height: 1.3; }
  .consent-list { margin-top: .35rem; gap: .25rem; }
  .consent-list li { padding-left: 1.95rem; font-size: 1rem; line-height: 1.36; }
  /* 矮屏上首句不再独占一行（bold 仍在，靠字重分辨），省下的行正好把第 3 条说完 */
  .consent-list li strong { display: inline; margin-bottom: 0; font-size: 1rem; }
  .consent-list li::before { width: 1.6rem; height: 1.6rem; font-size: .85rem; }
  .consent-more { margin-top: .5rem; padding: .5rem .7rem; font-size: 1rem; line-height: 1.5; }
  .sheet-actions {
    gap: .35rem;
    margin-top: .5rem;
    padding-block: .4rem calc(.45rem + env(safe-area-inset-bottom));
  }
  .sheet-actions .btn-big { min-height: max(3.05rem, 61px); font-size: 1.2rem; }  /* 61px，仍 ≥56 底线 */
  .confirm-body { font-size: 1rem; line-height: 1.6; }
}

/* --------------------------------------------------------------------------
   11. 轻提示 toast（停留时长由 JS 控制，CSS 不做自动消失）
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  width: max-content;
  max-width: min(92vw, 34rem);
  padding: .7rem 1.05rem;
  background: var(--ink);
  color: #FFF9EE;
  border-radius: 1rem;
  font-size: 1.05rem;                     /* 21px */
  line-height: 1.6;
  text-align: center;
  text-wrap: balance;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
}

/* --------------------------------------------------------------------------
   12. 录音/播放各状态的整体呼应（body[data-state]）
   -------------------------------------------------------------------------- */
/* 录音中：纸面微微转暖，和按钮的脉搏环呼应；文字对比仍 ≥7:1 */
body[data-state="listening"] #screen-talk {
  background: linear-gradient(180deg, var(--paper) 0%, #F9EDE7 100%);
}
/* 录音中不再显示"说完了再点一下"的静态提示，计时数字接班 */
body[data-state="listening"] .record-hint { display: none; }
body[data-state="listening"] .prompt-label::before { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* 处理中：提示语前的点改成虚线描边，表示"在忙" */
body[data-state="uploading"] .prompt-label::before,
body[data-state="thinking"] .prompt-label::before {
  background: transparent;
  border: 2.5px dashed var(--red);
}

/* 离线：顶部始终能看到"没联网"的徽章（JS 负责显隐） */
body[data-state="offline"] .net-badge { display: inline-flex; }

/* --------------------------------------------------------------------------
   13. 响应式：竖屏小机 / 平板 / 横屏
   -------------------------------------------------------------------------- */

/* 矮屏竖屏（360×640 这类）：收紧留白，字号守底线。
   屏幕矮时优先保证「问题 + 大按钮 + 操作」一屏看全：
   实时转写只留语音播报（视觉上收成 0 高，说完去核对屏看全文），
   操作按钮靠底放，拇指够得着 */
@media (max-height: 700px) and (orientation: portrait) {
  .talk-wrap { padding: .15rem .9rem .15rem; gap: 0; }
  .talk-top { min-height: 0; }
  /* 矮屏上「我问您一句」这类装饰说明让位给问题本身和录音键 */
  .prompt-label { display: none; }
  .question { font-size: clamp(1.6rem, 8.6vw, 2rem); line-height: 1.3; }  /* ≥32px，行距收紧省高度 */
  .hint { margin-top: .1rem; font-size: 1rem; line-height: 1.35; }
  .record-zone { grid-template-rows: auto 1.4rem; }
  .live-text,
  .live-text:not(:empty) {
    height: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    overflow: hidden;
  }
  .talk-actions { margin-top: auto; gap: .3rem .5rem; padding-top: .1rem; }
  .welcome-wrap { gap: .7rem; padding-top: 1rem; }
  .welcome-title { font-size: clamp(2.6rem, 13vw, 3.4rem); }
  .welcome-owner { font-size: 22px; }      /* 矮屏也保 22px，仍不挤主按钮 */
  .welcome-lead { font-size: 1.15rem; }
  .review-text { max-height: 38dvh; }
}

/* 平板 / 桌面：内容收窄居中，问题与按钮都不再放大，视线更稳 */
@media (min-width: 700px) {
  .talk-wrap, .review-wrap, .rest-wrap, .welcome-wrap { max-width: 40rem; }
  .question { font-size: clamp(2.1rem, 1.8rem + .9vw, 2.5rem); }
  .sheet { align-items: center; padding: 1.2rem; }
  .sheet-card { max-height: 90vh; border-radius: 1.6rem; }
  .talk-actions { gap: .6rem 1rem; }
}

/* 横屏手机：左边看内容，右边按大按钮——一屏看全，不用滚动、不裁切 */
@media (orientation: landscape) and (max-height: 560px) and (min-width: 600px) {
  /* ---- 说话屏：问题在左，录音键在右 ---- */
  .talk-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto auto auto auto;
    grid-template-areas:
      "top    top"
      "label  rec"
      "quest  rec"
      "hint   rec"
      "live   live"
      "action action";
    align-content: center;
    align-items: center;
    gap: .1rem 1.4rem;
    max-width: 56rem;
    padding: 0 1.2rem;
  }
  .talk-top { grid-area: top; min-height: 2.8rem; }
  #btn-rest { min-height: 2.8rem; padding-block: 0; }   /* 横屏每 1px 都金贵，仍 ≥56px */
  .prompt-label { grid-area: label; align-self: end; }
  .question {
    grid-area: quest;
    align-self: start;
    font-size: clamp(1.55rem, 1.2rem + 1vw, 1.9rem);  /* 31–38px */
    line-height: 1.32;
  }
  .hint { grid-area: hint; align-self: start; font-size: 1rem; line-height: 1.35; }
  .record-zone {
    grid-area: rec;
    justify-self: end;
    align-self: center;
    margin: 0;
    padding-top: 0;
    grid-template-rows: auto 1.7rem;
  }
  .btn-record { width: clamp(180px, 24vw, 196px); height: clamp(180px, 24vw, 196px); }
  .live-text { grid-area: live; margin-top: 0; max-height: 3.4rem; font-size: 1.05rem; line-height: 1.55; }
  .talk-actions {
    grid-area: action;
    position: static;
    justify-content: flex-start;
    padding-top: 0;
    padding-bottom: 0;
    gap: .4rem .6rem;
    background: none;
    box-shadow: none;
  }
  .talk-actions .btn { min-height: 2.8rem; }   /* 56px，仍达标，省下 4px 给极矮横屏 */

  /* ---- 欢迎屏：字在左，大按钮在右 ---- */
  .welcome-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title start"
      "owner start"
      "lead  start"
      "note  start"
      "cont  cont"
      "foot  foot";
    align-content: center;
    align-items: center;
    justify-items: start;
    column-gap: 1.6rem;
    row-gap: .25rem;
    max-width: 56rem;
    padding: .5rem 1.4rem;
    text-align: left;
  }
  .welcome-title { grid-area: title; font-size: clamp(2.2rem, 7vw, 2.8rem); }
  .welcome-owner { grid-area: owner; font-size: .95rem; margin-top: 0; }
  .welcome-lead { grid-area: lead; font-size: 1.05rem; line-height: 1.6; }
  .welcome-note { grid-area: note; font-size: .9rem; line-height: 1.55; max-width: none; }
  #btn-start { grid-area: start; justify-self: end; min-width: 12rem; }
  #btn-welcome-continue { grid-area: cont; justify-self: start; }
  .welcome-foot { grid-area: foot; justify-self: start; }

  /* ---- 核对屏：文字在左，操作在右一列 ---- */
  .review-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(14.5rem, 17rem);
    grid-template-areas:
      "label   actions"
      "title   actions"
      "text    actions"
      "edit    actions";
    align-content: center;
    align-items: start;
    column-gap: 1.4rem;
    row-gap: .3rem;
    max-width: 56rem;
    padding: .3rem 1.2rem;
  }
  .review-wrap .prompt-label { grid-area: label; }
  .review-title { grid-area: title; font-size: 1.5rem; line-height: 1.35; }
  .review-text {
    grid-area: text;
    min-height: 0;
    max-height: 33dvh;
    font-size: 1.05rem;
    line-height: 1.65;
    padding: .6rem .8rem;
  }
  .review-edit-zone { grid-area: edit; margin: 0; }
  .review-edit { min-height: 4.2rem; font-size: 1.05rem; }
  .review-actions {
    grid-area: actions;
    margin-top: 0;
    align-self: center;
    gap: .35rem;
  }
  .review-actions .btn-big { min-height: 3.1rem; }

  /* ---- 休息屏：左字右按钮，一屏放下 ---- */
  .rest-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title  cont"
      "lead   cont"
      "stats  cont"
      "family family";
    align-content: center;
    align-items: center;
    justify-items: start;
    column-gap: 1.4rem;
    row-gap: .2rem;
    max-width: 52rem;
    padding: .2rem 1.2rem;
    text-align: left;
  }
  .rest-title { grid-area: title; font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem); }
  .rest-lead { grid-area: lead; font-size: .95rem; line-height: 1.5; }
  .rest-stats { grid-area: stats; padding: .3rem .8rem; font-size: .95rem; }
  #btn-continue { grid-area: cont; min-width: 11rem; min-height: 3.2rem; font-size: 1.3rem; }
  #btn-family { grid-area: family; justify-self: start; }

  /* ---- 家人区 / 说明层 ---- */
  #family-panel { padding-top: .4rem; }
  .family-head { padding-block: .3rem; }
  .sheet { align-items: center; padding: .8rem; }
  .sheet-card { max-height: 92dvh; padding-block: .9rem; }
  .sheet-title { font-size: 1.4rem; }
  .consent-list li { padding-block: .5rem; }

  /* 横屏的说明层改成左右两栏：三条清单在左、三个按钮在右，
     一屏就能读完，不必上下滑（老人横屏不会滑） */
  #consent-sheet .sheet-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(13rem, 16rem);
    grid-template-areas:
      "title actions"
      "list  actions"
      "more  actions";
    grid-template-rows: auto auto auto;
    align-content: center;
    column-gap: 1.1rem;
    max-height: calc(100dvh - 10px);
    overflow-y: auto;
  }
  #consent-sheet .sheet-title { grid-area: title; }
  #consent-sheet .consent-list { grid-area: list; }
  #consent-sheet .consent-list li { padding-block: .25rem; }
  #consent-sheet .consent-more { grid-area: more; }
  #consent-sheet .sheet-actions {
    grid-area: actions;
    position: static;                       /* 横屏用两栏，不再需要吸底 */
    align-self: center;
    margin-top: 0;
    padding: 0;
    background: none;
    box-shadow: none;
  }
  #consent-sheet .sheet-actions .btn { width: 100%; }
}

/* 极窄屏（200% 浏览器缩放的等效宽度、老机型）：宁可略小，也不要横向溢出 */
@media (max-width: 340px) {
  html { font-size: 112.5%; }             /* 18px 正文，仍高于"能看清"的底线 */
  .btn-record {
    width: min(180px, calc(100vw - 2.2rem));
    height: min(180px, calc(100vw - 2.2rem));
  }
  .talk-wrap, .review-wrap, .rest-wrap, .welcome-wrap { padding-inline: .8rem; }
  /* 320 宽的屏上把底部两个按钮压成一行（图标让位，文字仍 26px） */
  .talk-actions { gap: .25rem .3rem; }
  .talk-actions .btn { padding-inline: .3rem; }
  .talk-actions .ico { display: none; }
  /* 极窄屏先保问题（≥32px）与录音键：柔和的引导语让位 */
  #hint-text,
  #record-hint { display: none; }
  .question { font-size: 1.8rem; line-height: 1.26; }
  .welcome-title { font-size: 2.6rem; }
  /* 字号被系统放大到极端时，允许这块屏幕上下滑，绝不把字裁掉 */
  .screen { overflow-y: auto; }
}

/* 极窄又极矮（200% 缩放 / 老机型）：操作条改回文档流，避免盖住录音键；靠上下滑看全 */
@media (max-width: 340px) and (max-height: 520px) {
  .talk-actions {
    position: static;
    background: none;
    box-shadow: none;
    padding-bottom: 0;
  }
}

/* --------------------------------------------------------------------------
   14. 降低动效偏好：所有动效归零，用静止形态表达状态
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  /* 脉搏环改成一个静止的粗描边：依然能看出"正在录音" */
  body[data-state="listening"] .btn-record::before,
  .btn-record[data-mode="recording"]::before {
    animation: none !important;
    opacity: 1;
    transform: none;
    border-width: 4px;
    inset: -9px;
  }
  /* 处理中的旋转环改成静止的虚线环 */
  .btn-record[data-mode="busy"]::after {
    animation: none !important;
    border-style: dashed;
    border-color: rgba(255, 248, 240, .75);
  }
  /* 提示点不再闪 */
  body[data-state="listening"] .prompt-label::before { animation: none !important; }
  .sheet { animation: none; }
}

/* --------------------------------------------------------------------------
   15. 高对比 / 强制颜色 / 打印
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .btn, .btn-record, .net-badge, .sheet-card, .review-text,
  #family-panel input, #family-panel select, #family-panel textarea {
    border: 2px solid ButtonText;
    forced-color-adjust: auto;
  }
  .btn-record::before { border-color: Highlight; }
}

@media (prefers-contrast: more) {
  :root { --ink-2: #2E2821; --line-strong: #6B5C43; }
  .review-text, #family-panel input, #family-panel select,
  #family-panel textarea { border-width: 3px; }
}

/* 家里打印回忆录时：去掉外壳与按钮，只留正文，白底黑字 */
@media print {
  html { font-size: 100%; }
  body { background: #fff; color: #000; }
  #app { display: block; height: auto; overflow: visible; padding: 0; }
  .screen { overflow: visible; max-height: none; }
  .screen[hidden] { display: none !important; }
  .btn, .talk-top, .family-head, #toast, .net-badge { display: none !important; }
  .review-text, .live-text { border: 0; background: none; max-height: none; overflow: visible; }
}

/* ── 「放到桌面上」引导（install.mjs） ─────────────────────────── */
.install-lead {
  font-size: var(--fs-lead, 1.3rem);
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 1rem;
}
.install-steps {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: .85rem;
}
.install-steps li {
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: var(--fs-body, 1.15rem);
  line-height: 1.5;
  color: var(--ink);
}
.install-num {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}
.install-text { flex: 1 1 auto; min-width: 0; }
.install-text b { color: var(--red-deep); white-space: nowrap; }
.install-figure {
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  color: var(--red-deep);
}
.install-note {
  font-size: var(--fs-small, 1rem);
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 .4rem;
}
@media (max-height: 700px) {
  .install-lead { font-size: 1.15rem; margin-bottom: .7rem; }
  .install-steps { gap: .55rem; }
  .install-steps li { font-size: 1.05rem; }
  .install-figure { width: 1.9rem; height: 1.9rem; }
}
