/* 日间模式样式 */
.theme-adaptive {
  /* 基础颜色 - iOS风格配色 */
  --bg-primary: rgba(255, 255, 255, 0.95);
  --bg-secondary: rgba(242, 242, 247, 0.9);
  --text-primary: #000000;
  --text-secondary: #8e8e93;

  /* 交互元素 - iOS蓝 */
  --accent-color: #007aff;
  --accent-hover: #0051a8;
  --border-color: rgba(60, 60, 67, 0.12);
  --divider-color: rgba(60, 60, 67, 0.06);

  /* 增强确定感的交互状态颜色 */
  --focus-state: rgba(0, 122, 255, 0.2);
  --active-state: rgba(0, 122, 255, 0.3);
  --hover-state: rgba(0, 122, 255, 0.1);
  --success-color: #34c759;
  --success-color-alpha: rgba(52, 199, 89, 0.1);
  --error-color: #ff3b30;
  --error-color-alpha: rgba(255, 59, 48, 0.1);
  --warning-color: #ff9500;
  --warning-color-alpha: rgba(255, 149, 0, 0.1);

  /* 组件特定颜色 */
  --header-bg: rgba(255, 255, 255, 0.95);
  --input-bg: rgba(242, 242, 247, 0.9);
  --ai-answer-bg: rgba(242, 242, 247, 0.7);
  --user-question-bg: #007aff;
  --code-block-bg: rgba(242, 242, 247, 0.8);
  --code-block-border: rgba(60, 60, 67, 0.1);

  /* 代码高亮颜色 - 明亮模式 */
  --code-comment: #707F8C;
  --code-keyword: #AD3DA4;
  --code-string: #D12F1B;
  --code-number: #1C00CF;
  --code-type: #3F6E75;
  --code-function: #326D74;
  --code-variable: #0B4FB6;
  --code-operator: #0B4FB6;
  --code-class: #3F6E75;
  --code-builtin: #3F6E75;

  /* 数学公式颜色 */
  --math-color: var(--text-primary);
  --math-bg: transparent;
  --math-operator: #0B4FB6;
  --math-number: #1C00CF;
  --math-function: #326D74;
  --math-symbol: #AD3DA4;

  /* 滚动条 */
  --scrollbar-bg: rgba(60, 60, 67, 0.06);
  --scrollbar-thumb: rgba(60, 60, 67, 0.12);

  /* 阴影效果 - iOS风格阴影 */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

  /* 思维链样式 */
  --reasoning-border: rgba(60, 60, 67, 0.12);
  --reasoning-text: #666666;

  /* 添加字体相关变量 */
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-size-base: 15px;
  --line-height-base: 1.4;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 600;

  /* 应用基础样式 */
  background-color: var(--bg-primary);
  color: var(--text-primary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);

  /* 添加字体重置 */
  font-family: var(--font-family) !important;
  font-size: var(--font-size-base) !important;
  line-height: var(--line-height-base) !important;
  font-weight: var(--font-weight-normal) !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;

  /* 确保所有子元素继承字体设置 */
  * {
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    font-weight: inherit !important;
    -webkit-font-smoothing: inherit !important;
    -moz-osx-font-smoothing: inherit !important;
  }
}

/* 确保对话内容使用正确的字体样式 */
.theme-adaptive .ai-answer,
.theme-adaptive .user-question {
  font-family: var(--font-family) !important;
  font-size: var(--font-size-base) !important;
  line-height: var(--line-height-base) !important;
  font-weight: var(--font-weight-normal) !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* 确保输入框使用正确的字体样式 */
.theme-adaptive .expandable-textarea,
.theme-adaptive .textarea-default {
  font-family: var(--font-family) !important;
  font-size: var(--font-size-base) !important;
  line-height: var(--line-height-base) !important;
  font-weight: var(--font-weight-normal) !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* 重置所有可能影响字体的元素 */
.theme-adaptive p,
.theme-adaptive span,
.theme-adaptive div,
.theme-adaptive textarea {
  font-family: var(--font-family) !important;
  font-size: var(--font-size-base) !important;
  line-height: var(--line-height-base) !important;
  font-weight: var(--font-weight-normal) !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* 暗色模式样式 */
.theme-adaptive.dark-mode {
  /* 基础颜色 - iOS暗色模式 */
  --bg-primary: rgba(28, 28, 30, 0.95);
  --bg-secondary: rgba(44, 44, 46, 0.9);
  --text-primary: #ffffff;
  --text-secondary: #98989d;

  /* 交互元素 */
  --accent-color: #0a84ff;
  --accent-hover: #409cff;
  --border-color: rgba(255, 255, 255, 0.15);
  --divider-color: rgba(255, 255, 255, 0.08);

  /* 增强确定感的交互状态颜色 - 暗色模式 */
  --focus-state: rgba(10, 132, 255, 0.3);
  --active-state: rgba(10, 132, 255, 0.4);
  --hover-state: rgba(10, 132, 255, 0.2);
  --success-color: #30d158;
  --success-color-alpha: rgba(48, 209, 88, 0.15);
  --error-color: #ff453a;
  --error-color-alpha: rgba(255, 69, 58, 0.15);
  --warning-color: #ff9f0a;
  --warning-color-alpha: rgba(255, 159, 10, 0.15);

  /* 组件特定颜色 */
  --header-bg: rgba(28, 28, 30, 0.95);
  --input-bg: rgba(58, 58, 60, 0.8);
  --ai-answer-bg: rgba(58, 58, 60, 0.7);
  --user-question-bg: #0a84ff;
  --code-block-bg: rgba(44, 44, 46, 0.8);
  --code-block-border: rgba(255, 255, 255, 0.1);

  /* 代码高亮颜色 - 暗色模式 */
  --code-comment: #7F8C98;
  --code-keyword: #FF7AB2;
  --code-string: #FF8170;
  --code-number: #D9C97C;
  --code-type: #78C2B3;
  --code-function: #6BDFFF;
  --code-variable: #5482FF;
  --code-operator: #FF7AB2;
  --code-class: #78C2B3;
  --code-builtin: #78C2B3;

  /* 数学公式颜色 */
  --math-color: var(--text-primary);
  --math-bg: transparent;
  --math-operator: #FF7AB2;
  --math-number: #D9C97C;
  --math-function: #6BDFFF;
  --math-symbol: #FF7AB2;

  /* 滚动条 */
  --scrollbar-bg: rgba(255, 255, 255, 0.04);
  --scrollbar-thumb: rgba(255, 255, 255, 0.16);

  /* 阴影效果 */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);

  /* 思维链样式 */
  --reasoning-border: rgba(255, 255, 255, 0.15);
  --reasoning-text: #98989d;

  /* 应用基础样式 */
  background-color: var(--bg-primary);
  color: var(--text-primary);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 输入框和发送按钮样式 */
.textarea-default {
  width: calc(100% - 40px);
  height: 44px;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 44px 12px 16px;
  margin: 0;
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 15px !important;
  line-height: 1.4 !important;
  background-color: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  resize: none;
  overflow-y: auto;
  transition: all 0.2s ease;
  word-wrap: break-word;
  word-break: normal;
  hyphens: none;
  -webkit-hyphens: none;
  -ms-hyphens: none;
}

.theme-adaptive .send-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
  z-index: 2;
  will-change: transform, opacity, color;
}

.theme-adaptive .send-icon:hover {
  opacity: 1;
  color: var(--accent-color);
  transform: translateY(-50%) scale(1.1);
  filter: drop-shadow(0 0 2px var(--accent-color-alpha));
}

.theme-adaptive .send-icon:active {
  transform: translateY(-50%) scale(0.9);
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 发送按钮可用状态提示 */
.theme-adaptive .expandable-textarea.has-content + .send-icon {
  opacity: 0.8;
  color: var(--accent-color);
}

/* 发送按钮禁用状态 */
.theme-adaptive .expandable-textarea[disabled] + .send-icon {
  opacity: 0;
  pointer-events: none;
}

/* 输入框容器样式 */
.input-container-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px 16px;
  background: inherit;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 2;
  box-sizing: border-box;
}

.input-container {
  position: relative;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 44px;
  height: auto;
}

/* 输入框样式优化 */
.theme-adaptive .expandable-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 44px 12px 16px;
  margin: 0;
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 15px !important;
  line-height: 1.4 !important;
  background-color: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  resize: none;
  overflow-y: auto;
  transition: height 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  word-wrap: break-word;
  word-break: normal;
  hyphens: none;
  -webkit-hyphens: none;
  -ms-hyphens: none;
  /* 隐藏默认滚动条 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* 隐藏 Webkit 默认滚动条 */
.theme-adaptive .expandable-textarea::-webkit-scrollbar {
  display: none;
}

/* 自定义滚动条样式 */
.theme-adaptive .expandable-textarea.has-content::-webkit-scrollbar {
  display: block;
  width: 8px;
  background-color: transparent;
}

.theme-adaptive .expandable-textarea.has-content::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 4px;
}

.theme-adaptive .expandable-textarea.has-content::-webkit-scrollbar-track {
  background-color: var(--scrollbar-bg);
  border-radius: 4px;
}

/* Firefox 滚动条样式 */
.theme-adaptive .expandable-textarea.has-content {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
}

/* 消息气泡基础样式 */
.user-question,
.ai-answer {
  position: relative !important;
  padding-right: 15px !important;
  margin: 5px 0;
  margin-bottom: 30px;
  display: block !important;
  clear: both !important;
  max-width: calc(100% - 40px);
  isolation: isolate; /* 创建新的层叠上下文 */
}

.ai-answer p,
.user-question p {
  margin-block-start: 0;
  margin-block-end: 0;
}

/* 用户问题样式 */
.theme-adaptive .user-question {
  background-color: var(--user-question-bg);
  color: white;
  padding: 10px 12px;
  margin: 12px 12px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
  max-width: 85%;
  margin-left: auto;
  border-bottom-right-radius: 4px;
  display: inline-block;
  float: right;
  word-wrap: break-word;
  word-break: break-word;
}

/* AI 回答样式 */
.theme-adaptive .ai-answer {
  background-color: var(--ai-answer-bg);
  color: var(--text-primary);
  padding: 0px 12px;
  margin: 12px 12px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
  max-width: 85%;
  margin-right: auto;
  border-bottom-left-radius: 4px;
  display: inline-block;
  float: left;
  word-wrap: break-word;
  word-break: break-word;
}

/* 调整消息内容的间距 */
.user-question p, .ai-answer p {
  margin: 0;
  padding: 0;
}

/* 调整连续消息的间距 */
.user-question + .user-question,
.ai-answer + .ai-answer {
  margin-top: 2px;
}

/* 不同类型消息之间的间距 */
.user-question + .ai-answer,
.ai-answer + .user-question {
  margin-top: 10px;
}

/* 图标包装器样式 */
.icon-wrapper {
  position: relative !important;
  z-index: 1 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 6px;
  transition: all 0.2s ease;
  opacity: 0.7;
  cursor: pointer;
}

.icon-wrapper:hover {
  opacity: 1;
  transform: scale(1.1);
  background-color: var(--bg-secondary);
}

.user-question .icon-wrapper:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.theme-adaptive.dark-mode .icon-wrapper:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.icon-wrapper:active {
  transform: scale(0.92);
  opacity: 0.6;
}

/* 图标容器基础样式 */
.icon-container {
  position: absolute !important;
  bottom: -25px !important;
  right: -5px !important;
  display: none;
  gap: 2px;
  align-items: center;
  z-index: 10 !important;
  padding: 4px 6px;
  border-radius: 8px;
  background-color: var(--bg-secondary);
  border: 0.5px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateZ(0);
}

/* 图标基础样式 */
.icon-container img {
  width: 18px;
  height: 18px;
  transition: all 0.2s ease;
  cursor: pointer;
  opacity: 0.8;
}

/* 日间模式图标样式 */
.theme-adaptive.light-mode .icon-container img {
  filter: brightness(0.3);
}

/* 夜间模式图标样式 */
.theme-adaptive.dark-mode .icon-container img {
  filter: invert(1) brightness(0.9);
}

/* 用户消息中的图标样式 */
.user-question .icon-container img {
  filter: brightness(10);
  opacity: 0.9;
}

/* 工具提示样式 */
.tooltip .tooltiptext {
  font-size: 9px;
  padding: 3px 6px;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  border: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  visibility: hidden;
  text-align: center;
  position: absolute;
  z-index: 1;
  width: max-content;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.1px;
}

.theme-adaptive.dark-mode .tooltip .tooltiptext {
  background-color: rgba(255, 255, 255, 0.9);
  color: rgba(0, 0, 0, 0.85);
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* 代码块基础样式 */
.theme-adaptive pre.hljs {
  background-color: var(--code-block-bg);
  border: 1px solid var(--code-block-border);
  border-radius: 8px;
  margin: 1em 0;
  position: relative;
  overflow: visible;
  padding: 16px;
  font-family: "SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  word-break: break-all !important;
  color: #24292f;  /* 添加默认文本颜色 */
}

/* 暗色模式下的代码块基础样式 */
.theme-adaptive.dark-mode pre.hljs {
  background-color: #161b22;  /* GitHub 暗色主题背景色 */
  color: #e6edf3;  /* 暗色模式下的默认文本颜色 */
}

/* 代码自动换行样式 */
.code-wrap,
.code-wrap code {
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  word-break: break-all !important;
  tab-size: 2 !important;
  -moz-tab-size: 2 !important;
  max-width: 100% !important;
  overflow-x: visible !important;
}

/* 移除所有与横向滚动相关的样式 */
.code-block-wrapper,
.code-block-wrapper pre,
.code-block-wrapper code {
  overflow-x: visible !important;
  overflow: visible !important;
}

/* 调整代码块容器样式 */
.code-block-wrapper {
  position: relative !important;
  overflow: visible !important; /* 允许按钮溢出显示 */
  margin: 1em 0;
  border-radius: 8px;
  isolation: isolate; /* 创建新的层叠上下文 */
}

.code-block-wrapper pre {
  margin: 0;
  padding: 16px;
  font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  border-radius: 12px;
  color: inherit;  /* 继承父元素的文本颜色 */
}

.code-block-wrapper code {
  font-family: "SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", monospace;
  font-size: 14px;
  line-height: 1.5;
  tab-size: 4;
  color: inherit;  /* 继承父元素的文本颜色 */
}

/* 明亮模式代码高亮 */
.theme-adaptive .hljs {
  color: #24292f;  /* GitHub 风格的基础文本颜色 */
  background: transparent;
}

.theme-adaptive .hljs-comment,
.theme-adaptive .hljs-quote {
  color: #6e7781;  /* 更深的注释颜色 */
  font-style: italic;
}

.theme-adaptive .hljs-keyword,
.theme-adaptive .hljs-selector-tag,
.theme-adaptive .hljs-subst {
  color: #cf222e;  /* 关键字使用红色 */
  font-weight: 600;
}

.theme-adaptive .hljs-number,
.theme-adaptive .hljs-literal,
.theme-adaptive .hljs-variable,
.theme-adaptive .hljs-template-variable,
.theme-adaptive .hljs-tag .hljs-attr {
  color: #0550ae;  /* 数字和变量使用蓝色 */
}

.theme-adaptive .hljs-string,
.theme-adaptive .hljs-doctag {
  color: #0a3069;  /* 字符串使用深蓝色 */
}

.theme-adaptive .hljs-title,
.theme-adaptive .hljs-section,
.theme-adaptive .hljs-selector-id {
  color: #8250df;  /* 标题和选择器使用紫色 */
  font-weight: 600;
}

.theme-adaptive .hljs-type,
.theme-adaptive .hljs-class .hljs-title {
  color: #953800;  /* 类型使用棕色 */
  font-weight: 600;
}

.theme-adaptive .hljs-regexp,
.theme-adaptive .hljs-link {
  color: #116329;  /* 正则表达式使用绿色 */
}

.theme-adaptive .hljs-symbol,
.theme-adaptive .hljs-bullet {
  color: #0550ae;  /* 符号使用蓝色 */
}

.theme-adaptive .hljs-built_in,
.theme-adaptive .hljs-builtin-name {
  color: #8250df;  /* 内置函数使用紫色 */
}

.theme-adaptive .hljs-meta {
  color: #6e7781;  /* 元信息使用灰色 */
}

.theme-adaptive .hljs-deletion {
  color: #cf222e;  /* 删除的内容使用红色 */
}

.theme-adaptive .hljs-addition {
  color: #116329;  /* 添加的内容使用绿色 */
}

/* 暗色模式代码高亮 */
.theme-adaptive.dark-mode .hljs {
  color: var(--text-primary);
}

.theme-adaptive.dark-mode .hljs-comment,
.theme-adaptive.dark-mode .hljs-quote {
  color: #7ec699;
  font-style: italic;
}

.theme-adaptive.dark-mode .hljs-keyword,
.theme-adaptive.dark-mode .hljs-selector-tag,
.theme-adaptive.dark-mode .hljs-subst {
  color: #4aa8ff;
  font-weight: bold;
}

.theme-adaptive.dark-mode .hljs-number,
.theme-adaptive.dark-mode .hljs-literal,
.theme-adaptive .hljs-variable,
.theme-adaptive .hljs-template-variable,
.theme-adaptive .hljs-built_in,
.theme-adaptive .hljs-type {
  color: #bd93f9;
}

.theme-adaptive.dark-mode .hljs-string,
.theme-adaptive.dark-mode .hljs-doctag,
.theme-adaptive.dark-mode .hljs-addition,
.theme-adaptive.dark-mode .hljs-title,
.theme-adaptive.dark-mode .hljs-section,
.theme-adaptive.dark-mode .hljs-selector-id,
.theme-adaptive.dark-mode .hljs-selector-class,
.theme-adaptive.dark-mode .hljs-regexp,
.theme-adaptive.dark-mode .hljs-attribute {
  color: #ff7b72;
}

.theme-adaptive.dark-mode .hljs-symbol,
.theme-adaptive.dark-mode .hljs-bullet,
.theme-adaptive.dark-mode .hljs-link {
  color: #bd93f9;
}

.theme-adaptive.dark-mode .hljs-deletion,
.theme-adaptive.dark-mode .hljs-meta {
  color: #8b949e;
}

.theme-adaptive.dark-mode .hljs-function {
  color: #4aa8ff;
}

/* 复制按钮样式优化 */
.theme-adaptive .code-block-wrapper .copy-button {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  z-index: 20 !important; /* 确保在代码块内容之上 */
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translateY(2px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.theme-adaptive .code-block-wrapper:hover .copy-button {
  opacity: 1;
  transform: translateY(0);
}

.theme-adaptive .code-block-wrapper .copy-button:hover {
  color: var(--text-primary);
  transform: translateY(0) scale(1.02);
  box-shadow: var(--shadow-sm);
}

.theme-adaptive .code-block-wrapper .copy-button:active {
  transform: translateY(1px) scale(0.98);
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-adaptive .code-block-wrapper .copy-button img {
  width: 14px;
  height: 14px;
  opacity: 0.6;
  transition: all 0.2s ease;
}

/* 暗色模式下复制按钮的图标颜色调整 */
.theme-adaptive.dark-mode .code-block-wrapper .copy-button img {
  filter: invert(1) brightness(0.9);
  opacity: 0.8;
}

.theme-adaptive .code-block-wrapper .copy-button:hover img {
  opacity: 0.8;
}

/* 复制成功状态 */
@keyframes copiedAnimation {
  0% {
    transform: translateY(0) scale(1);
  }
  30% {
    transform: translateY(-2px) scale(1.05);
  }
  60% {
    transform: translateY(1px) scale(0.98);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.theme-adaptive .code-block-wrapper .copy-button.copied {
  background-color: var(--bg-secondary);
  color: var(--accent-color);
  border-color: var(--accent-color);
  animation: copiedAnimation 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 复制成功图标样式 */
.theme-adaptive .code-block-wrapper .copy-button .copy-success {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 暗色模式下复制成功图标样式 */
.theme-adaptive.dark-mode .code-block-wrapper .copy-button .copy-success {
  color: #fff;
}

/* 复制成功后的图标样式 */
.theme-adaptive .code-block-wrapper .copy-button .copied-icon {
  opacity: 1 !important;
  filter: brightness(1) sepia(1) saturate(5) hue-rotate(180deg) !important;
}

/* 暗色模式下复制成功图标样式 */
.theme-adaptive.dark-mode .code-block-wrapper .copy-button .copied-icon {
  filter: invert(1) brightness(0.9) sepia(1) saturate(5) hue-rotate(180deg) !important;
  opacity: 1 !important;
}

.theme-adaptive .code-block-wrapper .copy-button.copied img {
  opacity: 1;
  filter: brightness(1) sepia(1) saturate(5) hue-rotate(180deg);
}

/* 组件样式 */
.theme-adaptive #ai-popup {
  position: fixed;
  width: 580px;
  height: 380px;
  padding-top: 16px;
  background-color: var(--bg-primary);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  z-index: 2147483647;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  contain: layout style paint;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  animation: popup-appear-spring 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: top center;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

@keyframes popup-appear-spring {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  40% {
    opacity: 1;
    transform: translateY(-5px) scale(1.01);
  }
  70% {
    transform: translateY(2px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.theme-adaptive #ai-popup.dragging {
  opacity: 0.98;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.1) !important;
  transition: box-shadow 0.2s ease, transform 0.05s ease !important;
  animation: dragging-pulse 2s ease-in-out infinite;
  cursor: grabbing;
}

@keyframes dragging-pulse {
  0% { box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.1); }
  50% { box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2), 0 8px 20px rgba(0, 0, 0, 0.15); }
  100% { box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.1); }
}

.theme-adaptive .drag-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background-color: var(--header-bg);
  color: var(--text-primary);
  border-bottom: 1px solid var(--divider-color);
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000;
  -webkit-perspective: 1000;
  contain: paint layout;
  z-index: 2;
  cursor: grab !important;
  background: linear-gradient(to bottom, var(--header-bg) 90%, transparent) !important;
  transition: background-color 0.2s ease;
}

.theme-adaptive .drag-handle:hover {
  background-color: var(--bg-hover, rgba(0, 0, 0, 0.02)) !important;
}

.theme-adaptive .drag-handle:active {
  cursor: grabbing !important;
  background-color: var(--bg-secondary) !important;
}

/* 右下角 resize 手柄样式 */
.theme-adaptive #ai-popup .resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  cursor: se-resize;
  z-index: 11;
}

/* 调整滚动条位置，避免与 resize 手柄冲突 */
.ps__rail-y {
  width: 0 !important;
  right: 0 !important;
  left: auto !important;
  margin-top: 20px !important;
  height: calc(100% - 100px) !important;
  background-color: transparent !important;
  opacity: 0 !important;
  transition: opacity 0.2s ease !important;
  z-index: 1;
}

/* 调整内容区域的内边距，为右侧滚动条留出空间 */
#ai-response {
  padding-top: 40px;
  padding-right: 20px !important;
  padding-left: 10px !important;
  box-sizing: border-box;
}

/* 确保内容容器不会溢出 */
.theme-adaptive #ai-response-container {
  height: calc(100% - 65px) !important;
  margin-bottom: 60px;
  background-color: var(--bg-primary);
  padding: 0 10px 40px 10px;
  scrollbar-width: thin;
  -ms-overflow-style: none;
  position: relative;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000;
  -webkit-perspective: 1000;
  overflow: hidden auto;
  contain: paint layout;
  &::-webkit-scrollbar {
    width: 8px;
    background-color: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 4px;
  }
  &::-webkit-scrollbar-track {
    background-color: transparent;
  }
}

.theme-adaptive #ai-response-container::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

/* 优化暗色模式下的样式 */
.theme-adaptive.dark-mode .ai-answer {
  background-color: var(--ai-answer-bg);
  box-shadow: var(--shadow-sm);
}

/* 数学公式样式 */
.theme-adaptive .math-inline,
.theme-adaptive .math-block {
  background: transparent !important;
  color: inherit !important;
}

.theme-adaptive .math-block {
  display: block;
  margin: 1em 0;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
}

.theme-adaptive .math-inline {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: 0 0.2em;
}

/* MathJax 特定样式 */
.theme-adaptive mjx-container {
  background: transparent !important;
  color: inherit !important;
}

.theme-adaptive mjx-container[display="true"] {
  margin: 1em 0 !important;
  padding: 0.5em 0 !important;
  text-align: center !important;
}

.theme-adaptive mjx-container:not([display="true"]) {
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 0.2em !important;
}

/* 确保公式在暗色模式下正确显示 */
.theme-adaptive.dark-mode mjx-container {
  filter: invert(1) hue-rotate(180deg);
}

/* 数学公式容器样式 */
.theme-adaptive .ai-answer {
  display: block;
  text-align: left;
}

/* 块级公式容器样式 */
.theme-adaptive .ai-answer .math-container {
  display: block;
  width: 100%;
  text-align: center;
  margin: 1em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* 数学公式样式 */
.theme-adaptive .ai-answer .MathJax,
.theme-adaptive .ai-answer .MathJax_SVG,
.theme-adaptive .ai-answer .MathJax_Display,
.theme-adaptive .ai-answer mjx-container {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  max-width: 100% !important;
  padding: 1px 0;
  margin: 0 auto !important;
  text-align: center !important;
}

/* 行内公式样式 */
.theme-adaptive .ai-answer mjx-container:not([display="true"]) {
  display: inline-flex !important;
  align-items: center !important;
  vertical-align: middle !important;
  margin: 0 0.2em !important;
  font-size: 1em !important;
}

/* 块级公式样式 */
.theme-adaptive .ai-answer mjx-container[display="true"] {
  display: block !important;
  width: fit-content !important;
  margin: 1em auto !important;
  text-align: center !important;
  padding: 0.5em 0 !important;
  font-size: 1.1em !important;
}

/* 确保公式容器不会影响行高 */
.theme-adaptive .ai-answer p {
  line-height: 1.6 !important;
  margin: 0.8em 0 !important;
  overflow-x: visible !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
}

/* 优化公式渲染 */
.theme-adaptive .ai-answer .MathJax {
  outline: none !important;
}

/* 确保块级公式前后有足够空间 */
.theme-adaptive .ai-answer p + mjx-container[display="true"] {
  margin-top: 1em !important;
}

.theme-adaptive .ai-answer mjx-container[display="true"] + p {
  margin-top: 1em !important;
}

/* 调整行内公式的基线对齐 */
.theme-adaptive .ai-answer mjx-container:not([display="true"]) mjx-math {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  vertical-align: baseline !important;
}

/* 自定义滚动条样式 */
.ps__rail-x {
  z-index: 10;
  bottom: 0 !important;
  height: 6px !important;
  background-color: transparent !important;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease !important;
}

.ps__thumb-x {
  height: 6px !important;
  bottom: 0 !important;
  background-color: var(--scrollbar-thumb) !important;
  border-radius: 3px !important;
  transition: background-color 0.2s ease !important;
}

/* 容器悬浮时显示滚动条 */
.code-block-wrapper:hover .ps__rail-x {
  opacity: 1;
  height: 6px !important;
  background-color: var(--scrollbar-bg) !important;
}

/* 滚动条悬浮和激活状态 */
.ps__rail-x:hover,
.ps__rail-x:focus,
.ps__rail-x.ps--clicking {
  height: 12px !important;
  background-color: var(--scrollbar-bg) !important;
}

.ps__rail-x:hover > .ps__thumb-x,
.ps__rail-x:focus > .ps__thumb-x,
.ps__rail-x.ps--clicking > .ps__thumb-x {
  height: 12px !important;
  bottom: 0 !important;
}

/* 调整代码块容器样式 */
.code-block-wrapper {
  position: relative;
  margin: 12px 0;
  border-radius: 12px;
  background-color: var(--code-block-bg);
  border: 1px solid var(--code-block-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 16px;
  font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  border-radius: 12px;
  color: inherit;  /* 继承父元素的文本颜色 */
}

.code-block-wrapper code {
  font-family: "SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", monospace;
  font-size: 14px;
  line-height: 1.5;
  tab-size: 4;
  color: inherit;  /* 继承父元素的文本颜色 */
}

/* 思维链样式 */
.theme-adaptive .reasoning-content {
  position: relative;
  padding: 0px 6px;
  margin: 8px 0;
  border-left: 3px solid var(--reasoning-border);
  color: var(--reasoning-text);
  font-size: 14px;
  line-height: 1.5;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  transition: all 0.3s ease-out;
}

/* 思维链收缩状态 */
.theme-adaptive .reasoning-content.collapsed {
  max-height: 32px;
  cursor: pointer;
  opacity: 0.8;
}

/* 思维链展开状态 */
.theme-adaptive .reasoning-content.expanded {
  max-height: none;
  opacity: 1;
}

/* 思维链内容容器 */
.theme-adaptive .reasoning-content-inner {
  padding: 4px 0;
  transition: opacity 0.3s ease-out;
}

/* 收缩状态下的文本省略 */
.theme-adaptive .reasoning-content.collapsed .reasoning-content-inner {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.7;
}

/* 展开状态下的内容 */
.theme-adaptive .reasoning-content.expanded .reasoning-content-inner {
  white-space: normal;
  overflow: visible;
  opacity: 1;
}

/* 思维链头部容器 */
.theme-adaptive .reasoning-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--reasoning-text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

/* 思维链切换按钮 */
.theme-adaptive .reasoning-toggle {
  width: 16px;
  height: 16px;
  cursor: pointer;
  opacity: 0.8;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-adaptive .reasoning-toggle:hover {
  opacity: 1;
}

/* 切换按钮图标 */
.theme-adaptive .reasoning-toggle::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--reasoning-text);
  border-bottom: 2px solid var(--reasoning-text);
  transform: rotate(45deg);
  transition: transform 0.3s ease;
}

/* 收缩状态的图标 */
.theme-adaptive .reasoning-content.collapsed .reasoning-toggle::before {
  transform: rotate(-45deg);
}

/* 展开状态的图标 */
.theme-adaptive .reasoning-content.expanded .reasoning-toggle::before {
  transform: rotate(45deg);
}

/* 确保最后一个消息的按钮正确显示 */
.theme-adaptive #ai-response-container {
  padding-bottom: 60px !important; /* 为最后一个消息的按钮预留空间 */
}

/* 修复最后一个消息的按钮位置 */
.theme-adaptive #ai-response-container > :last-child {
  margin-bottom: 40px !important; /* 确保最后一个消息有足够的底部间距 */
}

/* 确保按钮容器不会被截断 */
.theme-adaptive .ai-answer,
.theme-adaptive .user-question {
  overflow: visible !important;
  position: relative !important;
}

/* 优化按钮的显示层级 */
.theme-adaptive .icon-wrapper {
  position: relative !important;
  z-index: 1 !important;
}

/* Quick Action Buttons */
.quick-action-buttons {
  position: absolute;
  z-index: 2147483647;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  animation: fadeIn 0.2s ease;
}

.quick-action-buttons-container {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.quick-action-button {
  width: 28px !important;
  height: 28px !important;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  opacity: 0.7;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-action-button:hover {
  background-color: var(--bg-secondary);
  opacity: 1;
  transform: scale(1.1);
}

.quick-action-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: var(--text-primary-filter, none);
}

.language-select {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 120px;
  max-height: 200px;
  overflow-y: auto;
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin-top: 8px;
  display: none;
  z-index: 2147483647;
}

.language-option {
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.language-option:hover {
  background-color: var(--bg-secondary);
}

/* 自定义输入框样式 */
.custom-input-wrapper {
  display: flex;
  align-items: flex-start;
  width: 95%;
  margin: 2px 0 4px 0;
}

.custom-prompt-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.4;
  width: 100%;
  min-width: 180px;
  min-height: 36px;
  max-height: 80px;
  outline: none;
  transition: all 0.2s ease;
  overflow-y: auto;
  resize: vertical;
}

.custom-prompt-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

.custom-prompt-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background-color: transparent;
  margin-left: 4px;
  margin-top: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-prompt-send:hover {
  background-color: var(--bg-secondary);
}

.custom-prompt-send svg {
  color: var(--text-primary);
  opacity: 0.7;
  transition: all 0.2s ease;
}

.custom-prompt-send:hover svg {
  opacity: 1;
  transform: scale(1.1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 暗色模式图标适配 */
.theme-adaptive.dark-mode .quick-action-button img {
  filter: invert(1) brightness(0.9);
}

/* Loading icon 样式 */
.loading-icon-wrapper {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.loading-icon-wrapper:hover {
  background-color: var(--bg-secondary);
  transform: scale(1.1);
}

.loading-icon-wrapper:active {
  background-color: var(--active-state) !important;
  transform: scale(0.95) !important;
}

.loading-icon {
  width: 20px;
  height: 20px;
  animation: rotate 1s linear infinite;
  color: var(--text-secondary);
}

/* 暗色模式下loading图标样式 */
.theme-adaptive.dark-mode .loading-icon {
  color: #fff;
  opacity: 0.9;
}

.loading-icon.active {
  animation: rotate 1s linear infinite;
}

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

/* 输入框和按钮交互反馈样式 */
.theme-adaptive .expandable-textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-color-alpha, rgba(0, 122, 255, 0.2));
  outline: none;
}

/* 输入框颜色变量 */
.theme-adaptive {
  --input-bg-active: rgba(247, 247, 252, 0.9);
  --input-bg-active-subtle: rgba(247, 247, 252, 0.5); /* 添加更轻微的背景色变化 */
  --input-bg-active-subtle-minimal: rgba(247, 247, 252, 0.3); /* 更加微妙的背景色变化 */
  --input-bg-sent: rgba(232, 245, 255, 0.95);
  --accent-color-alpha: rgba(0, 122, 255, 0.2);
}

.theme-adaptive.dark-mode {
  --input-bg-active: rgba(68, 68, 70, 0.8);
  --input-bg-active-subtle: rgba(68, 68, 70, 0.4); /* 添加更轻微的背景色变化 */
  --input-bg-active-subtle-minimal: rgba(68, 68, 70, 0.25); /* 更加微妙的背景色变化 */
  --input-bg-sent: rgba(20, 80, 120, 0.8);
  --accent-color-alpha: rgba(10, 132, 255, 0.25);
}

/* 优化消息气泡出现动画，更平滑 */
.user-question, .ai-answer {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* 按键反馈样式优化 */
.theme-adaptive .expandable-textarea:focus-within {
  background-color: var(--input-bg);
  transition: background-color 0.25s ease;
}

/* 增强popup窗口的确定感和降低心智负担的样式 */

/* 1. 增强窗口出现的动画效果，提供更好的视觉反馈 */
.theme-adaptive #ai-popup {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.15) !important;
  animation: popup-appear-spring 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: top center;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

@keyframes popup-appear-spring {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  40% {
    opacity: 1;
    transform: translateY(-5px) scale(1.01);
  }
  70% {
    transform: translateY(2px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 2. 增强拖拽区域的视觉提示，让用户明确知道可拖拽区域 */
.theme-adaptive .drag-handle {
  cursor: grab !important;
  background: linear-gradient(to bottom, var(--header-bg) 90%, transparent) !important;
  border-bottom: 1px solid var(--divider-color) !important;
  transition: background-color 0.2s ease;
}

.theme-adaptive .drag-handle:hover {
  background-color: var(--bg-hover, rgba(0, 0, 0, 0.02)) !important;
}

.theme-adaptive .drag-handle:active {
  cursor: grabbing !important;
  background-color: var(--bg-secondary) !important;
}

/* 3. 为窗口增加可调整大小的明确视觉指示 */
.theme-adaptive #ai-popup .resize-handle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13 13L8 8M13 3L3 13' stroke='rgba(128, 128, 128, 0.5)' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.theme-adaptive #ai-popup:hover .resize-handle {
  opacity: 0.5;
}

.theme-adaptive #ai-popup .resize-handle:hover {
  opacity: 1;
}

/* 4. 改进输入区域的焦点状态，提供更明确的视觉反馈 */
.theme-adaptive .expandable-textarea:focus {
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 3px var(--focus-state) !important;
  outline: none !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
}

/* 5. 优化发送按钮的状态反馈 */
.theme-adaptive .send-icon {
  transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), opacity 0.15s ease !important;
}

.theme-adaptive .send-icon:hover {
  opacity: 1 !important;
  transform: translateY(-50%) scale(1.05) !important;
}

.theme-adaptive .send-icon:active {
  transform: translateY(-50%) scale(0.95) !important;
}

/* 6. 用户问题和AI回答的卡片设计改进，更符合格式塔原理 */
.theme-adaptive .user-question {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  border-radius: 12px !important;
  margin-bottom: 16px !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.theme-adaptive .ai-answer {
  border-radius: 12px !important;
  background-color: var(--ai-answer-bg) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  margin-bottom: 16px !important;
  transition: all 0.3s ease !important;
  opacity: 1;
  transform: translateY(0);
}

/* 7. 为正在生成的AI回答添加动画效果，提升确定感 */
.theme-adaptive .ai-answer.generating {
  position: relative;
}

.theme-adaptive .ai-answer.generating:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent-color);
  animation: loading-progress 2s infinite ease-in-out;
  border-radius: 0 0 12px 12px;
}

@keyframes loading-progress {
  0% {
    width: 0;
    left: 0;
  }
  50% {
    width: 100%;
    left: 0;
  }
  100% {
    width: 0;
    left: 100%;
  }
}

/* 8. 增强状态反馈 - 错误状态 */
.theme-adaptive .ai-answer.error {
  border-left: 3px solid var(--error-color) !important;
}

/* 9. 增强滚动体验和滚动条视觉 */
.theme-adaptive #ai-response-container::-webkit-scrollbar {
  width: 8px !important;
}

.theme-adaptive #ai-response-container::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb) !important;
  border-radius: 4px !important;
  transition: background-color 0.2s ease !important;
}

.theme-adaptive #ai-response-container::-webkit-scrollbar-thumb:hover {
  background-color: rgba(128, 128, 128, 0.5) !important;
}

.theme-adaptive #ai-response-container::-webkit-scrollbar-track {
  background-color: var(--scrollbar-bg) !important;
  border-radius: 4px !important;
}

/* 10. 改进加载状态图标样式，提供更明确的视觉反馈 */
.loading-icon-wrapper {
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1) !important;
  border-radius: 50% !important;
}

.loading-icon-wrapper:hover {
  background-color: var(--bg-secondary);
  transform: scale(1.1);
}

.loading-icon-wrapper:active {
  background-color: var(--active-state) !important;
  transform: scale(0.95) !important;
}

/* 11. 添加窗口操作的操作提示，增强确定感 */
.tool-tip {
  position: absolute;
  padding: 6px 10px;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  font-size: 12px !important;
  color: var(--text-secondary);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.tooltip-trigger:hover + .tool-tip {
  opacity: 1;
  transform: translateY(0);
}

/* 12. 拖拽放置时的动画增强 */
.theme-adaptive #ai-popup.drag-placed {
  animation: drag-placed 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes drag-placed {
  0% { transform: scale(1.03); }
  50% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

/* 距离指示器渐入动画 */
@keyframes fade-in {
  0% { opacity: 0; transform: translateY(5px) translateX(-50%); }
  100% { opacity: 0.9; transform: translateY(0) translateX(-50%); }
}

/* 准备就绪的轻微弹跳效果 */
.popup-ready {
  animation: popup-ready 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popup-ready {
  0% { transform: scale(1); }
  50% { transform: scale(1.01); }
  100% { transform: scale(1); }
}

/* 调整大小反馈优化 */
.resize-complete {
  animation: resize-complete 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resize-complete {
  0% { box-shadow: 0 0 0 3px var(--focus-state); }
  100% { box-shadow: 0 0 0 0px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.08); }
}

/* 修改关闭按钮的样式，完全去除背景 */
.theme-adaptive .close-button {
  background-color: transparent !important;
  border-radius: 6px !important;
  transition: color 0.2s ease, transform 0.15s ease !important;
  transform: none !important; /* 确保始终保持原位 */
  position: absolute !important; /* 确保位置固定 */
  right: 10px !important;
  top: 50% !important;
  transform: translateY(-50%) !important; /* 垂直居中 */
}

.theme-adaptive .close-button:hover {
  color: #0071e3 !important; /* 苹果蓝色 */
}

.theme-adaptive .close-button:active {
  /* 只修改颜色和缩放，不改变位置 */
  color: #0051a8 !important; /* 深蓝色 */
}

/* 完全移除关闭按钮激活样式类 */
.close-button-active {
  animation: none !important;
  transform: translateY(-50%) !important; /* 始终保持垂直居中 */
  background-color: transparent !important;
  color: inherit !important;
}

/* 简化关闭按钮图标样式 */
.close-button .close-icon {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 16px !important;
  height: 16px !important;
  transition: transform 0.15s ease !important;
}

.close-button .close-icon img {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
  transition: transform 0.15s ease !important;
}

/* 点击时图标放大，但按钮本身不移动 */
.theme-adaptive .close-button:active .close-icon {
  transform: scale(1.2) !important;
}

/* 组合内容容器样式 */
.combined-content {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background-color: var(--user-question-bg);
  border-radius: 12px;
  margin-bottom: 16px;
  color: white;
}

.selected-content {
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
}

.selected-content p {
  margin: 0;
  color: white;
  opacity: 0.6;
}

.user-prompt {
  position: relative;
}

.user-prompt p {
  margin: 0;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 600;
  color: white;
}

.theme-adaptive.dark-mode .combined-content {
  background-color: var(--user-question-bg);
}

.theme-adaptive.dark-mode .selected-content {
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* 输入框抖动动画 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.shake {
  animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
  transform: translate3d(0, 0, 0);
}

#ai-popup-container {
  transition: all 0.3s ease;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2147483647;
  pointer-events: none;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
}

/* 添加防止干扰选中状态的样式规则 */
.selection-safe-container {
  pointer-events: auto !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  z-index: 2147483647 !important;
  isolation: isolate !important;
  position: absolute !important;
  margin: 0 !important;
  padding: 0 !important;
  contain: layout style !important; /* 限制布局影响 */
}

/* 确保快捷按钮内部元素不会影响选中状态 */
.selection-safe-container * {
  pointer-events: auto !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
}

/* 允许输入框内的文本选择 */
.selection-safe-container .custom-prompt-input {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
}

