/* chat.css — Generation Page 布局 / Chat Panel / 消息样式 / 输入区域 / 附件栏 */

/* ══════ Generation Page ══════ */
.gen-page { display: none; height: 100%; padding-top: 48px; box-sizing: border-box; }
.gen-page.visible { display: flex; }
.gen-page.preview-open { padding-left: 24px; padding-right: 16px; }

/* Left: Chat — 默认居中，展开预览后靠左 */
.chat-panel {
  width: 50%; min-width: 360px; max-width: 640px; height: 100%;
  display: flex; flex-direction: column; background: var(--bg);
  transition: margin 0.4s ease; overflow: hidden; min-height: 0;
}
/* 预览面板未展开时，聊天面板居中 */
.gen-page:not(.preview-open) .chat-panel {
  margin: 0 auto; max-width: 720px; width: 100%;
}
/* 预览面板 & 拖拽条默认隐藏 */
.gen-page:not(.preview-open) .resizer,
.gen-page:not(.preview-open) .preview-panel {
  display: none;
}
/* 搜索/图片面板打开时，强制显示 preview-panel 但隐藏预览内容 */
.gen-page:not(.preview-open) .preview-panel:has(.search-panel.open),
.gen-page:not(.preview-open) .preview-panel:has(.image-panel.open),
.gen-page:not(.preview-open) .preview-panel:has(.parse-panel.open) {
  display: flex;
}
.gen-page:not(.preview-open) .preview-panel:has(.search-panel.open) > .work-toolbar,
.gen-page:not(.preview-open) .preview-panel:has(.search-panel.open) > .pv-body,
.gen-page:not(.preview-open) .preview-panel:has(.search-panel.open) > .export-progress,
.gen-page:not(.preview-open) .preview-panel:has(.image-panel.open) > .work-toolbar,
.gen-page:not(.preview-open) .preview-panel:has(.image-panel.open) > .pv-body,
.gen-page:not(.preview-open) .preview-panel:has(.image-panel.open) > .export-progress,
.gen-page:not(.preview-open) .preview-panel:has(.parse-panel.open) > .work-toolbar,
.gen-page:not(.preview-open) .preview-panel:has(.parse-panel.open) > .pv-body,
.gen-page:not(.preview-open) .preview-panel:has(.parse-panel.open) > .export-progress {
  display: none !important;
}
.gen-page:not(.preview-open) .preview-panel:has(.sa-preview-panel.open) {
  display: flex;
}
.gen-page:not(.preview-open) .preview-panel:has(.sa-preview-panel.open) > .work-toolbar,
.gen-page:not(.preview-open) .preview-panel:has(.sa-preview-panel.open) > .pv-body,
.gen-page:not(.preview-open) .preview-panel:has(.sa-preview-panel.open) > .export-progress {
  display: none !important;
}
/* chat-header removed — navbar handles branding now */

/* Resizer */
.resizer {
  width: 5px; background: var(--border); cursor: col-resize;
  transition: background 0.15s; flex-shrink: 0; position: relative;
}
.resizer:hover, .resizer.active { background: var(--accent); }
.resizer::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); width: 3px; height: 32px;
  border-radius: 2px; background: var(--text3); opacity: 0.4;
}
.resizer:hover::after, .resizer.active::after { background: var(--accent2); opacity: 0.8; }

/* Clarify form */
.clarify-form {
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px; padding: 14px 16px;
}
.cf-field { margin-bottom: 8px; }
.cf-field label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 3px; }
.cf-field label .r { color: var(--red); }
.cf-field input, .cf-field select {
  width: 100%; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); padding: 7px 10px;
  font-size: 13px; outline: none; font-family: inherit;
}
.cf-field input:focus, .cf-field select:focus { border-color: var(--accent); }
.cf-btns { display: flex; gap: 8px; margin-top: 10px; }
.cb {
  padding: 7px 14px; border-radius: 7px; font-size: 12px;
  font-weight: 500; cursor: pointer; border: none; transition: all 0.15s;
}
.cb.pr { background: var(--accent); color: #fff; }
.cb.pr:hover { background: var(--accent2); }
.cb.gh { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.cb.gh:hover { background: var(--bg4); color: var(--text); }

/* Chat feed */
.chat-feed { flex: 1; overflow-y: auto; padding: 18px 20px 12px; }
.chat-feed::-webkit-scrollbar { width: 4px; }
.chat-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Chat input — unified card (matches landing-input) */
.chat-input-area {
  margin: 8px 16px 28px; position: relative;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-area:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.chat-input-area textarea {
  width: 100%; background: transparent; border: none;
  color: var(--text); padding: 14px 48px 14px 132px;  /* 左侧给 attach + scene-override + expert 三个按钮挤位 */
  font-size: 14px; min-height: 80px; resize: none; outline: none; font-family: inherit;
  line-height: 1.6; position: relative; z-index: 0;
}
/* preset-select-btn 出现时（多 preset 部署）加宽左侧 padding 给第 4 个按钮挤位 */
.chat-input-area:has(.preset-select-btn) textarea,
.landing-input:has(.preset-select-btn) textarea { padding-left: 176px; }
/* system-select-btn 出现时同样加宽（第 4 位 = 盾牌）；与 preset 同时出现再加一档 */
.chat-input-area:has(.system-select-btn) textarea,
.landing-input:has(.system-select-btn) textarea { padding-left: 176px; }
.chat-input-area:has(.system-select-btn):has(.preset-select-btn) textarea,
.landing-input:has(.system-select-btn):has(.preset-select-btn) textarea { padding-left: 220px; }
/* 输入框第三个选择触点(专家专属下拉,广场卡片/详情页之外的选择入口) */
.expert-select-btn {
  position: absolute; left: 94px; bottom: 10px; z-index: 3;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background 0.15s, color 0.15s;
}
.expert-select-btn:hover { background: var(--bg3); color: var(--accent); }
.expert-select-btn svg { width: 18px; height: 18px; display: block; }
.landing-input .expert-select-btn { left: 98px; bottom: 12px; }
/* System skill 注入按钮（第 5 触点，盾牌；调试面板 docs/feat/system-skill-picker.md）。
   位置紧随专家按钮（skill 类按钮相邻），preset 右移让位 */
.system-select-btn {
  position: absolute; left: 136px; bottom: 10px; z-index: 3;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background 0.15s, color 0.15s;
}
.system-select-btn:hover { background: var(--bg3); color: var(--accent); }
.system-select-btn svg { width: 18px; height: 18px; display: block; }
.system-select-btn.has-system { color: var(--accent); }
.landing-input .system-select-btn { left: 140px; bottom: 12px; }
/* 第四个触点：preset 选择器（14 §4.2，多 preset 时才注入；_default-only 部署零行为变化）。
   原 left 136/140 → 178/182，给盾牌让位（2026-09-15） */
.preset-select-btn {
  position: absolute; left: 178px; bottom: 10px; z-index: 3;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background 0.15s, color 0.15s;
  overflow: visible;
}
.preset-select-btn:hover { background: var(--bg3); color: var(--accent); }
.preset-select-btn svg { width: 18px; height: 18px; display: block; }
.preset-select-btn.has-preset { color: var(--accent); }
.landing-input .preset-select-btn { left: 182px; bottom: 12px; }
.preset-select-btn .ps-badge {
  position: absolute; top: -6px; right: -6px; z-index: 10;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 600;
  border-radius: 8px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  line-height: 1; border: 1.5px solid var(--bg2);
}
.preset-select-menu .esm-item.is-active { background: var(--bg3); color: var(--accent); font-weight: 600; }

.expert-select-menu,
.system-select-menu {
  width: 260px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 10001;
  padding: 6px;
  font-size: 12.5px;
}
.esm-hd { padding: 6px 8px 4px; font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; }
.esm-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px; border-radius: 6px; cursor: pointer; color: var(--text);
}
.esm-item:hover { background: var(--bg3); }
.esm-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.esm-item-cat { font-size: 10px; color: var(--text3); flex-shrink: 0; }
.esm-empty, .esm-loading { padding: 14px 8px; color: var(--text3); text-align: center; }
/* system 菜单底部提示行（单选/共存/移除语义） */
.esm-hint {
  margin-top: 4px; padding: 7px 8px; border-top: 1px solid var(--border);
  font-size: 10.5px; color: var(--text3); line-height: 1.5;
}
.esm-viewall {
  margin-top: 4px; padding: 8px 8px; border-top: 1px solid var(--border);
  color: var(--accent); cursor: pointer; font-weight: 500; text-align: center;
}
.esm-viewall:hover { background: var(--bg3); border-radius: 0 0 8px 8px; }
.chat-input-area textarea::placeholder { color: var(--text3); }
.chat-input-area textarea:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-input-area .attach-btn {
  position: absolute; left: 10px; bottom: 10px; z-index: 2; border: none; background: transparent;
}
/* 本会话模型覆盖按钮 */
.scene-override-btn {
  position: absolute; left: 52px; bottom: 10px; z-index: 3;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background 0.15s, color 0.15s;
  overflow: visible;
}
.scene-override-btn:hover { background: var(--bg3); color: var(--text); }
.scene-override-btn svg { width: 18px; height: 18px; display: block; }
.scene-override-btn.has-overrides { color: var(--accent); }
.scene-override-btn.has-native-mm { color: var(--accent); }
/* ── 原生多模态开关行（#181，Janus 行下方）── */
.so-row.so-native-mm { cursor: pointer; }
.so-row.so-native-mm.is-disabled {
  cursor: not-allowed; opacity: 0.5;
}
.so-row.so-native-mm.is-on .so-row-current { color: var(--accent); font-weight: 600; }
.so-nm-switch {
  flex: 0 0 auto; width: 28px; height: 16px; border-radius: 999px;
  background: var(--border); position: relative; transition: background 0.15s;
  margin-left: 6px;
}
.so-nm-switch.on { background: var(--accent); }
.so-nm-knob {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; transition: left 0.15s;
}
.so-nm-switch.on .so-nm-knob { left: 14px; }
.scene-override-btn .so-badge {
  position: absolute; top: -6px; right: -6px; z-index: 10;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 600;
  border-radius: 8px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  line-height: 1; border: 1.5px solid var(--bg2);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Scene Overrides — cascading menu (主列表 + 右侧子菜单) */
.so-modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: transparent;
  display: none;
}
.so-modal-mask.open { display: block; }

/* ── 主列表（场景行）── */
.so-modal {
  position: fixed;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; width: 240px; max-width: 92vw;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  overflow: hidden;
  font-size: 12.5px;
}
/* 第一栏行数随可选工具增长——固定紧凑上限（约 9 行），超出滚动，避免菜单顶出视口 */
.so-list { padding: 4px 0; max-height: 328px; overflow-y: auto; }
.so-list::-webkit-scrollbar { width: 5px; }
.so-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.so-list::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.so-empty { color: var(--text3); font-size: 12px; padding: 16px 0; text-align: center; }
.so-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: default;
  color: var(--text); transition: background 0.1s;
}
.so-row:hover, .so-row.is-hovered { background: var(--bg); }
.so-row-label { flex: 0 0 auto; font-weight: 500; }
.so-row-current {
  flex: 1 1 auto; min-width: 0; text-align: right;
  color: var(--text3); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.so-row.is-overridden .so-row-current { color: var(--accent); }
.so-row-arrow { flex: 0 0 auto; color: var(--text3); }
.so-row:hover .so-row-arrow, .so-row.is-hovered .so-row-arrow { color: var(--text); }
.so-foot {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 6px 10px; border-top: 1px solid var(--border);
}
.so-reset-icon {
  width: 26px; height: 26px; padding: 0; border: none; border-radius: 6px;
  background: transparent; color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.so-reset-icon:hover { background: var(--bg); color: var(--text); }

/* ── 子菜单（候选模型列表）── */
.so-submenu {
  position: fixed;
  display: none;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; width: 280px; max-width: 92vw;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  overflow: hidden;
  z-index: 201;  /* 高于主面板 */
  font-size: 12.5px;
}
.so-submenu-search {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  color: var(--text3);
}
.so-submenu-search input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 12px; color: var(--text); padding: 0;
}
.so-submenu-search input::placeholder { color: var(--text3); }
.so-submenu-list {
  max-height: 240px; overflow-y: auto; padding: 4px 0;
}
.so-submenu-list::-webkit-scrollbar { width: 6px; }
.so-submenu-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.so-submenu-list::-webkit-scrollbar-track { background: transparent; }
.so-sub-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 8px; cursor: pointer;
  color: var(--text); transition: background 0.1s;
}
.so-sub-item:hover { background: var(--bg); }
.so-sub-check { flex: 0 0 14px; width: 14px; color: var(--accent); visibility: hidden; }
.so-sub-item.selected .so-sub-check { visibility: visible; }
.so-sub-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.so-sub-default {
  font-size: 10px; color: var(--text3); margin-left: 6px;
  padding: 1px 5px; background: var(--bg); border-radius: 4px;
}
.so-sub-empty { color: var(--text3); padding: 14px; text-align: center; }

/* ── Janus A/B 实验(模型区下方,分割线分组;英文原样不 i18n)── */
.so-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.so-janus-badge {
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 600;
  border-radius: 999px; min-width: 15px; height: 15px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
/* Janus experiments / variants 级联面板(复用 submenu 视觉)*/
.so-janus-panel {
  position: fixed; display: none;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; width: 220px; max-width: 92vw;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  overflow: hidden; z-index: 202; font-size: 12.5px;
}
.so-janus-list { max-height: 300px; overflow-y: auto; padding: 4px 0; }
.so-janus-list::-webkit-scrollbar { width: 6px; }
.so-janus-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.so-exp-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  cursor: pointer; color: var(--text); transition: background 0.1s;
}
.so-exp-row:hover, .so-exp-row.is-active { background: var(--bg); }
.so-exp-name { flex: 0 0 auto; font-weight: 500; }
.so-exp-cur {
  flex: 1 1 auto; min-width: 0; text-align: right; color: var(--text3);
  font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.so-exp-cur.is-on { color: var(--accent); font-weight: 600; }
.so-exp-arrow { flex: 0 0 auto; color: var(--text3); }
.so-exp-row:hover .so-exp-arrow, .so-exp-row.is-active .so-exp-arrow { color: var(--text); }
.so-var-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 8px;
  cursor: pointer; color: var(--text); transition: background 0.1s;
}
.so-var-item:hover { background: var(--bg); }
.so-var-check { flex: 0 0 14px; width: 14px; color: var(--accent); visibility: hidden; }
.so-var-item.selected .so-var-check { visibility: visible; }
.so-var-label { flex: 1 1 auto; min-width: 0; }
.so-var-default {
  font-size: 10px; color: var(--text3); margin-left: 6px;
  padding: 1px 5px; background: var(--bg); border-radius: 4px;
}
.chat-input-area .mini-send {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
}
.chat-input-area .stop-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
}
.mini-send {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mini-send:disabled { opacity: 0.3; cursor: not-allowed; }
.mini-send svg { width: 16px; height: 16px; }
/* Attachment button */
.attach-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.15s;
}
.attach-btn:hover { background: var(--bg4); color: var(--text); border-color: var(--accent); }
.attach-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.attach-btn svg { width: 16px; height: 16px; }
/* Attachment bar (inside chat-input-area, above textarea) */
.attach-bar {
  display: flex; gap: 8px; flex-wrap: nowrap; padding: 10px 14px 0;
  overflow-x: auto; scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.attach-bar:empty { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: none; border-radius: 8px;
  padding: 5px 8px; font-size: 11px; color: var(--text); min-width: 120px; max-width: 180px;
  flex-shrink: 0;
}
.attach-chip .ac-icon-box { background: none !important; opacity: 0.35; transition: opacity 0.3s; }
.attach-chip.ready .ac-icon-box { opacity: 1; }
.attach-chip .ac-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500;
  color: var(--text2);
}
.attach-chip .ac-meta { color: var(--text3); font-size: 10px; }
.attach-chip .ac-meta.uploading { color: var(--orange); }
.attach-chip .ac-meta.error { color: var(--red); }
.attach-chip .ac-remove {
  cursor: pointer; color: var(--text3); font-size: 14px; line-height: 1;
  margin-left: 2px; transition: color 0.15s;
}
.attach-chip .ac-remove:hover { color: var(--red); }
/* Icon box for file type SVG icons */
.ac-icon-box {
  border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ac-icon-box.pdf { background: #FEE2E2; color: #EF4444; }
.ac-icon-box.docx { background: #DBEAFE; color: #3B82F6; }
.ac-icon-box.pptx { background: #FEF3C7; color: #F59E0B; }
.ac-icon-box.xlsx { background: #D1FAE5; color: #10B981; }
.ac-icon-box.image { background: #EDE9FE; color: #8B5CF6; }
.ac-icon-box.default { background: #F3F4F6; color: #6B7280; }
.ac-icon-box svg { width: 70%; height: 70%; }
.ac-info { display: flex; flex-direction: column; gap: 1px; overflow: hidden; min-width: 0; }
.ac-meta { font-size: 11px; color: var(--text3); white-space: nowrap; }
/* Attach bar scroll wrapper with arrows */
.attach-bar-wrap {
  position: relative; display: flex; align-items: center;
}
.attach-bar-wrap .ab-arrow {
  position: absolute; z-index: 2; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text2); font-size: 16px; cursor: pointer;
  display: none; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.attach-bar-wrap .ab-arrow:hover { background: var(--bg3); }
.attach-bar-wrap .ab-left { left: 4px; }
.attach-bar-wrap .ab-right { right: 4px; }
.attach-bar-wrap .ab-arrow.visible { display: flex; }
/* Landing page attachment */
.landing-input .attach-btn {
  position: absolute; left: 12px; bottom: 12px; z-index: 2; border: none; background: transparent;
}
.landing-input textarea { padding-left: 142px; }
.scene-override-btn.landing {
  position: absolute; left: 56px; bottom: 12px; z-index: 2;
}
.attach-bar::-webkit-scrollbar { display: none; }
.landing-attach-bar {
  display: flex; gap: 8px; flex-wrap: nowrap; padding: 12px 16px 0;
  overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.landing-attach-bar::-webkit-scrollbar { display: none; }
.landing-attach-bar:empty { display: none; }
/* Attachment chips inside user message bubbles */
.msg-att-bar { display: flex; gap: 4px; flex-wrap: nowrap; margin-top: 6px; align-items: center; min-width: 360px; max-width: 100%; overflow: hidden; }
.msg-att-bar.expanded { flex-wrap: wrap; overflow: visible; }
.msg-att-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg4); border: 1px solid var(--border);
  border-radius: 10px; padding: 2px 8px; font-size: 11px; white-space: nowrap;
  color: var(--text2);
}
.msg-att-more {
  font-size: 11px; color: var(--accent); padding: 2px 6px; cursor: pointer; flex-shrink: 0; white-space: nowrap;
}
.msg-att-more:hover { text-decoration: underline; }
.ac-icon { flex-shrink: 0; }
.stop-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--red); background: transparent; color: var(--red);
  cursor: pointer; display: none; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px; transition: all 0.15s;
}
.stop-btn.visible { display: flex; }
.stop-btn:hover { background: var(--red); color: #fff; }

/* Messages */
.msg { margin-bottom: 14px; animation: fadeUp 0.25s ease-out; }
@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.msg-u { display: flex; justify-content: flex-end; }
.msg-u-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; }
.msg-u .bub {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 8px 14px; max-width: 85%; font-size: 14px; line-height: 1.55;
}
.msg-a .lbl {
  font-size: 10px; color: var(--text3); margin-bottom: 3px;
  display: flex; align-items: center; gap: 5px;
}
.msg-a .lbl .d { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.msg-a .bub {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px; padding: 10px 14px;
  font-size: 14px; line-height: 1.55;
}
/* Error bubble + retry button */
.err-bub { border-color: var(--red) !important; color: var(--red) !important; display: flex; align-items: center; gap: 8px; }
.err-retry-btn {
  background: none; border: 1px solid var(--red); cursor: pointer;
  color: var(--red); padding: 3px 5px; border-radius: 5px;
  opacity: 0.5; transition: all 0.15s; flex-shrink: 0;
  display: inline-flex; align-items: center; margin-left: auto;
}
.err-retry-btn:hover { opacity: 1; background: rgba(239,68,68,0.08); }
/* Credits-exhausted suspended card — informational, not an error.
   Inherits .msg-a .bub base; only adds inline layout + a primary action button. */
.credits-bub {
  display: flex; align-items: center; gap: 12px;
}
.credits-text { flex: 1; color: var(--text); font-size: 13px; }
.credits-resume-btn {
  flex-shrink: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  border: 1px solid var(--accent);
  padding: 5px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  transition: opacity 0.15s;
}
.credits-resume-btn:hover { opacity: 0.85; }
.credits-resume-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Markdown content inside agent bubbles */
.msg-a .bub p { margin: 0 0 8px 0; }
.msg-a .bub p:last-child { margin-bottom: 0; }
.msg-a .bub strong { font-weight: 600; }
.msg-a .bub ul, .msg-a .bub ol { margin: 4px 0 8px 18px; }
.msg-a .bub li { margin-bottom: 2px; }
.msg-a .bub table {
  width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px;
}
.msg-a .bub th, .msg-a .bub td {
  border: 1px solid var(--border); padding: 5px 8px; text-align: left;
}
.msg-a .bub th { background: var(--bg4); font-weight: 600; font-size: 11px; }
.msg-a .bub code {
  background: var(--bg4); padding: 1px 5px; border-radius: 4px; font-size: 12px;
  font-family: 'SF Mono','Consolas','Menlo', monospace;
}
.msg-a .bub pre { background: var(--bg4); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.msg-a .bub pre code { background: none; padding: 0; }
.msg-a .bub h1,.msg-a .bub h2,.msg-a .bub h3 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
.msg-a .bub blockquote {
  border-left: 3px solid var(--accent); padding-left: 10px; margin: 6px 0; color: var(--text2);
}
.msg-p .bub {
  background: transparent; border: none; padding: 4px 0;
  color: var(--text2); font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.sp {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.msg-p.ok .sp {
  border-color: var(--green); animation: none;
  display: flex; align-items: center; justify-content: center;
}
.msg-p.ok .sp::after { content: '\2713'; font-size: 9px; color: var(--green); }
.msg-p.ok .bub { color: var(--green); }
/* Retry warning style (orange) — 三层动效 */
/* 1. Spinner: 灰底+橙顶边，旋转可见 */
.msg-p.retry-msg .sp { border-color: rgba(255,152,0,0.3); border-top-color: var(--orange); }
.msg-p.retry-msg .bub { color: var(--orange); }
.msg-p.retry-msg.ok .sp { border-color: var(--orange); animation: none; }
.msg-p.retry-msg.ok .sp::after { content: '!'; color: var(--orange); }
.msg-p.retry-msg.ok .bub { color: var(--orange); }
/* 2. Shimmer 扫光 */
.msg-p.retry-msg:not(.ok) .bub {
  position: relative; overflow: hidden;
  transition: opacity 0.2s;
}
.msg-p.retry-msg:not(.ok) .bub::after {
  content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,152,0,0.08) 40%, rgba(255,152,0,0.15) 50%, rgba(255,152,0,0.08) 60%, transparent 100%);
  animation: retryShimmer 2s ease-in-out infinite;
}
@keyframes retryShimmer { to { left: 100%; } }
/* 3. 省略号跳动（.ok 时隐藏） */
.msg-p.ok .retry-dots { display: none; }
.retry-dots span { animation: retryDot 1.4s infinite; opacity: 0; }
.retry-dots span:nth-child(1) { animation-delay: 0s; }
.retry-dots span:nth-child(2) { animation-delay: 0.3s; }
.retry-dots span:nth-child(3) { animation-delay: 0.6s; }
@keyframes retryDot { 0%,60%,100% { opacity: 0; } 30% { opacity: 1; } }
/* fade 过渡 */
.msg-p.retry-msg .bub.retry-updating { opacity: 0; }
.p-det { margin-top: 4px; padding-left: 22px; font-size: 11px; color: var(--text3); line-height: 1.7; }
.p-det li::marker { color: var(--accent); }

/* Outline card (Genspark style) */
.o-card {
  margin-top: 6px; background: var(--bg3); border-radius: 10px;
  padding: 16px; border: 1px solid var(--border);
}
.o-card .o-t {
  font-size: 12px; color: var(--accent2); font-weight: 600;
  margin-bottom: 12px;
}
.o-page {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.o-page:last-child { border-bottom: none; }
.o-page-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.o-page-content { flex: 1; min-width: 0; }
.o-page-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.4; margin-bottom: 4px;
}
.o-page-text {
  font-size: 12px; color: var(--text2); line-height: 1.6;
}
.o-page-text ul {
  margin: 2px 0 0 0; padding-left: 16px; list-style: disc;
}
.o-page-text ul li { margin-bottom: 1px; }
.o-page-text ul li ul { margin-top: 1px; list-style: circle; }

/* Streaming outline (markdown live render) */
.o-card-streaming { opacity: 0.95; animation: oStreamPulse 1.4s ease-in-out infinite; }
@keyframes oStreamPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.0); } 50% { box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.08); } }
.o-card-streaming .o-t .sp {
  display: inline-block; width: 8px; height: 8px; margin-left: 6px;
  border-radius: 50%; background: var(--accent);
  animation: oDot 0.9s ease-in-out infinite;
}
@keyframes oDot { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.o-props {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: 11px; color: var(--text2);
  padding: 4px 0 10px; margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.o-prop b { color: var(--text); font-weight: 600; margin-right: 2px; }
.o-type {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 10px; color: var(--accent2); background: rgba(66, 133, 244, 0.08);
  border-radius: 4px; font-weight: 500; vertical-align: middle;
}

/* Typing */
.typing { display: none; padding: 6px 0; }
.typing.on { display: flex; align-items: center; gap: 8px; }
.ty-dots { display: flex; gap: 3px; }
.ty-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text3); animation: ty 1.4s infinite;
}
.ty-dots span:nth-child(2) { animation-delay: 0.2s; }
.ty-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ty {
  0%,60%,100% { transform:translateY(0); opacity:0.3; }
  30% { transform:translateY(-3px); opacity:1; }
}
.ty-lbl { font-size: 11px; color: var(--text3); }

/* ══════ Gate 面板（确认点配置）══════ */
.gate-panel {
  display: none; width: 290px; flex-direction: column;
}
/* 仅规则栏可手动拖大（picker 也带 gate-panel 类，不能一起改） */
#gateRulesPanel {
  resize: both; overflow: auto;
  min-width: 290px; max-width: 520px; min-height: 220px; max-height: 82vh;
}
.gate-panel-title {
  padding: 10px 12px 6px; font-size: 10px; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.gate-rules-list { max-height: 240px; overflow-y: auto; padding: 3px 0; flex: 1 1 auto; }
/* 摘要编辑器展开时解除列表视口上限——textarea 拖高不被列表裁住/＋号贴脸 */
.gate-rules-list:has(.gate-sum-cfg[style*="block"]) { max-height: none; }
.gate-rules-list::-webkit-scrollbar { width: 5px; }
.gate-rules-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.gate-rule-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; color: var(--text);
}
.gate-rule-row:hover { background: var(--bg); }
.gate-rule-label { flex: 1 1 auto; font-weight: 500; min-width: 0; font-size: 12px; }
.gate-rule-tool { font-size: 9px; color: var(--text3); font-family: monospace; margin-top: 1px; }
.gate-when, .gate-rounds, .gate-n-input {
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg2); color: var(--text);
  font-size: 10px; padding: 1px 4px; cursor: pointer;
  outline: none; font-family: inherit; flex-shrink: 0;
}
.gate-rule-remove {
  width: 18px; height: 18px; border: none; border-radius: 4px;
  background: transparent; color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.gate-rule-remove:hover { background: var(--bg4); color: var(--text); }
.gate-add-row {
  display: flex; align-items: center; justify-content: center;
  padding: 8px 12px; color: var(--text3); cursor: pointer;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.gate-add-row svg { width: 14px; height: 14px; }
.gate-add-row:hover { background: var(--bg); color: var(--text2); }
.gate-picker { width: 260px; }
.gate-picker-search {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  color: var(--text3); flex-shrink: 0;
}
.gate-picker-search input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 12px; color: var(--text); font-family: inherit;
}
.gate-picker-search input::placeholder { color: var(--text3); }
.gate-picker-list { max-height: 200px; overflow-y: auto; padding: 3px 0; flex: 1 1 auto; }
.gate-picker-list::-webkit-scrollbar { width: 5px; }
.gate-picker-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.gate-picker-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; cursor: pointer; color: var(--text);
}
.gate-picker-item:hover { background: var(--bg); }
.gate-picker-label { flex: 1 1 auto; font-size: 12px; }
.gate-picker-tool { font-size: 9px; color: var(--text3); font-family: monospace; }

.gate-sum-cfg { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px; border-top: 1px dashed var(--border); background: var(--bg2); }
.gate-sum-cfg select {
  border: 1px solid var(--border); border-radius: 5px; background: var(--bg2);
  color: var(--text); font-size: 12px; padding: 4px 8px; outline: none; font-family: inherit;
}
.gate-sum-cfg .gate-sum-ta {
  width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg1, #fff); color: var(--text); font-size: 12px; line-height: 1.5;
  padding: 7px 9px; outline: none; font-family: inherit; resize: vertical;
  min-height: 56px; max-height: 260px;
}
/* 编辑器展开时给底部加缓冲，textarea 拖高不被＋号行贴住 */
.gate-sum-cfg { padding-bottom: 14px; }
.gate-sum-cfg .gate-sum-ta:focus { border-color: var(--accent); }

.gate-var-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.gate-var-lbl { font-size: 10px; color: var(--text3); }
.gate-var-chip {
  font-size: 10.5px; font-family: ui-monospace, monospace; cursor: pointer;
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
  background: var(--bg2); color: var(--text2);
}
.gate-var-chip:hover { border-color: var(--accent); color: var(--accent); }
.gate-sum-example { font-size: 10px; color: var(--text3); font-family: ui-monospace, monospace; word-break: break-all; }

.gate-md-bar { display: flex; gap: 3px; }
.gate-md-btn {
  min-width: 24px; height: 20px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg2); color: var(--text2); font-size: 11px; cursor: pointer;
  font-family: inherit; padding: 0 5px; line-height: 1;
}
.gate-md-btn:hover { border-color: var(--accent); color: var(--accent); }

.gate-sum-bar { display: flex; align-items: center; gap: 6px; }
.gate-lang-select {
  border: 1px solid var(--border); border-radius: 5px; background: var(--bg2);
  color: var(--text); font-size: 11px; padding: 2px 6px; outline: none; font-family: inherit;
}
.gate-mode-ico {
  width: 22px; height: 22px; border: none; background: transparent;
  color: var(--text3); cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.gate-mode-ico:hover { color: var(--text2); }
.gate-mode-ico.active { color: var(--accent); }

/* ── hint 调试入口（feat/hint-injection，admin 专用，scene-override-btn 同款 DNA）── */
.hint-debug-btn {
  position: absolute; left: 88px; bottom: 10px; z-index: 3;
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: background 0.15s, color 0.15s;
}
.hint-debug-btn:hover { background: var(--bg3); color: var(--text); }
.hint-debug-btn svg { width: 17px; height: 17px; display: block; }
.hint-debug-btn.is-on { color: var(--orange); }
.hint-debug-btn .dot {
  position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange); border: 1.5px solid var(--bg2);
}
.hint-pop-mask { position: fixed; inset: 0; z-index: 200; display: none; }
.hint-pop-mask.open { display: block; }
.hint-pop {
  position: fixed; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; width: 264px; max-width: 92vw;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18); overflow: hidden;
  font-size: 12.5px; z-index: 201;
}
.hint-pop .hp-head {
  display: flex; align-items: center; padding: 9px 12px 7px; font-weight: 600;
}
.hint-pop .hp-close {
  margin-left: auto; background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 5px;
}
.hint-pop .hp-close:hover { background: var(--bg3); color: var(--text); }
.hint-pop .hp-body { padding: 0 12px 4px; }
.hint-pop .hp-textarea {
  width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 9px; font-size: 12.5px; font-family: inherit; outline: none;
  background: var(--bg); color: var(--text); min-height: 72px; max-height: 160px;
}
.hint-pop .hp-textarea:focus { border-color: var(--accent); }
.hint-pop .hp-meta {
  display: flex; justify-content: space-between; padding-top: 4px;
  font-size: 10.5px; color: var(--text3); min-height: 14px;
}
.hint-pop .hp-escape { color: #b45309; }
.hint-pop .hp-foot {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 5px 10px; border-top: 1px solid var(--border); margin-top: 6px;
}
.hint-pop .hp-reset {
  width: 26px; height: 26px; border: none; border-radius: 6px; background: transparent;
  color: var(--text3); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.hint-pop .hp-reset:hover { background: var(--bg); color: var(--text); }
