:root {
  --bg: #F5F7F8;
  --card: #ffffff;
  --ink: #0f2750;
  --muted: #6b7681;
  --accent: #275288;
  --accent-soft: #d6deee;
  --line: #D5DADE;
  --doctor-bubble: #e8ebee;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  display: grid;
  grid-template-columns: minmax(360px, 5fr) minmax(420px, 7fr);
  gap: 18px;
  height: 100vh;
  padding: 18px;
  max-width: 1500px;
  margin: 0 auto;
}

/* —— 左侧医生面板 —— */
.doctor-pane {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(20, 52, 102, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand { padding: 18px 22px 12px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.avatar-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  /* 与医生精灵图背景色一致（边缘主色 ~#FFFFFF）：容器非方形时露出的上下左右
     不再出现色差分界（原 radial-gradient 的 #f5f7f8 与图片白底不一致） */
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}
#avatar { width: 100%; height: 100%; object-fit: contain; }

/* 状态栏：移到「李医生 AI 评估 Agent」同行，居中显示 */
.meta-head { position: relative; }
.avatar-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(22, 34, 78, 0.78);
  color: #fff;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: opacity 0.3s;
}

.doctor-meta { padding: 30px 22px 18px; border-top: 1px solid var(--line); }
.doc-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.doc-tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.progress-row { margin-top: 60px; }
/* 进度区：条 + 竖线分隔 + 上下交替的段标签 */
.progress-zone { position: relative; margin: 18px 0 26px; }
.progress-bar {
  height: 8px;
  background: #e8ebee;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5c86b8, var(--accent));
  /* 左圆角、右直角：非满进度时右缘与各题分割线对齐，不再凸出一块圆角错位；
     满进度时右角由父级 .progress-bar 的 overflow:hidden + 圆角裁切，自然呈圆角 */
  border-radius: 999px 0 0 999px;
  transition: width 0.4s ease;
}
.progress-ticks { position: absolute; inset: 0; pointer-events: none; }
.progress-tick {
  position: absolute;
  top: 0;
  height: 100%;
  width: 1px;
  background: rgba(13, 33, 84, 0.18);
}
.progress-labels { position: absolute; inset: 0; pointer-events: none; }
.progress-label-item {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10.5px;
  line-height: 1.2;
  color: #6b7681;
  white-space: nowrap;
  text-align: center;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress-label-item.above { bottom: calc(100% + 5px); }
.progress-label-item.below { top: calc(100% + 5px); }
.progress-label-item.active { color: var(--accent); font-weight: 600; }
/* 计数：进度条下方居中 */
.progress-label {
  display: flex;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

.voice-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.engine-hint { margin-top: 8px; font-size: 12px; color: #A06A0A; min-height: 16px; }

/* —— 右侧聊天面板 —— */
.chat-pane {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(20, 52, 102, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.chat-title { font-size: 16px; font-weight: 700; }
.chat-tip { font-size: 12px; color: var(--muted); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 开始评估卡片（用户手势入口，满足浏览器语音自动播放策略）
   样式对齐入口页（index.html 方案 D）的量表卡片：右上主题底图 / 白底浅描边投影 / 深蓝标题 / 青色代号 / 蓝色文字 CTA */
.start-card {
  position: relative;
  isolation: isolate;
  margin: auto 0;
  align-self: center;
  text-align: center;
  width: 270px;
  padding: 130px 27px 31px;
  border: 1px solid #d5dade;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 52, 102, .08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
  --card-img: url('/assets/entry/card-barthel.png');
}
/* 右上主题淡底图（与入口卡同款：62% 透明，被圆角裁切） */
.start-card::before {
  content: "";
  position: absolute;
  inset: 0;
  /* 宽度铺满、高度按原比例缩放（3:4），不再 100% 100% 拉伸——卡片变高后右上角图案不会变形 */
  background: var(--card-img) top center / 100% auto no-repeat;
  opacity: .62;
  pointer-events: none;
}
.start-card > * { position: relative; }
.start-card:hover {
  transform: translateY(-2px);
  border-color: #b0b7bc;
  box-shadow: 0 16px 36px rgba(20, 36, 102, .14);
}
.start-title { font-size: 20px; font-weight: 700; line-height: 29px; color: #0F2750; margin: 0; }
.start-tag { font-size: 12px; font-weight: 600; line-height: 17px; color: #275288; }
.start-desc { font-size: 13px; font-weight: 400; line-height: 22px; color: #6b7681; margin: 0; }
.start-btn {
  /* 与问诊输入栏「发送」按钮（.chat-input button）同款样式 */
  align-self: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  height: 46px;
  padding: 0 22px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.start-btn:hover { filter: brightness(1.1); }
.start-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 「继续历史评估」纯文本按钮：蓝字 + 下划线，视觉等级低于主按钮，防误点 */
.continue-link {
  align-self: center;
  background: none;
  border: none;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.continue-link:hover { filter: brightness(1.12); }
.continue-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* 返回按钮（chat-head 内，替代原「问诊对话」标题位；仅历史评估视图显示） */
.back-btn {
  border: none;
  background: none;
  padding: 2px 4px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  align-self: center;
}
.back-btn:hover { filter: brightness(1.12); }

/* ⚠️ 显式声明 display 的元素会压过 [hidden] 的 UA 样式（设了 hidden 仍显示），
   视图切换全部依赖 hidden 属性，这里逐一夺回隐藏能力 */
.start-card[hidden], .hv-convo[hidden], .hv-foot[hidden] { display: none; }

/* ===== 历史评估选择视图：左 未完成评估列表 ｜ 右 对话记录（样式参考评估中心） ===== */
.history-view {
  flex: 1;
  min-height: 0;
  display: flex;
  border-top: 1px solid var(--line);
}
.history-view[hidden] { display: none; }

/* 左：列表 */
.hv-list {
  width: 264px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f5f7f8;
  min-height: 0;
}
.hv-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.hv-search input {
  width: 100%;
  height: 32px;
  border: 1px solid #d5dade;
  border-radius: 8px;
  padding: 0 8px;
  font-family: inherit;
  font-size: 12.5px;
  color: #0F2750;
  background: #fff;
  min-width: 0;
}
.hv-search input:focus { outline: none; border-color: var(--accent); }
.hv-items {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hv-items .empty { padding: 24px 12px; text-align: center; font-size: 12px; color: var(--muted); }
.hv-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid #e8ebee;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.hv-item:hover { border-color: #8fa9ce; box-shadow: 0 4px 14px rgba(20, 52, 102, .08); }
.hv-item.selected { background: #edf1f8; border-color: #5c86b8; }
.hv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.hv-name {
  font-size: 13px;
  font-weight: 600;
  color: #0F2750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.hv-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.hv-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 右：对话记录 */
.hv-detail {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.hv-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
}
.hv-convo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hv-foot {
  flex-shrink: 0;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}
.hv-start-btn { width: 220px; }
/* 历史对话气泡：医生左（灰底），患者右（主色底白字）——与评估中心对话区同款观感 */
.hv-msg { display: flex; gap: 10px; max-width: 80%; }
.hv-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.hv-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  background: #275288;
}
.hv-msg.me .hv-dot {
  background: #d6deee;   /* primary-100 浅主色底 */
  color: #275288;        /* primary-700 主色字 */
  box-shadow: inset 0 0 0 1px #aec1dd; /* primary-200 内描边 */
}
/* 医生头像：与聊天页一致——脸图 + 外圈浅细描边 */
.hv-msg.them .hv-dot {
  background: var(--accent-soft) url('/assets/sprites/00-base-neutral.jpg') center/cover;
  color: transparent;
  box-shadow: 0 0 0 1px var(--doctor-bubble); /* 边框=医生气泡底色 */
}
.hv-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #0f2750;
  background: #e8ebee;
  box-shadow: 0 2px 8px rgba(20, 52, 102, .06);
  white-space: pre-wrap;
  word-break: break-word;
}
.hv-msg.them .hv-bubble { border-top-left-radius: 4px; }
.hv-msg.me .hv-bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; }

.msg { display: flex; gap: 10px; max-width: 86%; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.doctor { align-self: flex-start; }
.msg.doctor .avatar-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-soft) url('/assets/sprites/00-base-neutral.jpg') center/cover;
  box-shadow: 0 0 0 1px var(--doctor-bubble); /* 浅浅细细的描边（外圈，边框=医生气泡底色） */
}
.msg.doctor .bubble { background: var(--doctor-bubble); border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; }
/* 患者头像：与评估中心患者头像一致——浅主色底 + 主色字，中间「我」 */
.msg.user .avatar-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #d6deee; /* primary-100 */
  color: #275288;      /* primary-700 */
  box-shadow: inset 0 0 0 1px #aec1dd; /* primary-200 */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 400;
}

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* 报告下载卡片 */
.report-card {
  align-self: flex-start;
  max-width: 86%;
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  background: linear-gradient(180deg, #f5f7f8, #e8ebee);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.report-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  flex-shrink: 0;
}
.report-info { flex: 1; }
.report-title { font-size: 14px; font-weight: 700; color: var(--accent); }
.report-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.report-dl {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  flex-shrink: 0;
}
.report-dl:hover { filter: brightness(1.1); }

.chat-input {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #f5f7f8;
  align-items: center;
}
/* display:flex 会覆盖 hidden 属性的 UA 样式——未开始对话前须真正隐藏输入区 */
.chat-input[hidden] { display: none; }

/* 输入方式切换按钮（语音⇄文本）：语音态显示键盘图标，文本态显示语音图标 */
.mode-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7681;
  transition: transform 0.15s, border-color 0.2s, color 0.2s;
  padding: 0;
}
.mode-toggle:hover { border-color: var(--accent); color: var(--accent); }
.mode-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.mode-toggle svg { display: block; }

.text-body { display: flex; flex: 1; gap: 10px; align-items: center; min-width: 0; }
.text-body[hidden] { display: none; }

/* 按住说话大按钮（微信式） */
.voice-body { flex: 1; min-width: 0; }
.voice-body[hidden] { display: none; }
.hold-btn {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* 允许在按钮上做纵向滑动手势 */
  transition: background 0.15s, transform 0.1s;
}
.hold-btn:active { transform: scale(0.98); }
.hold-btn.recording { background: #e5484d; }
.hold-btn.cancelling { background: #dc2626; }
.hold-btn:disabled { background: #8d97a0; cursor: not-allowed; }

/* 上滑取消浮层提示 */
.slide-hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.slide-hint[hidden] { display: none; }

/* 实时识别气泡（按住说话时在聊天区逐字上屏） */
.msg.user.live .bubble::after {
  content: "▍";
  display: inline-block;
  margin-left: 2px;
  animation: live-caret 0.9s steps(1) infinite;
}
@keyframes live-caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.chat-input input {
  flex: 1;
  height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  min-width: 0;
}
.chat-input input:focus { border-color: var(--accent); }
.text-body button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  height: 46px;
  padding: 0 22px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.text-body button:disabled { background: #8d97a0; cursor: not-allowed; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .avatar-wrap { max-height: 46vh; }
  .chat-pane { height: 80vh; }
}

/* 系统小提示（语音播报不可用等） */
.msg.system { justify-content: center; }
.msg.system .bubble { background: transparent; color: var(--gray-400, #8D97A0); font-size: 12px; box-shadow: none; }

/* ============ 全局滚动条统一样式（长期约定：全系统所有滚动条均按此样式） ============
   8px 圆角浅色滑块、悬停绿色、透明轨道 —— 与后台 admin-common.css 的统一约定一致 */
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-thumb{background:var(--line);border-radius:4px}
::-webkit-scrollbar-thumb:hover{background:var(--accent)}
::-webkit-scrollbar-track{background:transparent}
html{scrollbar-width:thin;scrollbar-color:var(--line) transparent}
