/* ======================================================================
   全站样式。想改颜色、字体、圆角，改 :root 里的变量即可。
   ====================================================================== */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --text: #1f2328;
  --text-2: #5c6470;
  --border: #e4e6ea;
  --accent: #2f6fed;
  --accent-hover: #2359c7;
  --user-bubble: #e9effd;
  --ai-bubble: #ffffff;
  --warn: #ffd166;
  --danger: #d64545;
  --ok: #2e9e5b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --conv-max: 760px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.6; font-size: 15.5px; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: var(--accent); }
.muted { color: var(--text-2); font-size: 0.9rem; }
.hidden { display: none !important; }

/* ---------- 通用按钮 / 表单 ---------- */
.btn, button.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-size: 0.95rem; cursor: pointer; background: var(--accent); color: #fff;
  text-decoration: none; transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #c3cad6; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b73a3a; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; border-radius: 8px; }
.btn.icon { padding: 6px; border-radius: 8px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.95rem;
  font-family: inherit; background: var(--surface); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,237,0.12); }
label.check { display: flex; gap: 8px; align-items: flex-start; margin: 16px 0; cursor: pointer; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions { margin-top: 20px; }
.error { color: var(--danger); margin-top: 8px; font-size: 0.9rem; }

/* ---------- 普通页面（同意、检测、问卷、结束） ---------- */
.page-top {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; font-weight: 600; gap: 10px;
}
.page-top .logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #2f6fed, #7aa5ff); }
.container { max-width: 720px; margin: 0 auto; padding: 32px 16px 64px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.content h1 { font-size: 1.45rem; margin: 0 0 14px; }
.content h2 { font-size: 1.12rem; margin: 20px 0 8px; }
.content h3 { font-size: 1.02rem; margin: 14px 0 6px; }
.content p { margin: 8px 0; }
.content ul { padding-left: 1.3em; }

/* ---------- 测试模式 ---------- */
#test-banner {
  background: var(--warn); color: #3b2f00; font-weight: 600; text-align: center;
  padding: 3px 12px; font-size: 0.85rem; position: relative; z-index: 60;
}
/* 测试面板：实验进度时间轴（一行，固定像素字号，不随聊天页缩放） */
#test-panel {
  background: #fff8dc; border-bottom: 1px solid #f0d78c; padding: 4px 20px; font-size: 14px; line-height: 1.4;
  display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: center; position: relative; z-index: 60; color: #3b2f00;
}
#test-panel .tp-main { flex: 1 1 620px; min-width: 0; display: flex; align-items: center; gap: 4px; }
#test-panel .tp-title { flex: 0 0 auto; cursor: help; white-space: nowrap; }
#test-panel .tp-main .tl { flex: 1 1 auto; }
#test-panel .tp-side { flex: 0 1 auto; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
#test-panel label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
#test-panel .tp-btn { padding: 4px 10px; font-size: 13px; border-radius: 7px; background: #8a6d00; color: #fff; border: none; cursor: pointer; }
#test-panel .tp-btn:hover { background: #6b5400; }
#test-panel .tp-btn:disabled { background: #c9b98a; cursor: not-allowed; }
#test-panel a { color: #6b5400; }
#test-debug { font-family: ui-monospace, Consolas, monospace; color: #6b5400; font-size: 12.5px; min-width: 21em; }
#test-reopen { display: none; position: fixed; top: 4px; right: 8px; z-index: 70; font-size: 12px; padding: 3px 10px; border-radius: 7px; border: 1px solid #f0d78c; background: #fff8dc; color: #6b5400; cursor: pointer; }
body.tp-collapsed #test-panel { display: none; }
body.tp-collapsed #test-reopen { display: block; }

.tl { position: relative; height: 40px; margin: 2px 36px 0; cursor: pointer; touch-action: none; user-select: none; }
.tl-track { position: absolute; left: 0; right: 0; top: 12px; height: 6px; background: #ecdca4; border-radius: 99px; }
.tl-done { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #b48a00; border-radius: 99px; transition: width 0.2s; }
.tl.dragging .tl-done, .tl.dragging .tl-handle { transition: none; }
.tl-node { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.tl-node .dot { width: 14px; height: 14px; margin-top: 8px; border-radius: 50%; background: #fff; border: 2px solid #c9ae55; }
.tl-node .lbl { margin-top: 1px; font-size: 13px; white-space: nowrap; color: #8a6d00; padding: 0 3px; border-radius: 4px; }
.tl-node .lbl:hover { background: #f5e6b0; }
.tl-node.past .dot { background: #b48a00; border-color: #b48a00; }
.tl-node.cur .lbl { color: #3b2f00; font-weight: 700; }
.tl-node.aim .lbl { color: #fff; background: #b48a00; }
.tl-handle {
  position: absolute; top: 5px; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%;
  background: #fff; border: 4px solid #8a6d00; box-shadow: 0 1px 4px rgba(0,0,0,0.25); transition: left 0.2s; cursor: grab; z-index: 2;
}
.tl.dragging .tl-handle { cursor: grabbing; transform: scale(1.15); }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 32, 0.4); display: flex;
  align-items: center; justify-content: center; z-index: 200; padding: 16px; animation: fade 0.15s ease-out;
}
.modal {
  background: #fff; border-radius: 16px; padding: 24px; max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22); animation: pop 0.18s ease-out;
  /* 内容再长也不会超出屏幕：中间内容区滚动，按钮始终在底部 */
  max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
}
.modal.wide { max-width: min(1200px, 96vw); }
.modal h3 { margin: 0 0 10px; font-size: 1.1rem; flex: 0 0 auto; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.modal p { margin: 0 0 16px; white-space: pre-wrap; }
.modal .row { justify-content: flex-end; }
.modal .modal-actions { flex: 0 0 auto; padding-top: 14px; }
.modal .transcript, .modal .events { max-height: none; }
@keyframes pop { from { transform: scale(0.96) translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ======================================================================
   聊天页
   布局：左侧细栏 ｜ 右边上面是固定顶栏，下面是居中的聊天栏 + 圆角输入框。
   整体大小随浏览器宽度按比例放大（1920 宽时根字号约 22px）；
   想再大/再小：config.yaml → ui.chat_scale（整体）、ui.topbar_scale（只调顶栏）。
   尺寸单位：rem 跟随整体；var(--tb) 跟随顶栏。
   ====================================================================== */
/* 1920 宽、chat_scale=0.7 时约 15.5px；小屏保底 14px，被试的字不会太小 */
html.chat-page { font-size: max(14px, calc(clamp(17px, 1.05vw + 2px, 26px) * var(--chat-scale, 1))); }
body.chat-body {
  font-size: 1rem; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  --tb: calc(1rem * var(--topbar-scale, 1));
  --col: max(40rem, 40vw);            /* 中间聊天栏宽度：屏幕宽度的 40%（1920 宽约 770px，参考主流 AI 聊天产品） */
  --c: calc(var(--tb) * 0.85);       /* 顶栏三个块（两条 RAM、计时器）的尺寸单位 = 顶栏单位的 85% */
}
body.chat-body #test-banner, body.chat-body #test-panel { flex: 0 0 auto; }
/* 只有对话区自己滚动，顶栏永远固定在最上方 */
.app { position: relative; flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden; background: var(--bg); }

/* ---------- 左侧细栏 ---------- */
.rail {
  flex: 0 0 auto; width: 3.6rem; display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  padding: 0.9rem 0; background: var(--surface); border-right: 1px solid var(--border); z-index: 25;
}
.rail-fill { flex: 1; }
.rail-avatar {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; background: linear-gradient(135deg, #2f6fed, #7aa5ff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.icon-btn {
  width: 2.6rem; height: 2.6rem; border-radius: 0.7rem; border: none; background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 1.4rem; height: 1.4rem; }

.shell { position: relative; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; flex: 0 0 auto; height: calc(var(--tb) * 4.5);
  display: flex; align-items: center; gap: var(--tb);
  padding: 0 calc(var(--tb) * 1.2); background: var(--surface); border-bottom: 1px solid var(--border); z-index: 20;
}
.tb-title { flex: 0 1 auto; min-width: 0; max-width: calc(var(--tb) * 9); }
.conv-title { font-weight: 600; font-size: calc(var(--tb) * 1.05); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-spacer { flex: 1 1 0; min-width: 0; }
.tb-right { flex: 0 0 auto; display: flex; align-items: center; gap: calc(var(--tb) * 1.1); }

/* 三个一样大的块：认知 RAM、情绪 RAM、计时器 */
.hud-chip {
  flex: 0 0 auto; height: calc(var(--c) * 3.3); display: flex; align-items: center; gap: calc(var(--c) * 0.6);
  padding: 0 calc(var(--c) * 1); border: 2px solid #d5d9e0; border-radius: 999px; background: var(--surface);
  color: var(--text); white-space: nowrap; font-size: calc(var(--c) * 1.1); box-shadow: 0 1px 3px rgba(16,24,40,0.06);
}
.ram-group { flex: 0 0 auto; display: flex; gap: var(--c); align-items: center; margin-left: var(--tb); }
.ram .name { font-weight: 700; }
.ram .track { width: calc(var(--c) * 8); height: calc(var(--c) * 1.2); border-radius: 999px; background: #e3e6ec; overflow: hidden; position: relative; }
.ram .fill {
  height: 100%; width: 0; border-radius: 999px; background: #3b82f6;
  transition: width 0.25s linear, background-color 0.6s linear;
  animation: ramPulse 2.4s ease-in-out infinite;
}
.ram .pct { width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
@keyframes ramPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }

.timer-chip svg { width: calc(var(--c) * 1.5); height: calc(var(--c) * 1.5); color: var(--text-2); }
.timer-chip .lbl { font-weight: 700; }
.timer { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: calc(var(--c) * 1.75); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.timer-chip.paused { opacity: 0.5; }

/* Wi-Fi 状态 */
.wifi { display: inline-flex; align-items: center; gap: calc(var(--tb) * 0.4); font-size: calc(var(--tb) * 0.95); color: var(--text-2); white-space: nowrap; }
.wifi svg { width: calc(var(--tb) * 1.6); height: calc(var(--tb) * 1.6); }
.wifi .label { display: none; }
.wifi.online svg { color: var(--ok); }
.wifi.reconnecting svg { color: #e0a100; animation: blink 1s infinite; }
.wifi.offline svg { color: var(--danger); }
.wifi.reconnecting .label, .wifi.offline .label { display: inline; }   /* 出问题时才显示文字 */

.instr-btn {
  border: 2px solid var(--accent); background: var(--surface); color: var(--accent); font-weight: 700;
  border-radius: 999px; height: calc(var(--tb) * 2.6); padding: 0 calc(var(--tb) * 1.2); font-size: calc(var(--tb) * 1.05);
  cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.instr-btn:hover { background: #eef4ff; }

/* ---------- 聊天区：内容在中间一栏 ---------- */
.main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.conv { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; padding: 1.4rem 1.5rem 8rem; }
.conv-inner { width: 100%; max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: 1.2rem; }
.date-label { align-self: center; font-size: 0.85rem; color: var(--text-2); background: var(--surface-2); padding: 0.15rem 0.9rem; border-radius: 999px; margin-bottom: 0.3rem; animation: rise 0.3s ease-out; }

.msg { display: flex; animation: rise 0.28s cubic-bezier(.2,.8,.2,1); }
.msg.user { justify-content: flex-end; }
.msg.ai { justify-content: flex-start; }
.bubble {
  max-width: 82%; padding: 0.85rem 1.25rem; border-radius: 1.3rem; white-space: pre-wrap; word-break: break-word; line-height: 1.7; font-size: 1.1rem;
}
.msg.user .bubble { background: var(--user-bubble); border-bottom-right-radius: 0.45rem; }
.msg.ai .bubble { background: var(--ai-bubble); border: 1px solid var(--border); border-bottom-left-radius: 0.45rem; box-shadow: 0 1px 2px rgba(16,24,40,0.04); }
.msg.ai .avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: linear-gradient(135deg, #2f6fed, #7aa5ff); flex: 0 0 auto; margin-right: 0.9rem; margin-top: 0.2rem; }
.thinking .bubble { color: var(--text-2); display: inline-flex; align-items: center; gap: 0.45rem; }
.thinking .dots span { display: inline-block; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; margin: 0 1px; animation: dot 1.2s infinite; }
.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0.3; } }

/* 输入区：首屏居中，开始对话后贴底；宽度和聊天栏一致 */
.composer-wrap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0.9rem 1.5rem 1.2rem;
  background: linear-gradient(to top, var(--bg) 72%, rgba(247,247,248,0)); transition: bottom 0.45s cubic-bezier(.2,.8,.2,1), top 0.45s cubic-bezier(.2,.8,.2,1), transform 0.45s;
}
.app.empty .composer-wrap { top: 42%; bottom: auto; transform: translateY(-50%); background: none; }
.app.empty .conv { display: none; }
.hero { display: none; text-align: center; color: var(--text); font-size: 2.2rem; font-weight: 600; margin-bottom: 1.4rem; animation: rise 0.4s ease-out; }
.app.empty .hero { display: block; }
.composer {
  width: 100%; max-width: var(--col); margin: 0 auto; display: flex; align-items: flex-end; gap: 0.7rem; background: var(--surface);
  border: 1px solid #d5d9e0; border-radius: 2rem; padding: 0.65rem 0.65rem 0.65rem 1.5rem; box-shadow: 0 2px 10px rgba(16,24,40,0.08);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.composer:focus-within { border-color: #b9ccf8; box-shadow: 0 0 0 4px rgba(47,111,237,0.1), 0 2px 10px rgba(16,24,40,0.08); }
.composer textarea {
  flex: 1; border: none; background: transparent; resize: none; padding: 0.55rem 0; min-height: 1.7rem; max-height: 12rem; font-size: 1.1rem; line-height: 1.55; box-shadow: none;
}
.composer textarea:focus { box-shadow: none; }
.send-btn {
  width: 2.9rem; height: 2.9rem; border-radius: 50%; border: none; background: var(--accent); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s, transform 0.1s; flex: 0 0 auto;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: #c3cad6; cursor: not-allowed; }
.send-btn svg { width: 1.3rem; height: 1.3rem; }
.composer-hint { width: 100%; max-width: var(--col); margin: 0.45rem auto 0; font-size: 0.8rem; color: var(--text-2); display: flex; justify-content: space-between; padding: 0 1rem; }
.ended-bar {
  width: 100%; max-width: var(--col); margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 1.2rem;
  padding: 1rem 1.4rem; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; box-shadow: var(--shadow); animation: rise 0.3s;
}
.ended-bar .muted { font-size: 1.05rem; }
.ended-bar .btn { font-size: 1.05rem; padding: 0.6rem 1.3rem; }

/* ---------- 侧栏（点左上角按钮展开） ---------- */
.sidebar {
  position: absolute; top: 0; bottom: 0; left: 0; width: 18rem; background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform 0.28s cubic-bezier(.2,.8,.2,1); z-index: 40; display: flex; flex-direction: column; padding: 1rem;
}
.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,0.12); }
.sidebar h4 { margin: 0.5rem 0.4rem 0.7rem; font-size: 0.85rem; color: var(--text-2); font-weight: 600; letter-spacing: 0.02em; }
.sidebar .conv-item { padding: 0.7rem 0.8rem; border-radius: 0.7rem; background: var(--surface-2); font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .foot { margin-top: auto; padding: 0.7rem 0.8rem; border-top: 1px solid var(--border); font-size: 0.95rem; color: var(--text-2); }
.sidebar .foot b { color: var(--text); font-family: ui-monospace, Consolas, monospace; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.18); z-index: 30; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- 右侧实验说明面板 ---------- */
.instr-panel {
  position: absolute; top: 0; bottom: 0; right: 0; width: min(36rem, 92vw); background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.28s cubic-bezier(.2,.8,.2,1); z-index: 40; display: flex; flex-direction: column;
}
.instr-panel.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,0.12); }
.instr-panel .head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1.3rem; }
.instr-panel .body { flex: 1 1 auto; padding: 1.3rem 1.6rem; overflow-y: auto; font-size: 1.1rem; line-height: 1.75; }
.instr-panel .body h3 { margin: 0 0 0.6rem; font-size: 1.25rem; }
.instr-panel .body ul { padding-left: 1.3em; }
.instr-panel .pause-note { margin: 0; padding: 0.8rem 1.3rem; font-size: 0.95rem; color: var(--text-2); background: var(--surface-2); border-top: 1px solid var(--border); }
/* 聊天页里的弹窗也跟着放大 */
body.chat-body .modal { max-width: 32rem; font-size: 1.05rem; padding: 1.6rem; }
body.chat-body .modal h3 { font-size: 1.3rem; }
body.chat-body .modal .btn { font-size: 1.05rem; padding: 0.6rem 1.2rem; }

/* 屏幕不够宽时，顶栏元素自动收窄 */
@media (min-width: 2100px) { .wifi .label { display: inline; } }
@media (max-width: 1200px) { .tb-title { display: none; } .ram .track { width: calc(var(--c) * 6.5); } }
@media (max-width: 1000px) { .ram .track { width: calc(var(--c) * 4); } .timer-chip .lbl { display: none; } }
@media (max-width: 860px) {
  .rail { display: none; }
  .ram .name { display: none; }
  .bubble { max-width: 90%; }
}
@media (max-width: 600px) {
  .timer-chip, .ram .pct { display: none !important; }
  .instr-btn { padding: 0 0.6rem; }
}

/* ---------- 连接检测 ---------- */
.net-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.net-stat { background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; }
.net-stat .v { font-size: 1.3rem; font-weight: 700; }
.net-stat .k { font-size: 0.78rem; color: var(--text-2); }
.progress { height: 8px; background: #e6e8ee; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }
.status-ok { color: var(--ok); font-weight: 600; }
.status-bad { color: var(--danger); font-weight: 600; }

/* ---------- 问卷 ---------- */
.q { margin: 22px 0; padding-bottom: 18px; border-bottom: 1px dashed var(--border); }
.q .qt { font-weight: 600; margin-bottom: 10px; }
.q .req { color: var(--danger); margin-left: 4px; }
.likert { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.likert .anchor { font-size: 0.8rem; color: var(--text-2); width: 100%; display: flex; justify-content: space-between; }
.likert label { flex: 1; min-width: 36px; text-align: center; cursor: pointer; }
.likert label span { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 8px 0; transition: background 0.12s; }
.likert input { display: none; }
.likert input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.opts label { display: flex; gap: 8px; align-items: center; margin: 6px 0; cursor: pointer; }
.q.invalid .qt { color: var(--danger); }

/* ======================================================================
   管理员控制台
   ====================================================================== */
/* 控制台铺满整个浏览器宽度，字号整体比别的页面大（随屏幕宽度放大，1920 宽约 19px） */
/* --admin-scale 默认 0.8（= 上一版的 80%，1920 宽约 15.4px），可在控制台右上角「页面大小」调 */
html.admin-html { font-size: max(12.5px, calc(clamp(16px, 0.9vw + 2px, 20px) * var(--admin-scale, 0.8))); }
body.admin-page { font-size: 1.05rem; }
.admin { max-width: none; margin: 0; padding: 1.6rem clamp(24px, 3.5vw, 80px) 3.5rem; }
.admin .card { padding: 1.6rem; }
.admin .btn { padding: 0.55rem 1rem; }
.size-ctl { display: inline-flex; align-items: center; gap: 4px; }
.size-ctl button { width: 1.8rem; height: 1.8rem; border: 1px solid var(--border); background: var(--surface); border-radius: 0.45rem; cursor: pointer; font-size: 1rem; line-height: 1; color: var(--text); }
.size-ctl button:hover { background: var(--surface-2); }
.size-ctl b { min-width: 2.8em; text-align: center; }
.admin h1 { font-size: 1.75rem; margin: 0; }
.admin h2 { font-size: 1.3rem; margin: 0 0 12px; }
.admin .muted { font-size: 0.95rem; }
.admin .btn { font-size: 1rem; }
.admin .btn.small { font-size: 0.92rem; padding: 0.35rem 0.75rem; }
.admin input[type=text], .admin input[type=password], .admin input[type=number], .admin textarea, .admin select { font-size: 1rem; }
body.admin-page .modal h3 { font-size: 1.35rem; }
body.admin-page .modal { padding: 28px; }
.tile.archived .v { color: #8b8f97; }
.restart-bar { background: var(--danger); color: #fff; font-weight: 600; padding: 12px 18px; border-radius: 12px; margin-bottom: 16px; font-size: 1.05rem; }
.bulkbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 12px; padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; transition: background 0.2s, border-color 0.2s;
}
.bulkbar.active { background: #eef4ff; border-color: #9fbcf5; }
.bulkbar .sel-count { font-size: 1.05rem; min-width: 6.5em; }
.bulkbar .bulk-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.bulkbar .btn:disabled { opacity: 0.45; }
.bulkbar .btn.secondary:disabled { background: var(--surface); color: var(--text-2); }
.chk-all { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.pager select { width: auto; padding: 5px 8px; }
table.tbl th.chk, table.tbl td.chk { width: 4rem; text-align: center; padding-left: 0.5rem; padding-right: 0.5rem; }
table.tbl input[type=checkbox] { width: 1.15rem; height: 1.15rem; cursor: pointer; vertical-align: middle; }
table.tbl td.ops { white-space: normal; min-width: 19rem; }
table.tbl td.ops .btn { margin: 2px 0; }
table.tbl tr.selected td { background: #f1f6ff; }
table.tbl tr.archived td { color: #7b818a; }
.note-edit { display: inline-flex; align-items: center; gap: 6px; max-width: 15rem; }
.note-edit .note-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-edit .pen { border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--accent); font-size: 0.85rem; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.note-edit .pen:hover { background: #eef4ff; border-color: #9fbcf5; }
.note-edit input { width: 13rem; padding: 0.25rem 0.5rem; font-size: 0.95rem; }
.section { margin-top: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 14px 10px; text-align: center; }
.tile .v { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.tile .k { font-size: 0.88rem; color: var(--text-2); margin-top: 2px; }
.tile.created .v { color: #6b7280; } .tile.active .v { color: var(--ok); } .tile.disconnected .v { color: #e0a100; }
.tile.completed .v { color: var(--accent); } .tile.terminated .v { color: var(--danger); } .tile.cancelled .v { color: #9aa0a6; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.toolbar select, .toolbar input[type=text] { width: auto; padding: 8px 11px; font-size: 1rem; }
.toolbar input[type=text] { min-width: 15rem; }
.tbl-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 1rem; }
table.tbl th, table.tbl td { border-bottom: 1px solid var(--border); padding: 0.65rem 0.75rem; text-align: left; vertical-align: middle; white-space: nowrap; }
table.tbl th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; font-weight: 600; }
table.tbl tr:hover td { background: #fafbfd; }
table.tbl tr.clickable { cursor: pointer; }
.tag { display: inline-block; font-size: 0.82rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); line-height: 1.5; }
.tag.test { background: var(--warn); }
.tag.cost { background: #ffe0d6; } .tag.control { background: #dbe7ff; }
.tag.st-created { background: #eceff3; color: #4b5563; }
.tag.st-active { background: #dcf5e6; color: #166534; }
.tag.st-disconnected { background: #fff3cd; color: #7a5a00; }
.tag.st-completed { background: #dbe7ff; color: #1e3a8a; }
.tag.st-terminated { background: #fde2e2; color: #991b1b; }
.tag.st-cancelled { background: #eceff3; color: #6b7280; text-decoration: line-through; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.form-grid label { font-size: 0.9rem; color: var(--text-2); display: block; margin-bottom: 4px; }
.link-box { font-family: ui-monospace, Consolas, monospace; font-size: 0.88rem; word-break: break-all; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }
.pre { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; font-size: 0.88rem; max-height: 50vh; overflow: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 1rem; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 10px 0 14px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 9px 14px; cursor: pointer; font-size: 1rem; color: var(--text-2); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.transcript { max-height: 55vh; overflow: auto; }
.transcript .m { padding: 10px 12px; border-radius: 10px; margin: 6px 0; font-size: 1rem; white-space: pre-wrap; }
.transcript .m.user { background: var(--user-bubble); }
.transcript .m.ai { background: var(--surface-2); }
.transcript .meta { font-size: 0.82rem; color: var(--text-2); margin-bottom: 3px; white-space: normal; }
.events { font-size: 0.95rem; max-height: 55vh; overflow: auto; }
.events div { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.events .t { color: var(--text-2); font-family: ui-monospace, Consolas, monospace; margin-right: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.88rem; z-index: 300; animation: rise 0.2s; }

@media (max-width: 760px) {
  .container { padding: 16px 12px 40px; }
  .card { padding: 18px; }
}

/* ============================================================
   后测问卷页（survey.html / survey.js）
   英文为主；中文参考译文用浅灰色、稍小字号显示在英文下面
   ============================================================ */
.survey-page { --zh: #9aa1ab; }
.sv-container { max-width: 940px; }
.sv-card { padding: 32px 36px; }
.survey-page .en { color: var(--text); }
.survey-page .zh { color: var(--zh); font-size: 0.86em; margin-top: 2px; }
.survey-page span.en, .survey-page span.zh { display: block; }
.zh-inline { color: inherit; opacity: 0.62; font-size: 0.86em; margin-left: 4px; }

.sv-head { margin-bottom: 18px; }
.sv-part { font-weight: 600; font-size: 1.02rem; }
.sv-part .zh { font-weight: 400; }
.sv-progress { height: 6px; border-radius: 999px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.sv-progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

.sv-intro h1 { font-size: 1.5rem; margin: 4px 0 18px; }
.sv-intro-text p { margin: 0; font-size: 1.08rem; line-height: 1.7; }
.sv-intro-text p.zh { margin-top: 6px; font-size: 0.98rem; }

.sv-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; }
.sv-actions .btn { min-width: 132px; padding: 10px 20px; font-size: 1rem; }
.sv-actions #btn-next { margin-left: auto; }
.sv-err { color: var(--danger); margin-top: 14px; font-size: 0.95rem; }
.sv-err .zh { color: #dd8a8a; }

.sv-stmt { display: flex; gap: 8px; line-height: 1.5; }
.sv-num { color: var(--text-2); min-width: 1.6em; flex: 0 0 auto; }
.sv-item.sv-missing, .sv-matrix tr.sv-missing td { background: #fdeeee; }

/* ---- 矩阵式 n 点量表（7 点 / 5 点）：表头刻度滚动时保持在顶部 ---- */
.sv-matrix { width: 100%; border-collapse: separate; border-spacing: 0; margin: 4px 0 8px; table-layout: fixed; }
.sv-matrix th { position: sticky; top: 0; z-index: 2; background: var(--surface); vertical-align: bottom; font-weight: 500;
  font-size: 0.8rem; line-height: 1.3; padding: 8px 4px 10px; border-bottom: 2px solid var(--border); text-align: center; }
.sv-matrix th.sv-mstmt { width: 40%; }
.sv-matrix th .sv-pt { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }
.sv-matrix th .zh { font-size: 0.92em; }
.sv-matrix td { border-bottom: 1px solid var(--border); padding: 12px 4px; text-align: center; vertical-align: middle; }
.sv-matrix td.sv-mstmt { text-align: left; padding-right: 14px; }
.sv-matrix tbody tr:hover td { background: #f7f9fd; }
.sv-matrix tbody tr.answered td.sv-mstmt .en { color: var(--text-2); }
.sv-cell label { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; min-height: 40px; }
.sv-cell input { position: absolute; opacity: 0; pointer-events: none; }
.sv-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #b9c0cb; background: #fff; transition: all 0.12s; }
.sv-cell label:hover .sv-dot { border-color: var(--accent); }
.sv-cell input:checked + .sv-dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px #fff; }
.sv-cell input:focus-visible + .sv-dot { box-shadow: 0 0 0 3px rgba(47,111,237,0.25); }
.sv-cell-lab { display: none; }

/* ---- 无数字滑块（PETS）：一开始没有圆点 ---- */
.sv-slider-item { padding: 18px 0 16px; border-bottom: 1px solid var(--border); }
.sv-slider { position: relative; margin: 14px 2% 2px; padding: 14px 0; cursor: pointer; touch-action: none; outline: none; }
.sv-track { position: relative; height: 8px; border-radius: 999px; background: #e3e7ee; }
.sv-track::before, .sv-track::after { content: ""; position: absolute; top: -5px; width: 2px; height: 18px; background: #c4cad4; }
.sv-track::before { left: 0; } .sv-track::after { right: 0; }
.sv-slider:hover .sv-track { background: #d8deea; }
.sv-slider:focus-visible .sv-track { box-shadow: 0 0 0 3px rgba(47,111,237,0.2); }
.sv-thumb { display: none; position: absolute; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(16,24,40,0.3); }
.sv-slider-item.answered .sv-thumb { display: block; }
.sv-ends { display: flex; justify-content: space-between; font-size: 0.86rem; margin: 0 0; }
.sv-ends .right { text-align: right; }
.sv-hint { margin-top: 6px; font-size: 0.8rem; color: var(--text-2); text-align: center; }
.sv-slider-item.answered .sv-hint { visibility: hidden; }

/* ---- 其他题型（以后加题用） ---- */
.sv-item:not(tr):not(.sv-slider-item) { padding: 16px 0; border-bottom: 1px solid var(--border); }
.sv-opts { margin: 10px 0 0 2em; }
.sv-opts label { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; cursor: pointer; }
.sv-input { margin: 10px 0 0 2em; width: calc(100% - 2em); }

/* ---- 窄屏：矩阵改成每题一块，每个选项下面直接显示标签 ---- */
@media (max-width: 760px) {
  .sv-card { padding: 20px 16px; }
  .sv-matrix, .sv-matrix tbody, .sv-matrix tr, .sv-matrix td { display: block; width: 100%; }
  .sv-matrix thead { display: none; }
  .sv-matrix tr { border-bottom: 1px solid var(--border); padding: 12px 0; }
  .sv-matrix td { border: none; padding: 0; }
  .sv-matrix td.sv-mstmt { padding-bottom: 8px; }
  .sv-matrix td.sv-cell { display: inline-block; width: calc(100% / var(--n)); vertical-align: top; }
  .sv-cell-lab { display: block; font-size: 0.7rem; margin-top: 4px; line-height: 1.25; }
}

/* ---- 控制台：问卷测量数据预览 ---- */
.m-wrap { max-height: 60vh; overflow: auto; }
table.tbl.m-tbl th, table.tbl.m-tbl td { font-size: 0.85rem; padding: 0.45rem 0.6rem; }
table.tbl.m-tbl th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.m-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.m-tbl th.m-score { color: #1f4fae; }
.m-tbl td.m-score { font-weight: 600; }
.m-tbl th.m-rt, .m-tbl td.m-rt { color: var(--text-2); }
.m-tbl tr.m-fastrow td { background: #fdeeee; }
table.tbl.sv-admin td.wrap { white-space: normal; min-width: 22rem; }
.sv-admin-h { font-size: 1rem; margin: 18px 0 2px; }

/* ============================================================
   任务说明 + 话题自查（instructions.html / instructions.js）
   md 里用 > 开头的那段 = 浅色高亮框（每页最关键的一句）
   ============================================================ */
.instr-container { max-width: 780px; }
.instr-head { margin-bottom: 18px; }
.instr-head .sv-progress { margin-top: 8px; }
.instr-page { font-size: 1.04rem; line-height: 1.85; }
.instr-page h2 { font-size: 1.25rem; margin: 6px 0 14px; }
.instr-page h2:not(:first-child) { margin-top: 28px; }
.instr-page ol, .instr-page ul { padding-left: 1.5em; }
.instr-page li { margin: 6px 0; }
.instr-page blockquote { margin: 18px 0; padding: 14px 18px; background: #fff7df; border: 1px solid #f2dc9b; border-left: 4px solid #e9b949;
  border-radius: 10px; color: #4a3b10; }
.instr-page blockquote p { margin: 0; }
.tc-items { margin: 14px 0 6px; }
.tc-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; }
.tc-item:has(input:checked) { border-color: var(--accent); background: #f3f7ff; }
.tc-item input { margin-top: 5px; }
#tc-back { margin-top: 4px; }
.instr-hint { min-height: 1.4em; margin-top: 18px; color: var(--text-2); font-size: 0.92rem; }
.instr-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }
.instr-actions .btn { min-width: 120px; }
.net-ok { margin-top: 6px; }
.net-ok p:first-child { color: var(--ok); font-weight: 600; }

/* 问卷：滑块数值（show_value）、页面顶部说明、开放题输入框 */
.sv-val { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); min-width: 34px; padding: 2px 7px; border-radius: 7px;
  background: var(--accent); color: #fff; font-size: 0.82rem; font-weight: 600; text-align: center; line-height: 1.5; pointer-events: none; }
.sv-val::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--accent); }
.sv-slider-item .sv-slider { margin-top: 40px; }
.sv-endnum { font-size: 0.8rem; color: var(--text-2); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.sv-page-instr { background: var(--surface-2); border-radius: 10px; padding: 12px 16px; margin: 0 0 8px; }
.sv-page-instr .en { font-weight: 600; }
.survey-page textarea.sv-input { min-height: 96px; font-size: 1rem; line-height: 1.6; }
