/* ============================================================
   智能学伴 · 对话界面（PRD-V7 UI 重构）
   目标：对齐豆包 / ChatGPT 等主流大模型对话界面
   侧边导航 + 居中消息流 + 一体化输入框 + 自绘 SVG 图标
   ============================================================ */

:root {
  --bg:          #f7f8fa;
  --sidebar:     #f1f2f6;
  --panel:       #ffffff;
  --border:      #e7e9ef;
  --border-2:    #dfe2ea;
  --text:        #14161c;
  --text-2:      #5b6070;
  --muted:       #9198a8;
  --brand:       #4f6ef7;
  --brand-dark:  #3f5bea;
  --brand-soft:  #eef1ff;
  --user-bubble: #e3e9ff;
  --grad:        linear-gradient(135deg, #5b6cff 0%, #8b5cf6 100%);
  --red:         #e5484d;
  --red-soft:    #fff1f1;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --sh-1: 0 1px 2px rgba(20, 22, 28, .04), 0 2px 8px rgba(20, 22, 28, .04);
  --sh-2: 0 4px 16px rgba(20, 22, 28, .07);
  --sh-3: 0 12px 36px rgba(46, 54, 96, .13);
  --sb-w: 258px;
  --content-w: 748px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }

body {
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
               "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* 学习机是触摸屏：去掉点击时的半透明高亮块（简约界面上显得脏）。
     注意**不要**加全局 user-select:none —— 那会让学生没法选中 AI 的解答来抄题。 */
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; display: block; flex: none; }

/* 通用图标按钮 */
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-2);
  border-radius: var(--r-sm); cursor: pointer;
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: rgba(20, 22, 28, .06); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.tiny { width: 28px; height: 28px; }
.icon-btn.tiny .ico { width: 16px; height: 16px; }

/* ============================================================
   登录屏
   ============================================================ */
.login-screen {
  position: fixed; inset: 0; z-index: 50;
  /* 保持原行为：flex-start + 卡片 margin:auto ⇒ 居中且超高可滚动、不裁顶 */
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px;
  overflow-y: auto; overscroll-behavior: contain;
  background:
    radial-gradient(880px 620px at 6% -10%, rgba(79, 110, 247, .30), transparent 62%),
    radial-gradient(760px 560px at 98% 4%, rgba(139, 92, 246, .28), transparent 60%),
    radial-gradient(900px 640px at 46% 112%, rgba(56, 189, 248, .22), transparent 62%),
    linear-gradient(165deg, #eff2fc 0%, #f9fafe 48%, #eef5fd 100%);
  isolation: isolate;
}

/* ── 卡片：半透明 + 毛玻璃，浮在极光之上 ── */
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 396px;
  margin: auto;              /* 配合 flex-start：居中且可滚动、不裁顶 */
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 28px;
  box-shadow:
    0 1px 2px rgba(16, 24, 40, .04),
    0 24px 56px -16px rgba(46, 54, 96, .28),
    0 0 0 1px rgba(16, 24, 40, .04);
  padding: 44px 32px 30px;
  text-align: center;
  overflow: hidden;
  animation: cardIn .5s var(--ease) both;
}
/* 卡片顶部一道柔光高光，让"玻璃"有实体感 */
.login-card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .95), transparent);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* ── Logo：加一圈柔光晕，让线稿不至于孤零零贴在白底上 ── */
.login-logo {
  position: relative;
  width: 68px; height: 68px; margin: 0 auto 18px;
  display: grid; place-items: center;
}
.login-logo::before {
  content: ""; position: absolute; inset: -16px; border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 108, 255, .22), rgba(139, 92, 246, .07) 58%, transparent 72%);
}
/* 品牌 Logo 位图（2026-09-25 起用 AI 生成图，替代内联符号 #i-bot）：
   **无底色紫色线稿**（背景透明）——容器不画底色，图直接落在页面背景上。 */
.brand-img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* 小尺寸（消息头像 32px / 侧栏 30px）：Logo 画布自带留白，放大一点更清晰 */
.msg-avatar .brand-img, .sb-logo .brand-img { transform: scale(1.22); }

.login-title { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: .3px; }
.login-sub {
  display: inline-block; margin: 10px 0 0;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; color: var(--text-2);
  background: rgba(79, 110, 247, .08);
  border: 1px solid rgba(79, 110, 247, .14);
}

/* ── 输入框：加前置图标，抬高到 52px，聚焦时描边+柔光圈 ── */
.login-field { margin-top: 28px; position: relative; }
.login-ico {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 19px; height: 19px; color: var(--muted); pointer-events: none;
  transition: color .18s;
}
.login-field:focus-within .login-ico { color: var(--brand); }

/* 姓名输入态：整张卡上移，把下半屏让给软键盘与候选列表（2026-09-19）。
   纯 CSS、不依赖键盘检测 —— 这样即使浏览器探不到软键盘，输入框与候选也都看得见。
   取 max(44vh, --kb)：浏览器探到键盘时用**实测高度**，探不到时用 44vh 兜底；
   两者取大避免"检测到键盘 + 固定 44vh"叠加把卡片顶出屏幕。失焦自动复位。 */
.login-screen:focus-within { padding-bottom: max(44vh, var(--kb, 0px)); }
/* 姓名联想**上拉**（2026-09-29 研究者要求：定位于输入框**上方**，
   避免和软键盘重叠；绝对定位不挤压登录卡布局）。 */
.login-suggest {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 20;
  background: #fff; border: 1px solid var(--border-2); border-radius: 16px;
  /* 上限同时受视口约束：矮屏上不能占掉大半屏（2026-09-19）；
     overflow-y + overscroll-behavior：列表内可上下滑动、滑到头不带动页面。 */
  box-shadow: 0 12px 32px -8px rgba(46, 54, 96, .22);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; max-height: min(260px, 42vh);
  padding: 6px;
}
.login-suggest-item {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px; border: 0; background: transparent; cursor: pointer;
  font-size: 15px; font-family: inherit; color: var(--text); border-radius: 11px;
}
/* 收细滚动条，和页面其它滚动条保持一致（默认那条在小白卡上太抢眼） */
.login-suggest::-webkit-scrollbar { width: 7px; }
.login-suggest::-webkit-scrollbar-thumb { background: #d8dce6; border-radius: 4px; border: 2px solid #fff; }
.login-suggest-item.on, .login-suggest-item:hover { background: var(--brand-soft); color: var(--brand-dark); }
.login-input {
  width: 100%; padding: 16px 16px 16px 46px;
  font-size: 15.5px; font-family: inherit;
  color: var(--text); background: #fff;
  border: 1.5px solid var(--border-2); border-radius: 16px;
  outline: none; transition: border-color .18s, box-shadow .18s, background .18s;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.login-input::placeholder { color: #a9b0c0; }
.login-input:focus {
  background: #fff; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 110, 247, .14), 0 6px 18px -8px rgba(79, 110, 247, .4);
}
.login-btn {
  width: 100%; margin-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px; font-size: 15.5px; font-weight: 700; letter-spacing: .3px; color: #fff;
  background: var(--grad); border: none; border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 12px 26px -10px rgba(91, 108, 255, .75), 0 2px 6px rgba(91, 108, 255, .2);
  transition: filter .18s, transform .12s, box-shadow .18s;
}
.login-btn .ico { width: 18px; height: 18px; transition: transform .18s; }
.login-btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 16px 30px -10px rgba(91, 108, 255, .8); }
.login-btn:hover .ico { transform: translateX(2px); }
.login-btn:active { transform: translateY(0) scale(.995); }
.login-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.login-hint { margin: 20px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* 编码能力测试入口（2026-10-28）：设备摸底期临时可见，由 .env 的
   PROBE_LINK_ENABLED 控制——关掉后模板整块不渲染，这里留样式不影响。
   刻意做得很轻：小字、弱色、无边框，学生不会把它当成"该点的按钮"。 */
.probe-link {
  display: inline-block; margin-top: 14px; padding: 4px 0;
  font-size: 12px; color: var(--muted); text-decoration: none;
  border-bottom: 1px dashed currentColor; opacity: .72;
  -webkit-tap-highlight-color: transparent;
}
.probe-link:hover, .probe-link:active { opacity: 1; }

/* ============================================================
   应用骨架
   ============================================================ */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- 侧边导航 ---------- */
.sidebar {
  width: var(--sb-w); flex: 0 0 var(--sb-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 10px 10px;
  transition: margin-left .28s var(--ease);
}
.app.sb-collapsed .sidebar { margin-left: calc(var(--sb-w) * -1); }

.sb-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 2px 12px; }
.sb-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sb-logo {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
}
.sb-brand-name { font-size: 14.5px; font-weight: 650; white-space: nowrap; }

.sb-new {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; margin-bottom: 16px;
  font-size: 14px; font-weight: 550; color: var(--text);
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: var(--r-md); cursor: pointer;
  box-shadow: var(--sh-1);
  transition: border-color .16s, color .16s, transform .1s;
}
.sb-new .ico { width: 17px; height: 17px; color: var(--brand); }
.sb-new:hover { border-color: var(--brand); color: var(--brand); }
.sb-new:active { transform: translateY(1px); }

.sb-label {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  letter-spacing: .6px; padding: 0 8px 7px;
}
.sb-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -2px; padding: 0 2px; }
.sb-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-2);
  cursor: pointer; border: none; background: transparent;
  text-align: left; width: 100%;
  transition: background .14s, color .14s;
}
.sb-item .ico { width: 15px; height: 15px; flex: none; opacity: .7; }
.sb-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item:hover { background: rgba(20, 22, 28, .055); color: var(--text); }
.sb-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 550; }
.sb-item.active .ico { opacity: 1; }
.sb-empty { font-size: 12.5px; color: var(--muted); padding: 8px 10px; line-height: 1.6; }

.sb-bottom { border-top: 1px solid var(--border-2); padding-top: 9px; margin-top: 8px; }
.sb-user { display: flex; align-items: center; gap: 9px; padding: 5px 6px; }
.sb-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad); color: #fff; font-size: 13px; font-weight: 600;
}
.sb-uname {
  flex: 1; min-width: 0; font-size: 13.5px; font-weight: 550;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-out:hover { color: var(--red); background: var(--red-soft); }

.sb-mask { display: none; }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* 顶部栏（.topbar）已于 2026-09-15 整体删除：学生在学习机上易误触其中的按钮，
   且栏内除标题外只剩「新会话」（会切断当前研究会话）。品牌名与书名仍保留在
   侧栏 .sb-brand 内。 */
/* 侧栏展开按钮改为悬浮：仅在侧栏收起时出现，是此时打开侧栏（内含退出登录）的唯一入口 */
#menuBtn {
  display: none;
  position: fixed; left: 12px; top: 12px; z-index: 30;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--sh-2);
}
.app.sb-collapsed #menuBtn { display: grid; }

/* 右上角「开始新对话」：**故意做得显眼**（研究者 2026-09-23 要求，原为白底灰字小按钮）。
   ⚠️ 非破坏性：不清空聊天展示，只插一条说明并新开 sessionId（见 agent.js 的 softNewSession）。
   风险已被设计吸收；代价是学生手滑会产生更多 sessionId（可用 session_new 事件度量）。 */
.soft-new {
  position: fixed; right: 12px; top: 12px; z-index: 30;
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--brand); border-radius: 10px;
  background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 650;
  box-shadow: 0 2px 10px rgba(91, 108, 255, .30);
  transition: filter .16s, transform .1s, box-shadow .16s;
}
.soft-new .ico { width: 17px; height: 17px; color: #fff; }
.soft-new:hover { filter: brightness(.95); box-shadow: 0 3px 14px rgba(91, 108, 255, .42); }
.soft-new:active { transform: scale(.96); }

/* ---------- 消息流 ---------- */
.stream {
  flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth;
  /* 触摸屏：滚动不"传染"给外层（防误触反弹），并给最后一条消息留点呼吸 */
  overscroll-behavior: contain;
  scroll-padding-bottom: 10px;
}
.stream-inner {
  max-width: var(--content-w); margin: 0 auto;
  padding: 14px 22px 26px; min-height: 100%;
  display: flex; flex-direction: column;
}
.stream::-webkit-scrollbar { width: 9px; }
.stream::-webkit-scrollbar-thumb { background: #d3d7e3; border-radius: 5px; border: 2.5px solid var(--bg); }
.stream::-webkit-scrollbar-thumb:hover { background: #bcc2d4; }

/* 欢迎页 */
.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 20px 0 34px;
  animation: fadeUp .45s var(--ease) both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
.wc-logo {
  width: 60px; height: 60px;
  display: grid; place-items: center;
  margin-bottom: 18px;
}
.wc-title { font-size: 25px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.wc-sub { font-size: 14px; color: var(--text-2); margin: 10px 0 0; max-width: 430px; line-height: 1.7; }
.wc-chips {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin-top: 30px; width: 100%; max-width: 580px;
}
.wc-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 15px; text-align: left;
  font-size: 13.5px; color: var(--text); line-height: 1.5;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md); cursor: pointer; box-shadow: var(--sh-1);
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
.wc-chip .ico { width: 16px; height: 16px; color: var(--brand); opacity: .85; }
.wc-chip:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--sh-2); }
.wc-chip:active { transform: translateY(0); }

/* 链式推荐问句（PRD-V13 §3.4） */
.rec-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 10px 0 2px; animation: msgIn .25s var(--ease) both;
}
.rec-chip {
  padding: 8px 14px; font-size: 13px; line-height: 1.3;
  border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  transition: border-color .16s, transform .16s, box-shadow .16s, background .16s;
}
.rec-chip:hover { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--sh-2); }
.rec-chip:active { transform: translateY(0); }
.rec-chip.rec-pref { border-color: rgba(91, 108, 255, .45); color: #4a56c9; }
.rec-chip.rec-default { color: var(--text-2); background: transparent; box-shadow: none; border-style: dashed; }
.rec-chip.rec-default:hover { color: var(--brand); border-color: var(--brand); }

/* 消息 */
.msgs { display: flex; flex-direction: column; gap: 22px; padding-top: 6px; }
/* 「已开始新会话」分隔提示（右上角软新会话插入，非互动消息、不参与上下文） */
.sys-note {
  align-self: center; max-width: 90%;
  padding: 5px 14px; border-radius: 999px;
  background: rgba(20, 22, 28, .055);
  color: var(--text-2); font-size: 12.5px; line-height: 1.5; text-align: center;
}
.msg { display: flex; gap: 12px; animation: msgIn .3s var(--ease) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } }

.msg-avatar {
  /* 无底色线稿 Logo：头像保留一圈**极淡**品牌色底，让圆头像有可辨边界 */
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: rgba(91, 108, 255, .10);
}
.msg-avatar .ico { width: 19px; height: 19px; }
.msg-body { min-width: 0; flex: 1; }
.msg-name { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 4px 0 6px; }

/* AI 气泡 */
.msg.ai .bubble {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
  padding: 13px 17px; box-shadow: var(--sh-1);
  display: inline-block; max-width: 100%;
}
.msg.err .bubble {
  background: var(--red-soft); border: 1px solid #fbd5d5; color: var(--red);
  border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
  padding: 12px 16px; display: inline-block;
}
.msg.err .msg-avatar { background: linear-gradient(135deg, #f87171, #e5484d); box-shadow: none; }

/* 用户消息（右对齐、无头像，主流做法） */
.msg.user { justify-content: flex-end; }
.msg.user .msg-body { flex: 0 1 auto; display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); color: var(--text);
  border-radius: var(--r-lg) 4px var(--r-lg) var(--r-lg);
  padding: 11px 16px; max-width: 100%;
  line-height: 1.75; white-space: pre-wrap; word-break: break-word;
}
.msg.user .chat-img { margin-bottom: 8px; }

.chat-img {
  max-width: 220px; max-height: 220px; border-radius: 12px;
  display: block; border: 1px solid rgba(20, 22, 28, .08);
}

/* 消息操作条 */
.msg-acts { display: flex; gap: 2px; margin-top: 7px; opacity: 0; transition: opacity .16s; }
.msg:hover .msg-acts, .msg-acts.keep { opacity: 1; }
.act-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 8px; border: none; background: transparent;
  color: var(--muted); font-size: 12px; border-radius: 7px; cursor: pointer;
  transition: background .14s, color .14s;
}
.act-btn .ico { width: 14px; height: 14px; }
.act-btn:hover { background: rgba(20, 22, 28, .06); color: var(--text-2); }
.act-btn.done { color: #12A150; }

/* 打字指示 */
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 4px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: bounce 1.25s infinite ease-in-out both;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%, 70%, 100% { transform: translateY(0); opacity: .35; } 35% { transform: translateY(-4px); opacity: 1; } }

/* 光标 */
.cursor {
  display: inline-block; width: 7px; height: 15px; margin-left: 2px;
  background: var(--brand); border-radius: 1.5px;
  vertical-align: -2px; animation: blink .9s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Markdown 排版 ---------- */
.md { font-size: 15px; line-height: 1.82; color: var(--text); word-break: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 11px; }
.md h1, .md h2, .md h3 { margin: 18px 0 9px; line-height: 1.4; font-weight: 650; }
.md h1 { font-size: 18.5px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15.5px; }
.md ul, .md ol { margin: 0 0 11px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--brand); }
.md strong { font-weight: 650; color: #0e1015; }
.md em { font-style: italic; color: var(--text-2); }
.md a { color: var(--brand); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md code {
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: .89em; background: #f2f4f9; color: #b3315f;
  padding: 2px 5px; border-radius: 5px;
}
.md pre {
  background: #1f232e; color: #e7eaf3; border-radius: var(--r-md);
  padding: 13px 15px; overflow-x: auto; margin: 0 0 11px; line-height: 1.65;
}
.md pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
.md blockquote {
  margin: 0 0 11px; padding: 3px 0 3px 13px;
  border-left: 3px solid var(--brand-soft); color: var(--text-2);
}
.md hr { border: none; border-top: 1px solid var(--border); margin: 15px 0; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 11px; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border-2); padding: 7px 11px; text-align: left; }
.md th { background: #f5f6fa; font-weight: 600; }

/* 回到底部 */
.scroll-down {
  position: absolute; left: 50%; bottom: 172px; transform: translateX(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; z-index: 7;
  background: var(--panel); border: 1px solid var(--border-2);
  color: var(--text-2); cursor: pointer; box-shadow: var(--sh-2);
  transition: transform .16s, color .16s;
}
.scroll-down .ico { width: 17px; height: 17px; }
.scroll-down:hover { color: var(--brand); transform: translateX(-50%) translateY(-2px); }

/* ============================================================
   学习机使用锁定（2026-09-23）
   教师端关闭「允许学生使用学习机」时遮盖整个学生端。
   文案只用白话（六年级能懂），不出现"系统/记录/画像"等后台概念。
   ⚠️ 这只是"让学生看到原因"；真正的防线在服务端（**对话**会被 403；
      登录不拦——2026-09-25 研究者裁决：学生能进来、不能提问）。
   ============================================================ */
#lockScreen {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(244, 246, 251, .97);
  padding: 24px;
}
#lockScreen[hidden] { display: none !important; }
.lock-card {
  max-width: 420px; text-align: center;
  background: #fff; border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px;
  box-shadow: 0 8px 28px rgba(20, 22, 40, .10);
}
.lock-title { font-size: 19px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.lock-desc { font-size: 14px; line-height: 1.75; color: var(--text-2); }

/* ============================================================
   断网横幅与音频重试条（2026-09-22）
   两者都是 position:fixed 的轻量提示，不占布局、不遮挡输入区。
   ============================================================ */
#netBanner, #audioRetryBar { pointer-events: auto; }
#netBanner[hidden], #audioRetryBar[hidden] { display: none !important; }

/* ============================================================
   学生端取消侧边栏（2026-09-22，研究者要求：避免学生乱点）
   背景：侧栏里有会话列表、「开启新对话」与「退出登录」。学生误触会
   **中途切会话 / 开新会话**，把同一节课的数据切成多个 sessionId，也带来
   与学习无关的操作。故整体隐藏；退出入口移到顶栏（#topLogoutBtn）。
   ⚠️ 只隐藏 UI：**不动 state.sessions 与会话模型** —— 上下文装配与
   历史恢复逻辑保持不变；renderSessions() 仍会写入隐藏的 DOM（无害）。
   ============================================================ */
.sidebar { display: none !important; }
.sb-mask { display: none !important; }
#menuBtn, .app.sb-collapsed #menuBtn { display: none !important; }

/* 顶栏「退出」：放在原侧栏展开按钮的位置（左上），避免与右上「新会话」重叠。
   低调样式，防误触靠 JS 的二次确认（不靠视觉隐藏——共用学习机必须能换人）。 */
#topLogoutBtn {
  position: fixed; left: 12px; top: 12px; z-index: 30;
  width: 34px; height: 34px;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--sh-2);
  color: var(--text-2); opacity: .85;
}
#topLogoutBtn:active { transform: scale(.96); }
#topLogoutBtn .ico { width: 17px; height: 17px; }

/* ============================================================
   几何图示 + 分步板书（2026-09-20）
   图示：模型只给受控 JSON，前端画 SVG（见 agent.js renderFigure）
   板书：把「### 第N步」小节变成可逐步展开的卡片（见 agent.js buildSteps）
   ============================================================ */
.fig { margin: 12px 0; text-align: center; }
.fig svg { max-width: 300px; height: auto; }

.steps { margin: 10px 0 2px; }
.step-card {
  position: relative;
  margin: 0 0 10px; padding: 12px 14px 12px 44px;
  background: #fafbff; border: 1px solid var(--border-2); border-radius: var(--r-md);
}
.step-badge {
  position: absolute; left: 12px; top: 12px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 12.5px; font-weight: 700;
}
.step-card > .step-body > *:first-child { margin-top: 0; }
.step-card > .step-body > *:last-child { margin-bottom: 0; }
.step-bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; }
.step-next {
  border: 1px solid var(--brand); background: #fff; color: var(--brand);
  border-radius: 999px; padding: 7px 16px; font-size: 13.5px;
  font-family: inherit; cursor: pointer; transition: background .16s, color .16s;
}
.step-next:hover { background: var(--brand-soft); }
.step-next:disabled {
  border-color: var(--border-2); color: var(--muted); cursor: default; background: #fff;
}
.step-count { font-size: 12.5px; color: var(--muted); }

/* 动态虚拟形象（.tutor 五态机器人）样式已于 2026-09-25 整体删除（含 5 组 keyframes 动画）。
   研究者裁决：「虚拟形象」只指品牌 Logo（登录页/对话页），不需要会动的形象与动作。
   品牌 Logo 由 `#i-bot` 符号 + .login-logo/.wc-logo/.sb-logo/.msg-avatar 承载。 */

/* ============================================================
   输入区
   ============================================================ */

/* 常驻提示条样式（.face-hint / -text / -retry / -close）已随提示层整体删除（2026-09-25）
   —— 摄像头/麦克风异常不再向学生显示任何提示（只进事件日志）。 */

.composer-zone {
  flex: none;
  /* --kb = 软键盘实际占高（由 agent.js 的 visualViewport 写入，2026-09-19）。
     页面是 overflow:hidden、本身不滚动，所以只能靠这份内边距把输入区抬到键盘之上；
     键盘收起时 --kb=0，即原来的 12px。不加 transition：要跟键盘动画同步，不能有滞后。 */
  padding: 0 22px calc(12px + var(--kb, 0px));
  background: linear-gradient(to bottom, rgba(247, 248, 250, 0), var(--bg) 28%);
}
.composer-inner { max-width: var(--content-w); margin: 0 auto; }

/* 输入框：一行三件套 —— 拍照（框内左）、文本域（自适应）、发送（框内右）。
   align-items:flex-end 让按钮在文本域长高时始终贴着底边。 */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--panel);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-xl);
  padding: 7px 8px;
  box-shadow: var(--sh-2);
  transition: border-color .18s, box-shadow .18s;
}
.composer:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(79, 110, 247, .1), var(--sh-2);
}
.composer textarea {
  flex: 1; min-width: 0; display: block; resize: none;
  /* 上限同时受视口约束：矮屏上输入框不该吃掉大半个屏幕（2026-09-19） */
  min-height: 34px; max-height: min(176px, 26vh);
  padding: 7px 4px; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 15px; line-height: 1.5; color: var(--text);
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea::-webkit-scrollbar { width: 6px; }
.composer textarea::-webkit-scrollbar-thumb { background: #d8dce6; border-radius: 3px; }

/* 框内工具按钮：定宽方形、去掉描边，避免在输入框里显得像"两个框" */
.composer .tool-btn {
  flex: none; width: 34px; height: 34px; padding: 0;
  justify-content: center; border-color: transparent;
}
.tool-btn {
  display: flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 11px;
  font-size: 13px; color: var(--text-2);
  background: transparent; border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.tool-btn .ico { width: 16px; height: 16px; }
.tool-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.tool-btn:active { transform: scale(.97); }
.tool-btn.recording {
  background: var(--red-soft); color: var(--red); border-color: #fbd5d5;
  animation: recPulse 1.4s ease-in-out infinite;
}
@keyframes recPulse { 50% { box-shadow: 0 0 0 5px rgba(229, 72, 77, .1); } }
.tool-btn:disabled { opacity: .5; cursor: not-allowed; }

.send-btn {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; border: none; cursor: pointer;
  background: var(--grad); color: #fff;
  box-shadow: 0 4px 12px rgba(91, 108, 255, .3);
  transition: filter .15s, transform .12s, background .2s, box-shadow .2s;
}
.send-btn .ico { width: 18px; height: 18px; }
.send-btn:hover:not(:disabled) { filter: brightness(1.07); }
.send-btn:active:not(:disabled) { transform: scale(.93); }
.send-btn:disabled {
  background: #dfe2ea; color: #fff; cursor: not-allowed; box-shadow: none;
}
.send-btn.stop { background: var(--text); box-shadow: none; }

.composer-tip {
  text-align: center; font-size: 11.5px; color: var(--muted);
  margin: 9px 0 0;
}

/* 附件条（录音 / 图片） */
.attach-bar {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; margin-bottom: 9px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--sh-1);
  animation: fadeUp .22s var(--ease) both;
}
.attach-bar.rec { background: var(--red-soft); border-color: #fbd5d5; color: var(--red); }
.attach-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 9px; flex: none; }
.attach-input {
  flex: 1; min-width: 0; padding: 9px 11px; font-size: 13.5px; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  outline: none; background: #fafbfe; color: var(--text);
}
.attach-input:focus { border-color: var(--brand); background: #fff; }
.attach-send {
  padding: 9px 16px; font-size: 13px; font-weight: 600; color: #fff;
  background: var(--grad); border: none; border-radius: var(--r-sm); cursor: pointer;
}
.attach-tip { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.rec-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: recBlink 1s infinite; }
@keyframes recBlink { 50% { opacity: .25; } }
.rec-wave { display: inline-flex; align-items: center; gap: 3px; height: 18px; }
.rec-wave i {
  width: 3px; height: 6px; border-radius: 2px; background: var(--red); opacity: .75;
  animation: wave 1s ease-in-out infinite;
}
.rec-wave i:nth-child(2) { animation-delay: .1s; }
.rec-wave i:nth-child(3) { animation-delay: .2s; }
.rec-wave i:nth-child(4) { animation-delay: .3s; }
.rec-wave i:nth-child(5) { animation-delay: .18s; }
.rec-wave i:nth-child(6) { animation-delay: .08s; }
.rec-wave i:nth-child(7) { animation-delay: .26s; }
@keyframes wave { 0%, 100% { height: 6px; } 50% { height: 16px; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 120px; z-index: 90;
  transform: translateX(-50%) translateY(10px);
  background: rgba(20, 22, 28, .92); color: #fff;
  font-size: 13px; line-height: 1.5; max-width: 78vw;
  padding: 10px 17px; border-radius: 11px;
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   摄像头拍摄模态框（PRD-V7 §3.5）
   ============================================================ */
.cam-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 18, 28, .92); padding: 16px;
}
.cam-box {
  width: min(520px, 100%);
  background: #000; border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  animation: camIn .25s ease both;
}
@keyframes camIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.cam-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 18px; color: #fff; font-size: 15px; font-weight: 700;
  background: rgba(255, 255, 255, .07);
}
.cam-box video {
  width: 100%; max-height: 62vh; display: block;
  background: #000; object-fit: cover;
}
.cam-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; padding: 14px 16px 18px;
}
.cam-btn {
  border: none; border-radius: 12px; cursor: pointer; color: #fff;
  font-size: 15px; padding: 12px 20px; background: rgba(255, 255, 255, .16);
  transition: background .15s, transform .1s;
}
.cam-tip {
  margin: 0 0 8px; font-size: 12.5px; line-height: 1.5;
  color: rgba(255, 255, 255, .82); text-align: center;
}
.cam-btn:hover { background: rgba(255, 255, 255, .26); }
.cam-btn:active { transform: scale(.96); }
.cam-shoot { background: var(--accent, #4f6ef7); font-weight: 700; padding: 12px 28px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    box-shadow: var(--sh-3); margin-left: calc(var(--sb-w) * -1);
  }
  .app:not(.sb-collapsed) .sidebar { margin-left: 0; }
  .sb-mask {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(20, 22, 28, .34); animation: fadeIn .2s both;
  }
  @keyframes fadeIn { from { opacity: 0; } }
  .stream-inner { padding: 12px 15px 22px; }
  .composer-zone { padding: 0 14px 10px; }
  .wc-chips { grid-template-columns: 1fr; max-width: 420px; }
  .wc-title { font-size: 22px; }
  .scroll-down { bottom: 168px; }
}

@media (max-width: 480px) {
  .tool-btn span { display: none; }
  .tool-btn { padding: 0 9px; }
  .msg { gap: 9px; }
  .composer-tip { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .stream { scroll-behavior: auto; }
}

/* ============ 前置摄像头采集小窗（自课中系统迁移） ============ */
.face-cam {
  position: fixed;
  left: 20px;
  bottom: 88px;
  width: 184px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(15, 23, 42, .22);
  border: 1px solid rgba(15, 23, 42, .12);
  z-index: 45;
  overflow: hidden;
  transition: width .25s ease;
}
.face-cam-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.face-cam-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  animation: faceCamPulse 2s infinite;
  flex: none;
}
@keyframes faceCamPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.face-cam-label { flex: 1; }
.face-cam-toggle {
  width: 22px; height: 22px;
  border: none;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.face-cam-toggle:hover { background: rgba(255, 255, 255, .28); }
.face-cam-body {
  position: relative;
  width: 100%;
  height: 138px;
  background: #0f172a;
  overflow: hidden;
  transition: height .25s ease;
}
.face-cam-body video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.face-cam.collapsed { width: 132px; }
.face-cam.collapsed .face-cam-body { height: 0; }

@media (max-width: 900px) {
  .face-cam { left: 12px; bottom: 84px; width: 150px; }
  .face-cam-body { height: 112px; }
}
