/* ==========================================
   AI 聊天页样式（叠加在 style.css 之上）
   ========================================== */

body {
  overflow: hidden;
}

/* ---------- 会话列表 ---------- */
/* 伸缩容器：无会话时收起，有会话时展开（新建/删除对话自动触发） */
.session-list-wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.session-list-wrap.has {
  max-height: 320px;
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -4px;
  padding: 0 4px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-sub);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.session-item:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.session-item:active {
  transform: scale(0.985);
}

.session-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 会话信息块：标题 + 自动总结 */
.session-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-del {
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.session-item:hover .session-del {
  display: flex;
}

.session-del:hover {
  background: var(--bg-hover-strong);
  color: var(--text-main);
}

/* ---------- 聊天布局（视图容器由 style.css 的 .view 接管） ---------- */
.chat-view.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* 顶栏：与聊天区完全同底色（无深浅色差），靠内容留白自然区分 */
.chat-topbar {
  height: 62px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  background: transparent;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* token 速度显示：仅输出时出现 */
.speed-display {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-right: 2px;
  transition: opacity 0.2s ease;
}

/* 消息区 */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 8px 12px;
}

.msg-col {
  max-width: 760px;
  margin: 0;
}

/* 消息进入动画 */
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg-user,
.msg-ai {
  animation: msg-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* 用户消息：右侧浅灰气泡，工具按钮在气泡左侧 */
.msg-user {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 22px;
}

.msg-user .bubble {
  max-width: 100%;
  background: var(--bg-bubble);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  transition: background-color 0.3s ease;
}

/* 文件消息卡片 */
.msg-user .bubble-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  max-width: 320px;
  white-space: nowrap;
}

.bubble-file .file-ico {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.bubble-file .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.bubble-file .file-size {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-faint);
}

/* 用户消息内容列（引用块 + 气泡） */
.msg-col-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 82%;
  min-width: 0;
}

/* 被引用内容块 */
.quote-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 100%;
  background: var(--bg-code);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-sub);
}

.quote-block-label {
  font-weight: 600;
  color: var(--accent);
  font-size: 11px;
}

.quote-block-text {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* 消息操作按钮（hover 浮现） */
.msg-tools,
.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.msg-user:hover .msg-tools,
.msg-ai:hover .msg-actions {
  opacity: 1;
}

.msg-actions {
  margin-top: 6px;
  padding-left: 2px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tool-btn svg {
  width: 14px;
  height: 14px;
}

.tool-btn:hover {
  background: var(--bg-hover-strong);
  color: var(--text-main);
}

.tool-btn.flashed {
  width: auto;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

/* AI 消息：左侧无气泡纯文本，操作栏在内容下方 */
.msg-ai {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 22px;
}

.ai-body {
  width: 100%;
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
}

/* Markdown 内容样式 */
.ai-body p {
  margin: 0 0 0.6em;
}

.ai-body p:last-child {
  margin-bottom: 0;
}

.ai-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 0.4em 0 0.9em;
  font-size: 13px;
  line-height: 1.6;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 代码块头部：语言标签 + 复制按钮 */
.ai-body .md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(127, 127, 127, 0.07);
}

.ai-body .md-code-lang {
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--text-sub);
}

.ai-body .md-code-copy {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-body .md-code-open {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-body .md-code-open:hover {
  background: var(--inline-code-tint);
  color: var(--text-main);
}

.ai-body .md-code-ops {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.ai-body .md-code-copy:hover {
  background: var(--inline-code-tint);
  color: var(--text-sub);
}

/* 生成中代码块：徽标 + 代码尾部闪烁光标 */
.ai-body .md-code-badge {
  font-size: 10px;
  line-height: 1;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 7px;
}

.ai-body .md-code.live code::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--text-sub);
  border-radius: 1px;
  animation: cursor-blink 0.9s steps(2, start) infinite;
}

.ai-body code {
  background: var(--inline-code-tint);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  transition: background-color 0.3s ease;
}

.ai-body pre code {
  background: none;
  padding: 0;
}

.ai-body .md-code > code {
  display: block;
  padding: 10px 14px;
  overflow-x: auto;
}

/* 公式渲染：块级居中 / 行内随文 */
.ai-body .md-formula {
  text-align: center;
  margin: 0.6em 0 0.9em;
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 15px;
  color: var(--text-main);
}

.ai-body .md-formula-inline {
  font-family: "Cambria Math", "Times New Roman", serif;
  color: var(--text-main);
}

.ai-body .frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  line-height: 1.15;
  margin: 0 2px;
  font-style: normal;
}

.ai-body .frac-n {
  border-bottom: 1px solid currentColor;
  padding: 0 3px;
}

.ai-body .frac-d {
  padding: 0 3px;
}

/* 流式淡入：逐字显现（最后一段） / 整块淡入（代码块等） */
.ai-body .tok {
  opacity: 0;
  animation: tok-in 0.22s ease-out forwards;
}

.ai-body .fade-in {
  animation: stream-in 0.3s ease both;
}

@keyframes tok-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: none; }
}

@keyframes stream-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Markdown 块级元素（标题 / 引用 / 列表 / 任务 / 分割线 / 表格） */
.ai-body h1.md-h,
.ai-body h2.md-h,
.ai-body h3.md-h,
.ai-body h4.md-h {
  font-weight: 700;
  line-height: 1.4;
  margin: 1.1em 0 0.45em;
  color: var(--text-main);
}

.ai-body h1.md-h { font-size: 19px; }
.ai-body h2.md-h { font-size: 17px; }
.ai-body h3.md-h { font-size: 16px; }
.ai-body h4.md-h { font-size: 15px; }

.ai-body blockquote {
  margin: 0.6em 0 0.9em;
  padding: 0.1em 1em;
  border-left: 3px solid var(--border);
  background: var(--bg-code);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-sub);
}

.ai-body ul,
.ai-body ol {
  margin: 0.4em 0 0.9em;
  padding-left: 1.4em;
}

.ai-body li {
  margin: 0.25em 0;
}

.ai-body li.task {
  list-style: none;
  position: relative;
  padding-left: 1.2em;
}

.ai-body li.task::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text-faint);
  border-radius: 3px;
  box-sizing: border-box;
}

.ai-body li.task.done::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--bg-code);
}

.ai-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

.ai-body .md-table {
  overflow-x: auto;
  margin: 0.6em 0 1em;
}

.ai-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.ai-body th,
.ai-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.ai-body th {
  background: var(--bg-code);
  font-weight: 600;
}

.ai-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.ai-body a:hover {
  border-bottom-color: var(--accent);
}

/* 流式输出光标 */
.cursor {
  display: inline-block;
  width: 7px;
  height: 16px;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--text-sub);
  border-radius: 1px;
  animation: cursor-blink 0.9s steps(2, start) infinite;
}

/* 思考过程折叠卡片 */
.ai-reason {
  margin: 0 0 14px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 13px;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.ai-reason summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  cursor: pointer;
  color: var(--text-sub);
  font-weight: 600;
  user-select: none;
  list-style: none;
}

.ai-reason summary::-webkit-details-marker {
  display: none;
}

/* 展开箭头（默认朝右，展开后朝下） */
.ai-reason summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s ease;
}

.ai-reason[open] summary::before {
  transform: rotate(90deg);
}

.ai-reason summary:hover {
  color: var(--text-main);
}

.ai-reason-body {
  padding: 0 0 12px;
  color: var(--text-sub);
  line-height: 1.7;
}

.ai-reason-body p {
  margin: 0 0 0.5em;
}

.ai-reason-body p:last-child {
  margin-bottom: 0;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 错误信息 */
.msg-error {
  color: #d64545;
  font-size: 13px;
  font-style: italic;
}

/* 空状态：视口居中 logo + 文字 */
.welcome {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding-bottom: 60px;
  animation: msg-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.welcome-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--grad-accent);
  border-radius: 14px;
  box-shadow: 0 8px 24px var(--shadow-glow);
}

.welcome-logo svg {
  width: 22px;
  height: 22px;
}

.welcome-text {
  font-size: 14px;
  color: var(--text-faint);
}

/* 空白页示例问题 */
.welcome-suggestions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.suggest-chip {
  border: 1px solid var(--border);
  background: var(--bg-code);
  color: var(--text-sub);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.suggest-chip:hover {
  border-color: var(--ring);
  color: var(--text-main);
  background: var(--bg-hover-tint);
}

.suggest-chip:disabled {
  opacity: 0.55;
  cursor: default;
}

/* AI 补位失败槽：嵌入在问题列表里的可点击重试（v63） */
.sugg-fail {
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 6px 10px;
  border: 1px dashed var(--glass-border);
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sugg-fail:hover {
  color: var(--text-sub);
  border-color: var(--ring);
}

/* ===== 输入区（豆包风：大圆角输入框 + 下方功能按钮行） ===== */
.chat-input-area {
  flex-shrink: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  /* 固定上限 780px；窄窗口下也保留左右边距并水平居中（flex 列布局下 align-self 兜底） */
  align-self: center;
  width: min(780px, calc(100% - 48px));
  margin: 0 auto;
  padding: 4px 16px 18px;
  box-sizing: border-box;
}

/* 输入行：输入框 + 右侧按钮（按钮在输入框外部右侧，同一行） */
.bb-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

/* 豆包式输入框容器 */
.bb-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 14px;
  box-shadow: 0 2px 10px rgba(20, 20, 20, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.bb-input-wrap:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.bb-input-wrap textarea {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
  max-height: 140px;
  padding: 6px 0;
}

.bb-input-wrap textarea::placeholder {
  color: var(--text-faint);
}

/* 推理档位按钮 + 弹出菜单 */
.effort-menu-wrap {
  position: relative;
  display: inline-flex;
}

.effort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.effort-btn svg {
  width: 14px;
  height: 14px;
}

.effort-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 28px rgba(15, 15, 15, 0.14);
  z-index: 60;
  min-width: 110px;
}

.effort-menu[hidden] {
  display: none;
}

/* ＋ 加号：下拉菜单（引用笔记 / 上传本地文件），笔记小卡片复用 note-ref-menu */
.bb-plus-wrap {
  position: relative;
  display: inline-flex;
}

.bb-plus-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 28px rgba(15, 15, 15, 0.14);
  z-index: 60;
  min-width: 150px;
}

.bb-plus-menu[hidden] {
  display: none;
}

.bb-plus-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-family: inherit;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.bb-plus-option:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* 引用笔记小卡片（上升，锚定加号按钮） */
.note-ref-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 28px rgba(15, 15, 15, 0.14);
  z-index: 61;
  min-width: 190px;
  max-height: 300px;
  overflow-y: auto;
}

.note-ref-menu[hidden] {
  display: none;
}

.note-ref-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-ref-item:hover {
  background: var(--bg-hover);
}

.note-ref-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.effort-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-family: inherit;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.effort-option:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.effort-option.active {
  color: var(--accent);
  font-weight: 600;
}

.effort-option.active::after {
  content: "✓";
  font-weight: 700;
}

/* 联网搜索按钮（含文字，激活高亮） */
.web-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.web-toggle:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.web-toggle svg {
  width: 14px;
  height: 14px;
}

.web-toggle.on {
  color: var(--accent);
  background: var(--accent-soft);
}

/* 引用条：内嵌于输入框顶部，无引用时不渲染 → hidden */
.quote-bar[hidden] {
  display: none;
}

.quote-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-sub);
}

.quote-bar-label {
  flex-shrink: 0;
  padding: 1px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 5px;
  font-size: 10px;
}

.quote-bar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-bar-close {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  cursor: pointer;
  border-radius: 4px;
}

.quote-bar-close:hover {
  color: var(--text-main);
  background: var(--bg-hover-tint);
}

/* 豆包式右侧按钮：空=麦克风 / 有字=发送箭头 / 流式=停止 */
.send-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 3px 10px var(--shadow-glow);
  transition: opacity 0.15s ease, box-shadow 0.25s ease, transform 0.15s ease, background-color 0.3s ease;
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn:hover:not(:disabled) {
  box-shadow: 0 4px 14px var(--shadow-glow);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* 语音聆听中：呼吸高亮 */
.send-btn.listening {
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--shadow-glow); }
  50% { box-shadow: 0 0 0 6px var(--accent-soft); }
}

/* ===== 功能按钮行：独立于输入框，位于输入框正下方、左对齐 ===== */
.bb-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 4px 6px;
  width: 100%;
}

.bb-plus {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.2s ease;
}

.bb-plus svg {
  width: 15px;
  height: 15px;
}

.bb-plus:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.bb-plus.rotated svg {
  transform: rotate(45deg);
}

/* 功能按钮（胶囊） */
.bb-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.bb-tool:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

/* 生成中：右侧按钮变为「停止」 */
.send-btn.streaming {
  background: var(--text-sub);
  box-shadow: none;
}

.send-btn.streaming:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}

/* ---------- 设置侧边栏（液态玻璃，v57：居中弹窗 → 右侧抽屉滑入） ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-card {
  width: 384px;
  max-width: calc(100vw - 40px);
  height: 100%;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  box-shadow: 0 24px 60px rgba(15, 15, 15, 0.16);
  overflow: visible;
  /* v64：滑入/滑出改用 margin-right 过渡（非合成属性）。
     headless 虚拟时间下 transform 合成过渡会冻结在起点，真机两者等价 */
  margin-right: -384px;
  transition: margin-right 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 0.3s ease;
}

.modal.open .modal-card {
  margin-right: 0;
}

/* 矮屏：抽屉整体可滚动，保证字段可达 */
@media (max-height: 720px) {
  .modal-card {
    overflow-y: auto;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid var(--glass-border);
}

.modal-body {
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.5px;
}

.field input {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--glass-input);
  transition: border-color 0.15s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.field input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input:hover {
  border-color: var(--ring);
  background: var(--glass-hover);
}

.field textarea {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--glass-input);
  resize: vertical;
  min-height: 64px;
  transition: border-color 0.15s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.field textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea:hover {
  border-color: var(--ring);
  background: var(--glass-hover);
}

/* 自绘温度下拉：玻璃触发按钮 + 浮层菜单（v54） */
.temp-select {
  position: relative;
}

.temp-trigger {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 34px 9px 12px;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  color: var(--text-main);
  background: var(--glass-input);
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.temp-trigger::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-sub);
  border-bottom: 2px solid var(--text-sub);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.temp-trigger:hover {
  background: var(--glass-hover);
}

.temp-trigger:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.temp-trigger.open {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.temp-trigger.open::after {
  transform: translateY(-35%) rotate(-135deg);
}

.temp-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  background: var(--glass-menu);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 44px rgba(15, 15, 15, 0.22);
  padding: 6px;
  overflow: hidden auto;
  max-height: 300px;
  animation: temp-in 0.16s ease;
}

/* v56：下方空间不足时向上弹出 */
.temp-select.drop-up .temp-menu {
  top: auto;
  bottom: calc(100% + 6px);
  animation-name: temp-in-up;
}

@keyframes temp-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@keyframes temp-in-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.temp-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.temp-option:hover {
  background: var(--glass-hover);
}

.temp-option .v {
  min-width: 26px;
  text-align: right;
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.temp-option .t {
  flex: 1;
  text-align: left;
  color: var(--text-sub);
}

.temp-option.active {
  background: var(--accent-soft);
}

.temp-option.active .v {
  color: var(--accent);
}

.temp-option.active .t {
  color: var(--text-main);
}

.temp-option.active::after {
  content: "✓";
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

/* ---------- v57：上下文按钮（圆环进度）+ 使用详情浮层 ---------- */
.ctx-wrap {
  position: relative;
}

.ctx-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 7px;
}

.ctx-ring-svg {
  width: 18px;
  height: 18px;
  transform: rotate(-90deg);
}

.ctx-ring-bg {
  fill: none;
  stroke: var(--glass-border);
  stroke-width: 2.5;
}

.ctx-ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.ctx-pct {
  min-width: 22px;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.ctx-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 268px;
  z-index: 80;
  padding: 14px;
  background: var(--glass-menu);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px rgba(15, 15, 15, 0.22);
  animation: temp-in 0.16s ease;
}

/* v64：窄窗翻转——按钮靠左时向右展开、顶部空间不足时向下展开 */
.ctx-panel.ctx-flip-h {
  left: 0;
  right: auto;
}

.ctx-panel.ctx-flip-v {
  bottom: auto;
  top: calc(100% + 8px);
}

.ctx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ctx-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
}

.ctx-num {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.ctx-rate {
  color: var(--accent);
  font-size: 14px;
}

.ctx-lbl {
  font-size: 10px;
  color: var(--text-faint);
}

.ctx-bar-wrap {
  margin-top: 12px;
}

.ctx-bar {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 999px;
  background: var(--glass-bg);
  overflow: hidden;
}

.ctx-seg {
  height: 100%;
  border-radius: 999px;
}

.ctx-seg.lg-read {
  background: var(--accent);
  opacity: 0.95;
}

.ctx-seg.lg-ink {
  background: var(--accent);
  opacity: 0.65;
}

.ctx-seg.lg-reason {
  background: #f5a623;
}

.ctx-seg.lg-out {
  background: var(--accent);
  opacity: 0.35;
}

.ctx-seg.lg-free {
  background: transparent;
}

.ctx-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 8px;
}

.ctx-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-faint);
}

.lg-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.lg-dot.lg-read { background: var(--accent); }
.lg-dot.lg-ink { background: var(--accent); opacity: 0.65; }
.lg-dot.lg-reason { background: #f5a623; }
.lg-dot.lg-out { background: var(--accent); opacity: 0.35; }
.lg-dot.lg-free { background: var(--glass-border); }

.field textarea::placeholder {
  color: var(--text-faint);
}

.field input::placeholder {
  color: var(--text-faint);
}

.modal-foot {
  padding: 0 22px 22px;
}

/* ---------- v73 设置：全屏窗口（覆盖抽屉样式） ---------- */
.settings-modal {
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: var(--overlay);
}
.settings-modal .modal-card {
  width: min(860px, 100%);
  max-width: none;
  height: min(92vh, 860px);
  margin-right: 0;
  border: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(10, 10, 10, 0.35);
}
.settings-modal .modal-head {
  flex-shrink: 0;
}
.settings-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 26px 26px;
}
.settings-modal .modal-foot {
  flex-shrink: 0;
  padding: 16px 26px 22px;
  display: flex;
  justify-content: flex-end;
}
/* 分组卡片 */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.set-group {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.set-group-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.set-group-title::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
}
.set-group-desc {
  margin: -4px 0 2px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-sub);
}
.set-group .field {
  margin: 0;
}

/* ---------- v75 抽屉（聊天设置）紧凑 ---------- */
#settingsModal .set-group {
  padding: 14px 16px;
  gap: 10px;
}
#settingsModal .settings-body {
  gap: 12px;
}
.drawer-temp {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 9px;
  background: var(--glass-input);
  color: inherit;
}
.drawer-temp:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- v76 方案卡：口令 → 预设方案（自动加载） ---------- */
.plan-card {
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--bg-hover-tint);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.plan-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.plan-label {
  color: var(--text-sub);
  flex-shrink: 0;
  font-size: 12px;
}
.plan-val {
  color: var(--text-main);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}
.plan-remark {
  margin-top: 3px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--accent);
  line-height: 1.5;
}
.plan-remark.empty {
  display: none;
}
.plan-error {
  margin: 0;
  font-size: 12.5px;
  color: #e05555;
  line-height: 1.5;
}

/* 平铺表单（v52：去掉分组卡片与方案预设，字段直接排列） */
.field-hint {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-faint);
}

/* ---------- 响应式 ---------- */

/* 中屏：侧边栏左上角悬浮（.app 由 style.css 控制） */

/* 小屏：顶部条布局由 style.css 处理，这里仅微调聊天区 */
@media (max-width: 780px) {
  body {
    overflow: auto;
  }

  /* 小屏：输入区间距收紧 */
  .chat-input-area {
    gap: 8px;
  }

  /* 小屏：档位菜单居中弹出 */
  .effort-menu {
    left: 50%;
    transform: translateX(-50%);
  }

  .chat-messages {
    padding-top: 20px;
  }

.msg-user .msg-col-user {
  max-width: 92%;
}

  /* 顶部条内：新对话按钮与会话列表横向排列 */
  .new-chat-btn {
    width: auto;
    padding: 8px 12px;
    flex-shrink: 0;
  }

  .session-list {
    flex: 1;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
    margin: 0;
    padding: 0 4px;
  }

  .session-item {
    flex-shrink: 0;
    width: auto;
    max-width: 120px;
    padding: 7px 10px;
  }

  /* 横向列表空间有限，标题单行省略即可 */
  .session-list-wrap {
    max-height: 46px;
  }

  .session-del {
    display: none;
  }

  /* 顶部条空间有限，隐藏导航（站标可回首页） */
  .sidebar .sidebar-nav {
    display: none;
  }
}

/* v67：预设问题分步出场——AI 生成好的问题逐个浮出 */
.suggest-chip.sugg-pop {
  animation: sugg-pop 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes sugg-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ========== 交互动效（v40） ========== */

/* 底部弹出菜单：浮起（用 margin 避免覆盖小屏 translateX 居中） */
.effort-menu,
.bb-plus-menu,
.note-ref-menu {
  animation: menu-rise 0.17s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes menu-rise {
  from {
    opacity: 0;
    margin-bottom: -6px;
  }
  to {
    opacity: 1;
    margin-bottom: 0;
  }
}

/* 引用条出现：轻浮起 */
.quote-bar {
  animation: quote-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes quote-pop {
  from {
    opacity: 0;
    margin-bottom: -4px;
  }
  to {
    opacity: 1;
    margin-bottom: 0;
  }
}

/* 会话删除按钮：悬停轻旋 */
.session-del svg {
  transition: transform 0.18s ease;
}

.session-del:hover svg {
  transform: rotate(90deg);
}