/* ===== 教学数字人 · 样式 ===== */
:root {
  --bg: #070b14;
  --bg-2: #0c1322;
  --panel: rgba(20, 30, 48, 0.72);
  --panel-line: rgba(120, 170, 220, 0.14);
  --text: #e8eef8;
  --text-dim: #93a4bd;
  --accent: #4fd1c5;
  --accent-2: #7aa7ff;
  --danger: #ff8095;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* hidden 属性必须真正生效：防止被后面的 display:flex 类样式覆盖 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: none;   /* 渐变装饰已并入 .scene 背景层 */
}

.app {
  height: 100%;
  position: relative;
  z-index: 1;              /* 浮在全屏背景层之上 */
  display: grid;
  grid-template-columns: minmax(320px, 1.02fr) minmax(360px, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top top"
    "stage chat";
  gap: 18px;
  padding: 18px 20px 20px;
}

/* ---------- 全屏场景背景层 ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  /* 未选自定义背景时的默认底色 + 原页面渐变装饰 */
  background:
    radial-gradient(900px 600px at 18% 8%, rgba(79, 209, 197, 0.13), transparent 60%),
    radial-gradient(800px 600px at 88% 92%, rgba(122, 167, 255, 0.13), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

/* ---------- 顶部 ---------- */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.16);
  animation: breathe 2.6s ease-in-out infinite;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.brand-sub {
  font-size: 12px; color: var(--text-dim);
  padding: 2px 8px; border: 1px solid var(--panel-line); border-radius: 999px;
}
.topbar-actions { display: flex; gap: 8px; }
.chip {
  /* 图标与文字用 inline-flex 垂直居中对齐：emoji 混排时靠基线会参差不齐 */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
  /* 顶栏按钮统一蓝渐变白字（用户指定样式，参考移动端主按钮风格） */
  background: linear-gradient(135deg, #2E8BFF, #1E9BFF);
  border: none;
  color: #fff;
  font-size: 14px;
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: .18s;
  font-family: inherit;
}
.chip .ico { font-size: 15px; line-height: 1; display: inline-block; transform: translateY(0.5px); }
.chip:hover { color: #fff; background: linear-gradient(135deg, #3E97FF, #2EA6FF); }
.chip.off { opacity: .5; }

/* -------- 顶栏按钮统一蓝渐变 + 按压反馈 --------
   :active 按下时渐变换成亮一档、轻微缩放（颜色变化反馈），松开恢复。
   各按钮不再有专属彩色底（2026-11-23 按用户要求统一为蓝渐变白字）。 */
.topbar-actions .chip { transition: background .15s, transform .12s; }
.topbar-actions .chip:active { transform: scale(.94); background: linear-gradient(135deg, #57A6FF, #35AEFF); }

/* 额度条与声音提示也统一蓝渐变白字（2026-11-23 按用户要求；告急红态保留语义） */
/* 额度告急红色态保留自己的颜色（放在基础色之后，ID+类优先级更高） */
#billChip.bill-low { background: rgba(255,120,100,.16); border-color: rgba(255,120,100,.42); color: #ffc4b8; }
#billChip.bill-low:active { background: rgba(255,120,100,.48); }

/* -------- 内嵌 PPT / 白板（embed=1）性能保护 --------
   嵌入式 WebView（希沃 / WPS / PowerPoint 网页容器）常走软件渲染，
   backdrop-filter 每帧全屏模糊是卡顿大头。内嵌时统一禁用毛玻璃，
   靠场景遮罩层保证可读性；浏览器正常打开时不受影响。 */
body.in-frame * { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
/* 内嵌时面板动画也全部关掉：软渲染下 0.2~0.26s 的滑动/淡入就是
   「点了半天没反应」的体感来源——直接瞬开，点击反馈立现。 */
body.in-frame .kb-drawer,
body.in-frame .kb-mask,
body.in-frame .vmenu { animation: none !important; }
/* 大投影阴影在软渲染下按帧重绘成本高，内嵌时减到一层轻描边 */
body.in-frame .kb-drawer { box-shadow: -1px 0 0 rgba(120, 170, 220, .25); }

/* 音色选择器 */
.voice-pick {
  position: relative;          /* 作为透明触发层 .vp-trigger 的定位基准 */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px 6px 15px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #2E8BFF, #1E9BFF);
  color: #fff;
  transition: .18s;
  cursor: pointer;
}
/* 透明触发层：盖住整个音色芯片，接管所有点击（select 已被 JS 禁掉指针事件） */
.voice-pick .vp-trigger {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
  outline: none;
}
.voice-pick .vp-trigger:focus-visible { border-radius: 999px; box-shadow: 0 0 0 2px rgba(120, 170, 220, .4); }
.voice-pick:hover { background: linear-gradient(135deg, #3E97FF, #2EA6FF); }
.voice-pick-label { font-size: 13px; color: rgba(255, 255, 255, .92); }
.voice-pick select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  padding: 2px 16px 2px 2px;
  cursor: pointer;
  outline: none;
  background-image: linear-gradient(45deg, transparent 50%, #ffffff 50%), linear-gradient(135deg, #ffffff 50%, transparent 50%);
  background-position: calc(100% - 8px) 52%, calc(100% - 3px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.voice-pick select option { background: #16202e; color: #e6eefb; }

/* 自绘音色下拉菜单（内嵌 WPS/PPT 时原生弹窗弹不出来，用 HTML 浮层替代） */
.vmenu {
  position: fixed;
  z-index: 9999;
  min-width: 170px;
  max-height: 320px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(120, 170, 220, .25);
  background: rgba(12, 20, 30, .96);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .5);
  animation: fadeUp .16s ease both;
}
.vmenu-item {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.vmenu-item:hover { background: rgba(79, 209, 197, .14); }
.vmenu-item.on { background: rgba(79, 209, 197, .2); color: #5fe0d1; }
/* 触屏：按压也要有反馈（hover 不触发时给用户"点到了"的感觉） */
.vmenu-item:active { background: rgba(79, 209, 197, .26); }

/* ---------- 数字人舞台（透明：人物站在全屏场景的地面上）---------- */
.stage {
  grid-area: stage;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;   /* 人物沉到画面底部，脚踩地面 */
  gap: 12px;
  padding: 18px 18px 10px;
}
.avatar-halo {
  position: absolute;
  width: 460px; height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 209, 197, 0.16), transparent 66%);
  top: 6%;
  filter: blur(6px);
  pointer-events: none;      /* 舞台不再裁切，光晕不能挡住右侧对话区的点击 */
  transition: opacity .4s, transform .6s;
  opacity: .8;
}
.stage.speaking .avatar-halo {
  opacity: 1;
  animation: haloPulse 1.9s ease-in-out infinite;
}
.avatar-wrap {
  position: relative;
  z-index: 1;
  width: min(88%, 400px);
  margin-bottom: 20px;            /* 给脚下地面阴影留出空间 */
  transform-origin: 50% 96%;      /* 以脚底为支点，呼吸时脚不离开地面 */
  animation: idleFloat 7s ease-in-out infinite;
}
/* 脚下接触阴影：让形象看着是站在地上，而不是浮在空中 */
.avatar-wrap::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -16px;
  transform: translateX(-50%);
  width: 84%;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
              rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0.34) 42%, rgba(0, 0, 0, 0) 74%);
  filter: blur(8px);
  pointer-events: none;
  z-index: -1;
  transition: opacity .35s, transform .35s;
}
.avatar { width: 100%; height: auto; display: block; }

/* -------- 全屏背景层：铺满视口，右侧渐暗衬托对话区 -------- */
.bg-media, .bg-scrim { position: absolute; inset: 0; }
.bg-media { z-index: 0; overflow: hidden; }
.bg-media img, .bg-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-scrim {
  z-index: 1;
  pointer-events: none;
  background:
    /* 左→右压暗：留出人物所在的左侧，右侧托住玻璃对话区 */
    linear-gradient(90deg, rgba(6, 10, 18, 0) 26%, rgba(6, 10, 18, 0.22) 50%,
                    rgba(6, 10, 18, 0.46) 74%, rgba(6, 10, 18, 0.58) 100%),
    /* 上→下压暗：顶栏与底部状态可读，中间留给人物 */
    linear-gradient(180deg, rgba(6, 10, 18, 0.46) 0%, rgba(6, 10, 18, 0.05) 20%,
                    rgba(6, 10, 18, 0) 54%, rgba(6, 10, 18, 0.34) 100%);
}

/* -------- 自定义形象（图片 / 视频） -------- */
.avatar-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity .45s ease;
}
.stage.avatar-photo .avatar-wrap {
  width: min(84%, 350px);
  aspect-ratio: 3 / 4;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}
.stage.avatar-photo .avatar-media { object-fit: cover; }
.stage.avatar-photo.photo-talking .avatar-wrap { animation: talkBounce 1.6s ease-in-out infinite; }
/* 透明抠像图：无相框，投影融入场景 */
.stage.avatar-photo.avatar-cutout .avatar-wrap {
  aspect-ratio: auto;
  height: min(78%, 560px);
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}
.stage.avatar-photo.avatar-cutout .avatar-media {
  object-fit: contain;
  filter: drop-shadow(0 16px 26px rgba(20, 30, 45, 0.35));
}
/* ---------- 半身模式：放大裁切，只显示腰部以上 ----------
   原理：把形象素材放大约 1.8 倍、以头部为锚点，容器裁掉下半身。
   对相框照片（object-fit:cover）和透明抠像（contain）都适用。 */
.stage.avatar-bust .avatar-wrap {
  overflow: hidden;                  /* 裁掉放大后超出容器的下半身 */
  border-radius: 20px;
  /* 半身模式必须也有高度上限：素材被 scale(1.9) 放大后，容器没有高度约束的话，
     容器一变大（希沃/PPT 里的宽视口）形象就会撑爆左栏、压到右边对话区。
     与全身模式 avatar-cutout 的 height: min(78%, 560px) 保持同一套口径。 */
  max-height: min(78%, 470px);
}
/* 半身不再在舞台容器裁切：裁切必须发生在「画布底缘之外」，否则角色会在
   舞台底边被水平切断、下方还露出一条背景 = 用户看到的「悬空截断框」。
   头部安全由顶部锚定布局保证（素材顶边固定在顶栏下方），无需 overflow:hidden。 */
.stage.avatar-bust .avatar-wrap::after { display: none; }   /* 没有脚，不画地面阴影 */
.stage.avatar-bust .avatar-media {
  transform: scale(1.9);             /* 固定倍率：比上一版（2.65）整体调小 */
  transform-origin: 50% 12%;         /* 锚在头部附近：放大后头部仍保持在画面上部 */
  filter: none;                      /* 去掉投影：投影会被裁切容器剪成矩形暗框 */
}
/* 半身时缩放支点改到头部：配合 slider 的整体大小调整更自然 */
.stage.avatar-bust .avatar-wrap { transform-origin: 50% 12%; }
/* 横版素材（角色居中，如小精灵 862x640）：半身放大改用中心锚点、系数更小，
   让角色垂直居中悬浮在画面左侧中部，而不是被「头部锚点放大」压到画面底部 */
.stage.avatar-bust.av-landscape .avatar-media {
  transform: scale(1.55);            /* 横版固定倍率：比上一版（2.05）整体调小 */
  transform-origin: 50% 45%;
}
.stage.avatar-bust.av-landscape .avatar-wrap { transform-origin: 50% 50%; }
.stage.avatar-bust .avatar-halo { opacity: .4; }
/* 全身悬浮（小精灵）：容器不裁切、不限制高度，媒体由 JS 按标定缩放后居中悬浮 */
.stage.avatar-float .avatar-wrap { overflow: visible; max-height: none; }
.stage.avatar-float .avatar-media { transform: none; transform-origin: 50% 0; }
/* 横版透明抠像角色（小精灵）半身：沿用「顶部锚定 + 身体越出画布」的无框布局。
   不能用 overflow:hidden 裁切——相框容器带淡背景/圆角，会露出一条矩形边界
   （用户明确不要「悬空截断框」）；放大后让腰部以下自然延伸出舞台底缘即可。
   margin-top 是顶栏安全区：素材里比标定头顶更高的一截芽尖/藤蔓会被放大甩到
   舞台上方，留足这段距离才不会压住顶栏文字与按钮。 */
.stage.avatar-bust.avatar-cutout.av-landscape .avatar-wrap {
  margin-top: 56px;
  margin-bottom: auto;              /* 顶部锚定，抵消 flex-end 沉底 */
  width: min(62%, 430px);
  height: 600px;
  flex-shrink: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  pointer-events: none;
  transform-origin: 50% 0;
}
.stage.avatar-bust.avatar-cutout.av-landscape .avatar-media {
  filter: none;                     /* 去掉投影，避免出现矩形暗边 */
}
/* 全身站立（标定）：同样不裁切，缩放与接地位置由 JS 按角色标定求解 */
.stage.avatar-full .avatar-wrap { overflow: visible; max-height: none; }
/* ---------- 半身·抠像（竖版角色）确定性锚定布局 ----------
   素材顶边固定锚在顶栏下方：头部永远在按钮栏之下、绝不会被切平或遮挡按钮；
   放大后身体自然越出舞台底缘（延伸到画布外），彻底消除「膝盖/腰部悬空截断」
   随窗口大小漂移的框感。仅作用于透明抠像的竖版角色；
   相框照片与横版角色（小精灵）保持原有居中布局。 */
.stage.avatar-bust.avatar-cutout:not(.av-landscape) .avatar-wrap {
  margin-top: 28px;
  margin-bottom: auto;              /* 顶部锚定：抵消 flex-end 沉底布局 */
  width: 420px;
  height: 560px;
  flex-shrink: 0;                   /* 舞台空间不足时不许被 flex 压缩，保证媒体底部越出画布 */
  overflow: visible;
  border-radius: 0;
  pointer-events: none;             /* 素材溢出舞台后不许挡住右侧对话区的点击 */
  transform-origin: 50% 0;          /* 大小滑块以头顶为支点缩放 */
}
.stage.avatar-bust.avatar-cutout:not(.av-landscape) .avatar-media {
  transform: scale(2.2);            /* 与小女孩1/2 原版观感一致（350×2.65 ≈ 420×2.2） */
  transform-origin: 50% 0;
}
/* 说话时身体起伏：脚不离地，只做小幅伸展，保证接地阴影稳定 */
@keyframes talkBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.stage.avatar-photo .avatar-halo { opacity: .5; }
#head { transform-origin: 160px 230px; animation: headSway 9s ease-in-out infinite; }
.stage.speaking #head { animation: headSwayFast 2.6s ease-in-out infinite; }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(10, 16, 28, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 1;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim);
  transition: .25s;
}
.status.listening .status-dot { background: #ffd166; box-shadow: 0 0 0 4px rgba(255, 209, 102, .16); }
.status.thinking .status-dot { background: var(--accent-2); box-shadow: 0 0 0 4px rgba(122,167,255,.16); }
.status.speaking .status-dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(79,209,197,.16); }

/* 声波 */
.wave {
  display: flex; align-items: center; gap: 4px; height: 26px; z-index: 1;
  opacity: 0; transition: opacity .3s;
  flex-shrink: 0;                 /* 舞台空间不足时也不许被压缩/参与挤压布局 */
}
.stage.speaking .wave { opacity: 1; }
/* 波形条用 scaleY 做动画：transform 不参与布局，
   否则条形高度变化会顶得整个数字人上下浮动（周期=动画周期0.9s） */
.wave i {
  width: 3px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: .85;
  transform: scaleY(.27);
  transform-origin: 50% 50%;
}
.stage.speaking .wave i { animation: bar 0.9s ease-in-out infinite; }
.wave i:nth-child(1) { animation-delay: 0s; }
.wave i:nth-child(2) { animation-delay: .1s; }
.wave i:nth-child(3) { animation-delay: .2s; }
.wave i:nth-child(4) { animation-delay: .3s; }
.wave i:nth-child(5) { animation-delay: .4s; }
.wave i:nth-child(6) { animation-delay: .3s; }
.wave i:nth-child(7) { animation-delay: .2s; }
.wave i:nth-child(8) { animation-delay: .1s; }
.wave i:nth-child(9) { animation-delay: 0s; }

/* ---------- 对话区（磨砂玻璃：透出背景，但文字清晰）---------- */
.chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 22px;
  /* 透明底：不蒙毛玻璃框，气泡直接浮在场景上 */
  background: transparent;
  border: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow: hidden;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-thumb { background: rgba(140, 170, 210, .22); border-radius: 3px; }

.msg { display: flex; gap: 10px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

/* 气泡左侧的数字人小头像（跟随形象库切换） */
.msg-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 12%;      /* 全身素材裁头部 */
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  flex: none;
  align-self: flex-start;
  margin-top: 2px;
  background: rgba(10, 14, 24, 0.5);
}

.bubble {
  font-size: 14.5px;
  line-height: 1.72;
  padding: 11px 15px;
  border-radius: 16px;
  border-top-left-radius: 5px;
  /* 机器人气泡：浅色实底（参考教学一体机样式），深色文字 */
  background: rgba(255, 255, 255, 0.92);
  color: #20283a;
  border: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble {
  background: linear-gradient(135deg, #8b5cf6, #a855f7);
  color: #fff;
  border-top-left-radius: 16px;
  border-top-right-radius: 5px;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
}
.msg.user .bubble .msg-img-cap { color: rgba(255, 255, 255, 0.88); }
.msg.bot .bubble { animation: fadeUp .3s ease both; }
/* 浅色气泡里的打字点用深色才看得见 */
.msg.bot .bubble .typing i { background: #6b7385; }

/* 语音同步模式：每句话在她开口的瞬间淡入，读到哪里字就到哪里 */
.say-chunk { animation: sayIn .24s ease-out both; }
@keyframes sayIn {
  from { opacity: 0; transform: translateY(2px); filter: blur(1.5px); }
  to { opacity: 1; transform: none; filter: none; }
}

.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-dim);
  animation: typingDot 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }

/* 快捷问题 */
.suggest {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 20px 10px;
}
.sug {
  font-family: inherit;
  font-size: 13px;
  color: #d7e6fa;
  background: rgba(12, 18, 32, 0.82);   /* 深色实底，浮在场景上看得清 */
  border: 1px solid rgba(122, 167, 255, .4);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: .18s;
}
.sug:hover { color: #fff; border-color: rgba(122,167,255,.7); background: rgba(30, 42, 66, 0.95); }

/* 错误/诊断提示：琥珀色高对比 + 右上角关闭按钮 */
.error-bar {
  margin: 0 20px 10px;
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.65;
  color: #ffe2a8;
  background: rgba(255, 176, 60, .14);
  border: 1px solid rgba(255, 176, 60, .45);
  border-radius: 10px;
  white-space: pre-line;        /* 语音自检的多行报告能正常换行 */
  max-height: 170px;
  overflow-y: auto;
  cursor: pointer;              /* 点一下复制诊断内容 */
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.error-bar .err-text { flex: 1; min-width: 0; }
.error-bar .err-close {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border: 1px solid rgba(255, 226, 168, .5);
  border-radius: 50%;
  background: rgba(255, 226, 168, .12);
  color: #ffe2a8;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
}
.error-bar .err-close:hover { background: rgba(255, 226, 168, .28); }
/* 登录按钮：黄色提示条里的主操作，视觉上要比关闭按钮更醒目 */
.error-bar .err-login {
  flex: 0 0 auto;
  padding: 4px 14px;
  border: 1px solid rgba(255, 226, 168, .65);
  border-radius: 999px;
  background: #ffe2a8;
  color: #6b4a12;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.error-bar .err-login:hover { background: #ffedc2; }
.error-bar .err-login:active { transform: scale(.96); }
.error-bar .err-login:disabled { opacity: .6; cursor: default; }

/* 输入区：上面工具行（图片/键盘），下面胶囊或输入框 */
.composer {
  display: flex; flex-direction: column; align-items: stretch;
  padding: 12px 16px 6px;
  border-top: 1px solid rgba(120, 170, 220, .1);
}
.composer-tools {
  display: flex; gap: 14px;
  align-items: center;
  padding: 0 2px 12px;
}
.composer-main {
  display: flex; align-items: center; gap: 10px;
}

/* 大号「点击说话」胶囊（参考教学一体机样式） */
.tap-speak {
  flex: 1;
  height: 60px;
  border: none;
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #7c3aed;
  font-size: 17.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;      /* 禁双击缩放延迟：PPT 触屏点击更快响应 */
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  transition: background-color .08s linear, color .08s linear, filter .08s linear, transform .08s linear;
}
.tap-speak:hover { transform: translateY(-1px); }
.tap-speak:active { transform: scale(.97); filter: brightness(.94); }
/* 录音反馈统一走 .rec 类：micPressDown 在 pointerdown 一瞬就挂上它，
   按下立即变橙——不走 data-status（那条要等异步流程切换，会先白后橙） */
.tap-speak.rec {
  background: linear-gradient(135deg, #ff5a5a, #ff7a45);
  color: #fff;
  animation: recPulse 1.4s ease-in-out infinite;
}
.tap-speak.rec svg { color: #fff; }
/* PPT 内嵌：脉冲动画的 box-shadow 逐帧重绘在软渲染下很贵，换成背景明暗闪烁 */
body.in-frame .tap-speak { animation: none !important; }
@keyframes recBlink {
  0%, 100% { background: linear-gradient(135deg, #ff5a5a, #ff7a45); }
  50% { background: linear-gradient(135deg, #e04848, #e86a38); }
}
body.in-frame .tap-speak.rec { animation: recBlink 1s ease-in-out infinite; }
body.in-frame .tap-speak { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25); }
/* 蓝色系圆形按钮（图片上传），与「文字 / 语音」胶囊并排在左侧 */
.round-btn {
  flex: 0 0 auto;
  width: 66px; height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(96, 165, 250, .4);
  display: grid; place-items: center;
  background: rgba(59, 130, 246, .18);
  color: #9cc8ff;
  cursor: pointer;
  transition: .2s;
}
.round-btn:hover { background: rgba(59, 130, 246, .3); transform: translateY(-1px); }
/* 蓝色「文字 / 语音」切换胶囊（参考教学一体机样式），靠左与图片按钮并排 */
.mode-pill {
  height: 60px;
  padding: 0 28px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(135deg, #3d8bff, #38bdf8);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(61, 139, 255, 0.4);
  transition: .2s;
}
.mode-pill:hover { transform: translateY(-1px); filter: brightness(1.06); }
.mode-pill:active { transform: scale(.97); }
.composer.text-mode .mode-pill { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.65), 0 10px 26px rgba(61, 139, 255, 0.4); }
/* 语音/打字模式切换：语音模式隐藏输入框和发送；打字模式隐藏胶囊（键盘按钮保留，便于切回） */
.composer:not(.text-mode) #txtInput,
.composer:not(.text-mode) #btnSend { display: none; }
.composer.text-mode .tap-speak { display: none; }
/* btnMic 现在只作逻辑挂载点，永久隐藏（hidden 属性会被 .mic 的 display:grid 盖掉，需显式规则） */
.mic[hidden] { display: none !important; }
.mic {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(79, 209, 197, .34);
  background: rgba(79, 209, 197, .1);
  color: var(--accent);
  cursor: pointer;
  transition: .2s;
}
.mic:hover { background: rgba(79, 209, 197, .18); transform: translateY(-1px); }
.mic.rec {
  background: rgba(255, 128, 149, .16);
  border-color: rgba(255, 128, 149, .5);
  color: var(--danger);
  animation: recPulse 1.4s ease-in-out infinite;
}
#txtInput {
  flex: 1;
  height: 60px;                 /* 与「点击说话」胶囊同高 */
  padding: 0 18px;
  font-size: 15px;
  font-family: inherit;
  color: #fff;
  background: rgba(12, 18, 32, 0.82);   /* 深色底，浮在场景上看得清 */
  border: 1px solid rgba(122, 167, 255, .38);
  border-radius: 30px;
  outline: none;
  transition: .2s;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}
#txtInput::placeholder { color: #8fa2bd; }
#txtInput:focus { border-color: rgba(122, 167, 255, .65); background: rgba(12, 18, 32, 0.92); }
.send {
  flex: 0 0 auto;
  height: 60px;
  padding: 0 22px;
  font-family: inherit;
  font-size: 15px;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, #3d8bff, #38bdf8);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: .2s;
  box-shadow: 0 10px 26px rgba(61, 139, 255, 0.4);
}
.send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.send:disabled, .mic:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.foot-hint {
  padding: 1px 18px 12px;
  font-size: 11.5px;
  color: #5f708a;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.foot-sep { opacity: .45; }
#engineHint { color: #7fb0a8; }

/* ---------- 课程知识库设置面板 / 角色场景：统一蓝渐变后无需专属配色 ---------- */
/* PPT / 希沃内嵌窗口顶栏空间紧张：只留图标（title 有完整说明），避免挤掉「新对话」 */

.kb-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 7, 14, .62);
  animation: kbFade .2s ease both;
}
.kb-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(540px, 96vw);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0e1626, #0a1220);
  border-left: 1px solid rgba(120, 170, 220, .18);
  box-shadow: -30px 0 70px rgba(0, 0, 0, .5);
  animation: kbSlide .26s cubic-bezier(.2, .8, .3, 1) both;
}

.kb-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(120, 170, 220, .12);
}
.kb-head h2 { margin: 0 0 5px; font-size: 15.5px; font-weight: 600; letter-spacing: .2px; }
.kb-head p { margin: 0; font-size: 12px; line-height: 1.6; color: var(--text-dim); }
.kb-head-txt { flex: 1; }
.kb-close {
  flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--panel-line);
  color: var(--text-dim);
  font-size: 13px; cursor: pointer; transition: .18s;
}
.kb-close:hover { color: var(--text); background: rgba(255, 255, 255, .1); }

.kb-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 22px; }
.kb-body::-webkit-scrollbar { width: 6px; }
.kb-body::-webkit-scrollbar-thumb { background: rgba(140, 170, 210, .22); border-radius: 3px; }

.kb-sec { margin-bottom: 20px; }
.kb-label {
  font-size: 12px; color: #8fa2bd; letter-spacing: .3px;
  margin-bottom: 9px; display: flex; align-items: center; gap: 8px;
}
.kb-count {
  font-size: 11px; color: #6fbcb1;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(79, 209, 197, .1);
}
.kb-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.kb-sec-head .kb-label { margin-bottom: 0; }
.kb-sec-tools { display: flex; gap: 6px; }

/* 模式切换 */
.kb-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.kb-mode { cursor: pointer; display: block; }
.kb-mode input { display: none; }
.kb-mode-box {
  display: block; height: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .03);
  transition: .18s;
}
.kb-mode-box b { display: block; font-size: 13px; margin-bottom: 4px; }
.kb-mode-box i { font-style: normal; font-size: 11.5px; line-height: 1.5; color: var(--text-dim); }
.kb-mode:hover .kb-mode-box { border-color: rgba(120, 170, 220, .36); }
.kb-mode input:checked + .kb-mode-box {
  border-color: rgba(79, 209, 197, .55);
  background: rgba(79, 209, 197, .09);
  box-shadow: inset 0 0 0 1px rgba(79, 209, 197, .14);
}
.kb-mode input:checked + .kb-mode-box b { color: #8ef0e4; }

/* 表单 */
.kb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kb-field { display: flex; flex-direction: column; gap: 6px; }
.kb-field > span { font-size: 11.5px; color: #7d8ea6; }
.kb-field input, .kb-item-topic, .kb-item-content, #kbBulkText {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  padding: 8px 11px;
  outline: none;
  width: 100%;
  transition: .18s;
}
.kb-field input:focus, .kb-item-topic:focus, .kb-item-content:focus, #kbBulkText:focus {
  border-color: rgba(79, 209, 197, .45);
  background: rgba(255, 255, 255, .07);
}
.kb-field input::placeholder, .kb-item-topic::placeholder, .kb-item-content::placeholder, #kbBulkText::placeholder {
  color: #5c6c84;
}

/* 条目列表 */
.kb-list { display: flex; flex-direction: column; gap: 10px; }
.kb-item {
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .028);
  padding: 10px 12px 11px;
  display: flex; flex-direction: column; gap: 8px;
  animation: fadeUp .22s ease both;
}
.kb-item-head { display: flex; align-items: center; gap: 8px; }
.kb-item-idx {
  flex: 0 0 auto;
  width: 20px; height: 20px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 11px; color: #7fb0a8;
  background: rgba(79, 209, 197, .1);
}
.kb-item-topic { flex: 1; font-weight: 500; }
.kb-item-del {
  flex: 0 0 auto;
  height: 28px; padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 128, 149, .22);
  background: rgba(255, 128, 149, .07);
  color: #ff9fb0;
  font-size: 11.5px; font-family: inherit; cursor: pointer; transition: .18s;
}
.kb-item-del:hover { background: rgba(255, 128, 149, .16); border-color: rgba(255, 128, 149, .45); }
.kb-item-content { min-height: 76px; resize: vertical; }

.kb-empty {
  margin-top: 4px;
  padding: 20px 16px;
  font-size: 12.5px; line-height: 1.7; text-align: center;
  color: #6c7c94;
  border: 1px dashed rgba(120, 170, 220, .2);
  border-radius: 12px;
}

/* 批量粘贴 */
.kb-bulk {
  margin-bottom: 12px;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid rgba(122, 167, 255, .22);
  background: rgba(122, 167, 255, .06);
  display: flex; flex-direction: column; gap: 8px;
}
#kbBulkText { min-height: 120px; resize: vertical; }
.kb-bulk-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kb-tip { font-size: 11px; color: #7b8ba4; line-height: 1.5; }
.kb-tip code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
  padding: 1px 4px; border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  color: #9fc4ef;
}

/* 形象库 / 背景库 */
.av-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.av-grid.bg { grid-template-columns: repeat(3, 1fr); }
.av-card {
  position: relative;
  padding: 0;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .03);
  cursor: pointer;
  transition: .18s;
  display: flex; flex-direction: column;
}
.av-card:hover { border-color: rgba(120, 170, 220, .4); transform: translateY(-1px); }
.av-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background:
    linear-gradient(45deg, rgba(255,255,255,.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.04) 75%) 0 0/14px 14px,
    linear-gradient(45deg, rgba(255,255,255,.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.04) 75%) 7px 7px/14px 14px,
    rgba(10, 16, 28, .5);
  display: block;
}
.av-grid.bg .av-card img { aspect-ratio: 16 / 9; object-fit: cover; }
.av-card.on { border-color: rgba(79, 209, 197, .65); box-shadow: 0 0 0 1px rgba(79, 209, 197, .4); }
/* 受限档：被锁形象半透明锁定——形象仍可见（方便判断值不值得升级），
   叠一层暗色薄雾压住，锁标居中，点击提示升级尊享版 */
.av-card.locked { cursor: not-allowed; }
.av-card.locked:hover { transform: none; border-color: rgba(255, 200, 120, .4); }
.av-card.locked img { opacity: .5; filter: saturate(.55); }
.av-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 12, 20, .34) 0%, rgba(8, 12, 20, .5) 100%);
  pointer-events: none;
}
.av-lock {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .75);
}
.av-card.locked .av-name { color: #ffd9a0; }
.av-name {
  font-size: 11px; color: var(--text-dim);
  padding: 5px 6px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 自定义背景的删除角标：卡片本身是 button，这里用 span[role=button] 不嵌套 */
.av-del {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 20px; height: 20px; line-height: 18px;
  border-radius: 50%; text-align: center; font-size: 12px;
  color: #fff; background: rgba(8, 12, 20, .72);
  border: 1px solid rgba(255, 255, 255, .28);
  cursor: pointer;
}
.av-del:hover { background: #e05252; border-color: rgba(255, 255, 255, .5); }
.av-del:focus-visible { outline: 2px solid #7aa7ff; outline-offset: 1px; }

/* ---- AI 生图面板（独立生图卡密） ---- */
.image-activate { display: flex; gap: 8px; }
.image-activate input {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px; box-sizing: border-box;
  border-radius: 9px; border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .06); color: var(--text);
  font-size: 13px; outline: none;
}
.image-activate input:focus { border-color: rgba(122, 167, 255, .7); }
.image-quota { margin-top: 9px; font-size: 12px; line-height: 1.6; color: var(--text-dim); }
.image-quota.on { color: #7ee0c8; }
/* 标题右侧的「已激活」徽标（不显示卡密号） */
.image-activated-badge {
  font-size: 11px; color: #8ff0e5; white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid rgba(79, 209, 197, .45); background: rgba(79, 209, 197, .1);
}
.image-activated-badge[hidden] { display: none; }
#imagePrompt {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 72px;
  padding: 9px 10px; border-radius: 9px; border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .06); color: var(--text);
  font-size: 13px; line-height: 1.55; outline: none;
}
#imagePrompt:focus { border-color: rgba(122, 167, 255, .7); }
/* 尺寸比例：默认只露当前选中项，点击展开全部尺寸，选完自动收起 */
.image-ratio-current {
  display: flex; align-items: center; gap: 9px; width: 100%; box-sizing: border-box;
  padding: 9px 11px; border-radius: 9px; border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .03); color: var(--text);
  font-size: 12px; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.image-ratio-current:hover { border-color: rgba(122, 167, 255, .55); }
.irc-dot {
  width: 14px; height: 14px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid #4fd1c5; background: #4fd1c5;
  box-shadow: inset 0 0 0 3px rgba(10, 16, 28, .95);
}
.irc-caret { margin-left: auto; color: var(--text-dim); transition: transform .15s linear; }
.image-ratio-current[aria-expanded="true"] .irc-caret { transform: rotate(180deg); }
/* 展开后的尺寸：一排「比例图形 + 比例数字」，选中项高亮 */
.image-ratios { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 8px; }
.image-ratios[hidden] { display: none; }
.ratio-tile {
  position: relative; min-height: 76px; padding: 9px 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border-radius: 11px; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* radio 本身铺满整张卡片：appearance:none 后由它承担边框与选中背景 */
.ratio-tile input {
  position: absolute; inset: 0; margin: 0; width: 100%; height: 100%;
  appearance: none; -webkit-appearance: none; outline: none;
  border: 1px solid var(--panel-line); border-radius: 11px;
  background: rgba(255, 255, 255, .03); cursor: pointer;
}
.ratio-tile input:checked {
  border-color: rgba(79, 209, 197, .6); background: rgba(79, 209, 197, .13);
}
.ratio-tile input:focus-visible { box-shadow: 0 0 0 2px rgba(122, 167, 255, .6); }
.ratio-shape {
  position: relative; z-index: 1; pointer-events: none; display: block; box-sizing: border-box;
  border: 1.5px solid #cfd9ea; border-radius: 3px; background: transparent;
}
.rs-16-9 { width: 26px; height: 15px; }
.rs-1-1  { width: 19px; height: 19px; }
.rs-9-16 { width: 13px; height: 23px; }
.rs-2-3  { width: 15px; height: 23px; }
.rs-auto { width: 22px; height: 18px; border-style: dashed; border-radius: 4px; }
.ratio-num {
  position: relative; z-index: 1; pointer-events: none;
  font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.ratio-tile input:checked ~ .ratio-shape { border-color: #4fd1c5; background: rgba(79, 209, 197, .16); }
.ratio-tile input:checked ~ .ratio-num { color: #8ff0e5; font-weight: 700; }
@media (max-width: 380px) {
  .image-ratios { gap: 4px; }
  .ratio-tile { min-height: 70px; }
}
.image-generate { width: 100%; height: 38px; }
.image-status { margin-top: 9px; font-size: 12px; color: #ffd9a0; }
#imagePreview {
  display: block; width: 100%; border-radius: 10px;
  border: 1px solid var(--panel-line); background: rgba(10, 16, 28, .5);
}
.image-result-meta { margin: 8px 0; font-size: 12px; color: var(--text-dim); }
.image-download {
  display: block; text-align: center; line-height: 34px; text-decoration: none;
  color: inherit;
}
/* ---- 我的图库：缩略图网格（滚动分批，点开才加载原图） ---- */
.image-gallery-count { font-size: 11px; color: var(--text-dim); }
.image-gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.image-gallery-tile {
  display: flex; flex-direction: column;
  border: 1px solid var(--panel-line); border-radius: 10px; overflow: hidden;
  background: rgba(255, 255, 255, .03);
}
.image-gallery-tile .ig-thumb {
  display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  cursor: zoom-in; background: rgba(10, 16, 28, .5);
}
.image-gallery-tile .ig-dl {
  margin: 7px; padding: 4px 0; text-align: center;
  border-radius: 7px; font-size: 11px; text-decoration: none; color: #dce7ff;
  background: rgba(122, 167, 255, .18); border: 1px solid rgba(122, 167, 255, .4);
  cursor: pointer;
}
.image-gallery-tile .ig-dl:hover { background: rgba(122, 167, 255, .3); }
.image-gallery-empty { padding: 14px 0; text-align: center; font-size: 12px; color: var(--text-dim); }
.image-gallery-more { display: block; margin: 10px auto 0; }
.image-hint { margin: 9px 0 0; font-size: 11px; color: var(--text-dim); line-height: 1.55; }
/* 聊天里生成的图片：初始就按大图展示（用户指定红框尺寸），
   只作用于 AI 生图结果，聊天里其它图片消息仍保持 220px 缩略图 */
.bubble.gen-img-bubble {
  position: relative;
  width: min(560px, 76vw);
  max-width: 100%;
  padding: 8px;
  box-sizing: border-box;
}
.bubble.gen-img-bubble .msg-img {
  display: block;
  width: 100%;
  max-width: none;
  max-height: none;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
}
.gen-img-bubble { position: relative; }
/* 右上角操作区：重新生成小图标在左、下载按钮在右 */
.gen-img-actions {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
}
.chat-img-download {
  display: inline-block; padding: 7px 14px;
  border-radius: 9px; font-size: 12px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, #4b8cff, #7a6bff);
  box-shadow: 0 4px 12px rgba(60, 100, 200, .25);
}
.gen-img-bubble .chat-img-download { position: static; margin: 0; }
.chat-img-download:hover { filter: brightness(1.08); }
/* 重新生成：圆形刷新小图标，鼠标悬停才显示「重新生成」四字 */
.chat-img-regen {
  position: relative; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(10, 16, 28, .62); color: #fff; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.chat-img-regen svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.chat-img-regen:hover { background: rgba(30, 44, 72, .92); }
.chat-img-regen::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  background: rgba(8, 12, 22, .94); color: #fff; font-size: 12px; line-height: 1.2;
  opacity: 0; pointer-events: none; transition: opacity .12s linear;
}
.chat-img-regen:hover::after { opacity: 1; }
#imageActivateSec.need-activate { animation: imgFlash 1.4s ease-out; }
@keyframes imgFlash {
  0% { background: rgba(255, 200, 120, .18); }
  100% { background: transparent; }
}
.av-card.on .av-name { color: #8ef0e4; }
.av-badge {
  position: absolute; top: 5px; left: 5px;
  font-size: 9.5px; color: #ffd9a0;
  background: rgba(60, 40, 10, .8);
  border: 1px solid rgba(255, 200, 120, .3);
  padding: 1px 6px; border-radius: 999px;
}
.av-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(255, 128, 149, .3);
  background: rgba(40, 12, 18, .85);
  color: #ff9fb0; font-size: 10px;
  cursor: pointer; opacity: 0; transition: .15s;
}
.av-card:hover .av-del { opacity: 1; }
.av-del:hover { background: rgba(90, 20, 30, .95); }
.av-hint { font-size: 11px; color: #6c7c94; margin: 9px 0 0; line-height: 1.6; }
/* 角色位置与大小调节 */
.av-pos {
  margin-top: 14px;
  padding: 11px 12px 9px;
  border: 1px solid rgba(120, 170, 220, .14);
  border-radius: 11px;
  background: rgba(255, 255, 255, .025);
}
.av-pos .kb-label { margin-bottom: 4px; }
.av-pos-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.av-pos-name { width: 30px; flex: none; font-size: 12px; color: #8fa2bd; }
/* 全身 / 半身 切换按钮组 */
.av-mode-mini { display: flex; gap: 6px; }
.av-mode-mini .kb-mini { opacity: .7; }
.av-mode-mini .kb-mini.on {
  opacity: 1;
  background: rgba(122, 167, 255, .22);
  border-color: rgba(122, 167, 255, .55);
  color: #dce7ff;
}
.av-pos-val {
  width: 44px; flex: none; text-align: right;
  font-size: 11.5px; color: #6fbcb1; font-variant-numeric: tabular-nums;
}
.av-pos-row input[type="range"] {
  flex: 1; min-width: 0; height: 4px;
  appearance: none; -webkit-appearance: none;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(79, 209, 197, .55), rgba(122, 167, 255, .55));
  outline: none; cursor: pointer;
}
.av-pos-row input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #eaf6ff;
  border: 2px solid #5fe0d1;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .4);
}
.av-empty {
  grid-column: 1 / -1;
  padding: 16px; text-align: center;
  font-size: 12px; color: #6c7c94;
  border: 1px dashed rgba(120, 170, 220, .2);
  border-radius: 11px;
}

/* 小按钮 */
.kb-mini {
  height: 28px; padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .045);
  color: var(--text-dim);
  font-size: 11.5px; font-family: inherit; cursor: pointer; transition: .18s;
  white-space: nowrap;
}
.kb-mini:hover { color: var(--text); border-color: rgba(120, 170, 220, .36); background: rgba(255, 255, 255, .08); }
.kb-mini.primary {
  color: #06201f; font-weight: 600;
  background: linear-gradient(135deg, #5fe0d1, #7aa7ff);
  border-color: transparent;
}
.kb-mini.primary:hover { filter: brightness(1.08); }

/* 底部操作栏 */
.kb-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid rgba(120, 170, 220, .12);
  background: rgba(8, 14, 24, .8);
}
.kb-foot-spacer { flex: 1; }
.kb-btn {
  height: 34px; padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .045);
  color: var(--text-dim);
  font-size: 12.5px; font-family: inherit; cursor: pointer; transition: .18s;
}
.kb-btn:hover { color: var(--text); border-color: rgba(120, 170, 220, .36); background: rgba(255, 255, 255, .08); }
.kb-btn.primary {
  color: #06201f; font-weight: 600;
  background: linear-gradient(135deg, #5fe0d1, #7aa7ff);
  border-color: transparent;
}
.kb-btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }

@keyframes kbFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kbSlide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  color: #d8f5f1;
  background: rgba(16, 34, 40, .95);
  border: 1px solid rgba(79, 209, 197, .34);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .22s, transform .22s;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 动画 ---------- */
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
/* 待机呼吸：以脚底为支点做轻微起伏，脚始终踩在地上（不再整体上下漂） */
/* 待机呼吸：只做上下浮动，**不带 scale**。
   以前是 scale(1.012)，说话时又切成 talkBounce 的 scale(1.008) —— 同一角色在
   待机/讲话两种状态下被套用两套缩放动画，看起来就是「大小模式来回切换」。
   现在两套动画都只位移，角色尺寸在任何状态下完全一致。 */
@keyframes idleFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes headSway {
  0%,100% { transform: rotate(-1.4deg) translateX(-2px); }
  50% { transform: rotate(1.6deg) translateX(2px); }
}
@keyframes headSwayFast {
  0%,100% { transform: rotate(-2.4deg); }
  50% { transform: rotate(2.6deg); }
}
@keyframes haloPulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes bar {
  0%,100% { transform: scaleY(.27); opacity: .5; }
  50% { transform: scaleY(1); opacity: 1; }
}
@keyframes typingDot { 0%,100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes recPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255, 128, 149, .35); }
  50% { box-shadow: 0 0 0 10px rgba(255, 128, 149, 0); }
}

/* ================= 弹窗（图片点评 / 手机联动） ================= */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 8, 15, .62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fadeIn .18s ease both;
}
.modal {
  position: fixed;
  z-index: 61;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid rgba(120, 170, 220, .2);
  background: linear-gradient(180deg, rgba(18, 27, 44, .97), rgba(10, 16, 28, .98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  overflow: hidden;
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1) both;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(120, 170, 220, .12);
}
.modal-head-txt { flex: 1; min-width: 0; }
.modal-head h2 {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: .2px;
}
.modal-head p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
.modal-close {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .05);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: .18s;
}
.modal-close:hover { color: var(--text); background: rgba(255, 255, 255, .1); }
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(120, 170, 220, .12);
}
.modal-foot .kb-btn { height: 38px; }

/* ---- 拖拽上传区 ---- */
.drop {
  position: relative;
  border-radius: 14px;
  border: 1.5px dashed rgba(120, 170, 220, .3);
  background: rgba(255, 255, 255, .028);
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  transition: .2s;
  outline: none;
}
.drop:hover, .drop:focus-visible { border-color: rgba(79, 209, 197, .5); background: rgba(79, 209, 197, .05); }
.drop.over { border-color: var(--accent); background: rgba(79, 209, 197, .1); }
.drop-icon { font-size: 30px; line-height: 1; margin-bottom: 10px; opacity: .9; }
.drop-main { margin: 0 0 6px; font-size: 13.5px; color: var(--text); }
.drop-sub { margin: 0; font-size: 12px; color: var(--text-dim); }
.drop-preview { position: relative; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.drop-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(0, 0, 0, .3);
  object-fit: contain;
}
.drop-preview-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.img-remove {
  border: 1px solid rgba(255, 128, 149, .35);
  background: rgba(255, 128, 149, .1);
  color: #ffb7c3;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.img-remove:hover { background: rgba(255, 128, 149, .2); }

/* ---- 点评模式 ---- */
.img-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.img-mode {
  text-align: left;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: .18s;
}
.img-mode b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.img-mode i { display: block; font-size: 11.5px; line-height: 1.5; color: var(--text-dim); font-style: normal; }
.img-mode:hover { border-color: rgba(120, 170, 220, .34); }
.img-mode.on {
  border-color: rgba(79, 209, 197, .55);
  background: rgba(79, 209, 197, .1);
  box-shadow: 0 0 0 1px rgba(79, 209, 197, .18) inset;
}
.img-mode.on b { color: #8ff0e5; }

.img-note { display: flex; flex-direction: column; gap: 6px; }
.img-note span { font-size: 12px; color: var(--text-dim); }
.img-note input {
  height: 40px;
  padding: 0 13px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  outline: none;
}
.img-note input:focus { border-color: rgba(79, 209, 197, .45); }
.img-hint {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: #7f93ad;
  background: rgba(122, 167, 255, .07);
  border: 1px solid rgba(122, 167, 255, .16);
  border-radius: 10px;
  padding: 9px 12px;
}

/* ---- 手机联动 ---- */
.pair-modal { width: min(620px, calc(100vw - 32px)); }
.pair-body { flex-direction: row; gap: 20px; align-items: flex-start; }
.qr-box {
  flex: 0 0 auto;
  width: 200px; height: 200px;
  border-radius: 14px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.qr-box svg, .qr-box img { width: 100%; height: 100%; display: block; }
.qr-loading { font-size: 12px; color: #556; text-align: center; }
.pair-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.pair-code { font-size: 13px; color: var(--text-dim); }
.pair-code b {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 19px;
  letter-spacing: 3px;
  color: var(--accent);
  margin-left: 4px;
}
.pair-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .04);
  align-self: flex-start;
}
.pair-status.online { color: #8ff0e5; border-color: rgba(79, 209, 197, .4); background: rgba(79, 209, 197, .1); }
.pi-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7d8ea6;
  display: inline-block;
}
.pair-status.online .pi-dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(79, 209, 197, .16); }
.pair-steps {
  margin: 2px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--text-dim);
}
.pair-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kb-btn:disabled { opacity: .5; cursor: wait; }
.pair-note { margin: 2px 0 0; font-size: 11.5px; line-height: 1.6; color: #6f8299; }

/* ---- 聊天气泡里的图片 ---- */
.bubble.has-img { padding: 7px; }
.bubble .msg-img {
  display: block;
  max-width: 220px;
  max-height: 240px;
  border-radius: 9px;
  cursor: zoom-in;
  border: 1px solid rgba(255, 255, 255, .12);
}
.bubble .msg-img-cap {
  display: block;
  margin-top: 6px;
  padding: 0 3px 2px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #5b6478;
}
.img-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 5, 10, .9);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
  animation: fadeIn .16s ease both;
}
.img-viewer img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 42vh) 1fr;
    grid-template-areas:
      "top"
      "stage"
      "chat";
    padding: 12px;
    gap: 12px;
  }
  .avatar-wrap { width: min(58%, 220px); }
  .avatar-halo { width: 300px; height: 300px; }
  .stage { padding: 10px; }
  /* 手机上对话区同样透明，只留气泡本身 */
  .chat {
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .chat-scroll { padding: 14px 14px 6px; }
  .foot-hint { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-actions { flex-wrap: wrap; }
  .kb-drawer { width: 100vw; }
  .kb-row { grid-template-columns: 1fr; }
  .kb-modes { grid-template-columns: 1fr; }
  .kb-body { padding: 14px 14px 18px; }
  .kb-foot { padding: 11px 14px; flex-wrap: wrap; }
  .av-grid { grid-template-columns: repeat(3, 1fr); }
  .av-grid.bg { grid-template-columns: repeat(2, 1fr); }
  /* 弹窗：手机上铺满宽度、竖向排列 */
  .modal {
    width: calc(100vw - 20px);
    max-height: 88vh;
    border-radius: 16px;
  }
  .modal-body { padding: 14px; }
  .modal-head { padding: 14px 14px 12px; }
  .pair-body { flex-direction: column; align-items: center; }
  .qr-box { width: 176px; height: 176px; }
  .pair-info { width: 100%; }
  .img-modes { grid-template-columns: 1fr; }
}

/* 图片按钮用次要色，和麦克风区分开 */
.mic.img-btn {
  border-color: rgba(122, 167, 255, .34);
  background: rgba(122, 167, 255, .1);
  color: var(--accent-2);
}
.mic.img-btn:hover { background: rgba(122, 167, 255, .2); }

/* ---------- 课件（幻灯片）浮层 ---------- */
.slide-panel {
  position: fixed;
  top: 82px;
  right: 22px;
  width: min(520px, 42vw);
  height: min(62vh, 520px);
  z-index: 38;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(120, 170, 220, .2);
  background: rgba(12, 20, 30, .82);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  animation: fadeUp .22s ease both;
  overflow: hidden;
}
.slide-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px 9px;
  border-bottom: 1px solid rgba(120, 170, 220, .12);
}
.slide-title { font-size: 13px; color: var(--text); letter-spacing: .3px; }
.slide-page {
  font-size: 11.5px; color: #6fbcb1;
  padding: 1px 8px; border-radius: 999px;
  background: rgba(79, 209, 197, .12);
  font-variant-numeric: tabular-nums;
}
.slide-x {
  margin-left: auto; width: 26px; height: 26px;
  border-radius: 8px; cursor: pointer;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .05);
  color: var(--text-dim); font-size: 12px; line-height: 1;
}
.slide-x:hover { color: var(--text); background: rgba(255, 255, 255, .1); }
.slide-body {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, .18);
}
.slide-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}
.slide-text {
  width: 100%; height: 100%;
  overflow: auto;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  color: #1c2633;
  font-size: 15px; line-height: 1.75;
  white-space: pre-wrap;
}
.slide-empty {
  font-size: 12.5px; color: #7d8ea6; line-height: 1.9;
  text-align: center; padding: 0 18px;
}
.slide-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 13px;
  border-top: 1px solid rgba(120, 170, 220, .12);
}
.slide-auto {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: #8fa2bd; cursor: pointer; user-select: none;
}
.slide-auto input { accent-color: #5fe0d1; cursor: pointer; }
@media (max-width: 900px) {
  .slide-panel { top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; height: 46vh; }
}

/* ---------- 被嵌入其他软件（PPT 加载项 / iframe）时：紧凑排版 ---------- */
body.in-frame { -webkit-user-select: none; }
body.in-frame .topbar { padding: 7px 10px; gap: 8px; }
body.in-frame .brand-sub { display: none; }
/* 手机联动在内嵌（WPS/PPT）里必须保留：它是内嵌时唯一可用的语音通道 */
body.in-frame #btnReset,
body.in-frame #btnSlide { display: none; }
body.in-frame .chip { height: 33px; padding: 0 14px; font-size: 13.5px; }
body.in-frame .chip .ico { font-size: 15px; }
body.in-frame .voice-pick { padding: 5px 13px 5px 15px; }
body.in-frame .voice-pick-label { font-size: 13px; }
body.in-frame .voice-pick select { font-size: 13.5px; }
body.in-frame .stage { padding: 6px 10px 4px; }
body.in-frame .chat { padding: 10px 12px; }
body.in-frame .composer { padding: 8px 10px 6px; }
body.in-frame .suggest,
body.in-frame .foot-hint,
body.in-frame .status { display: none; }
body.in-frame .bubble { font-size: 13.5px; }

/* ---------- 卡密额度 ---------- */
.sound-hint {
  color: #ffd68a; border-color: rgba(255, 198, 92, .5);
  background: rgba(255, 198, 92, .12); font-weight: 500;
}
.sound-hint:hover { color: #fff; border-color: rgba(255, 198, 92, .8); }
.bill-chip { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-chip.bill-low { color: #ffb4a8; border-color: rgba(255, 120, 100, .4); }
.bill-chip.bill-none { color: #ffd68a; border-color: rgba(255, 198, 92, .5); background: rgba(255, 198, 92, .1); }
/* 内嵌窗口窄，保证激活入口不会被顶栏挤掉 */
body.in-frame .topbar-actions { flex-wrap: nowrap; }
body.in-frame .bill-chip { flex: 0 0 auto; }
.bill-modal { width: min(460px, calc(100vw - 32px)); }
.bill-quota { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.bq-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px; border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(120, 170, 220, .12);
  font-size: 13px; color: #aebccd;
}
.bq-row b { color: var(--text); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.bq-note {
  font-size: 11.5px; color: #7d8ea6; line-height: 1.6;
  padding: 0 4px 2px; margin: -2px 0 2px;
}
.bq-code { font-size: 11.5px; color: #7d8ea6; text-align: center; }
.bq-code b { color: #9fc3e8; letter-spacing: 1px; }
.bill-act { display: flex; flex-direction: column; gap: 9px; }
.bill-input {
  height: 42px; border-radius: 10px;
  border: 1px solid rgba(120, 170, 220, .25);
  background: rgba(255, 255, 255, .06);
  color: var(--text); font-size: 14px; letter-spacing: 1.5px;
  padding: 0 14px; outline: none; text-transform: uppercase;
}
.bill-input:focus { border-color: rgba(95, 224, 209, .6); }
.bill-tip { font-size: 12px; color: #7d8ea6; margin: 0; line-height: 1.6; }

/* ---------- 竖版 / 窄容器自适应（Windows WPS 网页形状常见） ----------
   原 grid 两列各有 320px / 360px 最小宽度，容器一旦变窄就会被撑破，
   右侧对话区被裁到视口外 —— 表现为「很多东西看不到 / 位置错位」。 */
body.in-frame .app { grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr); min-width: 0; }
body.in-frame .stage,
body.in-frame .chat,
body.in-frame .topbar,
body.in-frame .topbar-actions { min-width: 0; }

/* JS 检测容器宽高比后打上 dh-portrait；也可用 ?layout=portrait 强制 */
body.dh-portrait .app {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(110px, 30%) minmax(0, 1fr);
  grid-template-areas: "top" "stage" "chat";
  gap: 8px;
  padding: 8px;
  height: 100%;
  overflow: hidden;
}
body.dh-portrait .topbar-actions { flex-wrap: wrap; }
body.dh-portrait #btnVoice,
body.dh-portrait .voice-pick,
body.dh-portrait #btnReset,
body.dh-portrait .suggest { display: none !important; }
body.dh-portrait .stage { padding: 4px 8px; }
body.dh-portrait .avatar-wrap { width: min(46%, 190px); }
body.dh-portrait .avatar-halo { width: 210px; height: 210px; }
body.dh-portrait .chat { padding: 8px; min-height: 0; }
body.dh-portrait .chat-scroll { min-height: 0; }
body.dh-portrait .composer { padding: 6px 8px; }
body.dh-portrait .bubble { font-size: 13px; }
body.dh-portrait .error-bar { margin: 0 8px 6px; padding: 6px 9px; font-size: 11.5px; }

/* 容器本身就是竖版视口时，即使 JS 没打标记也要自动堆叠 */
@media (max-aspect-ratio: 1/1) {
  body.in-frame .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(110px, 30%) minmax(0, 1fr);
    grid-template-areas: "top" "stage" "chat";
    gap: 8px; padding: 8px;
  }
  body.in-frame .topbar-actions { flex-wrap: wrap; }
  body.in-frame #btnVoice,
  body.in-frame .voice-pick { display: none; }
  body.in-frame .suggest { display: none !important; }
  body.in-frame .avatar-wrap { width: min(46%, 190px); }
  body.in-frame .error-bar { margin: 0 8px 6px; padding: 6px 9px; font-size: 11.5px; }
}

/* ---------- 幻灯片固定视图（?slide=1 / ?ppt=1）----------
   用途：WPS 编辑视图里网页形状也要「整页 + 左右结构」地正确展示。
   做法：把页面固定成 1280x720 的 16:9 设计稿，由 JS 等比缩放居中（fitSlideCanvas）。
   这样容器视口再窄、再竖，页面内部始终是横版左右两栏，不会被撑破或裁切。
   下面这些规则同时覆盖「窄视口自动竖版」的媒体查询（特异性更高）。 */
html.dh-slide-root {
  overflow: hidden;
  /* 画布外留黑边区域：用与场景一致的深色渐变补底，视觉上无缝 */
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
body.dh-slide {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  margin: 0;
  overflow: hidden;
  transform-origin: 0 0;
}
body.in-frame.dh-slide .app {
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr) !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  grid-template-areas: "top top" "stage chat" !important;
  gap: 14px;
  padding: 14px 18px 18px;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}
body.in-frame.dh-slide .topbar-actions { flex-wrap: nowrap; }
/* PPT/WPS 内嵌（embed=1&slide=1）也要能「清空对话重新开始」，
   之前被 body.in-frame #btnReset{display:none} 误伤，board 模式有覆盖、slide 模式漏了 */
body.in-frame.dh-slide #btnReset { display: inline-flex !important; }
body.in-frame.dh-slide #btnVoice,
body.in-frame.dh-slide .voice-pick { display: inline-flex !important; }
body.in-frame.dh-slide .suggest { display: flex !important; }
body.in-frame.dh-slide .avatar-wrap { width: min(58%, 330px); }
body.in-frame.dh-slide .error-bar { margin: 0 18px 8px; padding: 8px 12px; font-size: 12.5px; }

/* ---------- 固定画布通用覆盖（独立浏览器也走此模式）----------
   固定画布默认全局生效后，必须压过 @media(max-width:900px) 与
   @media(max-aspect-ratio:1/1) 的竖版堆叠规则，保证任何视口下
   「顶部 + 左形象 / 右对话」框架不变、整体同比缩放。 */
body.dh-slide .app {
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr) !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  grid-template-areas: "top top" "stage chat" !important;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
body.dh-slide .stage,
body.dh-slide .chat,
body.dh-slide .topbar,
body.dh-slide .topbar-actions { min-width: 0 !important; }
body.dh-slide .topbar { flex-wrap: nowrap !important; padding: 0 2px; gap: 8px; }
body.dh-slide .topbar-actions { flex-wrap: nowrap !important; }
/* 顶栏放不下时让按钮内部压缩，而不是把最右侧的按钮挤出容器被裁掉 */
body.dh-slide .topbar-actions .chip { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body.dh-slide .topbar-actions .voice-pick { flex: 0 1 auto; min-width: 0; }
body.dh-slide .stage { padding: 6px 12px 4px; }
body.dh-slide .avatar-wrap { width: min(62%, 330px); margin-bottom: 10px; }
/* 幻灯片画布更矮，半身形象的高度上限再收一点，保证不压到对话区 */
body.dh-slide .avatar-bust .avatar-wrap { max-height: min(84%, 420px); }
body.dh-slide .avatar-halo { width: min(52%, 300px); height: min(52%, 300px); }
body.dh-slide .chat { padding: 10px 14px; }
body.dh-slide .chat-scroll { padding: 10px 12px 6px; }
body.dh-slide .composer { padding: 8px 10px 6px; }
body.dh-slide .bubble { font-size: 13.5px; }
body.dh-slide .foot-hint { display: none; }
body.dh-slide .error-bar { margin: 0 14px 8px; padding: 8px 12px; font-size: 12.5px; }

/* ---------- 整页铺满视图（?board=1）----------
   用途：WPS「编辑视图」里不用按 F5，网页形状本身就是完整一页；
        把它拉到正常 PPT 页大小、甚至拉成任意比例，都保持「左形象 / 右对话」。
   与 ?slide=1 的区别：不锁 1280x720 设计稿、也不依赖 JS 计算缩放，
        .app 直接铺满容器，因此首屏（JS 还没跑）就是正确的左右结构，
        WPS 抓编辑态快照时不会只拍到左上角或变成竖版堆叠。
   以下规则全部带 !important，用来压过 max-width:900px / max-aspect-ratio:1/1
   的自动竖版媒体查询。 */
html.dh-board-root { overflow: hidden; }
body.dh-board {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  overflow: hidden;
  transform: none !important;
  position: relative;
}
body.dh-board.in-frame .app {
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr) !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  grid-template-areas: "top top" "stage chat" !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  gap: clamp(6px, 1.1vw, 16px);
  padding: clamp(6px, 1.3vw, 18px);
  overflow: hidden;
}
body.dh-board.in-frame .stage,
body.dh-board.in-frame .chat,
body.dh-board.in-frame .topbar,
body.dh-board.in-frame .topbar-actions,
body.dh-board.in-frame .chat-scroll,
body.dh-board.in-frame .composer {
  min-width: 0 !important;
  min-height: 0 !important;
}
body.dh-board.in-frame .topbar { padding: 0 2px; gap: 6px; flex-wrap: nowrap !important; }
body.dh-board.in-frame .topbar-actions { flex-wrap: nowrap !important; gap: 4px; overflow: hidden; }
body.dh-board.in-frame .brand-name { font-size: clamp(12px, 1.35vw, 17px); white-space: nowrap; }
body.dh-board.in-frame .chip {
  height: auto; padding: 5px 11px;
  font-size: clamp(12px, 1.25vw, 15px);
  white-space: nowrap;
}
body.dh-board.in-frame .voice-pick,
body.dh-board.in-frame #btnVoice,
body.dh-board.in-frame #btnReset,
body.dh-board.in-frame #btnKb,
body.dh-board.in-frame #btnAvScene,
body.dh-board.in-frame #btnPair,
body.dh-board.in-frame #btnMicDiag,
body.dh-board.in-frame .suggest { display: inline-flex !important; }
body.dh-board.in-frame .status,
body.dh-board.in-frame .foot-hint { display: none !important; }
body.dh-board.in-frame .avatar-halo {
  width: min(52%, 280px); height: min(52%, 280px);
}
body.dh-board.in-frame .avatar-wrap { width: min(62%, 330px); margin-bottom: 10px; }
body.dh-board.in-frame .bubble { font-size: clamp(11px, 1.2vw, 14px); }
body.dh-board.in-frame #txtInput,
body.dh-board.in-frame .send { font-size: clamp(10px, 1.1vw, 13px); }
/* PPT 嵌入紧凑模式：胶囊和圆按钮缩小一档 */
body.dh-board.in-frame .tap-speak { height: 42px; border-radius: 21px; font-size: 13.5px; gap: 8px; }
body.dh-board.in-frame .tap-speak svg { width: 19px; height: 19px; }
body.dh-board.in-frame .round-btn { width: 46px; height: 46px; }
body.dh-board.in-frame .round-btn svg { width: 22px; height: 22px; }
body.dh-board.in-frame .composer-tools { padding: 0 2px 8px; gap: 10px; }
body.dh-board.in-frame .mode-pill { height: 42px; padding: 0 18px; border-radius: 21px; font-size: 13px; }
body.dh-board.in-frame #txtInput { height: 42px; border-radius: 21px; font-size: 13px; }
body.dh-board.in-frame .send { height: 42px; border-radius: 21px; }
body.dh-board.in-frame .error-bar { margin: 0 8px 6px; padding: 6px 9px; font-size: 11.5px; }
