:root {
  /* 背景：暖米色 + 茶色，偏东方，又不老气 */
  --bg-gradient-top: #f6f3ea;
  --bg-gradient-middle: #efe2d2;
  --bg-gradient-bottom: #d5c3aa;

  /* 主卡片：类似苹果“设置”里的那种浅浅卡片 */
  --card-bg: rgba(252, 252, 250, 0.98);
  --card-border: rgba(15, 23, 42, 0.06);
  --card-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);

  /* 品牌主色：温暖的金橙色，代表「茶」「灯光」「温暖」 */
  --primary: #f59e0b;
  --primary-soft: rgba(245, 158, 11, 0.12);

  /* 字体颜色：墨色系，贴一点国风感觉 */
  --ink: #111827;
  --ink-soft: #6b7280;

  /* 轻微分隔线 / 边框 */
  --divider: rgba(15, 23, 42, 0.06);
}

/* 页面背景：苹果风 + 科技国风的茶室氛围 */
.page-bg {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;

  /* 多层渐变：柔和米色打底 + 角落一点暖光 */
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 55%),
    radial-gradient(circle at bottom right, rgba(245, 158, 11, 0.18), transparent 55%),
    linear-gradient(145deg, var(--bg-gradient-top), var(--bg-gradient-middle), var(--bg-gradient-bottom));

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}

/* 整个聊天应用的卡片：苹果风悬浮茶室 */
.app {
  width: 960px;
  max-width: 96vw;
  background: var(--card-bg);
  border-radius: 24px;
  padding: 24px 28px 18px;

  /* 柔和但有存在感的阴影，类似 Apple 卡片 */
  box-shadow:
    0 35px 60px rgba(15, 23, 42, 0.20),
    0 4px 8px rgba(15, 23, 42, 0.05),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.7);

  /* 轻微描边，增加质感 */
  border: 1px solid var(--card-border);

  /* 一点点玻璃磨砂效果 */
  backdrop-filter: blur(18px);

  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.25), transparent 35%),
    var(--card-bg);
  background-blend-mode: soft-light, normal;
}

/* 顶部老师信息区：像一块安静的横幅 */
.header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--divider);
}

.teacher-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 2px;
}

/* 老师头像：苹果风小光圈 + 一点东方金色 */
.teacher-avatar-wrap {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  padding: 3px;
  box-sizing: border-box;

  /* 外圈金色柔光，代表茶灯 / 温暖 */
  background: conic-gradient(
    from 140deg,
    rgba(245, 158, 11, 0.85),
    rgba(249, 250, 251, 0.2),
    rgba(251, 191, 36, 0.9),
    rgba(249, 250, 251, 0.4)
  );

  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.22);
}

.teacher-avatar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  object-fit: cover;
  background: radial-gradient(circle at 30% 10%, #fef9c3, #f3f4f6);
}

.teacher-info h1 {
  margin: 0 0 4px 0;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.teacher-subtitle {
  margin: 0 0 6px 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

.teacher-tags {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #92400e;
  font-size: 12px;
  margin: 0;
}

/* 聊天区：安静的茶室对话框 */
.chat-box {
  border-radius: 20px;
  padding: 18px 16px;
  height: 430px;
  overflow-y: auto;

  /* 内部用非常浅的米白，像宣纸 */
  background:
    radial-gradient(circle at top, rgba(249, 250, 251, 0.85), transparent 60%),
    linear-gradient(145deg, #f9faf7, #f3f4f2);

  border: 1px solid var(--divider);

background-image:
  radial-gradient(circle at top, rgba(249, 250, 251, 0.85), transparent 60%),
  linear-gradient(145deg, #f9faf7, #f3f4f2),
  url("data:image/svg+xml;utf8,\
  <svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none'>\
  <filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/></filter>\
  <rect width='160' height='160' filter='url(%23n)' opacity='0.015'></rect></svg>");

  /* 内部微微内凹一点点，让人有“坐进来”的感觉 */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(209, 213, 219, 0.25);
}

/* 滚动条美化（可选） */
.chat-box::-webkit-scrollbar {
  width: 8px;
}
.chat-box::-webkit-scrollbar-track {
  background: transparent;
}
.chat-box::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

/* 消息气泡布局 */
.message {
  display: flex;
  margin-bottom: 14px;
}

.message.bot {
  flex-direction: row;
}

.message.user {
  flex-direction: row-reverse;
}

/* 让第一条和最后一条稍微留多一点呼吸空间（可要可不要） */
.message:first-child {
  margin-top: 4px;
}
.message:last-child {
  margin-bottom: 4px;
}

/* 聊天消息左侧的小头像容器 */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  margin: 0 8px;
  flex-shrink: 0;

  /* 默认：什么都不显示（给用户用），文字也不显示 */
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 0;
  color: transparent;
  overflow: hidden;
}

/* 老师的每条消息：用迷你版老师头像 */
.message.bot .avatar {
  background-image: url("hongxinliang.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  /* 给老师的小头像一点柔和投影 */
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

/* 用户的每条消息：看起来就像没有头像，只保留一点点占位 */
.message.user .avatar {
  width: 12px;       /* 非常小，只当空白间距用 */
  margin: 0 4px;
  box-shadow: none;
  border: none;
}

/* 聊天气泡：像写在一张温柔的纸上 */
.bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  border: 1px solid rgba(209, 213, 219, 0.7);
  background: rgba(253, 253, 250, 0.95);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

/* 老师的消息：轻微茶色，带一点点金色暖意 */
.message.bot .bubble {
  background: linear-gradient(135deg, #fef9c3, #fef3c7);
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow:
    0 10px 25px rgba(245, 158, 11, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.6);
  outline: 1px solid rgba(250, 204, 21, 0.45);
}

/* 用户的消息：更安静、更“被允许表达” */
.message.user .bubble {
  background: rgba(248, 250, 252, 0.96);
  border-color: rgba(148, 163, 184, 0.7);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  outline: 1px solid rgba(255, 255, 255, 0.4);
}

/* 底部输入区域：苹果风胶囊输入条 */
.input-area {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 6px 6px 6px 16px;
  border-radius: 999px;

  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
  border: 1px solid var(--divider);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 14px 26px rgba(15, 23, 42, 0.16);

}

/* 文本输入框：透明嵌在胶囊里面 */
.input-area input {
  flex: 1;
  padding: 8px 6px;
  border: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
}

/* placeholder 更柔和一点 */
.input-area input::placeholder {
  color: rgba(148, 163, 184, 0.9);
}

.input-area input:focus {
  outline: none;
}

/* 发送按钮：小小一颗“茶色光点” */
.input-area .send-button {
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;

  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1f2933;

  box-shadow:
    0 10px 24px rgba(245, 158, 11, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.9);

  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, filter 0.12s ease-out;
}

/* 语音输入按钮：小圆形麦克风 */
.input-area .mic-button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;

  background: rgba(148, 163, 184, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 4px 10px rgba(15, 23, 42, 0.12);

  cursor: pointer;
  flex-shrink: 0;
  transition:
    transform 0.12s ease-out,
    box-shadow 0.12s ease-out,
    background 0.12s ease-out;
}

.input-area .mic-button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 8px 18px rgba(15, 23, 42, 0.18);
}

/* 正在录音时的高亮状态 */
.input-area .mic-button.listening {
  background: rgba(239, 68, 68, 0.18);
  box-shadow:
    0 0 0 1px rgba(248, 113, 113, 0.8),
    0 8px 18px rgba(248, 113, 113, 0.4);
}


/* 悬停时一点点“弹”起来 */
.input-area button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 14px 30px rgba(245, 158, 11, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.9);
  filter: brightness(1.03);
}

/* 点击时轻轻压下去 */
.input-area button:active {
  transform: translateY(0);
  box-shadow:
    0 6px 16px rgba(245, 158, 11, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.9);
}

.input-area button:disabled {
  background: linear-gradient(135deg, #e5e7eb, #d1d5db);
  color: #6b7280;
  box-shadow: none;
  cursor: default;
}

/* 小提示：轻声提醒“按 Enter 也可以说话” */
.hint {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.95);
  text-align: right;
}

/* 洪老师语音播放按钮（暖色系） */
.speak-btn {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #f59e0b;          /* 暖橙色边框 */
  font-size: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.95); /* 白底，带一点透明 */
  color: #b45309;                       /* 深一点的橙色文字 / 图标 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.08s ease-out, background 0.1s ease-out,
    box-shadow 0.1s ease-out, opacity 0.1s ease-out;
}

.speak-btn:hover {
  background: #fef3c7; /* 浅浅的米黄色 hover 效果 */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.speak-btn:active {
  transform: scale(0.97);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 语音按钮状态：生成中 */
.speak-btn.is-loading,
.speak-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.speak-btn.is-loading {
  background: #fff7ed;
}
/* 生成中：加一个旋转的小圆圈（CSS 动画） */
.speak-btn.is-loading {
  position: relative;
  padding-left: 38px; /* 给左侧 spinner 留空间 */
}

/* spinner */
.speak-btn.is-loading::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid rgba(234, 88, 12, 0.25);
  border-top-color: rgba(234, 88, 12, 0.95);
  animation: speakSpin 0.9s linear infinite;
}

@keyframes speakSpin {
  to { transform: rotate(360deg); }
}

/* 语音按钮状态：播放中 */
.speak-btn.is-playing {
  background: #fde68a;
}

/* 苹果风隐形滚动条 */
.chat-box::-webkit-scrollbar {
  width: 6px;
}

.chat-box::-webkit-scrollbar-track {
  background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ===================== */
/* 洪老师思考中的小动画  */
/* ===================== */

/* 让“思考中”的气泡里，文字 + 小点点排成一行 */
.message.bot.thinking .bubble {
  display: inline-flex;
  align-items: center;
}

/* 文案本身，比如“正在思考” */
.thinking-text {
  white-space: nowrap;
}

/* 三个小点的容器 */
.thinking-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

/* 每一个小点 */
.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.85);
  opacity: 0.25;
  animation: thinkingDot 1s infinite ease-in-out;
}

/* 让三个点错开时间依次跳动 */
.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* 小点上下轻轻弹跳的动画 */
@keyframes thinkingDot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.25;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* ===================== */
/* 手机端（小屏幕）布局优化 */
/* ===================== */

@media (max-width: 768px) {
  /* 整个背景：让内容往上贴一点，不要死居中 */
  .page-bg {
    align-items: stretch;
    padding: 10px 8px;
  }

  /* 主卡片：铺满屏幕，上下留一点点安全边距 */
  .app {
    width: 100%;
    max-width: 100%;
    height: 100vh;

    border-radius: 0;      /* 手机上不要大圆角，直接铺满 */
    padding: 14px 12px 10px;

    box-shadow: none;      /* 去掉大阴影，手机上会显得太重 */
    border: none;
  }

  /* 顶部老师信息区压缩一点高度 */
  .header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .teacher-card {
    gap: 12px;
  }

  /* 老师头像小一点，手机上刚刚好 */
  .teacher-avatar-wrap {
    width: 56px;
    height: 56px;
    padding: 2px;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.18);
  }

  .teacher-info h1 {
    font-size: 18px;
  }

  .teacher-subtitle {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .teacher-tags {
    font-size: 11px;
    padding: 2px 8px;
  }

  /* 聊天区：拉高一点，方便上下滑动 */
  .chat-box {
    padding: 14px 10px;
    border-radius: 16px;

    /* 100vh -（老师区+输入区的大致高度），后面你可以再微调 */
    height: calc(100vh - 230px);
  }

  /* 底部输入区：更紧凑一点 */
  .input-area {
    margin-top: 10px;
    padding: 6px 8px;
    gap: 8px;
    border-radius: 18px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.8),
      0 10px 20px rgba(15, 23, 42, 0.14);
  }

  .input-area input {
    font-size: 14px;
  }

/* 麦克风：小圆按钮就好 */
.input-area .mic-button {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

/* 发送按钮：保持胶囊形状，只是矮一点、紧凑一点 */
.input-area .send-button {
  height: 34px;          /* 稍微矮一点 */
  padding: 0 16px;       /* 左右留一点空间 */
  font-size: 14px;
  border-radius: 999px;  /* 继续保持圆角胶囊 */
}

  /* 提示文字 & 自动播放开关，字号再小一号 */
  .hint,
  .voice-toggle {
    font-size: 11px;
  }

  .voice-toggle {
    margin-top: 2px;
  }
}

.ai-notice {
  margin-top: 10px;
  padding: 6px 12px;
  font-size: 12px;
  text-align: center;

  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border-radius: 8px;

  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ===== 长回复折叠（方向1）===== */
.bubble {
  position: relative;
}

.bubble-text {
  line-height: 1.85;
}

/* 折叠状态：只露出一部分高度 */
.bubble.collapsed .bubble-text {
  max-height: 260px;      /* 你想露出更多，就调大 */
  overflow: hidden;
}

/* 展开/收起按钮 */
.collapse-toggle {
  margin-top: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.7);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

/* ===== 高端化：气泡操作（方案A）===== */

/* 文本层级：让渐隐遮罩、悬浮按钮有清晰的层级 */
.bubble-text { position: relative; z-index: 0; }

/* 折叠渐隐遮罩：只在 collapsed 时出现 */
.bubble-fade {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 88px;
  pointer-events: none;
  z-index: 1;
  border-radius: 0 0 14px 14px;
}

.bubble.collapsed .bubble-fade { display: block; }

/* 不同气泡背景，渐隐色要跟着走，才“高级不穿帮” */
.message.bot .bubble-fade {
  background: linear-gradient(to bottom, rgba(254, 243, 199, 0), rgba(254, 243, 199, 0.98));
}

.message.user .bubble-fade {
  background: linear-gradient(to bottom, rgba(248, 250, 252, 0), rgba(248, 250, 252, 0.98));
}

/* “展开/收起”做成轻链接（而不是大胶囊） */
.collapse-toggle{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  color: rgba(179, 86, 0, 0.88);
  opacity: 0.92;
  position: relative;
  z-index: 2;
}

.collapse-toggle:hover{
  text-decoration: underline;
  opacity: 1;
}

/* 气泡底部“操作按钮行”（语音）：始终可见，但默认更克制（高级感） */
.bubble-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;

  /* 不再默认隐藏：保持可见，但存在感更弱，避免抢内容 */
  opacity: 0.88;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.12s ease;
  position: relative;
  z-index: 2;
}

.message.bot:hover .bubble-actions,
.message.bot.show-actions .bubble-actions{
  opacity: 1;
}

/* 无 hover 的设备（手机）保持清晰可见 */
@media (hover: none) {
  .bubble-actions{ opacity: 1; }
}

.message.bot:hover .bubble-actions,
.message.bot.show-actions .bubble-actions{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 无 hover 的设备（手机）默认显示语音按钮，避免“找不到入口” */
@media (hover: none) {
  .bubble-actions{
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

/* 语音按钮原本有 margin-top，这里放进操作行就归零 */
.bubble-actions .speak-btn{ margin-top: 0; }

/* 悬浮操作：复制（右上角小图标），默认隐藏 */
.bubble-float-actions{
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 3;

  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.message.bot:hover .bubble-float-actions,
.message.bot.show-actions .bubble-float-actions{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 图标按钮（复制） */
.bubble-icon-btn{
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(179, 86, 0, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: rgba(179, 86, 0, 0.95);

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.bubble-icon-btn:hover{
  background: rgba(255, 255, 255, 0.92);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.bubble-icon-btn:active{
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
}

/* 轻提示（已复制 / 复制失败） */
.toast{
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(10px);

  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: rgba(255, 255, 255, 0.95);
  font-size: 12px;
  line-height: 1;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;

  z-index: 9999;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
}

.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
  .toast{ bottom: 96px; }
}

/* （展开/收起按钮样式已在上方以“轻链接”形式定义；此处不再覆盖） */

/* 微信环境：强制隐藏麦克风（双保险） */
html.is-wechat #mic-button {
  display: none !important;
}
