:root {
  --brand: #4a7ba6;
  --brand-dark: #3a6285;
  --bg: #eef2f5;
  --card: #ffffff;
  --text: #26333d;
  --muted: #6b7a86;
  --green: #2ecc71;
  --red: #e74c3c;
  --yellow: #f1c40f;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.65;
}

/* 顶栏 */
#topbar {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); position: sticky; top: 0; z-index: 30;
}
#app-title { font-weight: 600; font-size: 17px; }
#progress { font-size: 14px; opacity: .95; }

/* 舞台 */
#stage {
  min-height: calc(100vh - 52px);
  padding: 28px 20px 96px;
  display: flex; align-items: flex-start; justify-content: center;
}
/* 校准页仍用顶部浮层横幅，预留其高度避免遮挡 */
.calib-screen { margin-top: 80px; }

/* 录制页顶部"变色横幅"：左侧常驻标题，中间提示词/倒计时，右侧录制中+计时 */
.rec-headbar {
  align-self: stretch;
  display: flex; align-items: center; gap: 16px;
  background: #eaf2fb; border: 1px solid #cfe0f0; border-radius: 12px;
  padding: 12px 22px; min-height: 56px;   /* 固定高度：内容单行、不因提示词/倒计时变化而伸缩 */
}
.rhb-title { flex: 1 1 auto; min-width: 0; text-align: left; font-size: 22px; font-weight: 700; color: #23425f;
  line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rhb-status { flex: 0 1 auto; text-align: right; font-size: 22px; font-weight: 700; color: #23425f; white-space: nowrap; }
.rhb-status.rhb-go { font-size: 22px; }   /* "请开始…" 与"准备…"同字号 */
.rhb-timerbox { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }
.rhb-live { display: flex; align-items: center; gap: 6px; color: var(--red); font-weight: 600; font-size: 16px; }
.rhb-timerbox .rec-timer { font-size: 22px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.center-box { width: 100%; max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 34px 34px;
  box-shadow: 0 4px 20px rgba(0,0,0,.07); width: 100%;
}
.card.wide { max-width: 760px; }
h1 { font-size: 28px; margin: 6px 0; color: var(--brand-dark); }
h2 { font-size: 23px; margin: 4px 0 8px; color: var(--brand-dark); }
.lead { font-size: 19px; color: var(--text); }
.small { color: var(--muted); font-size: 14px; }
.prompt-text { font-size: 18px; line-height: 1.9; text-align: left; color: #2b3a44; }

/* 通知块 */
.notice { text-align: left; background: #f3f8fc; border: 1px solid #d9e7f2; border-radius: 12px; padding: 16px 20px; width: 100%; }
.notice ul { margin: 10px 0 0; padding-left: 22px; }
.notice li { margin: 7px 0; }

/* 按钮 */
.btn {
  border: none; border-radius: 12px; padding: 13px 26px; font-size: 18px; cursor: pointer;
  font-family: inherit; transition: transform .05s, background .15s; background: #e6ecf1; color: var(--text);
}
.btn:hover { filter: brightness(.98); }
.btn:active { transform: translateY(1px) scale(.99); filter: brightness(.94); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.loading { opacity: .92; cursor: default; }
.btn-spin { display: inline-block; width: 15px; height: 15px; margin-right: 8px; vertical-align: -2px;
            border: 3px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #dfe8ef; color: var(--brand-dark); }
.btn-outline { background: #fff; color: var(--brand); border: 2px solid var(--brand); }
.btn-lg { padding: 16px 40px; font-size: 20px; }
.btn.chosen { background: var(--green); color: #fff; border-color: var(--green); }
.spk-status { margin-top: 10px; font-size: 15px; color: var(--muted); }
.spk-status.ok { color: #1c7c46; font-weight: 600; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hidden { display: none !important; }

/* 提示文字条（顶部浮层，固定定位，出现/消失不影响下方布局）
   —— 提示词文本 与 倒计时数字 同一大小；"请开始…" 文本更大。 */
#banner {
  display: none; padding: 12px 22px; text-align: center;
  font-size: 26px; font-weight: 700; line-height: 1.5;
  background: #eaf2fb; color: #23425f; border-bottom: 1px solid #cfe0f0;
  position: fixed; top: 52px; left: 0; right: 0; z-index: 15;
}
/* 横幅内的倒计时 */
#banner.banner-countdown { padding: 8px 22px; }
#banner .cd-tip { font-size: 22px; margin-right: 12px; opacity: .85; }
#banner .cd-num { font-size: 26px; font-weight: 800; vertical-align: middle; } /* 与提示词同大小 */
#banner .cd-go { font-size: 36px; font-weight: 800; letter-spacing: 2px; }       /* 开始文本更大 */

/* 摄像头 */
.cam-wrap { position: relative; width: 480px; max-width: 90vw; aspect-ratio: 4/3; background: #000; border-radius: 14px; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.cam { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); background: #000; }
.cam-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-mini { width: 260px; }
/* 作答时的摄像头预览：固定在右上角（表头下方），不占布局、不遮挡居中内容 */
.rec-cam-corner {
  position: fixed; top: 156px; right: 18px; width: 240px; z-index: 12;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
@media (max-width: 1180px) { .rec-cam-corner { width: 200px; top: 150px; right: 12px; } }
.calib-title { font-size: 20px; font-weight: 600; color: var(--brand-dark); }
.calib-status { font-size: 17px; padding: 8px 14px; border-radius: 10px; background: #f0f3f6; }
.calib-status.green { color: #1c7c46; background: #e5f7ec; }
.calib-status.red { color: #b23b30; background: #fdecea; }
.calib-status.yellow { color: #8a6d0b; background: #fdf6e0; }
.ok-line { color: #1c7c46; font-weight: 600; margin-bottom: 8px; }
.error { color: var(--red); background: #fdecea; padding: 14px; border-radius: 10px; }

/* 设备检查 */
.field { text-align: left; width: 100%; margin-top: 6px; }
.field-label { font-weight: 600; margin-bottom: 8px; }
/* 被试登录/信息页 */
.login-field { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 460px; margin: 8px auto; text-align: left; }
.login-label { flex: 0 0 64px; font-weight: 600; color: var(--brand-dark); }
.login-input { flex: 1 1 auto; padding: 11px 12px; font-size: 17px; font-family: inherit;
  border: 2px solid #dbe4ec; border-radius: 10px; background: #fff; color: var(--text); }
.login-input:focus { outline: none; border-color: var(--brand); }
.login-err { color: var(--red); background: #fdecea; padding: 10px 14px; border-radius: 8px; margin: 10px auto; max-width: 460px; }

/* 设备检查页：摄像头预览居中 */
.dc-cam-block { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.dev-select {
  width: 100%; padding: 11px 12px; font-size: 16px; font-family: inherit;
  border: 2px solid #dbe4ec; border-radius: 10px; background: #fff; color: var(--text); cursor: pointer;
}
.dev-select:focus { outline: none; border-color: var(--brand); }
.dev-select:disabled { opacity: .6; }
.mic-bar { width: 100%; height: 16px; background: #e6ecf1; border-radius: 8px; overflow: hidden; }
.mic-level { width: 0%; height: 100%; background: linear-gradient(90deg,#7cc,#4a7ba6); transition: width .08s; }
.check { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; font-size: 17px; margin: 4px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; }

/* 倒计时 */
.countdown-num { font-size: 120px; font-weight: 700; color: var(--brand); line-height: 1; }
.countdown-tip { font-size: 20px; color: var(--muted); margin-bottom: 8px; }

/* 灰屏 */
.gray-space { width: 100%; height: 60vh; background: #b8bcc0; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
/* 看图任务图片之间的纯灰中间页：放在原图片位置、尺寸与情境图一致，无文字/无预览 */
.pic-gray { width: min(90vw, 720px); aspect-ratio: 4 / 3; background: #b8bcc0; border-radius: 12px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.pic-gray-text { color: #3a4046; font-size: 34px; font-weight: 600; letter-spacing: 3px; }
.gray-label { color: #4a5158; font-size: 20px; }

/* 朗读 / 问答 / 看图 内容 */
.reading-block, .qa-block, .pic-block, .tell-block { width: 100%; }
.reading-block, .qa-block { text-align: center; }
.pic-block, .tell-block { display: flex; flex-direction: column; align-items: center; }
.reading-title, .qa-index { font-size: 18px; color: var(--brand-dark); font-weight: 600; margin-bottom: 12px; }
.reading-text { text-align: left; font-size: 22px; line-height: 2.1; white-space: pre-wrap; max-width: 760px; margin: 0 auto; }
.qa-text { font-size: 24px; line-height: 1.8; font-weight: 500; max-width: 720px; margin: 0 auto; }
.scene-img { display: block; margin: 0 auto; max-width: 100%; max-height: 56vh; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.14); }
.drawing-in-tell { max-height: 44vh; margin-bottom: 12px; }

/* 录制期间持续显示的页面文字提示 */
.rec-hint { color: var(--muted); font-size: 15px; text-align: center; margin-top: 2px; }
.rec-overlay .go-label { font-size: 30px; letter-spacing: 2px; }

/* 录制屏 */
.rec-screen { width: 100%; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 16px; position: relative; }
.rec-topbar { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.rec-live { display: flex; align-items: center; gap: 8px; color: var(--red); font-weight: 600; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-timer { font-size: 24px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.rec-body { width: 100%; display: flex; justify-content: center; }
.rec-controls { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.more-controls { display: flex; gap: 12px; }
/* 倒计时徽标：放在顶部中央（浮层），不遮挡下方的朗读文字/图片 */
.rec-overlay {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 26;
  background: rgba(38,51,61,.92); color: #fff; padding: 12px 26px; border-radius: 16px;
  display: flex; align-items: center; gap: 16px; box-shadow: 0 6px 22px rgba(0,0,0,.25);
}
/* 录制期间人脸提示条 */
.face-warn {
  align-self: stretch; background: #fdecea; color: #b23b30; border: 1px solid #f5c6c0;
  padding: 8px 16px; border-radius: 10px; font-size: 15px; text-align: center;
}

/* 居中弹窗（"还有吗？"确认，不改变下方画面布局） */
.modal-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(20,28,34,.45);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #fff; border-radius: 16px; padding: 26px 28px; max-width: 440px; width: calc(100% - 48px);
  box-shadow: 0 12px 40px rgba(0,0,0,.28); text-align: center;
}
.modal-text { font-size: 19px; line-height: 1.7; margin-bottom: 18px; color: var(--text); }
.modal-btns { display: flex; gap: 12px; justify-content: center; }

/* 看图说话：常驻问题提示（图片上方） */
.pic-prompt {
  max-width: 720px; margin: 0 auto 14px; font-size: 18px; line-height: 1.7; font-weight: 500;
  color: var(--brand-dark); background: #f3f8fc; border: 1px solid #d9e7f2;
  padding: 12px 18px; border-radius: 12px; text-align: left;
}
.rec-overlay .countdown-tip { font-size: 17px; color: #dfe8ef; margin: 0; }
.rec-overlay .countdown-num { font-size: 44px; color: #fff; line-height: 1; }
.cam-mini { border-radius: 12px; }

/* 绘画 */
.draw-timer-wrap { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 8px 0; }
.draw-timer { font-size: 30px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.qr-box { width: 240px; height: 240px; background: #fff; padding: 10px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 6px auto; box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.qr-box img, .qr-box canvas { display: block; }
.qr-fallback { color: var(--muted); font-size: 14px; text-align: center; }
.qr-hint { color: var(--muted); font-size: 15px; }
.qr-url { font-family: monospace; font-size: 15px; background: #f0f3f6; padding: 10px 14px; border-radius: 8px; word-break: break-all; }
.wait-line { margin-top: 10px; color: var(--brand-dark); display: flex; align-items: center; justify-content: center; gap: 8px; }
.spinner { width: 16px; height: 16px; border: 3px solid #cdd8e1; border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.drawing-frame { max-width: 520px; margin: 8px auto; }
.drawing-preview { max-width: 100%; max-height: 56vh; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.14); transition: transform .2s; }

/* 休息 */
.rest-screen { gap: 18px; }
.rest-emoji { font-size: 54px; }
.rest-title { font-size: 30px; font-weight: 700; color: var(--brand-dark); }
.rest-text { max-width: 620px; color: var(--text); font-size: 18px; }
.rest-timer-wrap { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.rest-timer { font-size: 40px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }

/* 量表 */
.scale-page { width: 100%; max-width: 860px; margin: 0 auto; }
.scale-head { text-align: left; margin-bottom: 16px; }
.scale-progress { color: var(--brand); font-weight: 600; margin-bottom: 4px; }
.scale-instruction { font-size: 17px; color: #2b3a44; }
.scale-hint { font-size: 15px; color: var(--muted); background: #f0f3f6; padding: 8px 12px; border-radius: 8px; margin-top: 6px; }
.scale-leadin { font-size: 19px; font-weight: 600; margin: 10px 0; color: var(--brand-dark); }
.scale-list { display: flex; flex-direction: column; gap: 14px; }
.q-row { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: 0 2px 8px rgba(0,0,0,.05); text-align: left; }
.q-row.missing { box-shadow: 0 0 0 2px var(--red); }
.q-text { font-size: 18px; margin-bottom: 12px; }
.q-no { color: var(--brand); font-weight: 700; }
.opt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.opt-btn { flex: 1; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 8px; border: 2px solid #dbe4ec; background: #fff; border-radius: 10px; cursor: pointer; font-family: inherit; }
.opt-btn .opt-val { font-weight: 700; color: var(--brand); }
.opt-btn .opt-label { font-size: 13px; color: var(--muted); }
.opt-btn.selected { border-color: var(--brand); background: #e9f2fa; }
.opt-btn.selected .opt-label { color: var(--brand-dark); }
.cdi-opts { display: flex; flex-direction: column; gap: 8px; }
.cdi-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid #dbe4ec; background: #fff; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 17px; text-align: left; }
.cdi-box { width: 20px; height: 20px; border: 2px solid #b7c4cf; border-radius: 5px; flex: none; }
.cdi-opt.selected { border-color: var(--brand); background: #e9f2fa; }
.cdi-opt.selected .cdi-box { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 3px #fff; }
.scale-warn { color: var(--red); background: #fdecea; padding: 10px 14px; border-radius: 8px; margin: 14px 0; }
.skip-all { display: block; width: 100%; margin: 0 0 16px; border-style: dashed; color: #8a6d0b; border-color: #e6cf7a; background: #fdf6e0; }
/* 测试用：右下角悬浮"跳过此任务"按钮（上线前 config.debug.taskSkip=false 即隐藏） */
.skip-task-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  padding: 8px 14px; font-size: 13px; font-family: inherit; cursor: pointer;
  background: #fdf6e0; color: #8a6d0b; border: 1px dashed #e6cf7a; border-radius: 10px;
  box-shadow: 0 3px 12px rgba(0,0,0,.15); opacity: .85;
}
.skip-task-btn:hover { opacity: 1; }
.scale-page .btn-lg { display: block; margin: 18px auto 0; }

/* 结束 */
.progress-bar { width: 100%; max-width: 420px; height: 14px; background: #e6ecf1; border-radius: 8px; overflow: hidden; margin: 6px auto; }
.progress-fill { width: 8%; height: 100%; background: var(--brand); transition: width .5s; }
.big-check { font-size: 60px; color: var(--green); }
.done { color: #1c7c46; }
.fail { color: var(--red); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .card { padding: 22px 18px; }
  .reading-text { font-size: 19px; }
  .qa-text { font-size: 20px; }
  .countdown-num { font-size: 80px; }
}
