/* ════════════════════════════════════════════════════════════════
   H3 Video Studio · 设计系统
   冷调近黑 + 单一锐利 azure 强调 · Clash Display / General Sans
   详见 DESIGN.md（reference-driven，禁止 AI 默认风）
   ════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════════
   H3 Video Studio · 设计系统
   冷调近黑 + 单一锐利 azure 强调 · Clash Display / General Sans
   详见 DESIGN.md（reference-driven，禁止 AI 默认风）

   主题：用 [data-theme="dark|light"] 切换；不指定时按系统 prefers-color-scheme
   默认深色，body/root 选择器即绑定 dark。所有硬编码颜色已替换为 token。
   ════════════════════════════════════════════════════════════════ */

:root,
[data-theme="dark"] {
  /* 颜色 — 90/10 权重 */
  --bg:            oklch(0.155 0.008 255);
  --bg-grad:       oklch(0.17 0.010 255);
  --surface:       oklch(0.21 0.008 255);
  --surface-2:     oklch(0.245 0.008 255);
  --surface-3:     oklch(0.28 0.008 255);
  --border:        oklch(1 0 0 / 0.09);
  --border-strong: oklch(1 0 0 / 0.16);
  --text:          oklch(0.96 0.004 255);
  --text-2:        oklch(0.72 0.008 255);
  --text-3:        oklch(0.55 0.010 255);
  --accent:        oklch(0.66 0.16 238);
  --accent-hi:     oklch(0.74 0.15 238);
  --accent-soft:   oklch(0.66 0.16 238 / 0.14);
  --accent-line:   oklch(0.66 0.16 238 / 0.40);
  --on-accent:     oklch(0.17 0.03 255);
  --danger:        oklch(0.62 0.19 25);
  --danger-soft:   oklch(0.62 0.19 25 / 0.14);
  --danger-bg:     oklch(0.62 0.19 25 / 0.10);
  --success:       oklch(0.72 0.16 150);
  --warn:          oklch(0.78 0.15 85);

  /* 主题级 token（深色专属） */
  --topbar-bg:     linear-gradient(180deg, oklch(0.19 0.008 255), oklch(0.165 0.008 255));
  --dot-pattern:   radial-gradient(oklch(1 0 0 / 0.05) 1px, transparent 1px);
  --shadow-1:      0 1px 2px rgba(0,0,0,.4);
  --shadow-2:      0 10px 34px rgba(0,0,0,.5);
  --mask-bg:       oklch(0.1 0.01 255 / 0.62);
  --selection-bg:  oklch(0.66 0.16 238 / 0.25);
  --toast-error-fg:oklch(0.82 0.14 25);
  --skel-color:    oklch(1 0 0 / 0.05);
  --hist-notice-bg:oklch(0.66 0.16 238 / 0.06);

  /* 对话气泡 / Markdown（Primer 语义前景/背景 + WCAG AA 对比度） */
  --msg-user-bg:     oklch(0.55 0.18 255);
  --msg-user-text:   oklch(0.99 0 0);
  --msg-ai-bg:       oklch(0.245 0.008 255);   /* surface-2，深色主题一级抬升 */
  --msg-ai-text:     oklch(0.94 0.005 255);
  --msg-ai-head:     oklch(0.98 0.003 255);
  --err-msg-bg:      oklch(0.22 0.05 25 / 0.5);
  --err-msg-text:    oklch(0.80 0.14 25);
  --err-msg-border:  oklch(0.62 0.19 25 / 0.45);
  --md-link:         oklch(0.74 0.15 238);
  --md-code-bg:      oklch(1 0 0 / 0.07);
  --md-code-text:    oklch(0.78 0.13 330);
  --md-quote-bg:     oklch(1 0 0 / 0.04);
  --md-quote-border: oklch(0.72 0.01 255);
  --md-quote-text:   oklch(0.68 0.008 255);
  --md-pre-bg:       oklch(0.13 0.008 255);
  --md-pre-text:     oklch(0.88 0.006 255);
  --md-table-border: oklch(1 0 0 / 0.12);
  --md-table-head:   oklch(1 0 0 / 0.06);
  --md-hr:           oklch(1 0 0 / 0.12);
  --md-del:          oklch(0.60 0.01 255);
  --focus-ring:      oklch(0.66 0.16 238 / 0.45);

  /* 画布导航（缩放栏 / 缩略图面板 / 返回提示）：深色圆角面板 · 细边框 · 内框描边 */
  --cn-nav-bg:       rgba(20, 22, 30, 0.94);
  --cn-nav-border:   oklch(1 0 0 / 0.12);
  --cn-nav-shadow:   0 8px 24px rgba(0, 0, 0, 0.45);
  --cn-minimap-bg:   rgba(9, 11, 17, 0.82);
  --cn-minimap-line: oklch(1 0 0 / 0.14);
  --cn-node-stroke:  rgba(255, 255, 255, 0.55);
  --cn-view-stroke:  #fff;
  --cn-view-fill:    rgba(255, 255, 255, 0.10);

  /* 字体 */
  --font-display: "Clash Display", "Space Grotesk", "PingFang SC", system-ui, sans-serif;
  --font-body:    "General Sans", "Plus Jakarta Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* 间距 / 圆角 */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s6: 24px;
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --topbar-h: 60px;

  /* 动效 */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.22s;
}

[data-theme="light"] {
  /* 底色：淡蓝白（视觉参考「淡蓝云雾 + 白卡片悬浮」的新拟态浅色风格） */
  --bg:            oklch(0.972 0.008 238);
  --bg-grad:       oklch(0.962 0.012 235);
  --surface:       oklch(1.00  0      0);   /* 卡片纯白 */
  --surface-2:     oklch(0.960 0.010 238);
  --surface-3:     oklch(0.938 0.014 236);
  --border:        oklch(0.30 0.05 250 / 0.10);
  --border-strong: oklch(0.30 0.05 250 / 0.18);
  --text:          oklch(0.215 0.018 250);  /* 主文字冷调深灰 */
  --text-2:        oklch(0.42  0.02  250);
  --text-3:        oklch(0.56  0.02  250);
  /* 主色：纯蓝（参考 #2563EB） */
  --accent:        oklch(0.52 0.20 262);
  --accent-hi:     oklch(0.44 0.21 264);
  --accent-soft:   oklch(0.52 0.20 262 / 0.09);
  --accent-line:   oklch(0.52 0.20 262 / 0.32);
  --on-accent:     oklch(0.99 0 0);
  --danger:        oklch(0.54 0.19 25);
  --danger-soft:   oklch(0.54 0.19 25 / 0.09);
  --danger-bg:     oklch(0.54 0.19 25 / 0.08);
  --success:       oklch(0.53 0.14 150);
  --warn:          oklch(0.62 0.14 75);

  /* 主题级 token（浅色专属）：半透明白顶栏透出云雾底、柔和蓝影 */
  --topbar-bg:     linear-gradient(180deg, oklch(1 0 0 / 0.82), oklch(0.975 0.010 240 / 0.72));
  --dot-pattern:   radial-gradient(oklch(0.30 0.05 250 / 0.045) 1px, transparent 1px);
  --shadow-1:      0 2px 8px rgba(80,110,190,.08), 0 1px 2px rgba(80,110,190,.04);
  --shadow-2:      0 18px 44px rgba(80,110,190,.14), 0 4px 14px rgba(80,110,190,.08);
  --mask-bg:       oklch(0.25 0.04 250 / 0.28);
  --selection-bg:  oklch(0.52 0.20 262 / 0.16);
  --toast-error-fg:oklch(0.50 0.20 25);
  --skel-color:    oklch(0.30 0.05 250 / 0.05);
  --hist-notice-bg:oklch(0.52 0.20 262 / 0.07);

  /* 对话气泡 / Markdown（浅色主题同 token 族） */
  --msg-user-bg:     oklch(0.55 0.18 255);
  --msg-user-text:   oklch(1 0 0);
  --msg-ai-bg:       oklch(0.955 0.008 240);
  --msg-ai-text:     oklch(0.21 0.018 250);
  --msg-ai-head:     oklch(0.16 0.015 250);
  --err-msg-bg:      oklch(0.95 0.03 25 / 0.6);
  --err-msg-text:    oklch(0.47 0.18 25);
  --err-msg-border:  oklch(0.62 0.19 25 / 0.35);
  --md-link:         oklch(0.45 0.19 262);
  --md-code-bg:      oklch(0.30 0.05 250 / 0.08);
  --md-code-text:    oklch(0.50 0.19 350);
  --md-quote-bg:     oklch(0.97 0.008 240);
  --md-quote-border: oklch(0.65 0.03 255);
  --md-quote-text:   oklch(0.42 0.02 250);
  --md-pre-bg:       oklch(0.17 0.01 255);
  --md-pre-text:     oklch(0.90 0.005 255);
  --md-table-border: oklch(0.30 0.05 250 / 0.16);
  --md-table-head:   oklch(0.93 0.012 240);
  --md-hr:           oklch(0.30 0.05 250 / 0.18);
  --md-del:          oklch(0.56 0.02 250);
  --focus-ring:      oklch(0.52 0.20 262 / 0.35);

  /* 画布导航（浅色）：白卡悬浮 · 细边框 · 柔和蓝影，结构与深色一致 */
  --cn-nav-bg:       rgba(255, 255, 255, 0.92);
  --cn-nav-border:   oklch(0.30 0.05 250 / 0.14);
  --cn-nav-shadow:   0 8px 24px rgba(80, 110, 190, 0.14), 0 2px 8px rgba(80, 110, 190, 0.08);
  --cn-minimap-bg:   oklch(0.955 0.008 240);
  --cn-minimap-line: oklch(0.30 0.05 250 / 0.16);
  --cn-node-stroke:  rgba(255, 255, 255, 0.9);
  --cn-view-stroke:  oklch(0.52 0.20 262);
  --cn-view-fill:    oklch(0.52 0.20 262 / 0.12);

  /* 主题切换按钮 hover 反馈略不同 */
  --topbar-h: 60px;
}

/* ── 浅色模式 · 新拟态增强（视觉参考：淡蓝云雾背景 + 白卡片柔和投影） ── */
[data-theme="light"] body {
  background:
    radial-gradient(1100px 760px at 88% -8%, oklch(0.93 0.05 235 / 0.50), transparent 62%),
    radial-gradient(900px 700px at -8% 18%, oklch(0.92 0.05 262 / 0.28), transparent 56%),
    radial-gradient(800px 640px at 50% 115%, oklch(0.95 0.04 220 / 0.38), transparent 60%),
    linear-gradient(180deg, oklch(0.99 0.006 240), oklch(0.96 0.014 236));
}
[data-theme="light"] .topbar { backdrop-filter: blur(6px); }
[data-theme="light"] .chat-input-card,
[data-theme="light"] .attach-tray,
[data-theme="light"] .media-params,
[data-theme="light"] .task-item,
[data-theme="light"] .oss-lib-item,
[data-theme="light"] .drop-panel,
[data-theme="light"] .settings-actions {
  box-shadow: 0 2px 6px rgba(80,110,190,.06), 0 10px 28px rgba(80,110,190,.10);
}
[data-theme="light"] .task-item:hover {
  box-shadow: 0 4px 12px rgba(80,110,190,.10), 0 14px 36px rgba(80,110,190,.12);
}
/* 输入卡片聚焦：细蓝描边 + 轻柔蓝晕 */
[data-theme="light"] .chat-input-card:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px oklch(0.52 0.20 262 / 0.12), 0 10px 28px rgba(80,110,190,.10);
}
/* 主按钮「生成视频」：纯蓝 + 同色柔影，hover 加深 */
[data-theme="light"] .send-btn {
  box-shadow: 0 4px 14px oklch(0.52 0.20 262 / 0.28);
}
[data-theme="light"] .send-btn:hover:not(:disabled) {
  box-shadow: 0 8px 22px oklch(0.52 0.20 262 / 0.32);
}
/* 输入框聚焦：纯蓝环 */
[data-theme="light"] .input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.52 0.20 262 / 0.12);
}
/* 次要操作按钮：边框细化更利落 */
[data-theme="light"] .mp-upload,
[data-theme="light"] .drop-btn,
[data-theme="light"] .ghost-btn,
[data-theme="light"] .icon-act,
[data-theme="light"] .modal-close { border-color: var(--border-strong); }
/* 弹窗：更柔和的白色投影层级 */
[data-theme="light"] .modal {
  box-shadow: 0 28px 70px rgba(80,110,190,.16), 0 6px 18px rgba(80,110,190,.08);
}

/* ═══════════ 深色模式 · 冷调层次增强（与浅色新拟态同构，保持双主题平衡） ═══════════ */
/* 深色背景：极淡冷蓝光晕分层（低饱和、非紫蓝渐变），打破纯平近黑 */
[data-theme="dark"] body,
:root:not([data-theme="light"]) body {
  background:
    radial-gradient(920px 640px at 86% -12%, oklch(0.42 0.07 250 / 0.13), transparent 58%),
    radial-gradient(760px 560px at -8% 20%,  oklch(0.36 0.05 255 / 0.09), transparent 56%),
    radial-gradient(700px 520px at 50% 118%, oklch(0.30 0.03 255 / 0.08), transparent 62%),
    var(--bg);
}
/* 深色顶栏：半透明透出冷光，与浅色对齐的轻盈感 */
[data-theme="dark"] .topbar,
:root:not([data-theme="light"]) .topbar {
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, oklch(0.21 0.009 255 / 0.88), oklch(0.165 0.008 255 / 0.84));
}
/* 深色大卡片：仅两大卡片给克制的悬浮阴影（border 与 shadow 不叠加铺满，遵循「层次只给需要的地方」） */
[data-theme="dark"] .chat-input-card,
:root:not([data-theme="light"]) .chat-input-card,
[data-theme="dark"] .tasks-card,
:root:not([data-theme="light"]) .tasks-card {
  box-shadow: 0 1px 2px rgba(0,0,0,.28), 0 6px 18px rgba(0,0,0,.16);
}
[data-theme="dark"] .chat-input-card:focus-within,
:root:not([data-theme="light"]) .chat-input-card:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px oklch(0.66 0.16 238 / 0.10), 0 6px 18px rgba(0,0,0,.16);
}
/* 深色任务卡片 hover：补一层轻影增强层级（原有边框变化之上） */
[data-theme="dark"] .task-item:hover,
:root:not([data-theme="light"]) .task-item:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,.22);
}
/* 深色输入控件聚焦：细蓝环 + 轻影（与浅色聚焦视觉对齐） */
[data-theme="dark"] .input-wrap input:focus,
:root:not([data-theme="light"]) .input-wrap input:focus,
[data-theme="dark"] .cfg-input:focus,
:root:not([data-theme="light"]) .cfg-input:focus,
[data-theme="dark"] .cfg-select:focus,
:root:not([data-theme="light"]) .cfg-select:focus,
[data-theme="dark"] .cfg-num:focus,
:root:not([data-theme="light"]) .cfg-num:focus,
[data-theme="dark"] .cfg-textarea:focus,
:root:not([data-theme="light"]) .cfg-textarea:focus {
  box-shadow: 0 0 0 3px oklch(0.66 0.16 238 / 0.10);
}

/* ═══════════ 浅色模式 · 细节打磨（聚焦聚拢、滚动条与状态对齐） ═══════════ */
/* 浅色：顶部主光晕更聚拢，让焦点自然落到输入区；底部光晕降一档避免发灰 */
[data-theme="light"] body {
  background:
    radial-gradient(900px 620px at 88% -6%,  oklch(0.93 0.05 235 / 0.55), transparent 60%),
    radial-gradient(760px 580px at -6% 16%,  oklch(0.92 0.05 262 / 0.30), transparent 54%),
    radial-gradient(700px 520px at 50% 118%, oklch(0.95 0.04 220 / 0.28), transparent 62%),
    linear-gradient(180deg, oklch(0.995 0.005 240), oklch(0.96 0.014 236));
}
/* 浅色：细滚动条统一用冷灰（与深色细滚动条对应），不抢视觉 */
[data-theme="light"] .left-col::-webkit-scrollbar-thumb,
[data-theme="light"] .task-list::-webkit-scrollbar-thumb,
[data-theme="light"] .modal-body::-webkit-scrollbar-thumb {
  background: oklch(0.35 0.04 250 / 0.22);
}

/* 统一：图标容器内的面形 SVG 尺寸（去 emoji 化后保证视觉一致） */
.attach-thumb svg          { width: 15px; height: 15px; color: var(--text-3); }
.attach-bed-badge svg      { width: 11px; height: 11px; vertical-align: -1px; display: inline-block; }
.at-ico svg                { width: 13px; height: 13px; }
.oss-lib-thumb svg         { width: 19px; height: 19px; }
.tok-tip-ph svg,
.at-tip-ph svg             { width: 15px; height: 15px; opacity: .7; }
.thumb-badge svg            { width: 10px; height: 10px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  /* 左侧导航栏 + 右上顶栏 + 右下主区 的栅格骨架 */
  display: grid;
  grid-template-columns: var(--sidebar-w, 196px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "sb main";
  transition: grid-template-columns .22s var(--ease);
}
body.sidebar-collapsed { --sidebar-w: 64px; }

/* ═══════════ 左侧导航栏（可折叠） ═══════════ */
.sidebar {
  grid-area: sb;
  display: flex; flex-direction: column;
  width: var(--sidebar-w, 196px); min-width: 0;
  height: calc(100dvh - var(--topbar-h));
  background: var(--topbar-bg);
  border-right: 1px solid var(--border);
  position: sticky; top: 0;
  z-index: 8;
  overflow: hidden;
  transition: width .22s var(--ease);
}
.sidebar-head { display: flex; align-items: center; justify-content: center; padding: 16px 12px 10px; flex: none; }
.sidebar-logo {
  width: 34px; height: 34px; flex: none; overflow: hidden;
  border-radius: 9px;
  box-shadow: 0 2px 10px var(--accent-soft);
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-collapse {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 13.5px;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.sidebar-collapse:hover { background: var(--surface-2); color: var(--text); }
.sidebar-collapse svg { display: block; flex: none; transition: transform .22s var(--ease); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.side-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 13.5px;
  position: relative; overflow: hidden;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active {
  background: linear-gradient(90deg, oklch(0.62 0.18 255 / .17), oklch(0.62 0.18 255 / .045) 72%, transparent);
  color: var(--text); border-color: oklch(0.62 0.18 255 / .16);
}
.side-item.active::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 16px;
  transform: translateY(-50%); border-radius: 0 4px 4px 0; background: var(--accent);
  box-shadow: 0 0 10px oklch(0.62 0.18 255 / .5);
}
.side-item.active .side-ico { color: var(--accent); opacity: 1; filter: drop-shadow(0 0 6px oklch(0.62 0.18 255 / .28)); }
.side-item.active .side-label { font-weight: 600; }
.side-item .side-ico { flex: none; opacity: .92; }
.side-item .side-ico svg { display: block; }
.side-label { flex: 1 1 auto; text-align: left; white-space: nowrap; overflow: hidden; }
.side-check { flex: none; font-size: 12px; font-weight: 700; color: var(--accent); }
.side-tag {
  flex: none; font-size: 9.5px; line-height: 1;
  color: var(--text-3); border: 1px solid var(--border); border-radius: 999px; padding: 2px 5px;
}
.side-item.is-soon:hover { color: var(--text-3); }

.sidebar-foot { flex: none; padding: 6px 8px 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.sidebar-ver { font-size: 10.5px; font-family: var(--font-mono); color: var(--text-3); text-align: center; margin-top: 5px; }

/* 折叠态：只保留图标列 */
body.sidebar-collapsed .side-label,
body.sidebar-collapsed .side-tag,
body.sidebar-collapsed .sidebar-ver { display: none; }
body.sidebar-collapsed .sidebar-head { justify-content: center; padding: 14px 8px 6px; }
body.sidebar-collapsed .sidebar-collapse { justify-content: center; padding: 10px 0; }
body.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
body.sidebar-collapsed .side-item { justify-content: center; padding: 10px 0; }
body.sidebar-collapsed .side-check { display: none; }
/* 极淡点阵底纹（中性、非彩色，避免渐变 blob 嫌疑） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--dot-pattern);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 30%, transparent 100%);
}
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); }
::selection { background: var(--accent-soft); color: var(--text); }

/* 全局焦点环（键盘可达性） */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ═══════════ 顶栏 ═══════════ */
.topbar {
  grid-area: top;
  position: relative; z-index: 5;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
}
.topbar-inner {
  height: 100%;
  padding: 0 var(--s4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.5px;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 9px;
  box-shadow: 0 2px 10px var(--accent-soft);
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 9px; }
.brand-text { min-width: 0; }
.brand-title {
  font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.conn-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}
.conn-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.conn-badge.on .dot { background: var(--success); box-shadow: 0 0 0 3px oklch(0.72 0.16 150 / 0.18); }
.conn-badge.off .dot { background: var(--danger); box-shadow: 0 0 0 3px oklch(0.62 0.19 25 / 0.18); animation: pulse-dot 1.8s ease-in-out infinite; }
.conn-badge.off { cursor: pointer; border-color: var(--danger-soft); color: var(--danger); }
.conn-badge.off:hover { background: var(--danger-soft); }
/* 待验证：已填 key 但还没点过检查（灰点无 pulse，区别于无效的红色 pulse） */
.conn-badge.pending .dot { background: var(--text-3); box-shadow: 0 0 0 3px oklch(1 0 0 / 0.06); }
.conn-badge.pending { cursor: pointer; border-color: var(--border); color: var(--text-2); }
.conn-badge.pending:hover { background: var(--surface-2); }
/* 校验无效（红点 + 红字 + 红边 + pulse 与「未设置」视觉一致但更醒目） */
.conn-badge.invalid .dot { background: var(--danger); box-shadow: 0 0 0 3px oklch(0.62 0.19 25 / 0.18); animation: pulse-dot 1.8s ease-in-out infinite; }
.conn-badge.invalid { cursor: pointer; border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.conn-badge.invalid:hover { background: var(--danger-soft); }
/* 自动校验进行中：蓝点 + 旋转描边环 + 蓝字（不打扰用户） */
.conn-badge.checking .dot { background: var(--accent); box-shadow: 0 0 0 3px oklch(0.72 0.13 238 / 0.22); }
.conn-badge.checking { cursor: default; border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.conn-badge.checking .dot { position: relative; }
.conn-badge.checking .dot::after {
  content: ""; position: absolute; inset: -4px; border: 1.5px solid var(--accent);
  border-top-color: transparent; border-radius: 50%;
  animation: spin-dot 0.9s linear infinite;
}
@keyframes spin-dot { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
/* 余额标签（顶栏，连接徽章右侧） */
.balance-badge {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.3px;
  color: var(--text-2);
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.balance-badge:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.balance-badge b { font-weight: 500; color: var(--text); }
.balance-badge.warn b { color: var(--warn); }
.balance-badge.danger b { color: var(--danger); }
.balance-badge.loading b { opacity: 0.4; }
.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; font-size: 16px;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
/* 主题切换按钮（与 icon-btn 同款，激活态用 accent 描边） */
.theme-toggle.is-active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }
[data-theme="dark"]  .theme-toggle .icon-moon,
:root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* ═══════════ 布局 ═══════════ */
.layout {
  grid-area: main;
  position: relative; z-index: 1;
  padding: var(--s4) var(--s4) var(--s4);
  display: grid; grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--s4);
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
}
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  body { overflow: auto; }
}

/* ═══════════ 响应式 · 平板（≤900） ═══════════ */
@media (max-width: 900px) {
  :root { --topbar-h: 56px; }
  /* 顶栏：brand 与右侧分两行（次级信息收起隐藏，避免挤爆） */
  .topbar-inner { flex-wrap: wrap; gap: 8px; padding: 6px 12px; height: auto; min-height: var(--topbar-h); }
  .brand { flex: 0 1 auto; min-width: 0; }
  .topbar-right { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .conn-badge .conn-text { font-size: 11.5px; }
  /* 副标题在 ≤720 才隐藏，平板仍显示 */
}

/* ═══════════ 响应式 · 手机（≤720） ═══════════ */
@media (max-width: 720px) {
  /* 侧边栏：移动端固定定位，不随内容滚动；强制图标模式，不管展开状态 */
  .sidebar { position: fixed; left: 0; top: 0; height: 100dvh; z-index: 10; overflow: hidden; }
  body { --sidebar-w: 64px; }
  body.sidebar-collapsed { --sidebar-w: 52px; }
  .sidebar .side-label, .sidebar .sidebar-ver, .sidebar .side-tag, .sidebar .side-check { display: none !important; }
  .sidebar .side-item { justify-content: center; padding: 14px 0; }
  .sidebar .sidebar-head { justify-content: center; padding: 14px 0; }
  .sidebar .sidebar-logo img { width: 32px; height: 32px; }
  .sidebar .sidebar-collapse { justify-content: center; padding: 14px 0; }
  .sidebar .sidebar-foot { align-items: center; gap: 4px; padding: 7px 0 10px; }
  .sidebar .soon-badge { display: none; }
  /* —— 顶栏：标题与右上角控制（连接点/余额/主题/设置）同一行，避免第二行压住附件区 —— */
  .topbar-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    gap: 8px;
  }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-sub { display: none; }              /* 副标"黄鑫波"在手机太挤，省略 */
  .brand-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right {
    flex: 0 0 auto;
    flex-wrap: nowrap;                       /* 同一行不换行 */
    justify-content: flex-end;               /* 靠右上角 */
    gap: 6px;
  }
  .topbar-right > * { flex: 0 0 auto; min-width: 0; }
  /* 连接状态：只保留状态圆点（绿=已连接 / 灰=待验证 / 红=未设置或无效 / 蓝=验证中），点击可打开设置 */
  .conn-badge {
    width: 26px; height: 26px; padding: 0;
    border: none; background: transparent;
    display: grid; place-items: center;
    flex: 0 0 26px; cursor: pointer;
  }
  .conn-badge .conn-text { display: none; }
  .conn-badge .dot { width: 9px; height: 9px; }
  .balance-badge { font-size: 10.5px; padding: 3px 7px; gap: 3px; }
  .icon-btn { width: 28px; height: 28px; font-size: 13px; border-radius: 7px; flex: 0 0 28px; }

  /* —— 整体 padding 收紧 —— */
  .layout { padding: 10px; gap: 10px; }

  /* —— 附件条：芯片第一行 + 模式/计数换第二行 —— */
  .attach-tray { flex-direction: column; align-items: stretch; padding: 7px 9px; gap: 6px; transition: border-color .15s var(--ease), background .15s var(--ease); }
  .attach-tray.drag { border-color: var(--accent); background: var(--accent-soft); }
  .attach-meta { justify-content: space-between; }
  .attach-chips { max-height: 96px; overflow-y: auto; min-height: 22px; }
  .attach-tray.is-empty .attach-chips::before {
    content: "拖入或点击「全能参考」上传图片 / 音频 / 视频";
    color: var(--text-3); font-size: 11.5px; padding: 2px 4px; display: block;
  }

  /* —— 输入卡片：最小高度更小，给手机更多屏 —— */
  .chat-input-card { padding: 9px; border-radius: var(--r); }
  #prompt { min-height: 90px; font-size: 15px; }

  /* —— 参数行：固定两行结构，彻底解决乱排 —— */
  /*   第一行：参考图 / 参考音频 / 比例 / 时长 / 分辨率
     第二行：字数提示 + 立即生成（生成按钮 flex:1 占满右半，字数贴左） */
  .media-params {
    flex-wrap: wrap;
    padding: 8px 9px;
    gap: 7px;
  }
  .mp-upload, .mp-item { font-size: 12px; }
  .mp-upload { padding: 6px 9px; }
  .drop-btn.sm { padding: 6px 8px; font-size: 12px; }
  /* 用 order 让五个选项槽位排第一行；发送按钮强制第二行 */
  .mp-item:nth-of-type(1) { order: 1; }
  .mp-item:nth-of-type(2) { order: 2; }
  .mp-item:nth-of-type(3) { order: 3; }
  .mp-item:nth-of-type(4) { order: 4; }
  .mp-item:nth-of-type(5) { order: 5; }
  /* 第二行：发送。占满宽度 */
  .send-btn-wrap {
    order: 6;
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    gap: 8px;
  }
  .send-btn {
    flex: 1 1 auto;
    padding: 11px 14px;
    font-size: 14px;
  }
  .prompt-chars {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 4px 8px;
  }
  /* 清空按钮（罕见，隐藏即可） */
  .clear-prompt { display: none; }

  /* —— 卡片头 —— */
  .card-head { padding: 11px 12px; }
  .card-head h2 { font-size: 12.5px; }
  .ghost-btn { padding: 5px 8px; font-size: 11.5px; }

  /* —— 弹窗：全屏圆角小 —— */
  .modal-mask { padding: 0; }
  .modal {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100%;
    border-radius: 0;
    border: none;
  }
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px; }

  /* —— Toast：顶栏内水平垂直居中 —— */
  .toast-wrap { top: calc(var(--topbar-h) / 2); left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); align-items: center; max-width: calc(100vw - 20px); }
  .toast { max-width: 100%; text-align: left; }
}

/* ═══════════ 响应式 · 极窄手机（≤420） ═══════════ */
@media (max-width: 420px) {
  /* 参考图/音频按钮只显示图标 */
  .mp-upload { padding: 6px 7px; }
  .mp-upload span { display: none; }
  .mp-label { display: none; }              /* 比例/时长/分辨率标签在极窄屏省略，按钮本身就清楚 */
  .drop-btn.sm { padding: 6px 7px; }
  .send-btn { padding: 11px 10px; font-size: 13.5px; }
}

/* ═══════════ 左栏 ═══════════ */
.left-col {
  display: flex; flex-direction: column; gap: var(--s3); min-width: 0; min-height: 0;
  overflow-y: auto; padding-right: 2px;
}
.right-col { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* 附件条 */
.attach-tray {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface);
}
/* 附件区左侧上传入口：仅图标按钮（无文字，只有它能点击上传） */
.attach-upload-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 30px; height: 30px;
  border: 1px solid var(--accent-line); border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent);
  cursor: pointer; padding: 0;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.attach-upload-btn:hover { color: var(--accent-hi); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.attach-upload-btn svg { opacity: 1; }
.attach-title {
  font-family: var(--font-display); font-weight: 600; font-size: 12.5px;
  color: var(--text-3); letter-spacing: 0.2px;
  padding: 1px 8px; border: 1px dashed var(--border); border-radius: 999px;
  background: var(--bg);
}
.attach-chips { display: flex; gap: 7px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2);
  animation: chipIn var(--dur) var(--ease);
  cursor: pointer;
  position: relative;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.attach-chip:hover { border-color: var(--border-strong); background: var(--surface-3); }
.attach-chip.is-ref { border-color: var(--accent-line); }
.attach-chip.is-ref:hover { border-color: var(--accent); }
/* 刷新后从 localStorage 恢复的素材：File 已丢，仅作缩略图/记忆作用；淡虚线区分 */
.attach-chip.is-restored { border-color: var(--border); border-style: dashed; color: var(--text-3); }
.attach-chip.is-restored .attach-thumb { background: var(--bg); }
.attach-chip.no-thumb { border-style: dashed; }
/* 图片工作台刷新恢复：参考图未持久化（无 dataUrl / 未配置素材存储）时的占位提示 */
.attach-chip.is-ph { border-color: var(--warn-line, var(--border)); border-style: dashed; opacity: .85; }
.attach-chip.is-ph .attach-thumb { background: var(--surface-3); }
.attach-ph-tip { font-size: 10px; color: var(--warn, #b8872e); line-height: 1; }
.attach-thumb {
  width: 24px; height: 24px; border-radius: 6px; overflow: hidden; flex: none;
  background: var(--surface-3); display: grid; place-items: center;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* 名称默认隐藏（仅缩略图，节省空间）；悬停时以原生 title 提示，chip 边框高亮 */
.attach-name { display: none; }
/* 图床状态角标（⏳ 上传中 / ☁ 已上传 / ⚠ 失败 / ⛔ 禁用） */
.attach-bed-badge { font-size: 11px; margin-left: 4px; vertical-align: middle; line-height: 1; }
.attach-bed-badge.uploading { color: var(--text-3); animation: bedPulse 1.4s ease-in-out infinite; }
.attach-bed-badge.ok { color: var(--success); }
.attach-bed-badge.failed { color: var(--warn); }
.attach-bed-badge.disabled { color: var(--text-3); opacity: .6; }
@keyframes bedPulse { 50% { opacity: .35; } }
.attach-remove {
  border: none; background: transparent; color: var(--text-3); font-size: 11px;
  width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.attach-remove:hover { color: var(--danger); background: var(--danger-soft); }
.attach-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.input-mode-badge {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--accent-line);
}
.attach-count { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.attach-count b { color: var(--text); font-weight: 500; }
.attach-count .meta-sub { color: var(--text-3); font-size: 10.5px; margin-left: 2px; }
.attach-count .meta-sub.is-over { color: var(--danger); }

/* 首尾帧模式：首帧 / 尾帧上传槽（与全能参考上传入口同尺寸，小按钮 + 小缩略图） */
.keyframe-strip {
  display: flex; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface);
}
.kf-slot {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-2);
  padding: 5px 9px; border: 1px dashed var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.kf-slot:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.kf-label {
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
  color: var(--text-3); letter-spacing: 0.2px;
}
.kf-thumb {
  width: 34px; height: 34px; border-radius: 6px; overflow: hidden;
  display: grid; place-items: center; position: relative;
  background: var(--surface-3); flex: none;
}
.kf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kf-thumb.is-empty { border: 1px dashed var(--border); }
.kf-empty { font-size: 16px; color: var(--text-3); line-height: 1; }
.kf-remove {
  position: absolute; top: 2px; right: 2px;
  border: none; background: rgb(0 0 0 / 0.55); color: #fff;
  width: 16px; height: 16px; border-radius: 4px; cursor: pointer;
  display: grid; place-items: center; font-size: 9px; line-height: 1;
  transition: background var(--dur) var(--ease);
}
.kf-remove:hover { background: var(--danger); }

/* 主输入卡片 */
.chat-input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s3);
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.chat-input-card:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px oklch(0.66 0.16 238 / 0.08); }
/* 提示词框拖拽上传高亮 */
.chat-input-card.drag { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input-top { display: flex; align-items: stretch; gap: 8px; min-width: 0; height: 100%; }
.prompt-wrap { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-self: stretch; position: relative; }

#prompt {
  flex: 1 1 auto; min-height: 120px; width: 100%;
  resize: none; border: none; outline: none; background: transparent;
  color: var(--text); caret-color: var(--text); font-family: var(--font-body); font-size: 14.5px; line-height: 1.6;
  padding: 2px 4px;
}
#prompt::placeholder { color: var(--text-3); }
/* 自定义滚动条：暗色主题 */
#prompt::-webkit-scrollbar { width: 6px; }
#prompt::-webkit-scrollbar-track { background: transparent; }
#prompt::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
#prompt::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
/* 统一样式：所有 textarea / 长内容滚动容器共用一套细滚动条，与 .task-list / .modal-body 一致 */
textarea::-webkit-scrollbar,
.cfg-textarea::-webkit-scrollbar,
.at-pop::-webkit-scrollbar,
.chat-body::-webkit-scrollbar,
.sessions-list::-webkit-scrollbar,
.settings-body::-webkit-scrollbar { width: 8px; }
textarea::-webkit-scrollbar-track,
.cfg-textarea::-webkit-scrollbar-track,
.at-pop::-webkit-scrollbar-track,
.chat-body::-webkit-scrollbar-track,
.sessions-list::-webkit-scrollbar-track,
.settings-body::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb,
.cfg-textarea::-webkit-scrollbar-thumb,
.at-pop::-webkit-scrollbar-thumb,
.chat-body::-webkit-scrollbar-thumb,
.sessions-list::-webkit-scrollbar-thumb,
.settings-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
textarea::-webkit-scrollbar-thumb:hover,
.cfg-textarea::-webkit-scrollbar-thumb:hover,
.at-pop::-webkit-scrollbar-thumb:hover,
.chat-body::-webkit-scrollbar-thumb:hover,
.sessions-list::-webkit-scrollbar-thumb:hover,
.settings-body::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
/* Firefox 也走统一外观 */
textarea, .cfg-textarea, .at-pop, .chat-body, .sessions-list, .settings-body, .music-grid { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
/* 选区底色用主题半透明色，不覆盖文字颜色（由 JS syncSelOverlay 控制），避免与背景层文字叠加 */
#prompt::selection { background: var(--selection-bg); }
/* @ 高亮叠层 */
.prompt-backdrop { position: absolute; inset: 0; pointer-events: none; overflow: hidden; padding: 2px 4px; }
.bd-inner {
  font-family: var(--font-body); font-size: 14.5px; line-height: 1.6;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.tok { border-radius: 5px; padding: 0 3px; margin: 0 -3px; cursor: default; pointer-events: auto; }
.tok-pic { color: var(--accent); background: var(--accent-soft); }
.tok-vid { color: var(--accent); background: transparent; box-shadow: inset 0 0 0 1px var(--accent-line); }
.tok-aud { color: var(--accent); background: transparent; box-shadow: inset 0 0 0 1px var(--accent-line); }
.tok-file { color: var(--warn); background: transparent; box-shadow: inset 0 0 0 1px var(--accent-line); }
/* 视频 chip 超限提示（时长 2–15s 之外） */
.attach-chip.is-warn { border-color: var(--danger-soft); color: var(--danger); }
/* @ 弹窗 */
.at-pop {
  position: absolute; z-index: 30;
  min-width: 220px; max-height: 240px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-2); padding: 5px;
}
.at-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.at-item.active, .at-item:hover { background: var(--surface-3); color: var(--text); }
.at-item.empty { color: var(--text-3); cursor: default; justify-content: center; font-size: 12.5px; }
.at-ico { width: 22px; height: 22px; flex: none; display: grid; place-items: center; font-size: 13px;
  background: var(--surface-3); border-radius: 6px; }
/* @ 列表中的图片素材缩略图：直接显示参考图，选素材时一眼可辨 */
.at-thumb { width: 30px; height: 30px; flex: none; border-radius: 6px; overflow: hidden;
  background: var(--surface-3); display: grid; place-items: center; }
.at-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.at-label { font-size: 13px; }
.at-sub { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); }
/* @ 列表悬停预览（图片缩略图 / 视频首帧 / 音频波形） */
.at-tip {
  position: fixed; z-index: 60; max-width: 232px;
  display: flex; flex-direction: column; gap: 6px; padding: 7px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-2); pointer-events: none;
}
.at-tip[hidden] { display: none; }
.at-tip img { width: 216px; max-height: 122px; border-radius: var(--r-sm); object-fit: cover; display: block; }
.at-tip img.at-tip-wave { height: 56px; object-fit: fill; background: var(--surface-3); }
.at-tip-ph {
  width: 216px; height: 56px; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11.5px; color: var(--text-3); background: var(--surface-3); border-radius: var(--r-sm);
}
.at-tip-name { font-family: var(--font-mono); font-size: 11px; color: var(--text); word-break: break-all; }
/* token 悬浮提示（保持缩略图原始比例） */
.tok-tip {
  position: fixed; z-index: 60; pointer-events: none;
  display: none; flex-direction: column; gap: 6px; padding: 7px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-2); font-size: 12px; color: var(--text-2);
}
.tok-tip.show { display: flex; }
/* 缩略图保持原始宽高比：图片/视频首帧/音频波形；最大尺寸限制避免过大 */
.tok-tip .tok-tip-img { display: block; max-width: 240px; max-height: 180px; border-radius: var(--r-sm); object-fit: contain; background: var(--surface-3); }
/* 视频悬停预览：静音循环播放，保持原始比例 */
.tok-tip .tok-tip-vid { display: block; max-width: 240px; max-height: 180px; border-radius: var(--r-sm); object-fit: contain; background: var(--surface-3); }
/* 音频波形：固定 216x56，不裁切 */
.tok-tip .tok-tip-wave { width: 216px; height: 56px; object-fit: fill; border-radius: var(--r-sm); background: var(--surface-3); }
.tok-tip-ph {
  width: 216px; height: 56px; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11.5px; color: var(--text-3); background: var(--surface-3); border-radius: var(--r-sm);
}
.tok-tip-name { font-family: var(--font-mono); font-size: 11.5px; color: var(--text); }

/* ═══════════ 参数行（与发送按钮同一行） ═══════════ */
.media-params {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface);
}
.mp-upload {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2);
  padding: 7px 11px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.mp-upload:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.mp-upload svg { opacity: 0.8; }
/* 全能参考：作为统一上传入口更醒目 */
.mp-upload-all {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  font-weight: 600;
}
.mp-upload-all:hover { color: var(--accent-hi); border-color: var(--accent); background: var(--accent-soft); }
.mp-upload-all svg { opacity: 1; }
.mp-item { display: inline-flex; align-items: center; gap: 8px; }
.mp-label { font-size: 11.5px; color: var(--text-3); letter-spacing: 0.3px; }

/* 下拉 */
.dropdown { position: relative; }
.drop-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.drop-btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.drop-btn.sm { padding: 6px 9px; font-size: 12.5px; }
.drop-value { display: inline-flex; align-items: center; gap: 7px; }
.drop-arrow { font-size: 9px; color: var(--text-3); transition: transform var(--dur) var(--ease); }
.dropdown.open .drop-arrow { transform: rotate(180deg); }
.drop-panel {
  position: absolute; bottom: calc(100% + 7px); left: 0; z-index: 40;
  min-width: 180px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-2);
  display: none; animation: popIn var(--dur) var(--ease);
}
.dropdown.open .drop-panel { display: block; }
.drop-opt {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 10px; border: none; background: transparent; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.drop-opt:hover { background: var(--surface-3); color: var(--text); }
.drop-opt.active { color: var(--accent); }
.opt-name { flex: 1 1 auto; }
.opt-price { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.drop-opt.active .opt-price { color: var(--accent); opacity: .85; }
/* 分辨率档按钮（drop-value）内的内联单价 */
.opt-price-inline { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); opacity: .85; margin-left: 2px; }
.opt-check { color: var(--accent); opacity: 0; font-size: 12px; }
.drop-opt.active .opt-check { opacity: 1; }

/* 比例图标 */
.ratio-icon { width: 13px; height: 13px; border: 1.5px solid currentColor; border-radius: 2px; flex: none; display: inline-block; }
.ratio-icon.r9-16 { width: 9px; height: 13px; }
.ratio-icon.r16-9 { width: 13px; height: 9px; }
.ratio-icon.r1-1  { width: 12px; height: 12px; }
.ratio-icon.r21-9 { width: 13px; height: 6px; }
.ratio-icon.r4-3  { width: 12px; height: 9px; }
.ratio-icon.r3-4  { width: 9px; height: 12px; }
.ratio-icon.auto  { border: none; font-size: 12px; line-height: 1; }

/* 字数提示（提示词框内右下角，默认隐藏：仅内容变更或超限时显示） */
.prompt-chars {
  position: absolute; right: 8px; bottom: 6px; z-index: 12;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.3px;
  color: var(--text-3);
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2);
  white-space: nowrap;
  pointer-events: none;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.prompt-chars.over {
  color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft);
  animation: charsWarn 1.5s ease-in-out infinite;
}
@keyframes charsWarn { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* 发送按钮（参数行右端）：文字形式，busy 时置灰不可点并显示加载点 */
.send-btn-wrap { margin-left: auto; flex: none; display: flex; align-items: center; gap: 10px; padding-left: 2px; }
.send-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600; letter-spacing: 0.2px;
  color: var(--on-accent); padding: 9px 18px;
  border: none; border-radius: 11px; background: var(--accent);
  box-shadow: 0 4px 14px var(--accent-soft);
  transition: filter var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.send-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 18px var(--accent-soft); }
.send-btn:active:not(:disabled) { transform: scale(0.97); }
.send-btn:disabled { cursor: not-allowed; opacity: 0.72; }
.send-btn .send-dots { display: none; }
.send-btn.busy .send-dots { display: inline-flex; gap: 3px; align-items: center; }
.send-btn.busy .send-dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; animation: dotBounce 1.2s var(--ease) infinite;
}
.send-btn.busy .send-dots i:nth-child(2) { animation-delay: 0.15s; }
.send-btn.busy .send-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.55; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ═══════════ 提示词工具条（优化 / 续写） ═══════════ */
.prompt-tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 4px 2px 2px;
}
.ai-opt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 600;
  color: var(--accent);
  padding: 7px 14px;
  border: 1px solid var(--accent-line); border-radius: var(--r-sm);
  background: var(--accent-soft);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
              border-color var(--dur) var(--ease), filter var(--dur) var(--ease),
              transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.ai-opt-btn:hover:not(:disabled) {
  background: var(--accent-soft); border-color: var(--accent);
  filter: brightness(1.05); transform: translateY(-1px);
}
.ai-opt-btn:active:not(:disabled) { transform: scale(0.97); }
.ai-opt-btn:disabled {
  color: var(--text-3); border-color: var(--border);
  background: var(--surface-2); cursor: not-allowed; opacity: 0.7;
}
.ai-opt-btn.busy { color: var(--accent); }
.ai-opt-btn .ai-opt-icon { font-size: 13px; line-height: 1; }
.ai-opt-btn.busy .ai-opt-icon { animation: aiSpin 1.2s linear infinite; display: inline-block; }
@keyframes aiSpin { to { transform: rotate(360deg); } }

/* 文本模型上下文清空按钮（仅在多段剧本时显示，紧贴「优化/续写提示词」右侧） */
.ai-conv-reset {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  cursor: pointer;
  line-height: 1.2;
  transition: color .15s, border-color .15s, background .15s;
}
.ai-conv-reset:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(220, 60, 60, 0.06);
}
.ai-opt-status {
  font-size: 11.5px; color: var(--text-3);
  padding-left: 4px; line-height: 1.5;
}
.ai-opt-status.ok { color: var(--success); }
.ai-opt-status.warn { color: var(--warn); }
.ai-opt-status.err { color: var(--danger); }

/* 提示词下方说明 */
.prompt-hint {
  font-size: 12px; color: var(--text-3); line-height: 1.6;
  padding: 2px 2px 0;
}
.prompt-hint b { color: var(--text-2); font-weight: 600; }
.prompt-hint code {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--accent);
  background: var(--accent-soft); padding: 1px 6px; border-radius: 5px;
}

/* 隐藏的兼容卡片（保持 DOM，不显示） */
.card[hidden], .gen-bar[hidden], .paramCard[hidden], .materialCard[hidden], .prompt-card[hidden] { display: none !important; }

/* ═══════════ 右栏 · 历史 ═══════════ */
.tasks-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; flex: 1 1 auto;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 13.5px; letter-spacing: 0.2px;
  display: inline-flex; align-items: center; gap: 8px; color: var(--text);
}
.count-badge {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-2);
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.hist-actions { display: flex; gap: 7px; }
/* 设置弹窗底部：导出 / 导入设置 */
.settings-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-1);
}
.settings-foot-info { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); line-height: 1.6; flex: 1 1 auto; min-width: 0; }
.settings-foot-info b { color: var(--warn); }
.settings-foot-actions { display: flex; gap: 8px; flex: none; }
/* 历史面板顶部纯图标操作按钮（导出/导入/素材库/清空） */
.icon-act {
  width: 30px; height: 30px; padding: 0; flex: none;
  display: grid; place-items: center;
  color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-act:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.icon-act.danger { color: var(--text-3); }
.icon-act.danger:hover { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.ghost-btn {
  font-size: 12px; color: var(--text-2);
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
  display: inline-flex; align-items: center; gap: 4px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ghost-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.ghost-btn.danger { color: var(--text-3); }
.ghost-btn.danger:hover { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }

/* 历史卡内的「本地模式」说明：克制的小注释条 */
.hist-notice {
  display: flex; align-items: center; gap: 7px;
  margin: 10px 10px 6px; padding: 9px 11px;
  font-size: 11.5px; color: var(--text-3); line-height: 1.5;
  background: var(--hist-notice-bg);
  border: 1px solid var(--accent-line); border-radius: var(--r-sm);
}
.hist-notice svg { flex: none; color: var(--accent); }
.hist-notice b { color: var(--text-2); font-weight: 600; }

.query-bar { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.query-bar input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.query-bar input::placeholder { color: var(--text-3); }
.query-bar input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.query-btn {
  font-size: 12.5px; color: var(--text); padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.query-btn:hover { background: var(--surface-3); border-color: var(--accent-line); }

.task-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.empty-state {
  margin: auto; text-align: center; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 16px;
}
.empty-ico { font-size: 34px; opacity: 0.5; filter: grayscale(0.2); }

/* 任务卡片 */
.task-item {
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 5px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
/* 仅新任务首次出现时走一次入场动画，避免轮询/重命名时整面板抖动 */
.task-item.task-item--enter { animation: cardIn var(--dur) var(--ease); }
.task-item:hover { border-color: var(--border-strong); background: var(--surface-3); }
.task-item.succeeded, .task-item.completed { border-left: 2px solid var(--success); }
.task-item.failed { border-left: 2px solid var(--danger); }
.task-item.running, .task-item.queued, .task-item.in_progress { border-left: 2px solid var(--accent); }

.task-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.task-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.task-status {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.3px;
  border: 1px solid var(--border); color: var(--text-2); background: var(--surface);
}
.task-status.succeeded, .task-status.completed { color: var(--success); border-color: oklch(0.72 0.16 150 / 0.4); }
.task-status.failed { color: var(--danger); border-color: var(--danger-soft); }
.task-status.running, .task-status.queued, .task-status.in_progress { color: var(--accent); border-color: var(--accent-line); }
/* 失败任务内联的短错误标签（折叠 Failed to fetch 等） */
.status-error-chip {
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  color: var(--danger); background: var(--danger-soft); border: 1px solid oklch(0.7 0.15 25 / 0.35);
  cursor: help; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.submit-time { margin-left: auto; font-size: 11px; color: var(--text-3); }
.submit-time--inline { margin-left: 0; font-size: 10.5px; color: var(--text-3); }
.task-actions { margin-left: auto; display: flex; gap: 4px; }
.task-del {
  flex: none;
  width: 22px; height: 22px; border: none; background: transparent; color: var(--text-3);
  border-radius: 6px; font-size: 12px; display: grid; place-items: center;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.task-del:hover { color: var(--danger); background: var(--danger-soft); }

.task-title {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-display); font-weight: 500; font-size: 13.5px; color: var(--text);
  cursor: text; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.task-title:hover { color: var(--text); }
.task-rename-input {
  font-family: var(--font-display); font-weight: 500; font-size: 14px; color: var(--text);
  width: 100%; padding: 3px 6px; border: 1px solid var(--accent-line); border-radius: var(--r-sm);
  background: var(--bg); outline: none;
}
.task-prompt {
  font-size: 12px; color: var(--text-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-prompt code {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--accent);
  background: var(--accent-soft); padding: 0 5px; border-radius: 4px;
}
.task-error {
  font-size: 12px; color: var(--danger);
  /* 长错误（如内容审核驳回的长中文理由）容易把卡片撑爆：限高 + 滚动 + 暗背景 */
  max-height: 96px; overflow-y: auto;
  padding: 6px 10px; margin-top: 2px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--r-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  /* 滚动条样式与 .task-list / .modal-body / .at-pop 等全局统一（8px + 999px 圆角） */
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.task-error::-webkit-scrollbar { width: 8px; }
.task-error::-webkit-scrollbar-track { background: transparent; }
.task-error::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px; background-clip: padding-box;
}
.task-error::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
.queue-pos { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }

.task-progress-row { display: flex; align-items: center; gap: 9px; }
.progress-track { flex: 1 1 auto; height: 5px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s var(--ease); }
.progress-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); min-width: 34px; text-align: right; }

.task-result { display: flex; align-items: center; gap: 8px; }
/* 失败卡片：缩略图不再随错误块垂直居中，否则长错误会把缩略图挤变形 */
.task-result--failed { align-items: flex-start; }
.task-result--failed .task-thumb { margin-top: 2px; }
.task-thumb {
  position: relative; flex: none; width: 84px; height: 48px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-3); overflow: hidden; cursor: pointer;
  display: grid; place-items: center;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
/* 失败任务缩略图占位 */
.task-thumb--failed { background: var(--danger-soft); border-color: var(--danger); }
.task-thumb--failed .thumb-fail { font-size: 22px; color: var(--danger); font-weight: 600; }
/* 生成中缩略图：尺寸与已完成 .task-thumb 一致（84x48），背景填进度百分比 */
.task-thumb--progress { background: var(--surface-3); cursor: default; }
.task-thumb--progress:hover { transform: none; border-color: var(--border-strong); }
.thumb-progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--accent-soft) 0%, var(--accent) 100%);
  transition: width 0.4s var(--ease);
  z-index: 1;
}
.thumb-progress-text {
  position: relative; z-index: 2;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 2px oklch(0 0 0 / 0.45);
  pointer-events: none;
}
/* 状态徽章叠加在缩略图右上角（已完成 / 失败） */
.thumb-badge {
  position: absolute; top: 3px; right: 3px; z-index: 3;
  padding: 1px 6px; font-size: 10px; line-height: 1.4;
  background: oklch(0.2 0 0 / 0.65); color: var(--text);
  backdrop-filter: blur(2px);
}
.thumb-badge.succeeded, .thumb-badge.completed { color: var(--success); }
.thumb-badge.failed { color: var(--danger); background: oklch(0.2 0.08 25 / 0.7); }.task-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.task-thumb:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.thumb-skel {
  width: 100%; height: 100%;
  background: linear-gradient(100deg, transparent 30%, var(--skel-color) 50%, transparent 70%) var(--surface-3);
  background-size: 200% 100%;
  animation: thumb-shimmer 1.4s infinite;
}
@keyframes thumb-shimmer { to { background-position: -200% 0; } }
/* 视频链接失效：已迁到状态徽章旁的 .status-error-chip（与失败卡片同款紧凑标签），
   此处保留空规则仅作为历史兼容（不影响渲染）。 */
.task-thumb--link-expired { cursor: not-allowed; }
.result-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-self: stretch; justify-content: center; }
.result-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
/* 失败卡片的复用/再生成按钮：紧贴错误块下方并靠右 */
.result-row--actions { justify-content: flex-end; margin-top: 2px; }
.result-row--actions .result-btns { margin-left: 0; }
/* 头行：状态徽章在提交时间左侧，按钮组靠右 */
.result-row--head .result-btns { margin-left: auto; }
/* 参数标签行：位于提交时间下方，与状态徽章靠左对齐 */
.result-row--meta { align-items: flex-start; }
.res-tag {
  font-family: var(--font-mono); font-size: 10px; line-height: 1;
  color: var(--text-2); padding: 3px 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: default; white-space: nowrap;
}
/* 历史记录里的模型名标签：突出显示是哪款模型生成的 */
.res-tag.model-tag {
  font-family: inherit; font-weight: 600;
  color: var(--accent); border-color: var(--accent-line);
  background: var(--accent-soft, rgba(79, 140, 255, .10));
}
.result-btns { margin-left: auto; display: flex; gap: 4px; }
.res-ico {
  width: 24px; height: 24px; padding: 0; display: grid; place-items: center;
  color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.res-ico:hover { background: var(--surface-3); border-color: var(--accent-line); color: var(--accent); }
.res-ico svg { display: block; }

/* ═══════════ 弹窗 ═══════════ */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: var(--mask-bg); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  width: min(720px, 100%); max-height: 90vh; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column;
  animation: popIn var(--dur) var(--ease);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.modal-close {
  width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); font-size: 13px;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.modal-close:hover { color: var(--text); background: var(--surface-3); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal video { max-width: 100%; max-height: calc(90vh - 140px); width: auto; height: auto; border-radius: var(--r); background: #000; display: block; margin: 0 auto; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }

/* 结果预览：媒体与信息分栏，竖版图片不会把详情挤出视口 */
.result-modal { width: min(1160px, 96vw); height: min(800px, 92vh); max-height: 92vh; }
.result-modal--compact { width: min(560px, 96vw); height: auto; }
.result-body { flex: 1 1 auto; min-height: 0; padding: 0; overflow: hidden; }
.result-body.is-plain { padding: 24px; overflow: auto; }
.result-layout { display: grid; grid-template-columns: minmax(0, 1fr) 332px; height: 100%; min-height: 0; }
.result-media {
  min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow: hidden;
  background: radial-gradient(560px 400px at 50% 0%, rgba(77,141,255,.07), transparent 70%), #090c12;
}
.result-media img.preview-full {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 10px; background: #000; box-shadow: 0 14px 40px rgba(0,0,0,.36);
}
.result-media video {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 10px; background: #000; display: block;
}
/* 音频结果：不用黑底（适配浅色主题），播放器卡片占满可用宽度 */
.result-media--audio {
  background: var(--surface-2);
  align-items: flex-start; justify-content: stretch;
  overflow-y: auto; padding: 24px;
}
.result-media--audio .audio-result { width: 100%; max-width: 760px; margin: 0 auto; }
.result-side {
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 17px;
  padding: 22px 20px 24px; border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 38%);
}
.result-side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rs-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; color: var(--text-3); margin-bottom: 5px; }
.rs-title { font-family: var(--font-display); font-size: 18px; font-weight: 650; color: var(--text); }
.rs-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px;
  color: var(--success); background: rgba(62,207,142,.1); border: 1px solid rgba(62,207,142,.22);
  font-size: 11px; white-space: nowrap;
}
.rs-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(62,207,142,.12); }
.result-facts { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.result-fact {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-3);
}
.result-fact .rf-v { color: var(--text-1); text-align: right; min-width: 0; overflow-wrap: anywhere; }
.result-fact .rf-v b { color: var(--accent); font-weight: 650; }
.result-prompt { flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; }
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.rp-label { font-size: 11px; color: var(--text-3); letter-spacing: .02em; }
.rp-copy {
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text-3); font-size: 10.5px; line-height: 1.45;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.rp-copy:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rp-copy.ok { color: var(--success); border-color: rgba(62,207,142,.4); background: rgba(62,207,142,.08); }
.result-prompt-text {
  flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; padding: 11px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-2); font-size: 12.5px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere;
}
/* 结果详情滚动条：与站内其他滚动容器统一为细条 + 半透明圆角 */
.result-prompt-text, .result-side { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.result-prompt-text::-webkit-scrollbar, .result-side::-webkit-scrollbar { width: 8px; }
.result-prompt-text::-webkit-scrollbar-track, .result-side::-webkit-scrollbar-track { background: transparent; }
.result-prompt-text::-webkit-scrollbar-thumb, .result-side::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
.result-prompt-text::-webkit-scrollbar-thumb:hover, .result-side::-webkit-scrollbar-thumb:hover {
  background: var(--text-3); background-clip: padding-box;
}
.result-actions {
  flex: none; margin-top: 0; padding: 14px 18px; justify-content: flex-end;
  border-top: 1px solid var(--border); background: rgba(255,255,255,.012);
}
.result-modal--compact .result-body { padding: 24px; overflow: auto; }
@media(max-width:860px) {
  .result-modal { width: min(620px, 96vw); height: min(90vh, 820px); }
  .result-layout { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) auto; overflow-y: auto; }
  .result-media { min-height: 260px; padding: 14px; }
  .result-side { border-left: 0; border-top: 1px solid var(--border); overflow: visible; padding: 18px; }
  .result-prompt { flex: none; min-height: 0; }
  .result-prompt-text { max-height: none; flex: none; overflow: visible; }
}

/* 素材预览弹窗（附件区点击缩略图） */
.media-modal { width: min(560px, 100%); }
.media-body { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.media-body img#mediaImg { max-width: 100%; max-height: calc(90vh - 160px); border-radius: var(--r); object-fit: contain; }
.media-body video#mediaVideo { max-height: calc(90vh - 180px); }
#mediaAudioWrap { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
#mediaWave { width: 100%; max-width: 420px; border-radius: var(--r-sm); background: var(--surface-3); }
#mediaAudio { width: 100%; max-width: 420px; }
.media-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); word-break: break-all; text-align: center; }

/* 设置弹窗 */
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; }
.field .hint { color: var(--text-3); font-size: 11px; }
.input-wrap { display: flex; align-items: center; gap: 8px; }
.input-wrap input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input-wrap input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-wrap input[type="password"] { letter-spacing: 1px; }
.eye-btn {
  flex: none; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-2); font-size: 12.5px;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.eye-btn:hover { color: var(--text); background: var(--surface-3); }
.key-hint { display: block; font-size: 11.5px; color: var(--text-3); line-height: 1.6; margin-top: 7px; }
.key-hint a { border-bottom: 1px dashed var(--accent-line); padding-bottom: 1px; }
.settings-actions { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); }

/* 模型列表（视频 / 文本多模型切换） */
.profile-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.profile-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 12.5px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  color: var(--text-2); border: 1px solid var(--border); background: var(--surface-2);
  transition: all var(--dur) var(--ease);
  user-select: none;
}
.profile-chip:hover { color: var(--text); border-color: var(--border-strong); }
.profile-chip.active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); font-weight: 600; }
.profile-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: none; }
.profile-chip.active .dot { background: var(--accent); }
.profile-chip .chk { margin-left: 2px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.profile-empty { font-size: 12.5px; color: var(--text-3); margin-bottom: 10px; }

/* 设置弹窗内分组：用于「文本模型」等额外配置段 */
.settings-section {
  margin-top: 4px; padding: 16px 0 4px;
  border-top: 1px dashed var(--border);
}.settings-section h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 12.5px; letter-spacing: 0.3px;
  color: var(--text-2); margin: 0 0 12px;
}
.settings-section h3 .hint {
  font-family: var(--font-body); font-weight: 400;
  color: var(--text-3); font-size: 11px; letter-spacing: 0;
}
.settings-section h3 a {
  color: var(--accent); border-bottom: 1px dashed var(--accent-line);
  padding-bottom: 1px; font-family: var(--font-body); font-weight: 400;
  font-size: 11px; letter-spacing: 0;
}
.settings-section .field { margin-bottom: 14px; }
.settings-section .settings-actions {
  flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 4px 0 0; padding: 12px 14px;
}
.settings-section .settings-actions .key-hint { margin: 0; flex: 1 1 auto; }

/* ═══════════ 设置页：分类页签 ═══════════ */
.settings-tabs {
  display: flex; gap: 4px; padding: 8px 14px 0;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.settings-tab {
  border: none; background: transparent; color: var(--text-2); cursor: pointer;
  font-size: 12.5px; padding: 8px 16px 10px; position: relative;
  font-family: var(--font-display); letter-spacing: 0.3px;
  transition: color var(--dur) var(--ease);
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); font-weight: 600; }
.settings-tab.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}
.settings-pane { animation: chipIn var(--dur) var(--ease); }
.settings-pane .settings-section:first-child { border-top: none; padding-top: 8px; }

/* ═══════════ 模型配置：模型类型分组导航 ═══════════ */
.model-group-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 2px 16px;
}
.model-group-tab {
  padding: 7px 15px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.model-group-tab:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.model-group-tab.active {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600;
}
.model-group-pane { animation: chipIn var(--dur) var(--ease); }
.model-group-placeholder {
  padding: 34px 22px; text-align: center; color: var(--text-2);
  border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface);
}
.model-group-placeholder p { margin: 0 0 6px; font-size: 14px; }
.model-group-placeholder .hint { font-size: 12px; margin: 0; }

/* ═══════════ 素材存储：保存方式卡片 ═══════════ */
.storage-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.storage-option { position: relative; display: block; cursor: pointer; }
.storage-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.storage-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 14px 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.storage-option:hover .storage-card { border-color: var(--border-strong); }
.storage-option input:checked + .storage-card {
  border-color: var(--accent-line); background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.storage-ico { font-size: 20px; line-height: 1; }
.storage-t { font-size: 12.5px; font-weight: 600; color: var(--text); }
.storage-d { font-size: 10.5px; color: var(--text-3); line-height: 1.5; }
.storage-sub { margin: 6px 0 16px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); animation: chipIn var(--dur) var(--ease); }
.oss-backup-row { margin: 0 0 14px; }
.local-dir-row { display: flex; align-items: center; gap: 12px; }
.local-dir-name {
  font-family: var(--font-mono); font-size: 12px; color: var(--success);
  background: oklch(0.72 0.16 150 / 0.1); border: 1px solid oklch(0.72 0.16 150 / 0.4);
  padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%;
}
.local-dir-name.empty { color: var(--text-3); background: var(--surface-2); border-color: var(--border-strong); }
@media (max-width: 720px) {
  .storage-options { grid-template-columns: 1fr; }
  .local-dir-row { flex-direction: column; align-items: flex-start; }
  .local-dir-name { max-width: 100%; }
}

.ghost-btn.primary { color: var(--accent); border-color: var(--accent-line); }
.ghost-btn.primary:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 720px) { .field-row { grid-template-columns: 1fr; } }
.cfg-select, .cfg-num {
  width: 100%;
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cfg-select { font-family: var(--font-body); }
.cfg-select option, .cfg-num { color: var(--text); }
.cfg-select:focus, .cfg-num:focus, .cfg-textarea:focus {
  outline: none; border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cfg-textarea {
  width: 100%; min-height: 130px; resize: vertical;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text);
  padding: 10px 12px; line-height: 1.55;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
@media (max-width: 720px) {
  .settings-modal { max-width: 100%; }
}

/* ═══════════ 对象存储（可选）═══════════ */
/* 设置表单中的独立输入框（非 input-wrap 内） */
.cfg-input {
  width: 100%;
  font-family: var(--font-mono); font-size: 13px; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cfg-input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.cfg-input[type="password"] { letter-spacing: 1px; }
.input-wrap .cfg-input { flex: 1 1 auto; }

/* 开关（Switch） */
.switch-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border-strong); cursor: pointer; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch i::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-3); transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + i { background: var(--accent-soft); border-color: var(--accent-line); }
.switch input:checked + i::before { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }

.oss-switch-field { display: flex; flex-direction: column; gap: 4px; }
.oss-note {
  margin: 6px 0 4px; padding: 12px 14px; border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm); background: var(--bg); font-size: 11.5px; color: var(--text-3); line-height: 1.7;
}
.oss-note p { margin: 0 0 6px; }
.oss-note p:last-child { margin-bottom: 0; }
.oss-note b { color: var(--text-2); font-weight: 600; }
.oss-note code { font-family: var(--font-mono); color: var(--accent); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }

/* 素材库弹窗 */
.oss-lib-modal { width: min(720px, calc(100vw - 32px)); }
.oss-lib-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.oss-lib-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: var(--r-sm); border: 1px solid var(--border); }
.oss-tab {
  border: none; background: transparent; color: var(--text-2); font-size: 12.5px;
  padding: 5px 12px; border-radius: 7px; cursor: pointer; transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.oss-tab:hover { color: var(--text); }
.oss-tab.active { background: var(--surface-3); color: var(--text); }
.oss-lib-tools { display: flex; align-items: center; gap: 10px; }
.oss-lib-count { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.oss-lib-list { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.oss-lib-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 40px 16px; line-height: 1.8; }
.oss-lib-loading { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 30px; }
.oss-lib-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
  animation: chipIn var(--dur) var(--ease);
}
.oss-lib-item:hover { border-color: var(--border-strong); background: var(--surface-3); }
.oss-lib-thumb {
  width: 46px; height: 46px; border-radius: 8px; overflow: hidden; flex: none;
  background: var(--surface-3); display: grid; place-items: center; font-size: 18px; color: var(--text-3);
}
.oss-lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.oss-lib-main { flex: 1 1 auto; min-width: 0; }
.oss-lib-name { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oss-lib-name code { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); }
.oss-lib-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); margin-top: 3px; }
.oss-lib-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px; margin-left: 6px; vertical-align: 1px;
  border: 1px solid var(--border-strong); color: var(--text-3); letter-spacing: .3px;
}
.oss-lib-tag.ref { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.oss-lib-tag.video { color: var(--success); border-color: oklch(0.72 0.16 150 / 0.4); }
.oss-lib-actions { display: flex; gap: 6px; flex: none; }

/* 任务卡片：成片已备份到对象存储 */
.oss-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; color: var(--success); border: 1px solid oklch(0.72 0.16 150 / 0.4);
  background: oklch(0.72 0.16 150 / 0.1); padding: 1px 7px; border-radius: 999px;
  margin-left: 6px; vertical-align: 1px; letter-spacing: .2px;
}

.btn {
  font-size: 13px; color: var(--text); padding: 9px 16px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn.primary {
  background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600;
  box-shadow: 0 4px 14px var(--accent-soft);
}
.btn.primary:hover { filter: brightness(1.06); }

/* ═══════════ Toast ═══════════ */
/* 直接悬浮在顶栏内、水平垂直居中 */
.toast-wrap { position: fixed; top: calc(var(--topbar-h) / 2); left: 50%; transform: translate(-50%, -50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: min(420px, calc(100vw - 24px)); }
.toast {
  font-size: 12px; color: var(--text); padding: 7px 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-2); animation: toastIn var(--dur) var(--ease);
}
.toast.out { animation: toastOut 0.35s var(--ease) forwards; }
.toast.error { border-color: var(--danger-soft); color: var(--toast-error-fg); }

/* ═══════════ 动画 ═══════════ */
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes chipIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* 滚动条（克制） */
.left-col::-webkit-scrollbar, .task-list::-webkit-scrollbar, .modal-body::-webkit-scrollbar, .at-pop::-webkit-scrollbar { width: 8px; }
.left-col::-webkit-scrollbar-thumb, .task-list::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb, .at-pop::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.left-col::-webkit-scrollbar-track, .task-list::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ 系统提示词预设行 ═══════════ */
.preset-row { gap: 8px; }
.preset-row .cfg-select { flex: 1; min-width: 0; }
.preset-row .ghost-btn { flex-shrink: 0; }
.preset-row .ghost-btn.danger:hover { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-bg); }

/* ═══════════ 文本对话页（ChatGPT 式：中间聊天区 + 右侧历史会话） ═══════════ */
.chat-page { grid-area: main; position: relative; z-index: 1; min-height: 0; display: flex; }
.chat-page[hidden] { display: none; }
.chat-page-body { flex: 1; min-width: 0; display: flex; gap: 0; width: 100%; height: 100%; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-page-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); background: var(--topbar-bg); flex-shrink: 0;
}
.chat-head-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: transparent; border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  font-size: 12.5px; padding: 6px 12px; border-radius: 9px;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chat-head-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.chat-head-btn.icon-only { width: 34px; height: 32px; padding: 0; justify-content: center; }
.chat-page-title {
  flex: 1; min-width: 0; font-size: 15px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.chat-body {
  flex: 1; overflow-y: auto; padding: 22px 24px;
  display: flex; flex-direction: column; gap: 16px; min-height: 0; background: var(--bg);
}
.chat-empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; }
.chat-empty-btn { font-size: 12.5px; }

/* 消息行（带头像） */
.chat-msg-row { display: flex; gap: 10px; max-width: 85%; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.chat-msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-row.ai, .chat-msg-row.assistant { align-self: flex-start; }
.chat-msg-row.err { align-self: flex-start; }
/* 气泡占满除头像外的宽度，meta换行到气泡下方 */
.chat-msg-row .chat-msg { flex: 1; min-width: calc(100% - 42px); }
.chat-msg-row .chat-msg-meta { flex-basis: 100%; width: 100%; padding-left: 42px; }
.chat-msg-row.user .chat-msg-meta { padding-left: 0; padding-right: 42px; justify-content: flex-end; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: none; cursor: pointer;
  transition: transform var(--dur) var(--ease);
}
.chat-avatar:hover { transform: scale(1.08); }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-avatar svg { width: 18px; height: 18px; color: var(--text-2); }
.chat-avatar.user-avatar { background: #1a1a1a; }
.chat-avatar.user-avatar svg { color: #ffd700; }
/* AI 头像：与网页图标（logo.svg）一致；logo 自带底色，圆形裁切 */
.chat-avatar.ai-avatar { background: var(--msg-user-bg); }
.chat-avatar.ai-avatar img { border-radius: 50%; }
.chat-msg {
  flex: 1; min-width: 0; padding: 12px 16px; border-radius: var(--r-lg); font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: var(--shadow-1);
}
.chat-msg.user { background: var(--msg-user-bg); color: var(--msg-user-text); border: none; border-bottom-right-radius: 6px; }
.chat-msg.ai, .chat-msg.assistant { background: var(--msg-ai-bg); color: var(--msg-ai-text); border: none; border-bottom-left-radius: 6px; }
.chat-msg.err { background: var(--err-msg-bg); color: var(--err-msg-text); border: 1px solid var(--err-msg-border); border-bottom-left-radius: 6px; }
.chat-msg.typing { opacity: 0.6; }
/* 气泡内附件图 */
.chat-msg .msg-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat-msg .msg-imgs img { max-width: 200px; max-height: 160px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; display: block; }
.chat-msg .msg-file { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; color: var(--text-2); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 3px 9px; }
.chat-msg.user .msg-file { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: var(--on-accent); }

/* AI 消息 Markdown 渲染排版（全 token 化，双主题可读，对照 Primer 中性色阶 + WCAG AA） */
.chat-msg.ai .msg-text, .chat-msg.assistant .msg-text { font-size: 13.5px; line-height: 1.7; color: var(--msg-ai-text); word-break: break-word; }
.chat-msg.ai .msg-text > *:first-child { margin-top: 0; }
.chat-msg.ai .msg-text > *:last-child { margin-bottom: 0; }
.chat-msg.ai .msg-text p { margin: 6px 0; }
.chat-msg.ai .msg-text h1, .chat-msg.ai .msg-text h2, .chat-msg.ai .msg-text h3,
.chat-msg.ai .msg-text h4, .chat-msg.ai .msg-text h5, .chat-msg.ai .msg-text h6 {
  margin: 12px 0 6px; font-weight: 700; line-height: 1.4; color: var(--msg-ai-head);
}
.chat-msg.ai .msg-text h1 { font-size: 18px; }
.chat-msg.ai .msg-text h2 { font-size: 16px; }
.chat-msg.ai .msg-text h3 { font-size: 14.5px; }
.chat-msg.ai .msg-text h4, .chat-msg.ai .msg-text h5, .chat-msg.ai .msg-text h6 { font-size: 13.5px; }
.chat-msg.ai .msg-text strong { font-weight: 700; }
.chat-msg.ai .msg-text em { font-style: italic; }
.chat-msg.ai .msg-text del { color: var(--md-del); }
.chat-msg.ai .msg-text ul, .chat-msg.ai .msg-text ol { margin: 6px 0; padding-left: 22px; }
.chat-msg.ai .msg-text li { margin: 2px 0; }
.chat-msg.ai .msg-text blockquote {
  margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--md-quote-border);
  background: var(--md-quote-bg); border-radius: 0 8px 8px 0; color: var(--md-quote-text);
}
.chat-msg.ai .msg-text .md-code {
  font-family: var(--font-mono); font-size: 12px; background: var(--md-code-bg);
  padding: 1.5px 6px; border-radius: 5px; color: var(--md-code-text); word-break: break-all;
}
.chat-msg.ai .msg-text .md-pre {
  margin: 8px 0; padding: 10px 12px; background: var(--md-pre-bg); color: var(--md-pre-text);
  border-radius: 9px; overflow-x: auto; font-size: 12.5px; line-height: 1.55;
}
.chat-msg.ai .msg-text .md-pre code { font-family: var(--font-mono); background: none; color: inherit; padding: 0; font-size: inherit; }
.chat-msg.ai .msg-text .md-table {
  margin: 8px 0; border-collapse: collapse; width: 100%; font-size: 12.5px;
}
.chat-msg.ai .msg-text .md-table th, .chat-msg.ai .msg-text .md-table td {
  border: 1px solid var(--md-table-border); padding: 5px 10px; text-align: left;
}
.chat-msg.ai .msg-text .md-table th { background: var(--md-table-head); font-weight: 600; }
.chat-msg.ai .msg-text .md-link { color: var(--md-link); text-decoration: underline; }
.chat-msg.ai .msg-text .md-img { max-width: 100%; border-radius: 8px; margin: 6px 0; display: block; }
.chat-msg.ai .msg-text hr { border: none; border-top: 1px solid var(--md-hr); margin: 10px 0; }

/* 消息下方：元信息 + 操作按钮（在气泡外部，与气泡同级） */
.chat-msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 0 2px;
  font-size: 11px; color: var(--text-3); line-height: 1.4;
  min-height: 20px;
}
.chat-msg-meta.ai, .chat-msg-meta.assistant { justify-content: flex-start; }
.chat-msg-meta.user { justify-content: flex-end; }
.chat-msg-meta.err { justify-content: flex-start; }
.meta-info { font-family: var(--font-mono); letter-spacing: 0.2px; }
.meta-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.chat-msg-row:hover .meta-actions { opacity: 0.85; }
.chat-msg-row .meta-actions:hover { opacity: 1; }
.meta-btn {
  width: 24px; height: 24px; border-radius: 6px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.meta-btn:hover { background: var(--surface-2); color: var(--text); }

/* 键盘焦点可见性（shadcn/ui 规范：清晰 focus ring，WCAG 2.4.7） */
.chat-head-btn:focus-visible,
.chat-tool-btn:focus-visible,
.meta-btn:focus-visible,
.chat-send-btn:focus-visible,
.chat-tool-sel:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* 输入区（ChatGPT 式：工具条内嵌模型 / 思考等级 / 预设 / 附件） */
.chat-composer { padding: 8px 24px 10px; background: var(--bg); flex-shrink: 0; }
.chat-composer-box {
  border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.chat-composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input-wrap { position: relative; }
.chat-composer-box textarea {
  width: 100%; resize: none; min-height: 52px; max-height: 180px;
  background: transparent; border: none; color: var(--text); caret-color: var(--text);
  padding: 14px 16px 4px; font-size: 14px; font-family: inherit; line-height: 1.6;
  outline: none;
}
.chat-composer-box textarea::placeholder { color: var(--text-3); }
.chat-input-wrap .prompt-backdrop { padding: 14px 16px 4px; }
.chat-input-wrap .bd-inner { font-size: 14px; line-height: 1.6; }
.chat-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px 8px; flex-wrap: nowrap;
}
.chat-toolbar-left { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: nowrap; }
.chat-toolbar-right { display: flex; align-items: center; gap: 6px; flex: none; flex-wrap: nowrap; }
.chat-tool-btn {
  width: 30px; height: 30px; border-radius: 9px; border: none; background: transparent;
  color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.chat-tool-btn:hover { color: var(--text); background: var(--surface-2); }
.chat-tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; flex: none; }
.chat-tool-sel {
  max-width: 150px; min-width: 0; height: 30px; padding: 0 22px 0 10px;
  font-size: 12px; border-radius: 8px; background: var(--surface-2); border-color: var(--border);
}
.chat-model-sel { max-width: none; width: auto; min-width: 80px; }
.chat-upload-count { font-size: 12px; color: var(--text-2); font-family: var(--font-mono); }
.chat-send-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; flex: none;
  background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.chat-send-btn:hover { opacity: .9; transform: translateY(-1px); }
.chat-send-btn:disabled { opacity: .4; cursor: default; transform: none; }

/* 输入框下方功能区 */
.chat-composer-actions {
  display: flex; align-items: center; gap: 4px; padding: 6px 4px 0;
}
.chat-action-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.chat-action-btn:hover { color: var(--text); background: var(--surface-2); }

.chat-attach-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 8px; }
.chat-attach-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 220px;
  padding: 4px 7px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 12px; color: var(--text-2);
}
.chat-attach-chip { cursor: default; }
.chat-attach-chip.is-img { cursor: pointer; }
.chat-attach-chip.is-img:hover { border-color: var(--border-strong); }
.chat-attach-chip img { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; flex: none; }
.chat-attach-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach-chip .chip-del {
  width: 18px; height: 18px; border: none; background: transparent; color: var(--text-3);
  border-radius: 5px; cursor: pointer; font-size: 14px; line-height: 1; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-attach-chip .chip-del:hover { color: var(--danger); background: var(--danger-bg); }
.chat-disclaimer { margin-top: 6px; text-align: center; font-size: 11px; color: var(--text-3); }

/* 对话模型设置弹窗 */
.chat-settings-modal { width: 480px; max-width: 92vw; }
.chat-settings-modal .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chat-settings-modal .cfg-textarea { min-height: 80px; }

/* 右侧历史会话（可折叠） */
.chat-sessions {
  width: 270px; flex: none; min-width: 0; display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--topbar-bg);
  transition: width var(--dur) var(--ease), margin-right var(--dur) var(--ease), opacity var(--dur) var(--ease);
  overflow: hidden;
}
.chat-sessions.collapsed { width: 0; border-left: none; opacity: 0; }
.sessions-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap;
}
.sessions-close {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.sessions-close:hover { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }
.sessions-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.sessions-empty { padding: 26px 10px; text-align: center; color: var(--text-3); font-size: 12px; }
/* 历史面板头部操作区（导出 / 导入 / 清空） */
.sessions-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.sessions-icon {
  width: 24px; height: 24px; border: none; background: transparent; color: var(--text-3);
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sessions-icon:hover { color: var(--text); background: var(--surface-2); }
.sessions-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }
/* 历史搜索框 */
.sessions-search {
  display: flex; align-items: center; gap: 6px; margin: 0 8px 4px; padding: 0 9px;
  height: 28px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text-3); transition: border-color var(--dur) var(--ease);
}
.sessions-search:focus-within { border-color: var(--accent-line); }
.sessions-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: var(--font-body); font-size: 12px; color: var(--text);
}
.sessions-search input::placeholder { color: var(--text-3); }
.session-item {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 9px 30px 9px 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.session-item:hover { background: var(--surface-2); }
.session-item.active { background: var(--surface-2); border-color: var(--border); }
.session-title { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-time { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); }
.session-del, .session-edit {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border: none; background: transparent; color: var(--text-3);
  border-radius: 5px; cursor: pointer; font-size: 14px; line-height: 1; opacity: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.session-edit { right: 27px; }
.session-item:hover .session-del, .session-item:hover .session-edit { opacity: 1; }
.session-del:hover { color: var(--danger); background: var(--danger-bg); }
.session-edit:hover { color: var(--accent); background: var(--accent-soft); }

/* 移动端 */
@media (max-width: 760px) {
  /* 移动端侧边栏强制图标模式，不管展开状态 */
  body { --sidebar-w: 64px; }
  .sidebar .side-label, .sidebar .sidebar-ver, .sidebar .side-tag, .sidebar .side-check { display: none !important; }
  .sidebar .side-item { justify-content: center; padding: 14px 0; }
  .sidebar .sidebar-head { justify-content: center; padding: 14px 0; }
  .sidebar .sidebar-logo img { width: 36px; height: 36px; }
  .sidebar .sidebar-collapse { justify-content: center; padding: 14px 0; }
  .sidebar .sidebar-foot { align-items: center; gap: 4px; }
  .sidebar .soon-badge { display: none; }

  .chat-composer { padding: 8px 10px 10px; }
  .chat-toolbar { padding: 4px 8px 6px; gap: 4px; }
  .chat-toolbar-left { gap: 2px; }
  .chat-toolbar-right { gap: 4px; }
  .chat-tool-btn { width: 28px; height: 28px; }
  .chat-tool-sel { max-width: 72px; font-size: 10px; padding: 0 18px 0 6px; height: 28px; }
  .chat-model-sel { max-width: none; width: auto; min-width: 60px; }
  .chat-send-btn { width: 30px; height: 30px; }
  .chat-upload-count { font-size: 10px; }
  .chat-page-body { flex-direction: column; position: relative; overflow: hidden; }
  /* 移动端历史面板默认折叠，通过顶部按钮展开 */
  .chat-sessions {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 20;
    width: 280px; max-height: none; border-left: 1px solid var(--border);
    border-bottom: none; box-shadow: -4px 0 24px rgba(0,0,0,.3);
    transform: translateX(100%); transition: transform var(--dur) var(--ease);
  }
  .chat-sessions:not(.collapsed) { transform: translateX(0); }
  .chat-sessions.collapsed { width: 280px; opacity: 0; visibility: hidden; pointer-events: none; border-left: none; transform: translateX(100%) !important; }
  .sessions-list { flex-direction: column; overflow-y: auto; }
  .session-item { min-width: 0; }
  .chat-msg-row { max-width: 92%; }
  .chat-settings-modal .field-row { grid-template-columns: 1fr; }
  .chat-page-head { padding: 10px 12px; }
  .chat-head-btn span { display: none; }
  .chat-head-btn { padding: 8px; }
}


/* ═══════════ 图像生成工作台 ═══════════ */
.image-page { grid-area: main; position: relative; z-index: 1; min-height: 0; display: flex; }
.image-page[hidden] { display: none; }
/* 与视频生成页面 .layout 一致的 grid 布局：左栏 1fr + 右栏 440px */
.image-page-body {
  grid-area: main; position: relative; z-index: 1;
  padding: var(--s4) var(--s4) var(--s4);
  display: grid; grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--s4); align-items: stretch;
  width: 100%; height: 100%; min-height: 0; flex: 1;
}
/* 与视频生成页面 .left-col 一致：flex column + gap + 滚动 */
.image-main {
  display: flex; flex-direction: column; gap: var(--s3); min-width: 0; min-height: 0;
  overflow: hidden; padding-right: 2px; height: 100%;
}
/* 提示词输入卡片铺满剩余空间 */
.image-main #imageInputCard { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.image-main #imageInputCard .chat-input-top { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.image-main #imagePromptWrap { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
/* 其他元素不收缩 */
.image-main .attach-tray,
.image-main .media-params,
.image-main .prompt-hint { flex-shrink: 0; }
/* 图像生成提示词 textarea 与视频生成 #prompt 样式一致，铺满高度 */
#imagePrompt {
  flex: 1 1 auto; min-height: 0; width: 100%;
  resize: none; border: none; outline: none; background: transparent;
  color: var(--text); caret-color: var(--text); font-family: var(--font-body); font-size: 14.5px; line-height: 1.6;
  padding: 2px 4px; overflow-y: auto;
}
#imagePrompt::placeholder { color: var(--text-3); }
#imagePrompt:focus { outline: none; }
/* 与视频生成页面 .right-col 一致 + 历史面板样式 */
.image-history-panel {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden;
}
.image-history-panel .image-history-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.image-history-panel .image-history-head h2 {
  font-size: 13px; font-weight: 600; color: var(--text); margin: 0; display: flex; align-items: center; gap: 6px;
}
.image-history-panel .image-history-head .count-badge { font-size: 11px; color: var(--text-3); background: var(--bg-2); padding: 1px 7px; border-radius: 10px; font-weight: 500; }
.image-history-panel .image-history-head .hist-actions { display: flex; gap: 7px; }
.image-history-panel .image-history-head .icon-act {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  cursor: pointer; transition: all .15s; padding: 0;
}
.image-history-panel .image-history-head .icon-act:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.image-history-panel .image-history-head .icon-act.danger { color: var(--text-3); }
.image-history-panel .image-history-head .icon-act.danger:hover { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.image-history-panel .image-grid {
  padding: 14px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 10px; align-content: start;
}

.image-workspace { background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-bottom: 24px; }
.image-prompt-wrap { position: relative; margin-bottom: 14px; }

.image-prompt-stats { position: absolute; bottom: 8px; right: 12px; font-size: 11px; color: var(--text-3); }

.image-ref-area { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; min-height: 56px; }
.image-ref-upload { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--bg-1); border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--text-2); font-size: 13px; cursor: pointer; transition: all .2s; flex-shrink: 0; }
.image-ref-upload:hover { border-color: var(--accent); color: var(--accent); }
.image-ref-chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.image-ref-chip { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); flex-shrink: 0; }
.image-ref-chip img { width: 100%; height: 100%; object-fit: cover; }
.image-ref-chip .ref-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; border: none; }

.image-params { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.image-gen-row { display: flex; align-items: center; gap: 14px; }
.image-gen-status { font-size: 13px; color: var(--text-3); }

/* 历史记录网格 */
.image-history { flex: 1; }
.image-history-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 15px; font-weight: 600; color: var(--text); }
.image-history-count { font-size: 12px; color: var(--text-3); background: var(--bg-2); padding: 2px 8px; border-radius: 10px; }
.image-grid { display: flex; flex-direction: column; gap: 12px; }
.image-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: transform .2s, box-shadow .2s; }
.image-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.image-card-result { display: flex; gap: 10px; padding: 8px 10px; }
.image-card-thumb { width: 72px; height: 72px; flex: none; border-radius: 8px; object-fit: cover; background: var(--bg-1); cursor: pointer; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.image-card-thumb.loading { display: flex; align-items: center; justify-content: center; }
.thumb-loading-text { font-size: 11px; color: var(--text-3); }
.thumb-fail-text { font-size: 11px; color: var(--error); }
.thumb-preview-icon { position: absolute; bottom: 4px; right: 4px; font-size: 12px; opacity: 0; transition: opacity .15s; background: rgba(0,0,0,.5); color: #fff; border-radius: 4px; padding: 2px 4px; }
.image-card-thumb:hover .thumb-preview-icon { opacity: 1; }
.image-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.image-card-row { display: flex; align-items: center; gap: 6px; }
.image-card-row--title { justify-content: space-between; }
.image-card-title { font-size: 12px; font-weight: 600; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-card-del { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 2px 4px; border-radius: 4px; font-size: 12px; line-height: 1; transition: all .15s; flex: none; }
.image-card-del:hover { color: var(--error); background: var(--error-soft); }
.image-card-row--head { justify-content: flex-start; flex-wrap: wrap; }
.image-card-status { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--success-soft); color: var(--success); font-weight: 500; }
.image-card-status.failed { background: var(--error-soft); color: var(--error); }
.image-card-status.generating, .image-card-status.queued { background: var(--accent-soft); color: var(--accent); }
.image-card-btns { display: flex; gap: 4px; margin-left: auto; }
.image-card-btn { background: var(--bg-1); border: 1px solid var(--border); border-radius: 5px; padding: 3px 5px; color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 3px; transition: all .15s; font-size: 11px; }
.image-card-btn:hover { border-color: var(--accent); color: var(--accent); }
.image-card-btn--reuse { padding: 3px 8px; }
.image-card-btn--reuse span { font-size: 11px; }
.image-card-row--meta { flex-wrap: wrap; }
.image-card-tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--bg-1); border: 1px solid var(--border); color: var(--text-3); }

/* 响应式：与视频生成页面一致，≤1080px 变单列，但保持高度铺满 */
@media (max-width: 1080px) {
  .image-page-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: 100%; }
  .image-history-panel { max-height: 50vh; }
}
@media (max-width: 600px) {
  .image-history-panel .image-grid { flex-direction: column; }
}

/* ═══════════ 音乐生成工作台 ═══════════ */
.music-page {
  grid-area: main; position: relative; z-index: 1; min-height: 0;
  display: flex;
}
.music-page-body {
  padding: var(--s4);
  display: grid; grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-rows: minmax(0, 1fr);
  gap: var(--s4); align-items: stretch;
  width: 100%; height: 100%; min-height: 0; flex: 1;
}
.music-main {
  display: flex; flex-direction: column; gap: var(--s3); min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden; padding-right: 2px; height: 100%;
}
.music-main #musicInputCard { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 120px; }
/* 工具箱操作模式：输入框隐藏，输入卡收缩为操作行高度，避免底部大空白 */
.music-main #musicInputCard.music-op-mode { flex: 0 0 auto; min-height: 0; }
.music-main #musicInputCard .chat-input-top { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.music-main #musicPromptWrap { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
#musicPrompt {
  flex: 1 1 auto; min-height: 0; width: 100%;
  resize: none; border: none; outline: none; background: transparent;
  color: var(--text); caret-color: var(--text); font-family: var(--font-body); font-size: 14.5px; line-height: 1.6;
  padding: 2px 4px; overflow-y: auto;
}
#musicPrompt::placeholder { color: var(--text-3); }
/* backdrop 层正常渲染时，输入框文字转为透明由 backdrop 显示；未绑定/异常时保持实色兜底 */
.bd-live { color: transparent !important; }
#musicPrompt:focus { outline: none; }
/* 音乐提示词 backdrop：透明文字 + 高亮层显示，输入内容始终可见 */
.music-main #musicPromptWrap .prompt-backdrop { padding: 2px 4px; }
.music-main #musicPromptWrap .bd-inner { font-size: 14.5px; line-height: 1.6; color: var(--text); }
.music-main .attach-tray,
.music-main .media-params,
.music-main .prompt-hint,
.music-main .music-op-bar,
.music-main .music-advanced { flex-shrink: 0; }

/* 音乐页下拉：默认向上弹出（底部参数行），顶部操作面板向下，z-index 抬高防板块遮挡 */
.music-main .drop-panel { top: auto; bottom: calc(100% + 7px); z-index: 300; }
.music-main .music-op-head .drop-panel { bottom: auto; top: calc(100% + 7px); }

/* 音乐工具箱 */
.music-op-bar {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 12px;
}
.music-op-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.music-op-label { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.music-op-head .cfg-select { flex: 1; }
.music-op-form .op-hint { font-size: 12px; color: var(--text-3); margin: 4px 0 8px; line-height: 1.5; }
.music-op-form .op-field { margin-bottom: 8px; }
.music-op-form .op-field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 3px; }
.music-op-form .op-field .cfg-select,
.music-op-form .op-field .cfg-textarea,
.music-op-form .op-field input[type="text"],
.music-op-form .op-field input[type="number"] { width: 100%; }
.music-op-form .op-field .op-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }


/* 高级字段网格（升级：与视频/图像页参数行同风格） */
.music-advanced {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; flex-shrink: 0;
}
.ma-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.ma-field { min-width: 0; }
.ma-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.ma-field .cfg-input { width: 100%; }
.ma-field .cfg-select { width: 100%; }
.ma-checks { display: flex; flex-direction: row; align-items: center; gap: 16px; }
.ma-checks .switch-label { font-size: 12.5px; color: var(--text-2); gap: 7px; justify-content: flex-start; }
.ma-checks .switch { width: 26px; height: 15px; }
.ma-checks .switch i::before { top: 1.5px; left: 1.5px; width: 10px; height: 10px; }
.ma-checks .switch input:checked + i::before { transform: translateX(11px); }

/* 历史面板 */
.music-history-panel {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden;
}
.music-history-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.music-history-head h2 { font-size: 13px; font-weight: 600; color: var(--text); margin: 0; display: flex; align-items: center; gap: 6px; }
.music-history-head .count-badge { font-size: 11px; color: var(--text-3); background: var(--surface-2); padding: 1px 7px; border-radius: 10px; font-weight: 500; }
.music-history-head .hist-actions { display: flex; gap: 7px; }
.music-grid {
  flex: 1; overflow-y: auto; padding: 10px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; align-content: start;
}
.music-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column;
}
.music-card-thumb {
  position: relative; height: 110px; background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--text-3);
  background-size: cover; background-position: center;
}
.music-card-thumb.loading { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, var(--surface) 8px, var(--surface) 16px); }
.thumb-loading-text, .thumb-fail-text { font-size: 12px; color: var(--text-3); }
.thumb-preview-icon { position: absolute; bottom: 6px; right: 8px; font-size: 14px; opacity: .8; }
.music-card-info { padding: 7px 9px; display: flex; flex-direction: column; gap: 3px; }
.music-card-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.music-card-title { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.music-card-del { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 13px; padding: 0 2px; }
.music-card-del:hover { color: var(--danger); }
.music-card-status { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--surface); }
.music-card-status.completed { color: var(--success); }
.music-card-status.failed { color: var(--danger); }
.music-card-status.generating { color: var(--warn); }
.music-card-time { font-size: 11px; color: var(--text-3); }
.music-card-tag { font-size: 11px; color: var(--text-2); background: var(--surface); padding: 1px 6px; border-radius: 6px; }
.music-card-tag.err { color: var(--danger); }
.music-empty { color: var(--text-3); }

/* 预览弹窗 */
.music-preview-modal { max-width: 680px; width: 92vw; max-height: 84vh; display: flex; flex-direction: column; }
.music-preview-modal .modal-body { overflow-y: auto; }
.mp-track { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.mp-track-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mp-track-title { font-size: 14px; font-weight: 600; color: var(--text); }
.mp-track-dur { font-size: 12px; color: var(--text-3); }
.mp-track audio { width: 100%; }
.mp-tags { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.mp-lyrics { margin-top: 6px; font-size: 13px; }
.mp-lyrics pre, .mp-json { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); padding: 8px; border-radius: 6px; max-height: 300px; overflow-y: auto; }
.mp-note { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.mp-file-link { display: block; margin-bottom: 8px; font-size: 14px; color: var(--text); text-decoration: none; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; }
.mp-kv { font-size: 13px; color: var(--text); margin-bottom: 6px; }
.mp-kv code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.mp-bpm { font-size: 16px; color: var(--text); }
.mp-lyrics-box pre { white-space: pre-wrap; font-size: 14px; color: var(--text-2); }

@media (max-width: 900px) {
  .music-page-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); }
}

/* ═══════════════ 音乐工作台 UI 统一（v1.8.19） ═══════════════ */
/* 输入卡内操作头：标题 + 说明 + 工具箱下拉 */
.music-op-head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 2px 10px; flex-shrink: 0;
}
.music-op-sub {
  font-size: 12px; color: var(--text-3); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
/* 工具箱下拉：分组标题 + 滚动面板 */
.op-panel { max-height: 320px; overflow-y: auto; min-width: 220px; }
.drop-group-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  padding: 7px 10px 3px; letter-spacing: 0.3px;
}

/* 独立动态操作表单（承接原音乐工具箱块） */
.music-op-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 12px; flex-shrink: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px;
}
.music-op-form .op-hint { grid-column: 1 / -1; margin: 2px 0 4px; }
.music-op-form .op-field { margin: 0; }
.music-op-form .op-field.wide { grid-column: 1 / -1; }
.music-op-form .op-field .slider-row { align-items: center; }

/* 操作专属下拉条：版本/人声性别/歌词模型等并入底部参数行横排 */
.mp-op-sels { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.mp-op-sels .mp-op-item { display: flex; flex-direction: column; gap: 3px; }
.mp-op-sels .mp-op-label { font-size: 11px; color: var(--text-2); white-space: nowrap; }
.mp-op-sels .cfg-select { min-width: 92px; max-width: 150px; }

/* 滑块行：拖动选值 + 数值徽标 */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type="range"] {
  flex: 1; min-width: 0; height: 22px; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}
.slider-val {
  font-size: 12px; color: var(--text); min-width: 36px; text-align: right;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 1px 8px; flex: none;
}
/* 高级字段内滑块与标签同一行 */
.ma-field .slider-row { margin-top: 2px; }

/* 多选清单（下载格式等）：勾选即选 */
.op-checklist { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 2px 0; }
.op-checklist .op-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.op-checklist .op-check input { accent-color: var(--accent); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }


/* ═══════════════ v1.8.24：操作模式与主生成样式统一 ═══════════════ */
/* 1. 操作表单 textarea 与主输入框视觉统一：大高度、同字体、同圆角、同底色 */
.music-op-form .op-field.wide textarea {
  min-height: 340px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: var(--font-body); font-size: 14.5px; line-height: 1.6;
  color: var(--text); caret-color: var(--text);
  resize: none;
}
.music-op-form .op-field.wide textarea::placeholder { color: var(--text-3); }
.music-op-form .op-field.wide textarea:focus { outline: none; border-color: var(--border-strong); }

/* 2. 操作专属下拉与参数行 dropdown 视觉统一：label 小字 + 胶囊值 */
.mp-op-sels { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mp-op-sels .mp-op-item { display: flex; flex-direction: column; gap: 3px; }
.mp-op-sels .mp-op-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }


/* ═══════════════ v1.8.25：操作参数并入参数行 strip ═══════════════ */
/* 短文本字段：胶囊输入框（与参数行 dropdown 视觉一致） */
.mp-op-input {
  min-width: 110px; max-width: 190px;
  padding: 6px 9px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); caret-color: var(--text);
  font-family: var(--font-body);
}
.mp-op-input::placeholder { color: var(--text-3); }
.mp-op-input:focus { outline: none; border-color: var(--border-strong); }

/* strip 内滑块：窄行横排 */
.mp-op-sels .mp-op-item .slider-row { width: 150px; }
.mp-op-sels .op-checklist { display: flex; gap: 8px; flex-wrap: wrap; }
.mp-op-sels .op-check { font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.mp-op-sels .op-check input[type="checkbox"] { accent-color: var(--accent); }


/* ═══════════════ v1.8.26：参数行样式统一 + 文本字段上行 ═══════════════ */
/* 主参数 label：与控件同行 */
.mp-item-label {
  font-size: 11px; color: var(--text-3); white-space: nowrap;
  margin-right: -2px;
}
/* 文本字段行：主输入框下方横排，标题与输入框同行 */
.music-text-fields {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 9px 12px; flex-shrink: 0;
}
.music-text-fields .tf-item { display: flex; align-items: center; gap: 6px; min-width: 0; }
.music-text-fields .tf-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.music-text-fields .mp-op-input { min-width: 120px; }
/* strip 项：label 与控件同行（不再上下排列） */
.mp-op-sels .mp-op-item { flex-direction: row; align-items: center; gap: 6px; }
.mp-op-sels .mp-op-label { font-size: 11px; color: var(--text-3); }

/* 大文本输入栏：灵感音频URL等独立成栏，宽度与主输入框一致，避免挤压换行 */
.music-big-fields { flex-shrink: 0; }
.music-big-field { display: flex; flex-direction: column; gap: 6px; }
.music-big-field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.music-big-field .mp-op-textarea {
  width: 100%; min-height: 118px; resize: vertical;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 12px; color: var(--text); font-size: 13.5px; line-height: 1.55;
  outline: none; font-family: var(--font-body); caret-color: var(--text);
}
.music-big-field .mp-op-textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.music-big-field .mp-op-textarea::placeholder { color: var(--text-3); }

/* v1.8.28：历史歌曲卡片（每首歌一个卡片，可直接播放/下载，点开看歌词） */
.music-card.track-card { flex-direction: row; align-items: stretch; grid-column: 1 / -1; }
.mc-thumb {
  width: 96px; min-width: 96px; min-height: 118px; position: relative; cursor: pointer;
  background: var(--surface); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
}
.mc-play {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.35); transition: transform var(--dur) var(--ease);
}
.mc-play:hover { transform: scale(1.08); }
.mc-body { flex: 1; min-width: 0; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.mc-title-row { display: flex; align-items: center; gap: 6px; }
.mc-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mc-audio { width: 100%; height: 30px; }
.mc-note { font-size: 11.5px; color: var(--text-3); }
.mc-btns { display: flex; gap: 8px; }
.mc-btn {
  font-size: 11.5px; padding: 3px 10px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mc-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ═══════════ 画布工作台（v1.9.0） ═══════════ */
.canvas-page { grid-area: main; position: relative; z-index: 1; min-height: 0; display: flex; flex-direction: column; }
.canvas-page[hidden] { display: none; }
.canvas-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap;
}
.canvas-title { font-size: 15px; font-weight: 600; color: var(--text); }
.canvas-zoom {
  position: absolute; left: 14px; bottom: 14px; z-index: 8;
  display: flex; align-items: center; gap: 2px;
  background: var(--cn-nav-bg); border: 1px solid var(--cn-nav-border);
  border-radius: 10px; padding: 3px;
  box-shadow: var(--cn-nav-shadow);
  backdrop-filter: blur(6px);
}
.canvas-zoom-lbl { font-size: 12px; color: var(--text-2); min-width: 44px; text-align: center; }
.canvas-tb-btn {
  font-size: 12.5px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--text-2); border: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.canvas-tb-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.canvas-tb-btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.canvas-tb-btn.primary:hover { background: var(--accent-hi); }
.canvas-tb-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.canvas-body { flex: 1; min-height: 0; display: flex; }
.canvas-stage-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
/* 画布管理入口（画布页左上角浮动） */
.canvas-mgr-btn {
  position: absolute; top: 12px; left: 14px; z-index: 40;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 6px 11px; border-radius: 9px; cursor: pointer;
  background: var(--cn-nav-bg); color: var(--text-2); border: 1px solid var(--cn-nav-border);
  box-shadow: var(--cn-nav-shadow); backdrop-filter: blur(6px);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.canvas-mgr-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }

/* 多画布管理弹窗 */
.canvas-mgr-modal { width: min(760px, calc(100vw - 40px)); }
.canvas-mgr-modal .modal-body { padding: 16px; }
.cm-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cm-search {
  flex: 1; min-width: 0; font-size: 12.5px; padding: 7px 11px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; outline: none; transition: border-color var(--dur) var(--ease);
}
.cm-search:focus { border-color: var(--accent); }
.cm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
  max-height: min(56vh, 520px); overflow-y: auto; padding: 2px;
}
.cm-card {
  position: relative; border-radius: 12px; overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.cm-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.cm-card.new { display: flex; align-items: center; justify-content: center; min-height: 128px; border-style: dashed; background: var(--surface-2); color: var(--text-3); }
.cm-card.new:hover { color: var(--accent); border-color: var(--accent-line); }
.cm-card.new .cm-new-ic { font-size: 22px; line-height: 1; margin-bottom: 6px; }
.cm-card.new .cm-new-tx { font-size: 12.5px; }
.cm-cover {
  position: relative; width: 100%; aspect-ratio: 16 / 10; background: var(--dot-pattern), var(--surface-3);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.cm-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-cover .cm-cover-ph { font-size: 26px; color: var(--text-3); opacity: .55; }
.cm-badge { position: absolute; top: 6px; left: 6px; font-size: 10px; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cm-info { padding: 8px 9px 9px; }
.cm-title { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-time { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.cm-ops {
  position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.cm-card:hover .cm-ops { opacity: 1; }
.cm-op {
  font-size: 10.5px; padding: 3px 7px; border-radius: 6px; cursor: pointer;
  background: var(--cn-nav-bg); color: var(--text-2); border: 1px solid var(--cn-nav-border);
  backdrop-filter: blur(6px);
}
.cm-op:hover { color: var(--text); border-color: var(--border-strong); }
.cm-op.danger:hover { color: var(--danger); border-color: var(--danger); }
.cm-empty { padding: 36px 0; text-align: center; color: var(--text-3); font-size: 12.5px; grid-column: 1 / -1; }

/* 画布操作弹窗（新建 / 改名 / 删除） */
.canvas-dlg-modal { width: min(380px, calc(100vw - 40px)); }
.canvas-dlg-modal .modal-body { padding: 16px; }
.cm-dlg-tip { font-size: 12.5px; color: var(--text-2); line-height: 1.6; padding: 2px 0 4px; }
.cm-dlg-tip b { color: var(--text); font-weight: 600; }
.canvas-dlg-modal .btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.canvas-dlg-modal .btn.danger:hover { filter: brightness(1.06); }

/* 画布封面选择弹窗 */
.canvas-cover-modal { width: min(560px, calc(100vw - 40px)); }
.canvas-cover-modal .modal-body { padding: 16px; }
.cm-cv-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cm-cv-hint { font-size: 11.5px; color: var(--text-3); }
.cm-cv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px;
  max-height: min(44vh, 400px); overflow-y: auto; padding: 2px;
}
.cm-cv-item {
  position: relative; border-radius: 9px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; transition: border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.cm-cv-item:hover { border-color: var(--accent-line); opacity: .88; }
.cm-cv-item.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-line); }
.cm-cv-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.cm-cv-item .cm-cv-tag { position: absolute; left: 4px; top: 4px; font-size: 9.5px; padding: 1px 5px; border-radius: 999px; background: var(--cn-nav-bg); color: var(--text-2); backdrop-filter: blur(4px); }
.cm-cv-empty { padding: 28px 0; text-align: center; color: var(--text-3); font-size: 12.5px; }

/* 自动识别模型弹窗 */
.scan-entry { display: flex; align-items: center; gap: 10px; padding: 4px 2px 10px; }
.model-scan-modal { width: min(560px, calc(100vw - 40px)); }
.model-scan-modal .modal-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.scan-actions { display: flex; align-items: center; gap: 10px; }
.scan-status { font-size: 12px; color: var(--text-3); }
.scan-status.err { color: var(--danger); }
.scan-status.ok { color: var(--success, #22a06b); }
.scan-results { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.scan-results-bar { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.scan-check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.scan-type { font-size: 12.5px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); outline: none; }
.scan-list { max-height: 42vh; overflow-y: auto; }
.scan-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.scan-row:last-child { border-bottom: none; }
.scan-row .scan-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.scan-row .scan-badge { flex-shrink: 0; font-size: 10.5px; color: var(--text-3); }
.scan-row.done .scan-name { color: var(--text-3); text-decoration: line-through; }
.scan-list::-webkit-scrollbar, .cm-cv-grid::-webkit-scrollbar { width: 8px; }
.scan-list::-webkit-scrollbar-thumb, .cm-cv-grid::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.canvas-stage-wrap .canvas-stage {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  background: var(--bg-grad);
  background-image: var(--dot-pattern), var(--bg-grad);
  background-size: 22px 22px, auto;
  transition: box-shadow var(--dur) var(--ease);
  touch-action: none; user-select: none;
}
.canvas-stage.cn-dragover {
  box-shadow: inset 0 0 0 2.5px var(--accent-line);
  background: color-mix(in srgb, var(--accent-soft) 24%, var(--bg-grad));
}
#canvasStageInner {
  position: absolute !important; left: 0 !important; top: 0 !important;
  width: 0 !important; height: 0 !important; transform-origin: 0 0 !important;
}
.canvas-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.canvas-link-line {
  stroke: var(--accent-line); stroke-width: 1.8; fill: none;
  pointer-events: stroke; cursor: pointer;
  transition: stroke var(--dur) var(--ease), stroke-width var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.canvas-link-line:hover { stroke: var(--accent); stroke-width: 3; }
.canvas-link-line.cn-edge-del { stroke: var(--danger); stroke-width: 3; opacity: .9; }
.canvas-link-dot { fill: color-mix(in srgb, var(--accent-line) 85%, transparent); pointer-events: none; }
.canvas-link-arrow { fill: color-mix(in srgb, var(--accent-line) 85%, transparent); }
.canvas-link-temp { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-dasharray: 6 5; pointer-events: none; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 50%, transparent)); }
.canvas-nodes { position: absolute; left: 0; top: 0; }
.canvas-node {
  position: absolute; width: 236px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); display: flex; flex-direction: column; overflow: visible;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.canvas-node:hover { border-color: var(--border-strong); }
.canvas-node.selected { border-color: var(--accent-line); box-shadow: 0 0 0 2px var(--accent-soft), 0 3px 12px rgba(0,0,0,.22); }
.canvas-node-head {
  overflow: hidden; border-radius: 9px 9px 0 0;
}
.canvas-node-body {
  overflow: hidden; border-radius: 0 0 9px 9px;
}
.canvas-node.generating { border-color: var(--accent-line); }
.canvas-node.failed { border-color: var(--danger); }
.canvas-node-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: grab;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.canvas-node-head:active { cursor: grabbing; }
.cn-title { font-size: 12.5px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cn-title-input {
  flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--text);
  background: var(--surface-3); border: 1px solid var(--accent-line); border-radius: 5px;
  padding: 1px 4px; outline: none;
}
.cn-head-dl {
  flex: none; background: var(--accent-soft); color: var(--accent-hi);
  border: 1px solid var(--accent-line); font-size: 10px; line-height: 1.4;
  padding: 1px 7px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  transition: all var(--dur) var(--ease); text-decoration: none;
}
.cn-head-dl:hover { background: var(--accent); color: var(--on-accent); border-color: transparent; }
/* 生成进度展示在预览卡片上（卡片顶部无状态标签） */
.cn-preview-busy {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 92px; background: var(--surface-2);
}
.cn-progress {
  width: 78%; height: 6px; border-radius: 3px; background: var(--surface-3);
  overflow: hidden;
}
.cn-progress-bar {
  height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width .4s var(--ease);
}
.cn-progress-txt { font-size: 11px; color: var(--text-2); }
.cn-preview-fail {
  display: flex; align-items: center; justify-content: center; min-height: 92px;
  font-size: 11px; color: var(--danger); padding: 6px 10px; text-align: center;
  background: var(--surface-2); word-break: break-all;
}
.cn-del { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; }
.cn-del:hover { color: var(--danger); }
/* 选中节点头部快捷工具栏（运行/复制/删除），未选中只显示删除 */
.cn-head-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: 2px; flex-shrink: 0; }
.cn-head-act {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2);
  width: 20px; height: 20px; border-radius: 5px; cursor: pointer; font-size: 10px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: all var(--dur) var(--ease);
}
.cn-head-act:hover { color: var(--accent-hi); border-color: var(--accent-line); }
.cn-head-act.danger:hover { color: var(--danger); border-color: var(--danger); }
.cn-head-act[data-act="run"] { display: none; }
.canvas-node.selected .cn-head-act[data-act="run"] { display: inline-flex; }
.canvas-node-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
/* @ 引用候选 chips（@图片1 / @视频1 / @音频1） */
.cn-mentions { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.cn-mention {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--accent-hi);
  font-size: 11px; padding: 2px 9px; border-radius: 10px; cursor: pointer;
  transition: all var(--dur) var(--ease); line-height: 1.4;
}
.cn-mention:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-hi); }
/* 框选多选（Shift/Alt + 拖拽空白） */
.canvas-marquee {
  position: absolute; z-index: 60; pointer-events: none; display: none;
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 4px;
}
.cn-prompt-label { font-size: 11px; color: var(--text-3); }
.cn-prompt {
  width: 100%; min-height: 54px; max-height: 160px; resize: vertical; font-size: 12px; line-height: 1.55;
  padding: 8px 10px; border-radius: 9px; background: color-mix(in srgb, var(--bg) 78%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--border-strong) 40%, transparent); outline: none; font-family: inherit;
  caret-color: var(--accent);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cn-prompt:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.cn-sys-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.cn-sys-ta {
  width: 100%; min-height: 30px; max-height: 90px; resize: vertical; font-size: 12px; line-height: 1.5;
  padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--bg) 78%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--border-strong) 40%, transparent); outline: none; font-family: inherit;
  caret-color: var(--accent);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cn-sys-ta:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.cn-preview-text {
  font-size: 11px; line-height: 1.5; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
  align-items: flex-start; justify-content: flex-start; padding: 7px 9px; box-sizing: border-box;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.cn-preview-text:hover { border-color: var(--accent-line); color: var(--text); }
.cn-preview-text.cn-preview-ph { color: var(--text-3); align-items: center; justify-content: center; display: flex; }

/* 音乐节点：波形预览（下载仍为 mp3）；多首曲目上下排列 */
.cn-preview-waves { display: flex; flex-direction: column; gap: 4px; }
.cn-preview-waves .cn-preview-wave {
  display: flex; align-items: center; justify-content: center; min-height: 38px;
  background: var(--surface-2); border-radius: 7px; overflow: hidden;
}
.cn-preview-wave img.cn-wave-img { width: 100%; height: 38px; object-fit: cover; display: block; border-radius: 0; }
.cn-wave-ph { color: var(--text-3); font-size: 11px; }

/* 画布文本阅读弹窗 */
.text-read-modal { width: min(680px, 92vw); display: flex; flex-direction: column; }
.text-read-modal .modal-body { display: flex; flex-direction: column; }
.text-read-body {
  margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.75; font-size: 13.5px;
  color: var(--text); font-family: inherit; max-height: 62vh; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  box-sizing: border-box;
}
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 12px; }

.cn-preview {
  height: 88px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  overflow: hidden; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cn-preview img, .cn-preview video { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--surface-3); }
.cn-preview-auth-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-3); background: var(--surface-2); pointer-events: none; }
.cn-preview audio { width: 100%; height: 34px; padding: 0 6px; box-sizing: border-box; }
.cn-preview-ph { font-size: 11px; color: var(--text-3); }
.cn-model {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 3px 8px;
}
.cn-model-lbl { flex-shrink: 0; }
.cn-model select {
  flex: 1; min-width: 0; font-size: 11px; background: var(--surface-3); color: var(--text); border: none;
  border-radius: 5px; padding: 2px 4px; outline: none; cursor: pointer;
}
.cn-assets { display: flex; flex-direction: column; gap: 5px; }
.cn-assets-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--text-2); }
.cn-btn-sm {
  font-size: 11px; padding: 3px 10px; border-radius: 6px; cursor: pointer; user-select: none;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); font-weight: 500;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.cn-btn-sm:hover { color: var(--text); border-color: var(--border-strong); }
.cn-assets-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cn-asset { position: relative; display: block; }
.cn-asset img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-3); display: block; }
.cn-asset video { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-3); display: block; }
.cn-asset audio { width: 140px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.cn-asset-del {
  position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; line-height: 15px; text-align: center;
  border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text-2);
  font-size: 11px; cursor: pointer; padding: 0;
}
.cn-asset-del:hover { color: var(--danger); border-color: var(--danger); }
.cn-asset-loading { opacity: .35; }
.cn-params { display: flex; gap: 6px; flex-wrap: wrap; }
.cn-param {
  display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 3px 8px;
}
.cn-param select, .cn-param input[type=number] {
  font-size: 11px; background: var(--surface-3); color: var(--text); border: none;
  border-radius: 5px; padding: 2px 4px; outline: none; max-width: 96px;
}
/* 音乐节点参数：文本输入 / 滑块 / 勾选项与主工作台一致 */
.cn-param i { font-style: normal; opacity: .85; }
.cn-param input[type=text] {
  font-size: 11px; background: var(--surface-3); color: var(--text); border: none;
  border-radius: 5px; padding: 2px 4px; outline: none; width: 120px;
}
.cn-param input[type=range] { width: 92px; accent-color: var(--accent); }
.cn-adv { display: contents; }
.cn-check {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px;
  cursor: pointer; white-space: nowrap;
}
.cn-check input { accent-color: var(--accent); }
.cn-result { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.cn-result-text {
  font-size: 12px; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
  max-height: 160px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.cn-result-media { display: flex; flex-wrap: wrap; gap: 6px; }
.cn-result-media img, .cn-result-media video {
  max-width: 100%; max-height: 150px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); display: block;
}
.cn-result-media audio { width: 100%; height: 30px; }
.cn-empty-note { font-size: 11.5px; color: var(--text-3); font-style: italic; }
.cn-btns { display: flex; gap: 6px; }
.cn-btn {
  flex: 1; font-size: 12px; padding: 5px 0; border-radius: 6px; cursor: pointer;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.cn-btn:hover { color: var(--text); border-color: var(--border-strong); }
.cn-btn.run { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.cn-btn.run:hover { background: var(--accent-hi); }
.cn-btn.run:disabled { opacity: .55; cursor: not-allowed; }
.cn-io { position: absolute; width: 15px; height: 15px; border-radius: 50%; background: var(--surface-3); border: 2.5px solid var(--border-strong); z-index: 8; cursor: crosshair; opacity: 0; transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity .18s ease; }
.cn-io.in { left: -9px; top: 14px; }
.cn-io.out { right: -9px; top: 14px; background: var(--accent-soft); border-color: var(--accent-line); }
.canvas-node:hover .cn-io, .cn-io.active { opacity: 1; }
.canvas-node.cn-link-hover { outline: 2px dashed var(--accent-line); outline-offset: 3px; border-radius: 10px; }
.cn-io:hover, .cn-io.active { transform: scale(1.3); background: var(--accent); border-color: var(--accent-strong); }
.canvas-minimap {
  position: absolute; left: 14px; bottom: 66px; width: 196px; height: 148px;
  background: var(--cn-nav-bg); border: 1px solid var(--cn-nav-border); border-radius: 12px;
  z-index: 32; padding: 8px 8px 7px; box-sizing: border-box; box-shadow: var(--cn-nav-shadow);
  backdrop-filter: blur(6px); user-select: none;
  transition: height var(--dur) var(--ease), opacity var(--dur) var(--ease), padding var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.canvas-minimap.collapsed {
  height: 0; padding: 0 8px; border-color: transparent; opacity: 0;
  pointer-events: none; overflow: hidden;
}
.canvas-mini-toggle.active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.canvas-minimap-title { font-size: 10px; color: var(--text-3); margin-bottom: 5px; letter-spacing: .3px; }
.canvas-minimap-content { position: relative; width: 100%; height: calc(100% - 18px); overflow: hidden; border-radius: 7px; background: var(--cn-minimap-bg); border: 1px solid var(--cn-minimap-line); cursor: pointer; }
.cm-node { position: absolute; border-radius: 2px; opacity: .9; box-shadow: 0 0 0 1px var(--cn-node-stroke); }
.cm-view { position: absolute; border: 1.5px solid var(--cn-view-stroke); border-radius: 3px; background: var(--cn-view-fill); box-shadow: 0 0 0 1px rgba(0,0,0,.5); pointer-events: none; }
.cm-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-3); }
.canvas-return-tip {
  position: absolute; left: 14px; bottom: 224px; display: flex; align-items: center; gap: 10px;
  background: var(--cn-nav-bg); border: 1px solid var(--cn-nav-border); border-radius: 10px;
  padding: 9px 12px; font-size: 12px; color: var(--text-2); z-index: 32;
  box-shadow: var(--cn-nav-shadow); backdrop-filter: blur(6px);
}
.canvas-return-tip button {
  border: none; background: var(--accent, #4da3ff); color: #fff; font-size: 12px;
  padding: 4px 12px; border-radius: 7px; cursor: pointer;
}
.canvas-return-tip button:hover { opacity: .88; }
.canvas-return-tip[hidden] { display: none; }
.canvas-node-menu {
  position: fixed; z-index: 600; width: 232px; max-height: 340px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow-3); padding: 6px;
}
.canvas-node-menu .cnm-title { font-size: 11px; color: var(--text-3); padding: 4px 8px 7px; }
.canvas-mention {
  position: fixed; z-index: 900; width: 252px; max-height: 190px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-3); padding: 4px; display: none;
}
.canvas-mention .cm-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 12px; color: var(--text-1); }
.canvas-mention .cm-item:hover { background: var(--surface-3); }
.canvas-mention .cm-item img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; flex-shrink: 0; }
.canvas-mention .cm-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-node-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; margin: 0; border: 0;
  background: transparent; color: var(--text-1); font-size: 12px; border-radius: 8px; cursor: pointer; text-align: left;
}
.canvas-node-menu button:hover { background: var(--surface-3); }
.canvas-node-menu button .cnm-kind { margin-left: auto; font-size: 10px; color: var(--text-3); }
.canvas-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 13px; pointer-events: none; text-align: center; padding: 0 30px; }

/* 下游节点：上游素材缩略图行（点击删除连线） */
.cn-upstream { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,.06); background: rgba(255,255,255,.02); }
.cn-up-lbl { font-size: 11px; color: var(--sub,#8b93a5); white-space: nowrap; margin-right: 2px; }
.cn-up-item { position: relative; display: inline-block; width: 46px; height: 46px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); cursor: pointer; flex: 0 0 auto; background: #16181d; }
.cn-up-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cn-up-item i { position: absolute; top: 0; right: 0; width: 14px; height: 14px; line-height: 13px; text-align: center; font-style: normal; font-size: 10px; background: rgba(220,38,38,.9); color: #fff; border-radius: 0 0 0 6px; opacity: 0; transition: opacity .15s; }
.cn-up-item:hover i { opacity: 1; }
.cn-up-item:hover { border-color: rgba(220,38,38,.6); }
/* 素材节点精简素材区 */
.cn-assets-slim .cn-assets-head { padding: 6px 10px; }
/* 预览图失效兜底 */
.cn-preview-dead::after { content: "图片已失效"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-3); background: var(--surface-2); }
.cn-preview { position: relative; }
/* 选中节点下方独立配置面板（宽面板：输入框/模型/参数/生成按钮） */
.cn-panel {
  position: absolute; z-index: 6; background: var(--surface); border: 1px solid var(--accent-line);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.32), 0 0 0 2px var(--accent-soft);
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; max-height: 560px;
  pointer-events: none;   /* 空白区域点击穿透到下层卡片/画布，避免大面板遮挡相邻节点 */
}
.cn-panel select, .cn-panel textarea, .cn-panel input, .cn-panel button, .cn-panel a,
.cn-panel video, .cn-panel audio, .cn-panel .cn-mention, .cn-panel .cn-model { pointer-events: auto; }
.cn-panel-up { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cn-panel-prompt { display: flex; flex-direction: column; gap: 6px; }
.cn-panel-prompt .cn-prompt { min-height: 88px; font-size: 13px; }
.cn-panel-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cn-panel-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cn-panel-btns { display: flex; gap: 8px; }
.cn-panel-btns .cn-btn { padding: 7px 18px; font-size: 13px; }
.cn-panel .cn-model { padding: 5px 10px; font-size: 12px; }
.cn-panel .cn-param { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px; }
.cn-panel .cn-param select { font-size: 12px; background: var(--surface-3); color: var(--text); border: none; border-radius: 5px; padding: 2px 4px; outline: none; }
.cn-panel .cn-assets-slim .cn-assets-head { padding: 0; }

/* 节点卡片统一：212px 小卡 + 150px 缩略图 */
.canvas-node { width: 212px; }
.canvas-node .cn-preview { height: 150px; }

/* ═══════════ 声音克隆 / 音乐生成 专属面板 ═══════════ */
/* 图像/视频面板同样铺满左栏 */
#panelAV { display: flex; flex-direction: column; gap: var(--s3); flex: 1 1 auto; min-height: 0; }
#panelAV .chat-input-card { flex: 1 1 auto; min-height: 120px; }
/* 声音克隆 / 音乐生成 专属面板 */
.sub-panel { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; }
.sub-panel[hidden] { display: none; }
.panel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; flex: none; }
/* 内容卡片吃掉剩余高度，textarea 随面板拉伸 */
.panel-card--grow { flex: 1 1 auto; min-height: 140px; }
.panel-card--grow .panel-textarea { flex: 1 1 auto; resize: none; }
.panel-card.is-disabled { opacity: .45; }
.panel-card.is-disabled .panel-textarea { pointer-events: none; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.panel-title-sub { font-size: 11px; font-weight: 400; color: var(--text-3); }
.panel-textarea { width: 100%; resize: vertical; min-height: 52px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.65;
  padding: 10px 12px; outline: none; transition: border-color var(--dur) var(--ease); }
.panel-textarea:focus { border-color: var(--accent); }
.panel-textarea::placeholder { color: var(--text-3); }
.panel-note { font-size: 11.5px; color: var(--text-3); line-height: 1.7; padding: 0 4px; }
/* 预计耗时提示条：各功能模块统一 */
.eta-line { display: flex; align-items: center; gap: 8px; flex: none;
  padding: 8px 12px; border: 1px dashed var(--border-strong); border-radius: var(--r);
  background: var(--surface-2); font-size: 11.5px; color: var(--text-3); }
.eta-line > svg { color: var(--accent); flex: none; }
.eta-cap { white-space: nowrap; }
.eta-val { color: var(--text); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eta-desc { margin-left: auto; text-align: right; opacity: .82; }
/* 参考音频上传槽 */
.ref-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ref-slot { position: relative; border: 1.5px dashed var(--border-strong); border-radius: var(--r);
  background: var(--surface-2); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.ref-slot:hover { border-color: var(--accent); }
.ref-slot.dragover { border-color: var(--accent); background: var(--accent-soft); }
.slot-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 20px 12px; text-align: center; cursor: pointer; color: var(--text-3); }
.slot-empty:hover { color: var(--accent); }
.slot-name { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.slot-req { font-size: 10px; font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; }
.slot-opt { font-size: 10px; font-weight: 500; color: var(--text-3); background: var(--surface-3); border-radius: 4px; padding: 1px 6px; }
.slot-sub { font-size: 11px; color: var(--text-3); line-height: 1.5; }
.slot-filled { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.slot-file { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 上传槽内的小播放控件（替代浏览器原生 audio，与页面风格统一） */
.slot-audio { display: flex; align-items: center; gap: 8px; }
.slot-play { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text-2); font-size: 9px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; transition: all var(--dur) var(--ease); }
.slot-play:hover { color: var(--accent); border-color: var(--accent); }
.slot-dur { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.slot-del { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border: none; border-radius: 50%;
  background: var(--surface-3); color: var(--text-3); font-size: 11px; cursor: pointer; line-height: 1; }
.slot-del:hover { background: var(--red); color: #fff; }
/* 分段按钮（情绪强度 / 音乐模式） */
.seg-group { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg-label { font-size: 12px; color: var(--text-3); padding: 0 8px 0 10px; }
.seg-btn { border: none; background: transparent; color: var(--text-3); font-size: 12.5px; padding: 6px 14px;
  border-radius: 999px; cursor: pointer; transition: all var(--dur) var(--ease); }
.seg-btn:hover { color: var(--text-2); }
.seg-btn.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg-full { display: flex; width: 100%; }
.seg-full .seg-btn { flex: 1; padding: 8px 14px; font-size: 13px; }
.music-mode-hint { font-size: 11.5px; color: var(--text-3); }
.panel-foot { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.music-params { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.music-params label { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-3); }
.music-params select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px 9px; font-size: 12.5px; outline: none; }
@media (max-width: 640px) {
  .ref-slots { grid-template-columns: 1fr; }
  .panel-foot { flex-direction: column; align-items: stretch; }
  .panel-foot .send-btn { width: 100%; }
}

/* ═══════════ 音乐生成：风格输入框 ═══════════ */
.style-wrap { display: flex; flex-direction: column; min-height: 0; padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border); }
.style-wrap[hidden] { display: none; }
#styleInput { flex: 1 1 auto; min-height: 44px; width: 100%; resize: none; border: none; outline: none;
  background: transparent; color: var(--text); caret-color: var(--text);
  font-family: var(--font-body); font-size: 14.5px; line-height: 1.6; padding: 2px 4px; }
#styleInput::placeholder { color: var(--text-3); }

/* ═══════════ 历史分类过滤 ═══════════ */
.hist-filters { display: flex; gap: 6px; padding: 0 12px 8px; }
.hf-btn { font-size: 12px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.hf-btn:hover { color: var(--text-2); border-color: var(--border-strong); }
.hf-btn.active { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
/* 任务卡片的类型小标（图像/视频/语音） */
.task-kind-tag { font-size: 10.5px; color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; flex: none; }
/* 声音克隆缩略图（历史卡片） */
.tts-thumb { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; background: linear-gradient(135deg, var(--accent-soft), transparent); color: var(--accent); }
.tts-thumb span { font-size: 10px; color: var(--text-3); }
/* 音频缩略图：迷你波形 + 与视频封面一致的播放圆钮 */
.audio-thumb { position: relative; width: 100%; height: 100%; display: grid; place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, oklch(0.55 0.12 265 / .22), oklch(0.45 0.08 220 / .1));
  color: var(--accent); }
.audio-thumb .at-wave { width: 100%; height: 62%; opacity: .55; display: block; }
.audio-thumb .at-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.52); color: #fff;
  font-size: 10px; display: grid; place-items: center; }
/* 视频缩略图：静态首帧封面（不随列表刷新重载），悬停才加载 video */
.video-thumb { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(135deg, oklch(0.55 0.12 265 / .35), oklch(0.45 0.08 220 / .18));
  color: var(--text-2); }
.video-thumb span { font-size: 10px; color: var(--text-3); }
.video-thumb .vt-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.video-thumb .vt-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  z-index: 2; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.52);
  color: #fff; font-size: 10px; display: grid; place-items: center; pointer-events: none; }
.video-thumb .thumb-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: 3; }
/* 结果弹窗内的语音预览 */
.tts-preview { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  min-height: 220px; width: 100%; color: var(--accent); }
.tts-preview audio { width: min(420px, 90%); }

/* ═══════════ 音乐 / 语音结果：波形播放器 + 歌词 ═══════════ */
.audio-result { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.ap-player { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 10px; }
.ap-wave-wrap { position: relative; height: 110px; cursor: pointer; border-radius: var(--r-sm); overflow: hidden;
  background: var(--surface-3); }
.ap-wave { display: block; width: 100%; height: 100%; }
.ap-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); left: 0;
  box-shadow: 0 0 8px var(--accent); pointer-events: none; transition: left .08s linear; }
.ap-bar { display: flex; align-items: center; gap: 12px; }
.ap-play { width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 12px; line-height: 1;
  display: grid; place-items: center; transition: transform var(--dur) var(--ease); }
.ap-play:hover { transform: scale(1.06); }
.ap-time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ap-hint { margin-left: auto; font-size: 11px; color: var(--text-3); }
.lyrics-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.lc-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
  border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text); }
.lc-copy { border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
  font-size: 11.5px; padding: 4px 12px; border-radius: 999px; cursor: pointer; transition: all var(--dur) var(--ease); }
.lc-copy:hover { color: var(--accent); border-color: var(--accent); }
.lc-body { margin: 0; padding: 14px 16px; max-height: 240px; overflow-y: auto; white-space: pre-wrap;
  font-family: var(--font-body); font-size: 13.5px; line-height: 1.9; color: var(--text-2); }

/* ═══════════ 首屏历史记录骨架（shimmer 占位） ═══════════
   首次 loadHistory 返回前显示，避免历史区先空白再突然铺满 */
.hist-skel { display: flex; flex-direction: column; gap: 10px; padding: 2px; }
.hs-item { display: flex; gap: 10px; align-items: center; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.hs-thumb { width: 64px; height: 64px; flex: none; border-radius: var(--r-sm); }
.hs-lines { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.hs-lines i { display: block; height: 10px; border-radius: 5px; }
.hs-lines i:first-child { width: 74%; }
.hs-lines i:last-child { width: 46%; }
.hs-thumb, .hs-lines i {
  background: linear-gradient(90deg, var(--skel-color) 25%, var(--surface-3) 37%, var(--skel-color) 63%);
  background-size: 400% 100%; animation: hsShimmer 1.25s ease-in-out infinite;
}
@keyframes hsShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .hs-thumb, .hs-lines i { animation: none; }
}
