/* ==========================================
   aichat.css（v191.1）AI 全页对话
   —— 布局照搬笔记页（notes.css）：左侧会话列表 + 中线分隔 + 右侧对话区，无卡片
   —— 输入栏复刻旧版豆包风：大圆角输入框 + 右侧圆形三态按钮 + 下方功能行
   —— 消息区：用户右侧气泡；AI 左侧无气泡纯文本 + Markdown + 思考过程折叠
   —— 与悬浮球零关联：样式与数据皆独立
   ========================================== */

/* 移动端底栏：AI Chat 为低频入口，走玄关宫格（v144.3 IA 惯例） */
@media (max-width: 780px) {
  .sidebar .nav-link[data-view="aichat"] { display: none; }
}

/* ---------- 卡片页：规划中灰态（同教学锁定态） ---------- */
.game-card.aichat-soon { opacity: .55; cursor: default; }
.game-card.aichat-soon .game-ico {
  background: transparent; color: var(--text-faint); border: 1.5px solid var(--border);
}
[data-theme="dark"] .game-card.aichat-soon .game-ico { background: transparent; color: var(--text-faint); }
.game-card.aichat-soon:hover { border-color: var(--border); transform: none; box-shadow: none; }

/* ============================================================
   一、视图容器 + 左右两栏（照 notes-view / notes-side / notes-main）
   ============================================================ */
.app > .view.aichat-view {
  height: calc(100vh - var(--nav-height));
  height: calc(100dvh - var(--nav-height));
  overflow: hidden;
}
.aichat-view.active { display: flex; }

/* 左：会话列表栏（与笔记列表栏同宽、同分隔线） */
.ac-side {
  width: 248px; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: transparent;
  min-height: 0;
}
.ac-side-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding: 0 4px;
}
.ac-side-title { font-size: 14px; font-weight: 700; color: var(--text-main); }
.ac-new-btn {
  border: 1px solid var(--border); background: transparent; color: var(--text-sub);
  border-radius: var(--radius-sm); font-size: 12.5px; padding: 5px 11px;
  cursor: pointer; font-family: inherit;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.ac-new-btn:hover { background: var(--bg-hover-tint); color: var(--text-main); border-color: var(--text-sub); }
.ac-list {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  margin: 0 -6px; padding: 0 6px;
}
.ac-hint { font-size: 12px; color: var(--text-faint); line-height: 1.9; padding: 12px 6px; }
.ac-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background-color .15s ease; position: relative;
}
.ac-item:hover { background: var(--bg-hover-tint); }
.ac-item.active { background: var(--bg-hover-strong); }
.ac-item-main { flex: 1; min-width: 0; }
.ac-item-title {
  font-size: 13px; font-weight: 600; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-item-excerpt {
  font-size: 11.5px; color: var(--text-faint); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-item-time { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; opacity: .7; }
.ac-item-del {
  border: none; background: transparent; color: var(--text-faint);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 3px 5px;
  border-radius: 4px; display: none;
}
.ac-item:hover .ac-item-del { display: inline-block; }
.ac-item-del:hover { color: #e5484d; background: rgba(229, 72, 77, .1); }
.ac-item-edit {
  width: 100%; box-sizing: border-box; font-size: 13px; font-family: inherit;
  padding: 2px 6px; border: 1px solid var(--ring); border-radius: 6px;
  background: var(--bg-input); color: var(--text-main); outline: none;
}
/* v194.0：入场动画只在「真正进入这个视图」时播一次。
   原来挂在 .ac-item:first-child / .ac-msg / .ac-welcome 上，任何一次重排
   （切模式、新建对话、发消息后 renderBody）都会重播 —— 那就是「跳几下」的一半根因。 */
.ac-list.anim .ac-item:first-child { animation: acItemIn .28s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes acItemIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* 右：对话区（无卡片背景，靠中线区分） */
.ac-main {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; position: relative;
}
.ac-topbar {
  flex: none; height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
}
.ac-mback { display: none; }
.ac-title {
  flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-speed {
  flex: none; font-size: 12px; color: var(--text-faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ac-src {
  flex: none; font-size: 10.5px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px;
}

/* 消息滚动区 */
.ac-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 32px 10px; }

/* ============================================================
   二、消息（用户右侧气泡 / AI 左侧无气泡纯文本）
   ============================================================ */
.ac-msg-user, .ac-msg-ai {
  max-width: 780px; margin-left: auto; margin-right: auto;
}
/* v194.0：只有「本次真正新增」的消息才带入场动画（见 appendMsg 的 anim 参数） */
.ac-msg-user.ac-in, .ac-msg-ai.ac-in { animation: acMsgIn .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes acMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.ac-msg-user {
  display: flex; justify-content: flex-end; align-items: flex-end;
  gap: 6px; margin-bottom: 22px;
}
.ac-msg-user .ac-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;
}
.ac-bubble-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; max-width: 320px; white-space: nowrap;
}
.ac-bubble-file .ac-file-ico { flex-shrink: 0; width: 20px; height: 20px; color: var(--accent); }
.ac-bubble-file .ac-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.ac-bubble-file .ac-file-size { flex-shrink: 0; font-size: 12px; color: var(--text-faint); }
.ac-col-user {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 6px; max-width: 82%; min-width: 0;
}
.ac-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);
}
.ac-quote-block-label { font-weight: 600; color: var(--accent); font-size: 11px; }
.ac-quote-block-text {
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; word-break: break-word;
}

/* 消息操作按钮（hover 浮现） */
.ac-msg-tools, .ac-msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s ease; }
.ac-msg-user:hover .ac-msg-tools, .ac-msg-ai:hover .ac-msg-actions { opacity: 1; }
.ac-msg-actions { margin-top: 6px; padding-left: 2px; }
.ac-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 .15s ease, color .15s ease;
}
.ac-tool-btn svg { width: 14px; height: 14px; }
.ac-tool-btn:hover { background: var(--bg-hover-strong); color: var(--text-main); }
.ac-tool-btn.flashed { width: auto; padding: 0 6px; font-size: 11px; font-weight: 600; color: var(--accent); }

/* AI 消息：左侧无气泡纯文本 */
.ac-msg-ai { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 22px; }
.ac-aibody { width: 100%; font-size: 15px; line-height: 1.75; word-break: break-word; }

/* Markdown 内容 */
.ac-aibody p { margin: 0 0 .6em; }
.ac-aibody p:last-child { margin-bottom: 0; }
.ac-aibody h1.md-h, .ac-aibody h2.md-h, .ac-aibody h3.md-h, .ac-aibody h4.md-h {
  font-weight: 700; line-height: 1.4; margin: 1.1em 0 .45em; color: var(--text-main);
}
.ac-aibody h1.md-h { font-size: 19px; }
.ac-aibody h2.md-h { font-size: 17px; }
.ac-aibody h3.md-h { font-size: 16px; }
.ac-aibody h4.md-h { font-size: 15px; }
.ac-aibody blockquote {
  margin: .6em 0 .9em; padding: .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);
}
.ac-aibody ul, .ac-aibody ol { margin: .4em 0 .9em; padding-left: 1.4em; }
.ac-aibody li { margin: .25em 0; }
.ac-aibody li.task { list-style: none; position: relative; padding-left: 1.2em; }
.ac-aibody li.task::before {
  content: ""; position: absolute; left: 0; top: .35em;
  width: 12px; height: 12px; border: 1.5px solid var(--text-faint);
  border-radius: 3px; box-sizing: border-box;
}
.ac-aibody li.task.done::before { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--bg-code); }
.ac-aibody hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.ac-aibody a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.ac-aibody a:hover { border-bottom-color: var(--accent); }
.ac-aibody code {
  background: var(--inline-code-tint); border-radius: 5px; padding: 2px 6px;
  font-size: 13px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.ac-aibody pre {
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; margin: .4em 0 .9em;
  font-size: 13px; line-height: 1.6;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.ac-aibody pre code { background: none; padding: 0; display: block; padding: 10px 14px; overflow-x: auto; }
.ac-aibody .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, .07);
}
.ac-aibody .md-code-lang { font-size: 11px; letter-spacing: .4px; color: var(--text-sub); }
.ac-aibody .md-code-ops { display: inline-flex; align-items: center; gap: 2px; }
.ac-aibody .md-code-copy, .ac-aibody .md-code-run {
  border: none; background: transparent; color: var(--text-faint); font-size: 11px;
  cursor: pointer; padding: 2px 8px; border-radius: 4px; font-family: inherit;
  transition: background-color .15s ease, color .15s ease;
}
.ac-aibody .md-code-run { color: var(--accent); font-weight: 600; }
.ac-aibody .md-code-copy:hover, .ac-aibody .md-code-run:hover { background: var(--inline-code-tint); color: var(--text-main); }
.ac-aibody .md-code-badge {
  font-size: 10px; line-height: 1; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 99px; padding: 2px 7px;
}
.ac-aibody .md-table { overflow-x: auto; margin: .6em 0 1em; }
.ac-aibody table { border-collapse: collapse; width: 100%; font-size: 13px; }
.ac-aibody th, .ac-aibody td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.ac-aibody th { background: var(--bg-code); font-weight: 600; }
/* 公式 */
.ac-aibody .md-formula {
  text-align: center; margin: .6em 0 .9em;
  font-family: "Cambria Math", "Times New Roman", serif; font-size: 15px; color: var(--text-main);
}
.ac-aibody .md-formula-inline { font-family: "Cambria Math", "Times New Roman", serif; color: var(--text-main); }
.ac-aibody .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 2px; font-style: normal; }
.ac-aibody .frac-n { border-bottom: 1px solid currentColor; padding: 0 3px; }
.ac-aibody .frac-d { padding: 0 3px; }
.ac-aibody .sqrt-body { border-top: 1px solid currentColor; padding: 0 3px; }

/* 流式显现动画 */
.ac-aibody .tok { opacity: 0; animation: acTokIn .22s ease-out forwards; }
.ac-aibody .fade-in { animation: acStreamIn .3s ease both; }
@keyframes acTokIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
@keyframes acStreamIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 思考过程折叠 */
.ac-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;
}
.ac-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;
}
.ac-reason summary::-webkit-details-marker { display: none; }
.ac-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 .2s ease;
}
.ac-reason[open] summary::before { transform: rotate(90deg); }
.ac-reason summary:hover { color: var(--text-main); }
.ac-reason-body { padding: 0 0 12px; color: var(--text-sub); line-height: 1.7; }
.ac-reason-body p { margin: 0 0 .5em; }
.ac-reason-body p:last-child { margin-bottom: 0; }

/* 错误提示 */
.ac-err { color: #d64545; font-size: 13px; font-style: italic; }

/* 空态（居中 logo + 提示 + 示例问题） */
.ac-welcome {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  padding-bottom: 60px; max-width: none; margin: 0;
}
.ac-body.anim .ac-welcome { animation: acMsgIn .35s cubic-bezier(.2, .8, .2, 1) both; }
.ac-welcome-logo {
  width: 46px; height: 46px; display: grid; place-items: center;
  color: #fff; background: var(--grad-accent); border-radius: 14px;
  box-shadow: 0 8px 24px var(--shadow-glow);
}
.ac-welcome-logo svg { width: 22px; height: 22px; }
.ac-welcome-text { font-size: 14px; color: var(--text-faint); }
.ac-sugg { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 4px; }
.ac-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 .15s ease, color .15s ease, background-color .15s ease;
}
.ac-chip:hover { border-color: var(--ring); color: var(--text-main); background: var(--bg-hover-tint); }

/* ============================================================
   三、输入栏（复刻旧版：大圆角框 + 圆形三态按钮 + 功能行）
   ============================================================ */
.ac-input-area {
  flex: none; width: 100%; max-width: 844px; margin: 0 auto;
  padding: 4px 32px 18px; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ac-input-row { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; }
.ac-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;
  transition: border-color .15s ease, box-shadow .2s ease, background-color .3s ease;
}
.ac-input-wrap:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px var(--accent-soft); }
.ac-input-wrap textarea {
  /* v191.3 修：原来是 flex:1（flex-basis:0），高度被压成一两行，字多了看不全。
     改为按内容自然增高，高度交给 JS 的 autosize() 控制。 */
  flex: none; width: 100%; box-sizing: border-box;
  border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 15px; line-height: 1.6; color: var(--text-main);
  min-height: 26px; max-height: 260px; padding: 5px 0;
}
.ac-input-wrap textarea::placeholder { color: var(--text-faint); }

/* 圆形三态按钮：空=麦克风 / 有字=发送 / 流式=停止 */
.ac-send {
  flex-shrink: 0; display: grid; place-items: center; width: 36px; height: 36px;
  border: none; border-radius: 50%; background: var(--grad-accent); color: #fff;
  cursor: pointer; box-shadow: 0 3px 10px var(--shadow-glow);
  transition: opacity .15s ease, box-shadow .25s ease, transform .15s ease;
}
.ac-send svg { width: 17px; height: 17px; }
.ac-send:hover:not(:disabled) { box-shadow: 0 4px 14px var(--shadow-glow); transform: translateY(-1px); }
.ac-send:active:not(:disabled) { transform: translateY(0); }
.ac-send.listening { animation: acMicPulse 1.2s ease-in-out infinite; }
@keyframes acMicPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--shadow-glow); }
  50% { box-shadow: 0 0 0 6px var(--accent-soft); }
}

/* 功能行：输入框正下方，左对齐 */
.ac-tools { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 4px 6px; width: 100%; }
.ac-plus {
  display: grid; place-items: center; width: 28px; height: 28px;
  border: none; border-radius: 50%; background: transparent;
  color: var(--text-sub); cursor: pointer;
  transition: background-color .15s ease, color .15s ease, transform .2s ease;
}
.ac-plus svg { width: 16px; height: 16px; transition: transform .2s ease; }
.ac-plus:hover { background: var(--bg-hover-tint); color: var(--text-main); }
.ac-plus.rotated svg { transform: rotate(45deg); }
.ac-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 .15s ease, color .15s ease;
}
.ac-tool svg { width: 14px; height: 14px; }
.ac-tool:hover { background: var(--bg-hover-tint); color: var(--text-main); }
.ac-tool.on { color: var(--accent); background: var(--accent-soft); }
.ac-ctx-btn { display: inline-flex; align-items: center; gap: 3px; padding: 4px 9px; }
.ac-ring-svg { width: 18px; height: 18px; transform: rotate(-90deg); }
.ac-ring-bg { fill: none; stroke: var(--border); stroke-width: 2.5; }
.ac-ring-fg { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.ac-pct { min-width: 22px; text-align: left; font-size: 9px; font-weight: 600; color: var(--text-sub); font-variant-numeric: tabular-nums; }

/* 弹出菜单（+ / 引用笔记 / 上下文面板） */
.ac-pop-wrap { position: relative; display: inline-flex; }
.ac-pop {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px; min-width: 150px;
  box-shadow: 0 8px 28px rgba(15, 15, 15, .14); z-index: 60;
}
.ac-pop[hidden] { display: none; }
.ac-pop-opt {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent; color: var(--text-sub);
  font-size: 13px; font-family: inherit; padding: 7px 10px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background-color .12s ease, color .12s ease;
}
.ac-pop-opt:hover { background: var(--bg-hover-tint); color: var(--text-main); }
.ac-note-ref { min-width: 200px; max-width: 280px; max-height: 300px; overflow-y: auto; }

/* 引用条（内嵌输入框顶部） */
.ac-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);
}
.ac-quote-bar[hidden] { display: none; }
.ac-quote-bar-label { flex-shrink: 0; padding: 1px 6px; background: var(--accent-soft); color: var(--accent); border-radius: 5px; font-size: 10px; }
.ac-quote-bar-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-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; }
.ac-quote-bar-close:hover { color: var(--text-main); background: var(--bg-hover-tint); }

/* 上下文详情浮层 */
.ac-ctx-panel {
  position: absolute; left: 0; bottom: calc(100% + 8px); width: 272px; z-index: 80;
  padding: 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 18px 44px rgba(15, 15, 15, .22);
}
.ac-ctx-panel[hidden] { display: none; }
.ac-ctx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ac-ctx-cell { display: flex; flex-direction: column; gap: 1px; padding: 7px 9px; border-radius: var(--radius-sm); background: var(--bg-hover-tint); }
.ac-ctx-num { font-size: 12.5px; font-weight: 600; color: var(--text-main); font-variant-numeric: tabular-nums; }
.ac-ctx-rate { color: var(--accent); font-size: 14px; }
.ac-ctx-lbl { font-size: 10px; color: var(--text-faint); }
.ac-ctx-bar-wrap { margin-top: 12px; }
.ac-ctx-bar { display: flex; gap: 2px; height: 8px; border-radius: 999px; background: var(--bg-hover-tint); overflow: hidden; }
.ac-ctx-seg { height: 100%; border-radius: 999px; }
.ac-ctx-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 10.5px; color: var(--text-faint); }
.ac-ctx-legend .lg { display: inline-flex; align-items: center; gap: 4px; }
.ac-ctx-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ============================================================
   四、移动端（≤780px）：左列表全屏，对话区覆盖层（照 notes 做法）
   ============================================================ */
@media (max-width: 780px) {
  .ac-side { width: 100%; border-right: none; }
  .ac-main {
    position: absolute; inset: 0; z-index: 6;
    background: var(--bg-page);
    display: none; flex-direction: column;
  }
  .ac-main.m-open { display: flex; }
  .ac-mback {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; flex: none; border: none; background: transparent;
    color: var(--text-sub); cursor: pointer; border-radius: 8px; padding: 0;
    transition: background .15s ease;
  }
  .ac-mback:hover { background: var(--bg-hover-tint); }
  .ac-mback svg { width: 17px; height: 17px; }
  .ac-body { padding: 12px 14px 8px; }
  .ac-input-area { padding: 4px 14px 14px; }
}
@media (min-width: 781px) {
  .ac-mback { display: none; }
}

/* ============================================================
   五、动效兜底（铁律：reduced-motion / 界面动效开关）
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .ac-item, .ac-msg-user, .ac-msg-ai, .ac-welcome, .ac-aibody .tok, .ac-aibody .fade-in { animation: none !important; }
  .ac-side, .ac-plus svg { transition: none; }
}
html[data-motion="off"] .ac-item,
html[data-motion="off"] .ac-msg-user,
html[data-motion="off"] .ac-msg-ai,
html[data-motion="off"] .ac-welcome,
html[data-motion="off"] .ac-aibody .tok,
html[data-motion="off"] .ac-aibody .fade-in { animation: none !important; }
html[data-motion="off"] .ac-plus svg { transition-duration: .001s !important; }

/* ============================================================
   六、v191.2 增补：顶栏按钮 / Python 小终端 / 思考菜单选中 / 删除气泡
   ============================================================ */
.ac-top-btn {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-faint); cursor: pointer; padding: 6px;
  transition: background-color .15s ease, color .15s ease;
}
.ac-top-btn svg { width: 100%; height: 100%; }
.ac-top-btn:hover { background: var(--bg-hover-tint); color: var(--text-main); }

/* 思考模式菜单：选中项 */
.ac-pop-opt.sel { color: var(--accent); font-weight: 600; }
.ac-pop-opt.sel::after { content: "✓"; float: right; margin-left: 12px; }

/* Python 小终端：贴在代码块正下方 */
.ac-term {
  margin: -0.6em 0 1em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  overflow: hidden;
}
.ac-term-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-hover-tint);
  font-size: 11px; color: var(--text-sub);
}
.ac-term-close {
  border: none; background: transparent; color: var(--text-faint);
  font-size: 11px; cursor: pointer; padding: 2px 8px; border-radius: 4px; font-family: inherit;
}
.ac-term-close:hover { background: var(--inline-code-tint); color: var(--text-main); }
.ac-term-body {
  margin: 0; padding: 10px 14px; max-height: 260px; overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px; line-height: 1.6;
  color: var(--text-main); background: transparent;
  white-space: pre-wrap; word-break: break-word;
}

/* 删除确认气泡：沿用笔记同款外观，补一层不透明底色（笔记那版是 transparent） */
.ac-confirm {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
}
[data-theme="dark"] .ac-confirm { background: var(--bg-card); }

/* ============================================================
   七、v191.4 增补：对话模式切换（通用 / 写作 / 翻译）+ 笔记分隔线
   ============================================================ */
/* 当前模式徽章（9 个模式各自独立成页，靠它标明"你在哪一页"） */
.ac-mode-badge {
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

/* Markdown 分隔线（笔记与对话共用；MiniMD 的 <hr> 出口） */
.mm-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* ---------- v211.0 自定义提示词（点顶栏模型徽章下拉弹出） ---------- */
.ac-src-wrap { position: relative; }
.ac-src { cursor: pointer; transition: color .15s ease, border-color .15s ease; }
.ac-src:hover, .ac-src:focus-visible { color: var(--accent); border-color: var(--accent); }
.ac-src.sys-on { color: var(--accent); border-color: var(--accent); }
/* 顶栏的弹层往下弹（.ac-pop 默认向上，是给输入栏菜单用的） */
.ac-sys-pop {
  top: calc(100% + 10px); bottom: auto; left: auto; right: 0;
  width: min(320px, 86vw); padding: 14px 16px 12px;
  animation: acSysIn .2s ease both;
}
@keyframes acSysIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}
.ac-sys-head { display: flex; align-items: center; gap: 10px; }
.ac-sys-t { font-size: 13.5px; font-weight: 700; color: var(--text-main); }
.ac-sys-head .tt-switch { margin-left: auto; width: 44px; height: 26px; }
.ac-sys-head .tt-switch > i { width: 18px; height: 18px; top: 3px; left: 3px; }
.ac-sys-head .tt-switch.on > i { transform: translateX(18px); }
.ac-sys-tip {
  margin: 8px 0 0; font-size: 11.5px; line-height: 1.65; color: var(--text-sub);
}
/* 填写区折叠：grid 1fr↔0fr 两段式（v191.15 同款），开关切换带动画 */
.ac-sys-fold {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .28s cubic-bezier(.2, .8, .2, 1);
}
.ac-sys-fold.open { grid-template-rows: 1fr; }
.ac-sys-fold-in { overflow: hidden; min-height: 0; }
.ac-sys-ta {
  display: block; width: 100%; box-sizing: border-box; margin-top: 10px;
  resize: vertical; min-height: 96px; max-height: 260px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-hover-tint, transparent); color: var(--text-main);
  font-family: inherit; font-size: 12.5px; line-height: 1.7; padding: 9px 11px; outline: none;
  transition: border-color .15s ease;
}
.ac-sys-ta:focus { border-color: var(--accent); }
.ac-sys-ta::placeholder { color: var(--text-faint); }
.ac-sys-foot {
  display: flex; align-items: baseline; gap: 8px; margin-top: 6px;
  font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.ac-sys-foot-r { margin-left: auto; }
@media (prefers-reduced-motion: reduce) {
  .ac-sys-pop { animation: none; }
  .ac-sys-fold, .ac-sys-ta, .ac-src, .ac-sys-head .tt-switch, .ac-sys-head .tt-switch > i { transition: none; }
}
