/* ============ Composer ============ */
/* box 占位 = 视觉占位:不再用 margin-top:-32px 偷占 messages 区。顶部"渐隐遮罩"挪到
   ::before,absolute 浮在 composer box 之上的 32px 高度内,视觉效果不变,但 messages
   的 padding-bottom 终于能按字面意义控制最后一条消息到输入框上沿的间距。 */
.composer {
  padding: 0 24px 28px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-fade);
  position: relative;
}
.composer::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -32px;
  height: 32px;
  background: linear-gradient(to bottom, var(--bg-fade-0) 0%, var(--bg-fade) 100%);
  pointer-events: none;
}
.composer-inner {
  width: 100%;
  max-width: 960px;
}

/* B1 附件区重做：缩略图按扩展名分色、移除按钮更精致、上传中圆环、错误态描红 */
.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.attach-preview:not(:empty) { margin-bottom: 12px; padding: 0 4px; }

.attach-thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  animation: fadeUp 180ms ease-out;
  display: flex;
  align-items: stretch;
  transition: border-color 120ms, box-shadow 120ms, transform 120ms;
}
.attach-thumb:hover {
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.attach-thumb img {
  display: block;
  width: 72px;
  height: 72px;
  aspect-ratio: 1;
  object-fit: cover;
}

.attach-thumb .attach-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 36px 10px 10px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 280px;
  line-height: 1.3;
}
.attach-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--text-3);
}
.attach-thumb.ft-pdf  .attach-badge { background: #c14343; }
.attach-thumb.ft-doc  .attach-badge { background: #3a6db1; }
.attach-thumb.ft-xls  .attach-badge { background: #2f8a55; }
.attach-thumb.ft-ppt  .attach-badge { background: #c8743a; }
.attach-thumb.ft-txt  .attach-badge,
.attach-thumb.ft-md   .attach-badge { background: #6c6e75; }
.attach-thumb.ft-code .attach-badge { background: #4f6c8a; }
.attach-thumb.ft-audio .attach-badge { background: #8a4fbf; }
.attach-thumb.ft-video .attach-badge { background: #c14377; }
html[data-theme="dark"] .attach-badge { color: #f5f4ef; }

.attach-meta {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.attach-fname {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-size {
  font-size: 11px;
  color: var(--text-4);
  font-weight: 400;
}

/* 上传中：右下角进度环 + 百分比文字（取代之前无进度的旋转圈） */
.attach-thumb.uploading {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink-soft);
}
.attach-thumb.uploading::before {
  /* 上传中半透明遮罩，让 thumb 内容稍微沉一下，进度环更醒目 */
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  border-radius: inherit;
  pointer-events: none;
}
html[data-theme="dark"] .attach-thumb.uploading::before {
  background: rgba(20, 18, 18, 0.35);
}
.attach-ring {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 2;
}
.attach-ring svg {
  width: 100%;
  height: 100%;
  display: block;
}
.attach-ring svg .attach-ring-track {
  fill: none;
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 3;
}
html[data-theme="dark"] .attach-ring svg .attach-ring-track {
  stroke: rgba(255, 255, 255, 0.22);
}
.attach-ring svg .attach-ring-fill {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  transform-origin: center;
  transition: stroke-dasharray 120ms linear;
}
.attach-ring-pct {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
  color: var(--ink, #2a2724);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 3px rgba(20, 18, 18, 0.12);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .attach-ring-pct {
  color: #f5f4ef;
  background: rgba(40, 36, 36, 0.86);
}

/* 错误态：描红 + 右下角感叹号 */
.attach-thumb.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-soft);
}
.attach-err-icon {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-err-icon svg { width: 10px; height: 10px; }

/* 移除按钮：与项目文件卡片删除按钮 (.proj-file-del) 同款红色垃圾桶，视觉统一 */
.attach-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--danger, #c14343);
  border: 1px solid rgba(193, 67, 67, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  box-shadow: 0 2px 6px rgba(20, 18, 18, 0.10);
  opacity: 0.78;
  transition: opacity 140ms, transform 140ms, background 140ms, color 140ms;
}
.attach-thumb:hover .attach-remove { opacity: 1; }
.attach-remove:hover {
  background: var(--danger, #c14343);
  color: #fff;
  border-color: var(--danger, #c14343);
  opacity: 1;
  transform: scale(1.06);
}
html[data-theme="dark"] .attach-remove {
  background: rgba(40, 36, 36, 0.92);
  color: #ff8c8c;
  border-color: rgba(224, 118, 118, 0.28);
}
html[data-theme="dark"] .attach-remove:hover {
  background: #d96c6c;
  color: #fff;
}

.input-card {
  /* 设计：composer 不再像"第四个内容卡"——去边框、缩圆角、轻量化阴影，
     让它跟上方项目卡 / 消息流的视觉权重区分开。focus-within 时用 ring
     强调（而不是改边框颜色）。 */
  background: var(--card-bg);
  border: none;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px -8px rgba(0, 0, 0, 0.08);
  padding: 16px 18px 12px;
  transition: box-shadow 150ms, background 200ms;
  position: relative;
}
html[data-theme="dark"] .input-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px -8px rgba(0, 0, 0, 0.5);
}
.input-card:focus-within {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px -8px rgba(31, 60, 51, 0.16), 0 0 0 3px rgba(31, 60, 51, 0.12);
}
html[data-theme="dark"] .input-card:focus-within {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px -8px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(127, 195, 158, 0.18);
}
.input-card textarea,
.input-card #input {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  min-height: 32px;
  max-height: 220px;
  background: transparent;
  line-height: 1.55;
  padding: 2px 4px 6px;
}
.input-card textarea::placeholder { color: var(--text-5); }
/* contenteditable div：placeholder 用 data-placeholder 属性 + .is-empty class
   控制（不能用 :empty 选择器 —— 浏览器在用户清空后会留 <br> 让 :empty 失效）。
   syncEmptyClass() 在 input 事件里维护 .is-empty 状态。
   伪元素用 absolute 定位避免占位影响光标。 */
.input-card #input {
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
}
.input-card #input.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  /* 光标停在 padding-left=4px 处 —— placeholder 再让 4px 给光标，
     避免视觉重叠（用户原 textarea 时浏览器自动处理过这个间距）。 */
  left: 8px;
  top: 2px;
  color: var(--text-5);
  pointer-events: none;
}
/* mention chip：选中文件后插入到 input 内的不可编辑块。
   分两层：
   - .mention-chip 容器：linear-gradient 底色 + accent 边框 + 微阴影
   - .mention-at "@" 字符提亮成 accent 主题色，让块状识别更强 */
.mention-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  padding: 1px 9px 2px 7px;
  margin: 0 2px;
  background: linear-gradient(180deg,
    rgba(127, 195, 158, 0.18),
    rgba(127, 195, 158, 0.10));
  color: var(--ink);
  border: 1px solid rgba(127, 195, 158, 0.32);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1.45;
  user-select: none;
  cursor: default;
  white-space: nowrap;
  vertical-align: baseline;
  box-shadow:
    0 1px 0 rgba(31, 60, 51, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: border-color 120ms, box-shadow 120ms, transform 120ms;
}
.mention-chip:hover {
  border-color: rgba(127, 195, 158, 0.55);
  box-shadow:
    0 2px 6px rgba(31, 60, 51, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(-0.5px);
}
.mention-chip .mention-at {
  color: #2f7d52;
  font-weight: 700;
  margin-right: 1px;
  letter-spacing: 0;
}
html[data-theme="dark"] .mention-chip {
  background: linear-gradient(180deg,
    rgba(127, 195, 158, 0.22),
    rgba(127, 195, 158, 0.12));
  border-color: rgba(127, 195, 158, 0.38);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--text);
}
html[data-theme="dark"] .mention-chip .mention-at { color: #8fd1ad; }

.input-toolbar {
  display: flex;
  align-items: center;
  margin-top: 14px;
  gap: 8px;
}
.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 999px;
  transition: background 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
  flex-shrink: 0;
}
.btn-icon:hover { color: var(--ink); background: var(--ink-soft); }
.btn-icon:active { transform: scale(0.92); }
.btn-icon svg { width: 18px; height: 18px; }
.toolbar-spacer { flex: 1; }

/* ── Tool chip (e.g. image generation toggle) ── */
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  margin-left: 2px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, color 140ms;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1;
}
/* [hidden] 隐藏 chip(图像/报告互斥:激活一个就隐藏另一个 chip)。.tool-chip
   有 display:inline-flex,UA 的 [hidden]{display:none} 优先级不够,显式覆盖。
   同 .imagegen-dd[hidden] 模式。 */
.tool-chip[hidden] { display: none !important; }
.tool-chip:hover:not(.is-on) {
  background: color-mix(in srgb, var(--text) 4%, transparent);
  border-color: var(--border);
  color: var(--text);
}
.tool-chip-ico { width: 15px; height: 15px; flex-shrink: 0; }
.tool-chip-close { width: 13px; height: 13px; flex-shrink: 0; display: none; opacity: 0.85; }
.tool-chip.is-on {
  color: #2d6a4f;
  background: #e8f1ec;
  border-color: #b8d4c4;
  font-weight: 600;
}
html[data-theme="dark"] .tool-chip.is-on {
  color: #a8d6bc;
  background: rgba(127, 195, 158, 0.16);
  border-color: rgba(127, 195, 158, 0.45);
}
.tool-chip.is-on:hover { background: #dde9e1; border-color: #a3c5b1; }
html[data-theme="dark"] .tool-chip.is-on:hover { background: rgba(127, 195, 158, 0.22); }
.tool-chip.is-on .tool-chip-close { display: inline-block; }

/* Model selector — chip + dropdown */
.model-selector { position: relative; user-select: none; }
/* .model-chip 复用 .tool-chip 样式(line 375),只覆盖 chevron 行为 */
.model-chip { font-weight: 500; }
/* chip 图标:跟着 data-mode 切换 —— default 显示 C 形,fast 显示闪电 */
.model-chip .mode-ico { display: none; }
.model-chip[data-mode="default"] .mode-ico--default { display: inline-block; }
.model-chip[data-mode="fast"] .mode-ico--fast { display: inline-block; }
.model-chip[data-mode="fast"] { color: #d97706; }
.model-chip[data-mode="fast"]:hover { color: #b45309; }
html[data-theme="dark"] .model-chip[data-mode="fast"] { color: #fbbf24; }
.model-chip[aria-expanded="true"] {
  background: color-mix(in srgb, var(--text) 4%, transparent);
  border-color: var(--border);
  color: var(--text);
}
.model-chevron {
  width: 13px;
  height: 13px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 180ms, color 120ms;
  margin-left: -1px;
}
.model-selector.is-open .model-chevron { transform: rotate(180deg); color: var(--text-2); }

.model-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 12px 32px -4px rgba(15, 23, 42, 0.12),
    0 4px 12px -2px rgba(15, 23, 42, 0.06);
  opacity: 0;
  transform: translateY(6px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50;
}
html[data-theme="dark"] .model-menu {
  background: var(--card-bg);
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 16px 40px -4px rgba(0, 0, 0, 0.55),
    0 6px 14px -2px rgba(0, 0, 0, 0.35);
}
.model-selector.is-open .model-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.model-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: background 120ms;
}
.model-menu-item + .model-menu-item { margin-top: 1px; }
.model-menu-item:hover { background: var(--hover); }
.model-menu-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
  min-width: 0;
}
.model-menu-check {
  width: 14px;
  height: 14px;
  color: var(--ink);
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 120ms, transform 120ms;
}
.model-menu-item.is-active .model-menu-check {
  opacity: 1;
  transform: scale(1);
}
.model-menu-item.is-active .model-menu-title { color: var(--ink); }

/* ── Rich menu — 标题 + 描述 + 蓝色 check（参考 Claude.ai 设计） ── */
.model-menu--rich {
  min-width: 0;
  width: max-content;
  max-width: 320px;
  padding: 6px;
  border-radius: 14px;
}
.model-menu--rich .model-menu-item {
  align-items: flex-start;
  padding: 11px 14px;
  gap: 12px;
  border-radius: 9px;
  position: relative;
}
.model-menu--rich .model-menu-item + .model-menu-item { margin-top: 2px; }
.model-menu--rich .model-menu-item:hover { background: var(--hover); }
.model-menu--rich .model-menu-item.is-active {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}
html[data-theme="dark"] .model-menu--rich .model-menu-item.is-active {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.model-menu-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.model-menu--rich .model-menu-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.25;
}
/* 模型名后的小卡片 —— 一眼看出该模型擅长什么(细节丰富 / 图像编辑首选)。
   tinted soft tag:浅品牌色底 + 深品牌色字,对比够但克制,不喧宾夺主、不抢标题。
   小圆角(非全圆)避免被误当成按钮。亮/暗各调一套保证文字清晰。 */
.model-menu-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1.5px 7px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink);
  background: rgba(31, 60, 51, 0.12);
  border-radius: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
html[data-theme="dark"] .model-menu-badge {
  color: var(--ink-hover);
  background: rgba(127, 195, 158, 0.18);
}
.model-menu-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-4);
  line-height: 1.45;
}
.model-menu-item.is-active .model-menu-desc { color: var(--text-3); }
/* Tags removed in rich variant — descriptions carry the meaning */
.model-menu--rich .model-menu-tag { display: none; }
/* Blue check — only colored signal, marks current selection */
.model-menu--rich .model-menu-check {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  margin-right: 2px;
  color: #2563eb;
  flex-shrink: 0;
}
html[data-theme="dark"] .model-menu--rich .model-menu-check { color: #60a5fa; }
.model-menu--rich .model-menu-caret {
  margin-top: 12px;
  color: var(--text-4);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.model-menu--rich .model-menu-expander { padding: 11px 14px; }

/* ── 模式选择器(默认/快速)菜单 ── 独立 scope,不污染公共 .rich 样式 */
.model-menu--modes {
  min-width: 224px;
  padding: 7px;
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 14px 38px -6px rgba(15, 23, 42, 0.14),
    0 6px 16px -4px rgba(15, 23, 42, 0.08);
}
.model-menu--modes .model-menu-item {
  padding: 10px 11px;
  gap: 11px;
  align-items: center;
  border-radius: 11px;
  transition: background 140ms var(--ease), transform 120ms var(--ease);
}
.model-menu--modes .model-menu-item:hover { background: var(--hover); }
.model-menu--modes .model-menu-item:active { transform: scale(0.985); }
.model-menu--modes .model-menu-item.is-active {
  background: color-mix(in srgb, #2563eb 8%, transparent);
}
html[data-theme="dark"] .model-menu--modes .model-menu-item.is-active {
  background: color-mix(in srgb, #60a5fa 14%, transparent);
}
.model-menu--modes .model-menu-text { gap: 3px; }
.model-menu--modes .model-menu-title { font-size: 13.5px; }
.model-menu--modes .model-menu-desc {
  font-size: 11.5px;
  color: var(--text-4);
}
.model-menu--modes .model-menu-item.is-active .model-menu-title { color: #2563eb; }
html[data-theme="dark"] .model-menu--modes .model-menu-item.is-active .model-menu-title { color: #60a5fa; }
.model-menu--modes .model-menu-check {
  width: 15px;
  height: 15px;
  margin-top: 0;
  align-self: center;
  opacity: 0;
  transition: opacity 120ms;
}
.model-menu--modes .model-menu-item.is-active .model-menu-check { opacity: 1; }

/* vendor badge —— 选项左侧的圆形小图标 */
.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: var(--text-3);
  transition: background 140ms, color 140ms;
}
.mode-badge svg { width: 16px; height: 16px; }
.model-menu--modes .model-menu-item.is-active .mode-badge--default {
  background: color-mix(in srgb, #2563eb 14%, transparent);
  color: #2563eb;
}
.model-menu--modes .model-menu-item.is-active .mode-badge--fast {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #d97706;
}
html[data-theme="dark"] .model-menu--modes .model-menu-item.is-active .mode-badge--default {
  background: color-mix(in srgb, #60a5fa 20%, transparent);
  color: #93c5fd;
}
html[data-theme="dark"] .model-menu--modes .model-menu-item.is-active .mode-badge--fast {
  background: color-mix(in srgb, #fbbf24 22%, transparent);
  color: #fcd34d;
}

.model-menu-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 4px 2px;
}
.model-menu-section-label {
  padding: 6px 10px 2px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-4);
  letter-spacing: 0.04em;
  text-transform: none;
}
.model-menu-caret {
  width: 11px;
  height: 11px;
  color: var(--text-4);
  flex-shrink: 0;
  transition: color 120ms, transform 120ms;
}
.model-menu-sub-wrap { position: relative; }
.model-menu-sub-wrap:hover .model-menu-expander,
.model-menu-sub-wrap.is-open .model-menu-expander { background: var(--hover); }
.model-menu-sub-wrap:hover .model-menu-caret,
.model-menu-sub-wrap.is-open .model-menu-caret {
  color: var(--text);
  transform: translateX(1px);
}
.model-submenu {
  position: absolute;
  top: -5px;
  right: calc(100% + 8px);
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 12px 32px -4px rgba(15, 23, 42, 0.12),
    0 4px 12px -2px rgba(15, 23, 42, 0.06);
  opacity: 0;
  transform: translateX(4px) scale(0.98);
  transform-origin: right center;
  pointer-events: none;
  transition: opacity 160ms var(--ease), transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}
html[data-theme="dark"] .model-submenu {
  background: var(--card-bg);
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 16px 40px -4px rgba(0, 0, 0, 0.55),
    0 6px 14px -2px rgba(0, 0, 0, 0.35);
}
.model-submenu::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: -10px;
  width: 10px;
}
.model-menu-sub-wrap:hover .model-submenu,
.model-menu-sub-wrap:focus-within .model-submenu,
.model-menu-sub-wrap.is-open .model-submenu {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}
.model-submenu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms;
}
.model-submenu-item + .model-submenu-item { margin-top: 1px; }
.model-submenu-item:hover:not(.is-disabled) { background: var(--hover); }
.model-submenu-item.is-disabled {
  color: var(--text-4);
  cursor: not-allowed;
}
.model-submenu-label { flex: 1; min-width: 0; }
.model-submenu-tag {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--hover);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.model-submenu-note {
  padding: 8px 10px 4px;
  font-size: 11.5px;
  color: var(--text-4);
  line-height: 1.4;
  user-select: text;
  border-top: 1px solid var(--border-soft);
  margin-top: 4px;
  white-space: nowrap;
}

.btn-send {
  position: relative;
  width: 32px;
  height: 32px;
  margin-left: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms, transform 120ms;
  flex-shrink: 0;
}
html[data-theme="dark"] .btn-send { color: #14171a; }
.btn-send:hover:not(:disabled) { background: var(--ink-hover); }
.btn-send:active:not(:disabled) { transform: scale(0.94); }
.btn-send:disabled {
  /* 空输入态：明确"未就绪"，弱化背景 + 浅字 + 不响应 hover */
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-5);
  cursor: default;
}
html[data-theme="dark"] .btn-send:disabled { background: rgba(255, 255, 255, 0.06); }
.btn-send.is-stop { background: var(--danger); color: #fff; }
.btn-send.is-stop:hover:not(:disabled) { filter: brightness(1.08); }
/* Hover tooltip：把"Enter 发送 / Shift+Enter 换行"键盘提示从底部
   常驻区挪到这里，hover 1 秒后浮现 —— 不占用底部视觉空间，需要时
   才出来。is-stop 态（流式中）跳过 tooltip：那时按钮意义是"停止"，
   不是"发送"。 */
.btn-send::after {
  content: "Enter 发送 · Shift+Enter 换行";
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  padding: 6px 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 11.5px;
  white-space: nowrap;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 160ms ease 1s, transform 160ms ease 1s;
  z-index: 10;
}
.btn-send:hover:not(.is-stop):not(:disabled)::after {
  opacity: 1;
  transform: translateY(0);
}

/* ============ 敏感资料警告条 ============ */
.sensitive-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-4);
  margin-top: 8px;
  letter-spacing: 0.02em;
}
.sensitive-note svg { color: #c58b1a; flex-shrink: 0; }


/* ============ @ mention popup（项目对话内输入 @ 弹文件列表） ============ */
.mention-pop {
  position: fixed;
  z-index: 1200;
  width: 320px;
  max-width: calc(100vw - 16px);
  background: var(--card-bg, #fff);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  box-shadow:
    0 24px 48px rgba(15, 23, 42, 0.10),
    0 4px 12px rgba(15, 23, 42, 0.05);
  padding: 6px;
  overflow-y: auto;
  display: none;
  font-size: 13px;
}
.mention-pop.open { display: block; }
.mention-pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  transition: background 80ms;
}
.mention-pop-row[aria-selected="true"],
.mention-pop-row:hover {
  background: rgba(31, 60, 51, 0.06);
}
/* mention popup 内的小型彩色 badge —— 通过 mention-pop-icon.attach-badge 复用
   .ft-* 配色，但尺寸压小到 26×20 适合 popup 行高。颜色映射跟附件预览卡 +
   项目资料卡完全一致，不重复定义。 */
.mention-pop-row .mention-pop-icon.attach-badge {
  flex-shrink: 0;
  min-width: 28px;
  width: 28px;
  height: 20px;
  border-radius: 5px;
  padding: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--text-3);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mention-pop-row .mention-pop-icon-label {
  line-height: 1;
}
/* 颜色按文件类型 —— 跟附件卡 .attach-thumb.ft-* 同色 */
.mention-pop-row.ft-pdf  .attach-badge { background: #c14343; }
.mention-pop-row.ft-doc  .attach-badge { background: #3a6db1; }
.mention-pop-row.ft-xls  .attach-badge { background: #2f8a55; }
.mention-pop-row.ft-ppt  .attach-badge { background: #c8743a; }
.mention-pop-row.ft-txt  .attach-badge,
.mention-pop-row.ft-md   .attach-badge { background: #6c6e75; }
.mention-pop-row.ft-code .attach-badge { background: #4f6c8a; }
.mention-pop-row.ft-audio .attach-badge { background: #8a4fbf; }
.mention-pop-row.ft-video .attach-badge { background: #c14377; }
.mention-pop-row.ft-img  .attach-badge { background: #7a4eb0; }

.mention-pop-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Image-tool parameter panel ─────────────────────────────────────
   紧跟 #imageToolChip 右边,4 个 dropdown(模型 / 比例 / 尺寸 / 质量)。
   chip 关闭时整组 display:none;chip 点亮(.is-on)时整组展开。
   每个 dropdown 由 JS 渲染,trigger 复用 .tool-chip 视觉,popout 菜单
   复用 .model-menu--rich (Claude.ai 风格双层卡片)。 */
.imagegen-panel {
  display: none;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: 2px;
}
.imagegen-panel[data-active="true"] { display: inline-flex; }

/* 报告面板的 hero 小提示:整行放在工具条下方(不在 nowrap 工具条内,
   避免挤压布局),一句话告知格式特性(主要是 HTML 可导 PDF)。弱化视觉。 */
.reportgen-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
}
.reportgen-hint[hidden] { display: none; }

/* ── 单个 dropdown 容器(trigger + popout 菜单) ─────────────────── */
.imagegen-dd {
  position: relative;
  display: inline-flex;
}
.imagegen-dd[hidden] { display: none !important; }

/* ── trigger:复用 .tool-chip 形态但更紧凑 + 双层文字布局 ────────── */
.imagegen-dd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px 0 11px;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  transition: background 140ms, border-color 140ms, color 140ms;
  white-space: nowrap;
}
.imagegen-dd-trigger:hover {
  background: color-mix(in srgb, var(--text) 3%, transparent);
  border-color: var(--border);
  color: var(--text-2);
}
.imagegen-dd.is-open .imagegen-dd-trigger {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-color: var(--border);
  color: var(--text);
}
.imagegen-dd-cap {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-4);
  letter-spacing: 0.01em;
  user-select: none;
}
.imagegen-dd-trigger:hover .imagegen-dd-cap,
.imagegen-dd.is-open .imagegen-dd-cap { color: var(--text-3); }
.imagegen-dd-val {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text);
  user-select: none;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.imagegen-dd-chev {
  width: 12px;
  height: 12px;
  color: var(--text-4);
  flex-shrink: 0;
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1), color 120ms;
}
.imagegen-dd.is-open .imagegen-dd-chev {
  transform: rotate(180deg);
  color: var(--text-2);
}

/* ── popout 菜单:复用 .model-menu 弹出动画 + .model-menu--rich 双层文本 */
.imagegen-dd-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  /* 菜单宽度更宽一点容纳 desc 文案 */
  min-width: 240px;
  max-width: 320px;
  /* 比例 dropdown 有 13 个选项,菜单可能超出视口顶部 —— 给个上限
     + 内部滚动,避免被裁切。aspect dropdown 最高一档:13 项 × ~52px
     ≈ 680px,在 ~900px 视口里设 60vh 留出输入框/header 空间。 */
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* 滚动条样式跟主题一致 — 默认是浏览器原生的太突兀 */
.imagegen-dd-menu::-webkit-scrollbar { width: 8px; }
.imagegen-dd-menu::-webkit-scrollbar-track { background: transparent; }
.imagegen-dd-menu::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 999px;
  border: 2px solid var(--card-bg);
}
.imagegen-dd-menu::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text) 22%, transparent);
}
.imagegen-dd.is-open .imagegen-dd-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.imagegen-dd-menu .model-menu-item {
  position: relative;
  padding-right: 36px; /* 给右上角 check 留位 */
}
.imagegen-dd-menu .model-menu-check {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
}
.imagegen-dd-menu .model-menu-item.is-active .model-menu-check {
  transform: translateY(-50%) scale(1);
}

@media (max-width: 720px) {
  /* 移动端:整组折下一行,trigger 文字更紧凑 */
  .imagegen-panel { flex-basis: 100%; margin-left: 0; margin-top: 6px; }
  .imagegen-dd-val { max-width: 100px; font-size: 12px; }
  .imagegen-dd-menu { left: auto; right: 0; min-width: 220px; }
}
