/* MediVoice 患者端 —— 视觉层
 *
 * 定位：面向患者（含中老年）的语音导诊助手。按适老化标准做：
 *   正文 ≥ 16px / 主操作 ≥ 52px / 触控热区 ≥ 48px / 正文对比度 ≥ 7:1 /
 *   状态 = 图标 + 文字 + 颜色三通道，不靠颜色单独表意。
 * 令牌口径见 outputs/MediVoice-UI设计规范.md §2。
 * 零依赖：不用任何 npm 包 / CDN，装机包自包含部署。
 */

:root {
  /* 颜色 */
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f6f9fa;
  --ink: #16232b;
  --ink-2: #4d5f68;
  --ink-3: #78888f;
  --line: #dbe3e7;
  --line-strong: #b9c6cc;
  --brand: #0d6b66;
  --brand-strong: #0a5450;
  --brand-soft: #e4f1f0;
  --warm: #8a4b12;
  --warm-soft: #fdf3e7;
  --danger: #a32b2b;
  --danger-soft: #fdecec;
  --warn: #8a5a12;
  --warn-soft: #fff6e6;
  --ok: #1c6b45;
  --ok-soft: #e6f4ec;

  /* 字号 */
  --fs-2xs: 12px;
  --fs-xs: 13px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 28px;

  /* 间距 / 圆角 / 阴影 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-1: 0 1px 2px rgba(16, 32, 40, .05), 0 6px 18px -14px rgba(16, 32, 40, .28);
  --shadow-2: 0 2px 6px rgba(16, 32, 40, .08), 0 16px 40px -20px rgba(16, 32, 40, .4);

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, system-ui, sans-serif;

  --tabbar-h: 58px;
  --appbar-h: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-base)/1.65 var(--sans);
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
p { margin: 0; }

code {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* 焦点可见：键盘用户必须看得见自己在哪 */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 大字号模式：适老化。
   整套排版用的都是 --fs-* 变量，所以这里改一次变量就整体放大，
   不用逐个元素改 px（那是最容易漏的做法）。 */
body.font-large {
  --fs-2xs: 14px;
  --fs-xs: 15px;
  --fs-sm: 17px;
  --fs-base: 19px;
  --fs-md: 21px;
  --fs-lg: 24px;
  --fs-xl: 29px;
  --fs-2xl: 34px;
}
body.font-large input,
body.font-large textarea { padding: 15px var(--sp-3); }
body.font-large .btn { min-height: 56px; }
body.font-large .tab span { font-size: 13px; }

/* hidden 属性必须压过所有作者样式。
   下面 .banner / .empty / .err / .toast / .demo-line 都带 display，
   浏览器默认的 [hidden]{display:none} 会被它们盖掉 —— 结果是
   "该藏的横幅、错误条、空态全都露出来"。这条放在组件样式之前，
   优先级由 !important 兜住，谁都别想再盖回去。 */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- 横幅 */
.banner {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm); line-height: 1.5;
  padding-left: calc(var(--sp-4) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--sp-4) + env(safe-area-inset-right, 0px));
}
.banner span { flex: 1; }
.banner-icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.banner-offline {
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid #f0e0c2;
}
.banner-install {
  background: var(--brand-soft); color: var(--brand-strong);
  border-bottom: 1px solid #cfe4e2;
}
.btn-sm { padding: 0 12px; font-size: var(--fs-sm); min-height: 36px; }
.btn-icon { padding: 0; width: 36px; min-height: 36px; }
.btn-icon svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round;
}

/* ---------------------------------------------------------------- 品牌栏 */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}

.appbar-inner {
  max-width: 640px; margin: 0 auto;
  height: var(--appbar-h);
  padding: 0 var(--sp-4);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
}

.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.brand .mark {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--brand); color: #fff;
  display: grid; place-items: center; flex: none;
}
.brand .mark svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.brand-text { min-width: 0; }
.brand h1 { font-size: var(--fs-md); font-weight: 650; line-height: 1.25; }
.brand p {
  font-size: var(--fs-xs); color: var(--ink-3);
  line-height: 1.3; margin-top: 1px;
}

.who-chip {
  flex: none;
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 600;
  max-width: 45vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
body.logged-in .who-chip {
  background: var(--ok-soft); border-color: #c9e4d5; color: var(--ok);
}

/* 没登录时底部导航没有意义（四个视图都进不去），直接藏掉 */
body:not(.logged-in) .tabbar { display: none; }

/* ---------------------------------------------------------------- 正文 */
.page {
  max-width: 640px; margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--tabbar-h) + var(--sp-8) + env(safe-area-inset-bottom, 0px));
}

.view-head { margin-bottom: var(--sp-4); }
.view-head h1 { font-size: var(--fs-xl); font-weight: 680; line-height: 1.3; }
.view-sub {
  margin-top: var(--sp-2);
  font-size: var(--fs-sm); line-height: 1.6; color: var(--ink-2);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.card:last-child { margin-bottom: 0; }
.card-flat { padding: var(--sp-2); }
.card-title {
  font-size: var(--fs-md); font-weight: 640; margin-bottom: var(--sp-3);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-3);
}
.card-head .card-title { margin-bottom: 0; }

.muted { color: var(--ink-2); }
.small { font-size: var(--fs-xs); }

/* ---------------------------------------------------------------- 表单 */
.stack-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field-inline { display: flex; gap: var(--sp-2); align-items: stretch; }
.field-inline input { flex: 1 1 auto; min-width: 0; }
/* 「获取验证码」不许被挤成两行 */
.field-inline .btn { flex: none; white-space: nowrap; }

input, textarea {
  font: inherit;
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 13px var(--sp-3);
  width: 100%;
  min-height: 52px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 107, 102, .14);
}
input:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-3); }

.btn {
  font: inherit; font-size: var(--fs-md); font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 0 var(--sp-4);
  min-height: 52px;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-secondary {
  background: var(--surface); color: var(--brand-strong);
  border-color: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); }
.btn-danger {
  background: var(--surface); color: var(--danger);
  border-color: #e4caca; min-height: 44px; padding: 0 14px;
  font-size: var(--fs-sm); font-weight: 600; flex: none;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.err {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  color: var(--danger);
  font-size: var(--fs-sm); line-height: 1.6;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
}

/* 空错误位不占地方 —— 没有报错就别在患者面前摆一条红框。 */
.err:empty { display: none; }

.demo-line {
  display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap;
  margin-top: var(--sp-4); font-size: var(--fs-xs); color: var(--ink-2);
}

/* 开发登录口：折叠在正式登录下面。默认收起，别在患者眼前晃。 */
#dev-login-box {
  margin-top: var(--sp-4); padding-top: var(--sp-3);
  border-top: 1px dashed var(--line);
}
#dev-login-box summary {
  cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2);
  list-style: none; min-height: 32px; display: flex; align-items: center;
}
#dev-login-box summary::-webkit-details-marker { display: none; }
#dev-login-box summary::before { content: "＋ "; }
#dev-login-box[open] summary::before { content: "－ "; }
#dev-login-box .stack-form { margin-top: var(--sp-3); }

/* ---------------------------------------------------------------- 设备列表 */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: 0; padding-top: 0; }
.list .dev { font-weight: 650; font-size: var(--fs-md); }
.list .pid { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }

/* ---------------------------------------------------------------- 空态 */
.empty {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--ink-2);
}
.empty-icon {
  width: 34px; height: 34px; margin-bottom: var(--sp-3);
  fill: none; stroke: var(--ink-3); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.empty-title { font-size: var(--fs-lg); font-weight: 640; color: var(--ink); }
.empty-text { font-size: var(--fs-sm); margin-top: var(--sp-2); line-height: 1.6; }

/* ---------------------------------------------------------------- 语音 */
.voice-card { padding: var(--sp-4); }
.voice-row {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
}
.voice-switches { display: flex; flex-direction: column; gap: var(--sp-1); }

.btn-mic {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-width: 148px; min-height: 56px;
  padding: 0 var(--sp-5);
  border-radius: 999px;
  border: 1px solid var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: var(--fs-md); font-weight: 650;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.btn-mic svg {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn-mic:hover:not(:disabled) { background: #d6e9e7; }
.btn-mic:disabled { opacity: .5; cursor: not-allowed; }
.btn-mic.is-recording {
  background: var(--danger); border-color: var(--danger); color: #fff;
}
.btn-mic.is-recording svg { animation: mic-pulse 1s ease-in-out infinite; }

@keyframes mic-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.86); }
}

.voice-status {
  font-size: var(--fs-sm); color: var(--ink-2);
  margin-top: var(--sp-3); min-height: 22px;
}
.voice-status:empty { margin-top: 0; min-height: 0; }

.switch {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); color: var(--ink-2);
  min-height: 44px; cursor: pointer;
}
.switch input {
  width: 22px; height: 22px; min-height: 0; padding: 0;
  accent-color: var(--brand); flex: none;
}

/* ---------------------------------------------------------------- 聊天 */
.chat-log {
  min-height: 200px;
  max-height: 52vh; overflow-y: auto;
  padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--radius);
}
.chat-log:empty::before {
  content: "还没有对话。可以直接问：消化内科明天还有号吗";
  display: block;
  color: var(--ink-3); font-size: var(--fs-sm);
  text-align: center; padding: var(--sp-8) var(--sp-4);
}
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg .who {
  font-size: var(--fs-xs); color: var(--ink-3);
  margin-bottom: 4px; font-weight: 600;
}
.msg .body {
  padding: 11px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap; word-break: break-word;
  font-size: var(--fs-base); line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--line);
}
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.me .body { background: var(--brand-soft); border-color: #cfe4e2; }
.msg.bot { align-self: flex-start; }
.msg.bot .body { background: var(--warm-soft); border-color: #f0dfc9; color: var(--warm); }

/* 回答来源角标：这句答案是从哪儿来的。
 * 医疗场景不能糊弄 ——「查到的」和「模型说的」必须看得见，
 * 否则患者会把模型编的常识当成医院给的结论。 */
.msg .who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.msg .src {
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.2;
  padding: 2px 7px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); color: var(--ink-2);
  background: var(--surface-2); white-space: nowrap;
}
.msg .src.grounded { color: var(--brand-strong); border-color: #bcdcd6; background: var(--brand-soft); }
.msg .src.general { color: var(--warn); border-color: #e5d9b0; background: var(--warn-soft); }
.msg .src.human { color: var(--warm); border-color: #f0cfa8; background: var(--warm-soft); }
.msg .src.safety { color: var(--danger); border-color: #eec4c4; background: var(--danger-soft); }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td {
  text-align: left; padding: var(--sp-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tr:last-child td { border-bottom: 0; }
.table th {
  color: var(--ink-2); font-weight: 640; font-size: var(--fs-xs);
  background: var(--surface-2);
}
.table td { color: var(--ink); }

/* 可点的行：整行都是热区，不用瞄准那一列的小字。
   下方加一条极淡的指示，免得看着像普通表格不知道能点。 */
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--surface-2); }
.table tbody tr.is-clickable:active { background: var(--brand-soft); }
.table .cell-go {
  color: var(--ink-3); font-size: var(--fs-lg);
  text-align: right; width: 1%;
}

/* 会话 id 在手机上放不下整行，允许折行；
   完整 id 在 title 里。 */
.table td.cell-id {
  white-space: normal;
  word-break: break-all;
  max-width: 42%;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 异步面板三态 */
/* 加载中：骨架屏。空白 + 转圈会让患者以为页面坏了，
   骨架至少告诉"正在拿数据"。 */
.state-loading { display: flex; flex-direction: column; gap: var(--sp-3); }
.skeleton {
  height: 62px; border-radius: var(--radius);
  background: linear-gradient(90deg, #eef2f4 25%, #e3eaee 37%, #eef2f4 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}
@keyframes skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 出错：给一句人话 + 一个能点的重试，别只丢一个 500。 */
.state-error {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
}
.state-error-text {
  color: var(--danger); font-size: var(--fs-sm); line-height: 1.6;
}

/* ---------------------------------------------------------------- 预约单 */
.appt-list, .report-list { list-style: none; margin: 0; padding: 0; }
.appt {
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.appt:first-child, .report:first-child { border-top: 0; padding-top: 0; }
.appt-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
}
.appt-dept { font-size: var(--fs-lg); font-weight: 680; line-height: 1.3; }
.appt-when {
  font-size: var(--fs-md); font-weight: 640; color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
}
.appt-meta {
  font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.6;
}
.appt-actions { margin-top: var(--sp-2); }

/* 状态标签：颜色 + 文字两条通道，不靠颜色单独表意。 */
.chip {
  display: inline-flex; align-items: center;
  height: 26px; padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs); font-weight: 640;
  border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.chip-ok { background: var(--ok-soft); border-color: #c9e4d5; color: var(--ok); }
.chip-off { background: var(--surface-2); border-color: var(--line); color: var(--ink-3); }
.chip-warn { background: var(--warn-soft); border-color: #f0e0c2; color: var(--warn); }

.report {
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.report-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
}
.report-name { font-size: var(--fs-md); font-weight: 650; }
.report-date {
  font-size: var(--fs-sm); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.report-summary { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.6; }

/* ---------------------------------------------------------------- 抽屉 */
/* 抽屉打开时锁住背景滚动：不然手指在面板边缘一滑，
   底下那一页跟着滚，关闭时"人已经换了位置"是错觉。 */
body.sheet-open { overflow: hidden; }

.sheet {
  position: fixed; inset: 0; z-index: 55;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(16, 32, 40, .42);
}
.sheet-panel {
  position: relative;
  width: 100%; max-width: 640px;
  max-height: 86vh;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-2);
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: var(--sp-3);
  overflow-y: auto;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
}
.sheet-head h2 { font-size: var(--fs-lg); font-weight: 680; }
.sheet-meta {
  font-size: var(--fs-sm); color: var(--ink-2);
  padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line);
}
.sheet-chat { max-height: 52vh; }

/* ---------------------------------------------------------------- 设置行 */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
}
.setting-text { min-width: 0; }
.setting-name { font-size: var(--fs-md); font-weight: 640; }
.setting-desc {
  font-size: var(--fs-sm); color: var(--ink-2);
  line-height: 1.6; margin-top: 2px;
}
.setting-row .switch { flex: none; }

/* ---------------------------------------------------------------- 隐私正文 */
.doc { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: var(--sp-3); }
.doc li { color: var(--ink-2); line-height: 1.7; }
.doc strong { color: var(--ink); }

.doc-body { margin-top: var(--sp-2); }
.doc-body h2 { font-size: var(--fs-lg); margin: var(--sp-5) 0 var(--sp-2); }
.doc-body h2:first-child { margin-top: 0; }
.doc-body h3 {
  font-size: var(--fs-md);
  margin: var(--sp-5) 0 var(--sp-2);
  color: var(--ink);
  padding-left: 10px;
  border-left: 3px solid var(--brand);
}
.doc-body p { font-size: var(--fs-base); line-height: 1.75; color: var(--ink-2); margin: 0 0 var(--sp-3); }
.doc-body ul { margin: 0 0 var(--sp-3); padding-left: 20px; }
.doc-body li { font-size: var(--fs-base); line-height: 1.75; color: var(--ink-2); margin-bottom: var(--sp-2); }
.doc-body table { margin: var(--sp-2) 0 var(--sp-4); }
.doc-body .table { font-size: var(--fs-sm); }
.doc-body strong { color: var(--ink); }

/* 隐私说明里的表是「说明」不是「数据网格」：
   - 宽屏保持表格，但允许折行（nowrap 会把 4 列长中文撑到近千像素，
     整个页面横向溢出，手机上左右乱晃）；
   - 窄屏由下面那条媒体查询拆成卡片。 */
.doc-body .table-wrap { border: 0; overflow-x: auto; }
.doc-body .table th,
.doc-body .table td { white-space: normal; vertical-align: top; }
.doc-body .table th { width: 22%; }

@media (max-width: 640px) {
  /* 每行变成一张卡片，字段名用 data-label 显示在内容前面。
     表格拆开才看得清 —— 四列挤在 390px 里每列不到 90px，
     那是把「宁可横滚」都用不上的地方，该换版式而不是横滚。 */
  .doc-body .table-wrap { overflow: visible; }
  .doc-body .table,
  .doc-body .table tbody,
  .doc-body .table tr,
  .doc-body .table td { display: block; width: auto; }
  .doc-body .table thead { display: none; }
  .doc-body .table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--sp-2) 0;
    margin-bottom: var(--sp-3);
    background: var(--surface-2);
  }
  .doc-body .table td {
    border-bottom: 0;
    padding: var(--sp-2) var(--sp-3);
  }
  .doc-body .table td + td { border-top: 1px dashed var(--line); }
  .doc-body .table td::before {
    content: attr(data-label) "　";
    color: var(--ink-3);
    font-size: var(--fs-xs);
  }
  .doc-body .table td[data-label="类别"] {
    font-weight: 680;
    font-size: var(--fs-base);
    color: var(--ink);
  }
  /* 首列本身就是标题，不用再重复写一遍「类别」 */
  .doc-body .table td[data-label="类别"]::before { content: none; }
}

.err-note {
  font-size: var(--fs-base); line-height: 1.7;
  color: var(--ink-2);
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  margin: 0 0 var(--sp-3);
}
.err-note strong { color: var(--ink); }

/* ---------------------------------------------------------------- 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -1px 0 rgba(16, 32, 40, .04), 0 -12px 28px -22px rgba(16, 32, 40, .5);
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit;
  height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3);
  position: relative;
  min-height: 48px;
  transition: color .12s ease;
}
.tab svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.tab span { font-size: var(--fs-2xs); font-weight: 600; }
.tab::before {
  content: ""; position: absolute; top: 0; left: 50%;
  width: 24px; height: 2px; margin-left: -12px;
  background: var(--brand); border-radius: 0 0 2px 2px;
  opacity: 0; transition: opacity .12s ease;
}
.tab:hover { color: var(--ink-2); }
.tab.is-active { color: var(--brand-strong); }
.tab.is-active::before { opacity: 1; }
.tab.is-active span { font-weight: 700; }

/* ---------------------------------------------------------------- 同意页 */
.panel-consent {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  padding: calc(var(--sp-6) + env(safe-area-inset-top, 0px)) var(--sp-4)
           calc(var(--sp-8) + env(safe-area-inset-bottom, 0px));
}
.consent-card {
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: var(--sp-6) var(--sp-5);
}
.consent-mark {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; margin-bottom: var(--sp-4);
}
.consent-mark svg {
  width: 26px; height: 26px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.consent-card h1 { font-size: var(--fs-2xl); font-weight: 680; margin-bottom: var(--sp-3); }
.consent-lead { font-size: var(--fs-base); line-height: 1.7; color: var(--ink-2); margin-bottom: var(--sp-3); }
.consent-lead strong { color: var(--ink); }
.consent-card .doc { margin-bottom: var(--sp-4); }
.consent-more {
  margin-bottom: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
}
.consent-more > summary {
  cursor: pointer; font-size: var(--fs-sm); font-weight: 650; color: var(--ink);
  min-height: 32px; display: flex; align-items: center;
}
.consent-more[open] > summary { margin-bottom: var(--sp-2); }
.consent-actions { display: flex; flex-direction: column; gap: var(--sp-3); }
.consent-foot { margin-top: var(--sp-4); line-height: 1.6; }

body.consent-lock .appbar,
body.consent-lock .page,
body.consent-lock .tabbar { display: none; }

/* ---------------------------------------------------------------- 提示条 */
.toast {
  position: fixed; left: 50%;
  bottom: calc(var(--tabbar-h) + var(--sp-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--fs-sm); line-height: 1.5;
  box-shadow: var(--shadow-2);
  z-index: 50;
  pointer-events: none;   /* 提示条别挡住底下的按钮 */
}

/* ---------------------------------------------------------------- 窄屏 */
@media (max-width: 400px) {
  .page { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .card { padding: var(--sp-4); }
  .appbar-inner { padding: 0 var(--sp-3); }
  .btn-mic { min-width: 100%; }
}

/* 桌面（装机走查时用浏览器打开）：限制阅读宽度，别把表单拉成一条线 */
@media (min-width: 720px) {
  .page { padding-top: var(--sp-6); }
  .tabbar {
    max-width: 640px; margin: 0 auto;
    border-left: 1px solid var(--line); border-right: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

/* 降低动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-contrast: more) {
  :root { --line: #9fb0b8; --line-strong: #6d8089; --ink-3: #5c6c74; }
}
