
/* 字体 · 本地托管 + 按界面实际字符子集化（latin 可变字体，一份文件覆盖全部字重）
   上游是可变字体：Google 按 4 个字重各发一份同样的文件，按字重存会白下 3 遍。
   中文不在这个 unicode-range 内，照旧走系统字（PingFang / 微软雅黑），与改动前一致。 */


/* ============================================
   🎨 CSS 变量 · 主题系统
   ============================================ */
:root {
  /* 全屏高度的唯一出处：移动端 100vh 会把浏览器工具栏算进去，底部内容被系统栏吃掉。
     支持 dvh 就用 dvh（跟随工具栏收放），不支持才退回 vh。所有 calc(100vh - …) 一律走它，
     禁止再散写 100vh。 */
  --vh100: 100vh;

  --bg-primary: oklch(0.965 0.01 82);
  --bg-secondary: oklch(0.935 0.017 85);
  --bg-surface: oklch(0.98 0.009 85);
  --bg-elevated: oklch(0.988 0.007 89);
  --bg-glass: oklch(0.98 0.009 85 / 0.75);
  --bg-glass-heavy: oklch(0.965 0.01 82 / 0.92);
  --bg-card: oklch(0.958 0.012 84 / 0.55);

  --border-subtle: oklch(0.687 0.041 80 / 0.16);
  --border-medium: oklch(0.687 0.041 80 / 0.28);
  --border-strong: oklch(0.614 0.053 83 / 0.42);

  --text-primary: oklch(0.266 0.024 78);
  /* 三级文字实测对比度（对 --bg-primary / --bg-surface）：
     旧值 .486/.545 只有 5.78/4.49 —— 三级刚好压在 AA 线下，且它承载的都是 8–12px 小字。
     抬到 .47/.515 → 6.0/5.08，仍是「安静的一档」，但不再靠字号小来牺牲可读性。 */
  --text-secondary: oklch(0.47 0.035 77);
  --text-tertiary: oklch(0.515 0.034 78);
  --text-inverse: oklch(0.977 0.009 85);

  --accent: oklch(0.54 0.098 83);
  --accent-soft: oklch(0.54 0.098 83 / 0.09);
  --accent-medium: oklch(0.54 0.098 83 / 0.2);
  --accent-hover: oklch(0.5 0.09 83);
  --accent-glow: oklch(0.54 0.098 83 / 0.24);
  --accent-ink: oklch(0.44 0.078 84);
  /* 落在 accent-soft 底上的文字（选中 chip 标签）：--accent 在该底上只有 4.29，
     12px 半粗不属于「大字号」豁免，所以另开一档更深的同色相。暗色下反向（该档即 --accent 本身） */
  --accent-on-soft: oklch(0.455 0.082 84);
  --accent-bright: oklch(0.676 0.121 86);

  --success: oklch(0.53 0.088 140);
  --success-soft: oklch(0.53 0.088 140 / 0.11);
  --warning: oklch(0.55 0.102 76);
  --warning-soft: oklch(0.55 0.102 76 / 0.11);
  --danger: oklch(0.542 0.135 25);
  --danger-soft: oklch(0.542 0.135 25 / 0.11);

  --shadow-xs: 0 1px 2px oklch(0.293 0.025 72 / 0.04);
  --shadow-sm: 0 2px 8px oklch(0.293 0.025 72 / 0.05), 0 1px 3px oklch(0.293 0.025 72 / 0.03);
  --shadow-md: 0 4px 16px oklch(0.293 0.025 72 / 0.07), 0 2px 6px oklch(0.293 0.025 72 / 0.04);
  --shadow-lg: 0 8px 32px oklch(0.293 0.025 72 / 0.09), 0 4px 12px oklch(0.293 0.025 72 / 0.05);
  --shadow-xl: 0 16px 48px oklch(0.293 0.025 72 / 0.12), 0 6px 20px oklch(0.293 0.025 72 / 0.07);
  --shadow-glow: 0 0 24px oklch(0.54 0.098 83 / 0.14);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --font-display: 'Playfair Display', Georgia, 'Noto Serif SC', serif;
  --font-body: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  /* 渐进式字号体系 */
  --text-xs: 0.6875rem;    /* 11px · 辅助标注 */
  --text-sm: 0.75rem;      /* 12px · 次要信息 */
  --text-base: 0.8125rem;  /* 13px · 正文基准 */
  --text-md: 0.875rem;     /* 14px · 强调正文 */
  --text-lg: 1rem;         /* 16px · 小标题 */
  --text-xl: 1.25rem;      /* 20px · 标题 */
  --text-2xl: 1.5rem;      /* 24px · 大标题 */
  --text-3xl: 2rem;        /* 32px · 展示标题 */

  /* 行高体系 */
  --leading-tight: 1.25;
  --leading-snug: 1.45;
  --leading-normal: 1.65;
  --leading-relaxed: 1.8;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  /* 与 --ease-out 同曲线的别名：全站有 9 处 transition 一直在引用它却从未定义，
     那几条过渡此前等于失效——补上定义一次修好旧残留，也供 /video 舞台复用 */
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* 柔弹簧（抬起回位用）：峰值是行程的 1.43 倍，绝对量约 +1.2%，能看见但不夸张 */
  --ease-spring-soft: cubic-bezier(0.34, 1.28, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  /* 位移型指示器专用曲线：中段才发力。expo-out 会把 90% 位移压进前 40% 时间里，
     60px 的格子只剩三四帧可读位移，读成瞬移（实测：320ms + --ease-out 时 90% 在 132ms 就到） */
  --ease-slide: cubic-bezier(0.42, 0, 0.3, 1);
  /* 弹性幅度基准：过冲 2–3%、压扁 6–10%。数值只在这里改，组件里引用 token */
  --overshoot: 1.03;
  --squash: 0.92;

  /* 挂起反馈的四个档位，组件里只许引用这几个名字 */
  --duration-instant: 80ms;      /* 拖拽 / 按压等必须「跟手」的位移，长于此会像在拖橡皮筋 */
  --duration-micro: 150ms;       /* 悬停与点击的颜色 / 描边 / 透明度的微反馈 */
  --duration-exit: 220ms;        /* 淡出、收起、Toast 退场 */
  --duration-indicator: 320ms;   /* 滑动指示器、分段切换、面板级位移 */
  --duration-slide: 420ms;       /* 指示器位移专用：340–420 区间上限，实测 90% 位移落在 252ms */
  --duration-jelly: 540ms;       /* 果冻 ≈ 位移时长 ×1.3，两者同时起手 */
  --duration-enter: 450ms;       /* 揭幕、较大揭示、布局级变化 */
  /* 按压手感的两段：按下只求「立刻就动」（90ms 内到位，端到端 <100ms 才算跟手），
     抬起走弹性曲线回位 —— 过冲来自 --ease-spring-soft 的 1.2 段，不需要额外关键帧 */
  --duration-press: 90ms;
  --duration-release: 260ms;

  --hl-inset: inset 0 1px 0 oklch(0.99 0.007 89 / 0.4);

  --header-h: 64px;
  --touch: 44px;
  --focus-ring: 3px solid oklch(0.54 0.098 83 / 0.55);
  --focus-offset: 2px;

  /* 背景装饰：亮色下需更高的点阵对比度与曲线可见度，否则近乎隐形 */
  --dot-color: oklch(0.66 0.045 85 / 0.11);
  --ambient-glow: oklch(0.54 0.098 83 / 0.14);
  --overlay-scrim: oklch(0.22 0.02 75 / 0.55);
}
/* 逐点写死的抬起曲线：linear() 的数值是「行程倍数」，1.43 就是走过头 43%。
   不支持 linear() 的浏览器走 @supports 之外的贝塞尔，退化但不出错。
   注意别在这里改成贝塞尔：delta 0.028 时贝塞尔的 2.6% 过冲只有 0.0007，等于不弹。 */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ease-spring-soft: linear(0, 0.52 12%, 0.95 30%, 1.29 46%, 1.43 60%, 1.22 76%, 0.97 88%, 1);
  }
}

/* 低饱和暖灰 · 暗色主题 */
[data-theme="dark"] {
  --bg-primary: oklch(0.193 0.005 68);
  --bg-secondary: oklch(0.219 0.007 78);
  --bg-surface: oklch(0.25 0.009 75);
  --bg-elevated: oklch(0.282 0.01 81);
  --bg-glass: oklch(0.193 0.005 68 / 0.8);
  --bg-glass-heavy: oklch(0.225 0.006 75 / 0.92);
  --bg-card: oklch(0.275 0.009 78 / 0.6);

  --border-subtle: oklch(0.762 0.023 76 / 0.09);
  --border-medium: oklch(0.762 0.023 76 / 0.16);
  --border-strong: oklch(0.762 0.023 76 / 0.26);

  --text-primary: oklch(0.911 0.013 82);
  /* 同上：.666/.595 在 --bg-surface（L .25）上只有 3.97，三级文字读不清；
     .705/.635 → 6.3/4.66 全过。两档之间仍保留 0.07 的明度台阶。 */
  --text-secondary: oklch(0.705 0.018 79);
  --text-tertiary: oklch(0.67 0.017 81);   /* 原 0.635：侧栏 4.23:1 不达标 → 4.83:1 */
  --text-inverse: oklch(0.193 0.005 68);

  --accent: oklch(0.787 0.023 76);
  --accent-soft: oklch(0.787 0.023 76 / 0.1);
  --accent-medium: oklch(0.787 0.023 76 / 0.2);
  --accent-hover: oklch(0.83 0.019 78);
  --accent-glow: oklch(0.787 0.023 76 / 0.2);
  --accent-ink: oklch(0.659 0.021 72);
  --accent-on-soft: oklch(0.787 0.023 76);
  --accent-bright: oklch(0.851 0.017 79);

  --success: oklch(0.618 0.033 133);
  --success-soft: oklch(0.618 0.033 133 / 0.12);
  --warning: oklch(0.691 0.04 83);
  --warning-soft: oklch(0.691 0.04 83 / 0.12);
  --danger: oklch(0.629 0.056 25);
  --danger-soft: oklch(0.629 0.056 25 / 0.12);

  --shadow-xs: 0 1px 2px oklch(0.09 0.008 75 / 0.18);
  --shadow-sm: 0 2px 8px oklch(0.09 0.008 75 / 0.22), 0 1px 3px oklch(0.09 0.008 75 / 0.12);
  --shadow-md: 0 4px 16px oklch(0.09 0.008 75 / 0.26), 0 2px 6px oklch(0.09 0.008 75 / 0.14);
  --shadow-lg: 0 8px 32px oklch(0.09 0.008 75 / 0.3), 0 4px 12px oklch(0.09 0.008 75 / 0.18);
  --shadow-xl: 0 16px 48px oklch(0.09 0.008 75 / 0.36), 0 6px 20px oklch(0.09 0.008 75 / 0.22);
  --shadow-glow: 0 0 28px oklch(0.787 0.023 76 / 0.2);

  --hl-inset: inset 0 1px 0 oklch(0.97 0.011 85 / 0.04);

  --dot-color: oklch(0.762 0.023 76 / 0.12);
  --ambient-glow: oklch(0.787 0.023 76 / 0.18);
  --overlay-scrim: oklch(0.13 0.006 70 / 0.62);
}

/* ============================================
   🔄 基础重置
   ============================================ */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}
/* 表单控件默认不继承字体：漏写 font-family 的按钮会掉到 Arial，
   与同排的 <a>/<span> 字形和基线都不一致（报错卡片的「重试 / 新标签打开」就是这么露馅的）。
   只统一 family，不动 size/weight，避免连带改出一堆新排版问题。 */
button, input, select, textarea { font-family: inherit; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background:
    radial-gradient(1100px 640px at 78% -12%, var(--accent-soft), transparent 62%),
    var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--leading-normal);
  min-height: var(--vh100);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

::selection { background: var(--accent-medium); color: var(--text-primary); }

:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
:focus:not(:focus-visible) { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* 卡片整体可点（结果图 / 历史条目 / 历史面板卡片）：
   卡内放一颗 sr-only 的真实按钮承担键盘路径，鼠标路径仍是整卡点击。
   焦点落在隐藏按钮上时，把焦点环画在卡片上，用户看得见自己在哪 */
.result-image-wrap:has(.card-a11y-btn:focus-visible),
.history-item:has(.card-a11y-btn:focus-visible),
.hp-item:has(.card-a11y-btn:focus-visible) {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
.card-a11y-btn:focus-visible { outline: none; }
/* 小尺寸图标按钮：视觉不动，透明命中盒撑到 44px（菲茨定律） */
.theme-toggle, .sidebar-toggle, .sb-rail-btn, .api-key-toggle,
.history-delete, .history-cancel, .hp-item-del, .ref-thumb-remove,
.slot-remove, .compare-remove, .fail-modal-close, .toast-close,
.img-action-btn, .viewer-btn { position: relative; }
.theme-toggle::after, .sidebar-toggle::after, .sb-rail-btn::after,
.api-key-toggle::after, .history-delete::after, .history-cancel::after,
.hp-item-del::after, .ref-thumb-remove::after, .slot-remove::after,
.compare-remove::after, .fail-modal-close::after, .toast-close::after,
.img-action-btn::after, .viewer-btn::after {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px;
  min-width: 100%; min-height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 2000;
  padding: 10px 16px; border-radius: var(--radius-full);
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm); font-weight: 600;
  text-decoration: none;
  transform: translateY(-140%);
}
.skip-link:focus, .skip-link:focus-visible {
  transform: translateY(0);
}
/* 两条跳转链同点收起；聚焦时第二条让位到第一条下方，不互相覆盖 */
.skip-link + .skip-link { top: 10px; }
.skip-link + .skip-link:focus, .skip-link + .skip-link:focus-visible { top: 58px; }
.viewer-overlay[hidden],
.fail-modal-overlay[hidden],
.hpanel-overlay[hidden],
.set-overlay[hidden],
.confirm-overlay[hidden] {
  display: none !important;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-medium); border-radius: var(--radius-full);
  background-clip: padding-box; border: 1px solid transparent;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }

/* ============================================
   🌊 SVG 背景装饰
   ============================================ */
.bg-decoration {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
  contain: strict;
}
/* 纸感点阵底纹（中心渐隐） */
.bg-decoration::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 90% 72% at 50% 36%, #000 18%, transparent 78%);
  mask-image: radial-gradient(ellipse 90% 72% at 50% 36%, #000 18%, transparent 78%);
}
/* 左下环境光晕（静态） */
.bg-decoration::after {
  content: ''; position: absolute;
  width: 48vw; height: 48vw; left: -16vw; bottom: -20vw;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ambient-glow), transparent 65%);
}
/* 循环氛围只动 opacity/位移：禁止 scale/滤镜/阴影参与无限动画 */
@keyframes ambientBreath {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
/* 右上环境光晕 · 与左下错峰呼吸 */
.bg-glow-tr {
  position: absolute;
  width: 40vw; height: 40vw; right: -14vw; top: -16vw;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ambient-glow), transparent 65%);
  animation: ambientBreath 18s var(--ease-smooth) -8s infinite;
}
.bg-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, var(--ambient-glow) 0%, transparent 70%);
}
.bg-orb-1 {
  width: min(46vw, 520px); height: min(46vw, 520px);
  top: 6%; left: 4%;
  animation: orbFloat 20s var(--ease-smooth) infinite;
}
.bg-orb-2 {
  width: min(40vw, 440px); height: min(40vw, 440px);
  bottom: 8%; right: 6%;
  animation: orbFloat 26s var(--ease-smooth) -11s infinite reverse;
}
@keyframes orbFloat {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: 0.55; }
  33% { transform: translate3d(48px, -32px, 0); opacity: 0.95; }
  66% { transform: translate3d(-32px, 28px, 0); opacity: 0.7; }
}

/* ============================================
   🎬 首屏揭幕幕布（brand loader）
   字体锁字面量系统栈：webfont 换形只发生在幕布之下
   ============================================ */
.boot-curtain {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 540px at 72% -10%, var(--accent-soft), transparent 62%),
    var(--bg-primary);
  transition: transform var(--duration-indicator) var(--ease-out-expo), opacity var(--duration-indicator) var(--ease-out-expo);
}
.boot-curtain.lift { transform: translateY(-101%); opacity: 0; }
.boot-curtain.gone { display: none; }
.boot-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* 字标上飘用 exit 档：揭幕是「字标先走 → 幕布跟上」的错拍，两段同为 150ms 就没有先后了 */
  transition: transform var(--duration-exit) var(--ease-out-expo), opacity var(--duration-exit) var(--ease-out-expo);
}
.boot-curtain.lift .boot-inner { transform: translateY(-26px); opacity: 0; }
.boot-mark {
  width: 44px; height: 44px; color: var(--accent);
  animation: bootBob 2.4s var(--ease-smooth) infinite;
}
@keyframes bootBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.boot-word {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px; font-weight: 600; letter-spacing: -0.4px;
  color: var(--text-primary); line-height: 1.2; margin-top: 2px;
}
.boot-sub {
  font-size: 12px; letter-spacing: 6px; text-indent: 6px;
  color: var(--text-tertiary);
}
.boot-status {
  position: relative; width: 240px; height: 18px; margin-top: 14px;
}
.boot-status span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-secondary);
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--duration-micro) var(--ease-out-soft), transform var(--duration-micro) var(--ease-out-soft);
}
.boot-status span.on { opacity: 1; transform: translateY(0); }

/* ============================================
   📐 布局
   ============================================ */
@supports (height: 100dvh) {
  :root { --vh100: 100dvh; }
}
.app-container {
  position: relative; z-index: 1;
  height: var(--vh100);
  display: flex; flex-direction: column;
  overflow: hidden;
}
/* 进场全部挂在揭幕瞬间：与幕布上提是同一个上行手势，禁止在遮罩底下播完 */

/* ============================================
   🧭 顶部导航栏
   ============================================ */
.nav-header {
  position: relative; z-index: 100;
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-left { display: flex; align-items: center; gap: 14px; }

.nav-logo {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  /* 亮色主题用专属亮色 Logo，底色改为暖米白衔接；暗色保持纯黑 */
  background: linear-gradient(145deg, oklch(0.994 0.007 89), oklch(0.921 0.025 83));
  box-shadow: var(--shadow-sm), inset 0 0 0 1px oklch(0.585 0.107 84 / 0.25);
  transition: transform var(--duration-indicator) var(--ease-spring);
}
[data-theme="dark"] .nav-logo { background: oklch(0.17 0.004 75); box-shadow: var(--shadow-sm); }
.nav-logo:hover { transform: scale(1.08) rotate(-2deg); }

.nav-brand { display: flex; flex-direction: column; line-height: 1.2; }
.nav-title {
  font-family: var(--font-display);
  font-size: var(--text-xl); font-weight: 500;
  letter-spacing: -0.5px; color: var(--text-primary);
  white-space: nowrap;
  line-height: var(--leading-tight);
}

.nav-right { display: flex; align-items: center; gap: 10px; }

/* API Key 胶囊 */
.api-key-capsule {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  transition: border-color var(--duration-indicator) var(--ease-smooth), box-shadow var(--duration-indicator) var(--ease-smooth);
}
.api-key-capsule:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}

.api-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-tertiary); flex-shrink: 0;
  transition: background var(--duration-enter) var(--ease-smooth);
}
.api-status-dot.active {
  background: var(--success);
  box-shadow: 0 0 6px oklch(0.6 0.08 140 / 0.5);
  animation: pulseGlow 2s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.api-key-input {
  border: none; background: transparent; outline: none;
  font-family: var(--font-mono); font-size: 12px;
  /* 掩码点原本是近黑 12px 连排，在暖米底上读成一条黑杠 —— 侧栏里最重的东西成了最不重要的东西。
     降到二级灰并把点距拉开，恢复「字段」的质感；聚焦时才回到主文字色（那时它确实是焦点） */
  color: var(--text-secondary); width: 180px; letter-spacing: 1px;
  transition: color var(--duration-micro) var(--ease-out);
}
.api-key-input:focus { color: var(--text-primary); }
.api-key-input::placeholder {
  color: var(--text-tertiary); font-family: var(--font-body); font-size: 12px;
}

/* API Key 显示/隐藏按钮 */
.api-key-toggle {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 13px;
  transition: color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
  flex-shrink: 0;
}
.api-key-toggle:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft);
}
.api-key-toggle svg { width: 15px; height: 15px; }

/* 导航栏通用胶囊按钮 */
.nav-pill-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), box-shadow var(--duration-micro) var(--ease-smooth);
  white-space: nowrap;
}
.nav-pill-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-pill-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* 支持作者按钮特殊样式 */
.nav-pill-btn.support {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border-color: var(--accent-medium);
  color: var(--accent);
}
.nav-pill-btn.support:hover {
  background: linear-gradient(135deg, var(--accent-medium), var(--accent-soft));
  box-shadow: var(--shadow-sm), var(--shadow-glow);
}

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  box-shadow: var(--hl-inset);
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
}
.theme-toggle svg { width: 16px; height: 16px; transition: transform var(--duration-enter) var(--ease-spring); }
.theme-toggle:hover {
  transform: scale(1.08);
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.theme-toggle:hover svg { transform: rotate(24deg); }


/* ── 移动端顶栏唯一控件：圆形设置按钮 ──
   材质与 theme-toggle 完全同源，保证顶栏只有「一个」视觉重量的控件。
   打开态用 accent 描边 + 淡底，与浮层建立呼应。 */
.nav-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  box-shadow: var(--hl-inset);
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
}
.nav-icon-btn svg { width: 17px; height: 17px; transition: transform var(--duration-enter) var(--ease-spring); }
.nav-icon-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.nav-icon-btn:hover svg { transform: rotate(-10deg); }

.nav-icon-btn[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* 桌面端：顶栏内容整合进侧边栏，顶栏仅在移动端显示 */
@media (min-width: 901px) {
  .nav-header { display: none; }
}

/* ============================================
   📏 主内容区 · 左侧历史栏 + 右侧展示区
   ============================================ */
.main-content {
  flex: 1; display: grid;
  grid-template-columns: 232px 1fr;
  gap: 0;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns var(--duration-indicator) var(--ease-smooth);
}
.main-content.sidebar-collapsed { grid-template-columns: 56px 1fr; }

/* ============================================
   📜 左侧 · 历史记录侧边栏
   ============================================ */
.history-sidebar {
  padding: 14px 12px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

/* ── 侧边栏品牌区 ── */
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-shrink: 0;
}
.sb-brand .nav-logo { width: 32px; height: 32px; }
.sb-title {
  flex: 1; min-width: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg); font-weight: 500;
  letter-spacing: -0.4px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: var(--leading-tight);
}

/* ── 侧边栏设置区（移动端会被移入顶栏） ── */
.sb-controls {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 12px; margin-top: 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sb-controls .api-key-capsule { width: 100%; }
.sb-controls .api-key-input { flex: 1; min-width: 0; width: auto; }
.nav-right .sb-controls {
  flex-direction: row; align-items: center;
  border-top: none; padding-top: 0; margin-top: 0; gap: 8px;
}

.sb-actions { display: flex; align-items: center; gap: 6px; }
.sb-actions .nav-pill-btn { min-width: 0; justify-content: center; padding: 7px 10px; }
.sb-actions #wsOpenBtn { flex: 1 1 auto; }
.sb-actions .nav-pill-btn.support { flex: 0 0 auto; padding: 6px 8px; gap: 4px; font-size: 10.5px; }
.sb-actions .theme-toggle { width: 32px; height: 32px; flex-shrink: 0; margin-left: auto; }

/* 收起态专用：历史面板入口图标 */
.sb-rail-btn {
  display: none;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface); cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
  flex-shrink: 0; margin: 0 auto 10px;
}
.sb-rail-btn svg { width: 15px; height: 15px; }
.sb-rail-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* 展开/收起按钮 */
.sidebar-toggle {
  width: 32px; height: 32px; flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: var(--bg-surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
  transition: color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out);
}
.sidebar-toggle:hover { color: var(--accent); border-color: var(--accent); }
.sidebar-toggle svg { width: 13px; height: 13px; transition: transform var(--duration-indicator) var(--ease-smooth); }

/* ── 侧边栏收起态：竖向图标窄栏 ── */
.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar-collapsed .history-sidebar { padding: 12px 6px; }
.sidebar-collapsed .sb-brand {
  flex-direction: column; gap: 8px; margin-bottom: 12px;
}
.sidebar-collapsed .sb-brand .nav-logo { width: 34px; height: 34px; }
.sidebar-collapsed .sb-title,
.sidebar-collapsed .history-header,
.sidebar-collapsed .history-scroll,
.sidebar-collapsed .api-key-capsule { display: none; }
.sidebar-collapsed .sb-rail-btn { display: flex; }
.sidebar-collapsed .sb-controls {
  border-top: none; padding-top: 0; margin-top: auto;
}
.sidebar-collapsed .sb-actions { flex-direction: column; gap: 8px; }
.sidebar-collapsed .sb-actions .nav-pill-btn {
  flex: none; width: 34px; height: 34px; padding: 0;
  border-radius: 50%; justify-content: center;
}
.sidebar-collapsed .sb-actions .nav-pill-btn .pill-label { display: none; }

/* Prompt 输入区（胶囊内） */
.prompt-textarea {
  flex: 1; min-height: 44px; max-height: 200px;
  resize: none; overflow-y: hidden;
  padding: 12px 4px;
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-md); font-weight: 400;
  line-height: var(--leading-relaxed);
  color: var(--text-primary); outline: none;
}
.prompt-textarea::placeholder { color: var(--text-tertiary); font-weight: 300; }

/* 灵感标签 */
.inspiration-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 2px;
}

.inspiration-tag {
  position: relative;
  padding: 4px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: transparent;
  font-family: var(--font-body);
  font-size: 11px; color: var(--text-tertiary);
  cursor: pointer; transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
  white-space: nowrap;
}
.inspiration-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.inspiration-tag .tag-tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 11px; color: var(--text-secondary);
  line-height: 1.6; max-width: min(280px, calc(100vw - 48px)); min-width: 180px;
  white-space: normal; word-break: break-word;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-micro) var(--ease-smooth), transform var(--duration-micro) var(--ease-smooth);
  transform: translateX(-50%) translateY(4px);
  z-index: 50;
}
.inspiration-tag .tag-tooltip::after {
  content: '';
  position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border-medium);
}
.inspiration-tag:hover .tag-tooltip {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.inspiration-tag.disabled {
  opacity: 0.4; cursor: not-allowed;
  text-decoration: line-through;
  filter: grayscale(0.5);
}
.inspiration-tag.disabled:hover {
  border-color: var(--border-subtle);
  color: var(--text-tertiary);
  background: transparent; transform: none;
}

/* 比例选择 */
.option-chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* 通道/模型不支持的选项用 hidden 摘掉。
   ⚠️ 这条只对**没有 ID 前缀**的容器管用：凡是像 `#ratioChips .option-chip { display: flex }`
   那样带 ID 的 display 规则（1,1,0）都压得过它（0,2,0），结果就是属性摘掉了、视觉上照样显示。
   每个这样的容器都要在它自己那条规则旁边补一条 [hidden] 规则（见比例 chip 那一段）。 */
.option-chip[hidden] { display: none; }

/* 模型 chip · 两列等宽（带品牌图标） */
.model-chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
/* 模型数为奇数时，最后一个跨满整行 —— 否则右下角会空出半格 */
.model-chips .option-chip:last-child:nth-child(odd) { grid-column: 1 / -1; }
.model-chips .option-chip {
  padding: 9px 4px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-body); font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.model-chips .option-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.model-chips .option-chip img { width: 15px; height: 15px; flex-shrink: 0; object-fit: contain; }
/* 模型特性注释：微型胶囊标签，换行居中展示在模型名下方 */
.model-chips .model-note {
  flex-basis: 100%; display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap; gap: 3px; margin-top: 4px;
  font-style: normal; font-weight: 400; line-height: 1;
}
.model-chips .model-note em {
  font-style: normal; font-size: 9px; line-height: 1;
  padding: 2.5px 5px; border-radius: var(--radius-full);
  color: var(--text-tertiary);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.model-chips .option-chip.selected .model-note em {
  /* 不再叠 opacity：颜色 × opacity 是双重衰减，9px 小字上直接把对比度打到 3 以下 */
  color: var(--accent-on-soft);
  border-color: var(--accent-medium);
  background: var(--accent-soft);
}

/* 工具栏模型图标（随选中模型同步） */
.chip-ico { display: inline-flex; align-items: center; flex-shrink: 0; }
.chip-ico svg { width: 13px; height: 13px; }

/* 模型品牌 Logo · 图标统一来自 @lobehub/icons（内联 SVG，跟随主题 currentColor）
   · 配置面板 chip 内 15×15，底部工具栏同步图标 13×13 */
.model-logo { display: inline-flex; align-items: center; flex-shrink: 0; }
.model-logo img {
  flex-shrink: 0; object-fit: contain; display: block; opacity: 1;
}
.model-logo svg { width: 15px; height: 15px; flex-shrink: 0; }
#modelChipIcon .model-logo img,
#modelChipIcon .model-logo svg { width: 13px; height: 13px; }
/* 默认（亮色 / 未设置主题）显示亮色 logo，深色主题切换为深色版 */
.model-logo .logo-dark { display: none; }
[data-theme="dark"] .model-logo .logo-light { display: none; }
[data-theme="dark"] .model-logo .logo-dark { display: inline-block; }

/* 比例 chip · 最多五列，超出的档位自动换行（各模型按上游能力表显示不同数量） */
#ratioChips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
#ratioChips .option-chip { padding: 7px 2px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; }
/* 上面的 display:flex 带 ID，权重压过通用的 `.option-chip[hidden]` —— 必须在这里再补一条，
   否则 hidden 属性摘掉了、被模型隐藏的档位照样显示在画面上（实测踩过，jsdom 查 .hidden 属性看不出来）。 */
#ratioChips .option-chip[hidden] { display: none; }
.ratio-icon {
  display: block; width: var(--rw); height: var(--rh);
  border: 1.5px solid currentColor; border-radius: 2px;
  opacity: 0.55; transition: opacity var(--duration-micro) var(--ease-out);
}
.option-chip.selected .ratio-icon { opacity: 1; }
/* 「自动」的图标：虚线框 —— 形状还没定，由参考图决定。与实线的具体比例档形成对照 */
.ratio-icon-auto { border-style: dashed; }

/* 参考图上传 */
.ref-hint { font-size: 11px; color: var(--text-tertiary); font-weight: 400; margin-left: 6px; }
.ref-upload { display: flex; flex-direction: column; gap: 8px; }
.ref-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-thumb { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-subtle); }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-thumb-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: none; background: oklch(0.09 0.008 75 / .6); color: oklch(0.974 0.011 85); line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.ref-thumb-remove svg { width: 11px; height: 11px; }
.ref-thumb-remove:hover { background: var(--danger); }
.ref-add-btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border: 1.5px dashed var(--border-subtle); border-radius: 8px; background: transparent; color: var(--text-tertiary); cursor: pointer; font-size: 13px; transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out); width: 100%; }
.ref-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.ref-add-icon { display: inline-flex; align-items: center; }
.ref-add-icon svg { width: 15px; height: 15px; display: block; }
.ref-upload.dragover .ref-add-btn { border-color: var(--accent); color: var(--accent); background: oklch(0.54 0.098 83 / 0.08); }
.option-chip {
  padding: 7px 14px;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-mono); font-size: 12px;
  cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), box-shadow var(--duration-micro) var(--ease-out);
}
.option-chip:hover {
  border-color: var(--border-medium);
  background: var(--accent-soft);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.option-chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-medium);
}

/* ── 芯片组滑动指示器：选中态是一块真实滑块，按钮透明底 ── */
.chip-group { position: relative; }
/* 几何层与视觉层分层：外层只走位移/尺寸（transform 会放大位移量），
   内层 ::before 只走 squash & stretch —— 写在同一层会把位移一起缩放成抖动 */
.chip-slider {
  position: absolute; left: 0; top: 0;
  border-radius: var(--radius-full);
  background: transparent;
  pointer-events: none; z-index: 0;
  opacity: 0;
  transition: transform var(--duration-slide) var(--ease-slide),
              width var(--duration-slide) var(--ease-slide),
              height var(--duration-slide) var(--ease-slide),
              opacity var(--duration-micro) var(--ease-out);
}
.chip-slider::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--accent-soft);
  border: 1px solid var(--accent-medium);
  transform: scale(1, 1);
}
/* 暗色面板本身就在 L .19–.28，10% 的 accent-soft 铺上去与未选中的描边几乎同色：
   选中块要能一眼指认，才有「从哪滑到哪」—— 暗色单独提一档填充 */
[data-theme="dark"] .chip-slider::before { background: oklch(0.787 0.023 76 / 0.16); }
/* 每次换格都叠一层果冻：沿运动轴拉伸、垂直方向反向收，落点后衰减两级。
   幅度 --jelly-a 由 JS 按「相邻间隙 / 滑块宽度」算好写入，保证拉伸后不顶到相邻项 */
.chip-slider.is-jelly-x::before { animation: chipJellyX var(--duration-jelly) linear; }
.chip-slider.is-jelly-y::before { animation: chipJellyY var(--duration-jelly) linear; }
@keyframes chipJellyX {
  0%   { transform: scale(1, 1); }
  16%  { transform: scale(calc(1 + var(--jelly-a, .08)), calc(1 - var(--jelly-a, .08) * .5)); }
  38%  { transform: scale(calc(1 - var(--jelly-a, .08) * .35), calc(1 + var(--jelly-a, .08) * .22)); }
  62%  { transform: scale(calc(1 + var(--jelly-a, .08) * .45), calc(1 - var(--jelly-a, .08) * .22)); }
  84%  { transform: scale(calc(1 - var(--jelly-a, .08) * .12), 1); }
  100% { transform: scale(1, 1); }
}
@keyframes chipJellyY {
  0%   { transform: scale(1, 1); }
  16%  { transform: scale(calc(1 - var(--jelly-a, .08) * .5), calc(1 + var(--jelly-a, .08))); }
  38%  { transform: scale(calc(1 + var(--jelly-a, .08) * .22), calc(1 - var(--jelly-a, .08) * .35)); }
  62%  { transform: scale(calc(1 - var(--jelly-a, .08) * .22), calc(1 + var(--jelly-a, .08) * .45)); }
  84%  { transform: scale(1, calc(1 - var(--jelly-a, .08) * .12)); }
  100% { transform: scale(1, 1); }
}
.chip-group > .option-chip { position: relative; z-index: 1; background: transparent; }
.chip-group > .option-chip:hover { background: transparent; border-color: var(--border-medium); }
.chip-group > .option-chip.selected {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
/* 分段控件（历史面板预览比例）：容器即轨道，滑块吃进按钮内边距 */
.hp-preview-switch { position: relative; }
.hp-preview-switch .chip-slider { border-radius: var(--radius-full); }
.hp-preview-switch .hpanel-btn { position: relative; z-index: 1; }
.hp-preview-switch .hpanel-btn.active { background: transparent; }

/* ── 按下反馈：所有可点元素统一短缩放 ── */


/* ── 禁用态 chip：降透明度置灰，悬停不抬升不可选（当前无 chip 处于禁用态，保留作通用态） ── */
.option-chip:disabled, .option-chip.disabled {
  opacity: 0.45; cursor: not-allowed;
  filter: grayscale(0.6);
}
.option-chip:disabled:hover, .option-chip.disabled:hover {
  border-color: var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  transform: none;
  box-shadow: none;
}

/* 生成按钮 */
.generate-btn {
  position: relative; width: 100%;
  padding: 14px 24px;
  border: none; border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--accent), var(--accent-ink));
  color: var(--text-inverse);
  font-family: var(--font-body);
  font-size: 15px; font-weight: 600;
  letter-spacing: 0.3px; cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm), inset 0 1px 0 oklch(0.99 0.007 89 / 0.28);
  transition: transform var(--duration-micro) var(--ease-out), box-shadow var(--duration-micro) var(--ease-smooth), opacity var(--duration-micro) var(--ease-out);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-shrink: 0;
}
.generate-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 30%, oklch(0.99 0.007 89 / 0.14) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform var(--duration-enter) var(--ease-out);
}
/* 呼吸光晕：循环只动 ::after 的 opacity，按钮本体不缩放不位移 */
.generate-btn::after {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: 0;
  background: radial-gradient(130% 150% at 50% 125%, oklch(0.99 0.007 89 / 0.24), transparent 55%);
}
.generate-btn:hover::before { transform: translateX(100%); }
.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow), inset 0 1px 0 oklch(0.99 0.007 89 / 0.28);
}
.generate-btn:active { transform: translateY(0); }

.generate-btn:disabled {
  opacity: 0.45; cursor: not-allowed; transform: none; filter: none;
}
.generate-btn:disabled:hover::before { transform: translateX(-100%); }
.generate-btn:disabled:hover {
  transform: none; filter: none;
  box-shadow: var(--shadow-sm), inset 0 1px 0 oklch(0.99 0.007 89 / 0.28);
}

.generate-btn.breathing::after { animation: btnBreathe 2.4s var(--ease-smooth) infinite; }
@keyframes btnBreathe {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.btn-icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.btn-icon svg { width: 17px; height: 17px; display: block; }

.btn-disabled-hint {
  font-size: 11px; color: var(--text-tertiary);
  text-align: center;
  min-height: 16px; transition: opacity var(--duration-micro) var(--ease-out);
  flex-shrink: 0;
}
/* 常驻预留槽位：文案出现/消失不推挤胶囊布局，只淡入淡出 */
.btn-disabled-hint:empty { opacity: 0; }
.generate-btn[aria-busy="true"] .btn-content { opacity: 0.88; }

/* ============================================
   🖼️ 右侧 · 图片展示区
   ============================================ */
.panel-right {
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

.image-display {
  flex: 1; display: flex;
  align-items: center; justify-content: center; align-content: center;
  padding: 24px;
  position: relative;
  /* 纵向可滚：矮视口下 9:16 等待卡位（框+文案+取消钮）不被裁切 */
  overflow: hidden auto; overscroll-behavior: contain;
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 0;
  /* 作为尺寸容器，供结果图 cqh 精确适配实际可用高度 */
  container-type: size;
}

/* 空状态（进场挂在揭幕后：首启随幕布升入，动态重建时 boot-ready 已在） */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px; text-align: center;
}
html.boot-ready .empty-state { animation: fadeInUp 0.55s var(--ease-out); }
.empty-icon {
  width: 72px; height: 72px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
  box-shadow: var(--hl-inset);
  animation: emptyFloat 3.6s var(--ease-smooth) infinite;
}
.empty-icon svg { width: 30px; height: 30px; }
@keyframes emptyFloat {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -10px, 0); }
}
.empty-title {
  font-family: var(--font-display);
  font-size: var(--text-xl); font-weight: 500; color: var(--text-secondary);
  letter-spacing: -0.4px;
  line-height: var(--leading-tight);
}
.empty-desc {
  font-size: var(--text-base); color: var(--text-tertiary);
  max-width: 280px; line-height: var(--leading-relaxed);
  font-weight: 400;
  /* 居中短段走 balance：不这么做时 390px 下会把「也可以」拆成「也可 / 以」，孤字悬行 */
  text-wrap: balance;
}
.empty-cta {
  margin-top: 4px;
  padding: 10px 18px; min-height: var(--touch);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base); font-weight: 500;
  cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), box-shadow var(--duration-micro) var(--ease-out);
}
.empty-cta:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* 错误状态卡片 */
.error-state {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px; text-align: center;
  max-width: 380px;
}
html.boot-ready .error-state { animation: fadeInUp 0.5s var(--ease-out); }
.error-icon {
  width: 72px; height: 72px;
  border-radius: var(--radius-xl);
  background: var(--danger-soft);
  border: 1px solid oklch(0.585 0.11 25 / 0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--danger);
  animation: errorShake 0.5s var(--ease-spring);
}
@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.error-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600; color: var(--danger);
}
.error-desc {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.65;
}
/* 撞配额时附加的令牌池余量行：比正文再小半号、更弱一档，是「补充信息」不是主文案 */
.error-quota {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border-light, var(--border-medium));
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary, var(--text-secondary));
}
.error-retry-btn {
  padding: 10px 24px; min-height: var(--touch);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), box-shadow var(--duration-micro) var(--ease-out);
  display: flex; align-items: center; gap: 6px;
}
.error-retry-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* 主区域生成中计时面板 */
.generating-state {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px; text-align: center;
}
html.boot-ready .generating-state { animation: fadeInUp 0.5s var(--ease-out); }
/* ── 生成中卡位：几何由「卡位 → 比例框」两级定宽，绝不让内容撑宽 ──
   早前 .slot-ratio-frame 写 width:min(300px,80%)，但它的父级 .main-slot 是内容定宽的
   flex 项（百分比无从解析）→ 退化成内容宽度，横屏比例当场塌到 ~108px 宽；
   再叠加列向 flex 默认 flex-shrink:1，72×72 的呼吸环被压成 72×2 的椭圆。
   现在：卡位自带确定宽度（单一来源），比例框 width:100%，子项一律 flex:none。
   container-type:size 让内部尺寸可读 cqh —— 比例再扁也只是「整体缩小」，不会变形。 */
.main-slot.pending { width: min(300px, 100%); }
.main-slots.multi .main-slot.pending { width: calc(50% - 7px); }
.slot-ratio-frame {
  width: 100%; border: 1.5px dashed var(--accent-medium);
  border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 12px;
  background: var(--bg-surface); opacity: 0.85;
  min-height: 0; overflow: hidden;
  container-type: size;
}
.slot-ratio-frame > * { flex: none; }
/* 生成中卡位：框高不能吃掉底部「模型徽标 + 取消生成」的位置。
   展示区高度减去文字区约 210px 才是框的最大可用高度，按比例反算宽度；
   竖图因此自动收窄，单张 9:16 也不会把按钮顶到可视区外。 */
.main-slot.pending .slot-ratio-frame {
  width: min(100%, calc(max(0px, 100cqh - 210px) * var(--ar-w, 1) / var(--ar-h, 1)));
}
/* 环与字号跟框高走：越扁的框整体缩一号，而不是把圆压扁。
   计时字号给下限 11px —— 6px 的数字等于没写，宁可让环再挤一点 */
.slot-ratio-frame .generating-orb { width: min(72px, 42cqh); height: min(72px, 42cqh); }
.slot-ratio-frame .generating-orb .generating-timer { font-size: clamp(11px, 9cqh, 16px); }
.slot-ratio-frame .generating-eta { font-size: min(12px, 6.5cqh); }
.slot-ratio-frame .generating-label { font-size: min(12px, 6.5cqh); }
/* 框高不足以容纳三行时，先撤「正在生成…」（信息与呼吸环重复），保住计时与余量。
   阈值按内容盒算：容器查询量的是内容盒，不是含 padding 的边框盒
   （16:9 / 300px 宽时内容盒 ≈ 138px，三行合计 ≈ 110，所以照常显示）。
   撤掉两行后空出来的高度给环，不让它缩成一个点。 */
@container (max-height: 108px) {
  .slot-ratio-frame .generating-label { display: none; }
  .slot-ratio-frame .generating-orb { width: min(72px, 62cqh); height: min(72px, 62cqh); }
  .slot-ratio-frame .generating-orb .generating-timer { font-size: clamp(11px, 15cqh, 16px); }
}
@container (max-height: 84px) {
  .slot-ratio-frame .generating-eta { display: none; }
}
.generating-orb {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, var(--accent-soft), var(--bg-surface));
  border: 1.5px solid var(--accent-medium);
  display: flex; align-items: center; justify-content: center;
  animation: orbBreathe 2.5s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}
@keyframes orbBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.generating-timer {
  position: relative; z-index: 1;
  font-family: var(--font-mono);
  font-size: 20px; font-weight: 400;
  color: var(--accent);
  letter-spacing: 1px;
}
.generating-label {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 500;
  color: var(--text-secondary);
}
.generating-prompt-preview {
  font-size: 12px; color: var(--text-tertiary);
  max-width: 320px; line-height: 1.6;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical;
}
.generating-model-badge {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-tertiary);
  padding: 3px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
}

/* 生成结果 */
.result-container {
  max-width: 100%; max-height: 100%;
  display: flex; flex-direction: column;
  align-items: center;
  overflow: hidden;
}
html.boot-ready .result-container { animation: resultReveal 0.5s var(--ease-out-expo); }
@keyframes resultReveal {
  0% { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.98); }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

/* 多图并排展示 */
.result-images-row {
  display: flex; gap: 14px;
  align-items: center; justify-content: center;
  max-width: 100%; min-height: 0;
}
.result-images-row.dual .result-image-wrap { flex: 0 1 auto; min-width: 0; max-width: calc(50% - 7px); }
.result-images-row.dual .result-image-wrap img {
  max-height: calc(var(--vh100) - var(--header-h) - 210px);
  max-height: 100cqh; /* 支持容器查询时按展示区实际高度适配 */
}

.result-image-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform var(--duration-indicator) var(--ease-out);
  flex-shrink: 1;
  min-height: 0;
}
.result-image-wrap:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

.result-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: calc(var(--vh100) - var(--header-h) - 190px);
  max-height: 100cqh; /* 支持容器查询时按展示区实际高度适配，避免被裁切 */
  width: auto; height: auto;
  object-fit: contain;
  transition: transform var(--duration-enter) var(--ease-smooth);
}
.result-image-wrap:hover img { transform: scale(1.01); }

/* 主展示区 · 多卡位（等待与结果并存，支持一次多张或多任务并排） */
.main-slots {
  display: flex; gap: 14px;
  align-items: center; justify-content: center;
  flex-wrap: wrap;
  width: 100%; max-width: 100%; min-height: 0;
}
.image-display > .main-slots { flex: 0 1 auto; max-height: 100%; margin: auto 0; }
.image-display:has(.grid-mode) { overflow-y: auto; align-items: flex-start; }
.main-slot {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; text-align: center;
  flex: 0 1 auto; min-width: 0; min-height: 0;
}
html.boot-ready .main-slot { animation: fadeInUp 0.5s var(--ease-out); }
/* 对比网格为整表重绘：新条目不重播入场 */
.main-slots.no-anim .main-slot { animation: none; }
.main-slots.multi .main-slot { max-width: min(calc(50% - 7px), 300px); flex: 0 1 auto; }
.main-slots.multi .main-slot .generating-prompt-preview { max-width: 240px; }
.main-slots.multi .result-image-wrap img {
  max-height: calc(var(--vh100) - var(--header-h) - 210px);
  max-height: 100cqh;
  width: auto; height: auto; max-width: 100%;
  object-fit: contain;
}
/* 3+ 张：按列数等分，末行不足一列时整体居中；行高按实际行数均分，
   5 张以上也不会撑出展示区 */
.main-slots.grid-mode {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  align-content: center; align-content: safe center;
  gap: 12px; width: 100%;
}
/* 3 张时不再三等分整屏：每张最多 300px，整组靠中间排 */
.main-slots.grid-mode .main-slot {
  width: calc((100% - (var(--grid-cols, 4) - 1) * 12px) / var(--grid-cols, 4));
  max-width: 300px; min-width: 0;
}
.main-slots.grid-mode .result-image-wrap { max-width: 100%; }
.main-slots.grid-mode .result-image-wrap img {
  /* 3+ 张时按「实际行数」均分展示区高度：2 行各拿一半、3 行各拿三分之一，
     竖图能放大、横图由格子宽度兜住，同时避免末行被挤出可视区。 */
  height: auto; width: auto;
  max-width: 100%;
  max-height: min(
    calc((100cqh - 36px - (var(--grid-rows, 1) - 1) * 12px) / var(--grid-rows, 1)),
    56vh, 540px
  );
  object-fit: contain;
}
/* 多卡位/网格里的等待卡位不能沿用「50% 宽 + 9:16」：宽度按父级算会把高度撑到上千像素，
   四张竖图各自跑出可视区，只剩四个角。改成按固定宽度排，9:16 也不会爆高。 */
.main-slots.multi .main-slot.pending,
.main-slots.grid-mode .main-slot.pending { width: min(240px, 24vw); }

/* 图片操作浮层 */
.image-actions {
  position: absolute; bottom: 12px; right: 12px;
  display: flex; gap: 8px;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--duration-indicator) var(--ease-out), transform var(--duration-indicator) var(--ease-out);
}
.result-image-wrap:hover .image-actions {
  opacity: 1; transform: translateY(0);
}

.img-action-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  transition: transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out);
}
.img-action-btn svg { width: 16px; height: 16px; }
.img-action-btn:hover {
  background: var(--accent); color: var(--text-inverse);
  border-color: var(--accent); transform: scale(1.1);
}

/* 主展示区仅展示图片，模型/时间/提示词移至详情查看器 */

/* ============================================
   ✏️ 底部 · 输入胶囊
   ============================================ */
.composer {
  position: relative;
  width: 100%; max-width: 820px;
  margin: 0 auto;
  padding: 0 20px 16px;
  flex-shrink: 0;
}

.composer-capsule {
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--hl-inset);
  padding: 6px 10px 8px 16px;
  display: flex; flex-direction: column;
  transition: border-color var(--duration-indicator) var(--ease-smooth), box-shadow var(--duration-indicator) var(--ease-smooth);
}
.composer-capsule:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lg), var(--hl-inset);
}

.composer-input-row { display: flex; align-items: flex-end; gap: 10px; }
.composer-input-row .generate-btn {
  width: auto; padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  margin-bottom: 5px;
}

/* ── 输入框上方 · 参考图常驻条 ── */
.composer-refbar {
  display: none;
  align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 4px 2px;
}
.composer-refbar.show { display: flex; }
.composer-refbar-label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-tertiary);
  font-family: var(--font-body); flex-shrink: 0;
}
.composer-refbar-label svg { width: 12px; height: 12px; color: var(--accent); opacity: 0.75; }
.composer-refbar .ref-thumb { width: 44px; height: 44px; }
.composer-refbar .ref-thumb-remove { width: 16px; height: 16px; }
.composer-refbar .ref-thumb-remove svg { width: 10px; height: 10px; }
.composer-refbar-add {
  width: 44px; height: 44px; flex-shrink: 0;
  border: 1.5px dashed var(--border-medium);
  border-radius: 8px; background: transparent;
  color: var(--text-tertiary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.composer-refbar-add svg { width: 15px; height: 15px; }
.composer-refbar-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── 拖拽图片到输入胶囊 · 高亮遮罩 ── */
.composer-capsule { position: relative; }
.composer-capsule.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lg), var(--hl-inset);
}
.composer-drop-mask {
  position: absolute; inset: 0; z-index: 5;
  display: none; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-xl);
  background: var(--bg-glass-heavy);
  border: 1.5px dashed var(--accent);
  color: var(--accent); font-size: 13px; font-weight: 500;
  pointer-events: none;
}
.composer-drop-mask svg { width: 18px; height: 18px; }
.composer-capsule.dragover .composer-drop-mask { display: flex; }

.composer-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 0 2px;
}
.tool-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body); font-size: 12px;
  cursor: pointer; transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
  white-space: nowrap;
}
.tool-chip svg { width: 13px; height: 13px; color: var(--accent); opacity: 0.75; flex-shrink: 0; }
.tool-chip img { width: 13px; height: 13px; flex-shrink: 0; object-fit: contain; opacity: 0.75; }
.tool-chip:hover {
  border-color: var(--border-medium);
  background: var(--accent-soft);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.tool-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
}
.chip-arrow { display: inline-flex; opacity: 0.6; transition: transform var(--duration-micro) var(--ease-smooth); }
.chip-arrow svg { width: 11px; height: 11px; display: block; color: currentColor; opacity: 1; }
.tool-chip.active .chip-arrow { transform: rotate(180deg); }

/* PC 端拆分为「模型」与「比例·张数」两个 chip，移动端合并为「配置」 */
.tool-chip.chip-config { display: none; }
#modelChipIcon { display: inline-flex; align-items: center; }
#popConfig[data-sec="model"] .cfg-sec-param { display: none; }
#popConfig[data-sec="param"] .cfg-sec-model { display: none; }
#popConfig .cfg-sec + .cfg-sec { margin-top: 10px; }
.composer .btn-disabled-hint { margin-bottom: 6px; }

/* 胶囊上方弹出面板 */
.composer-pop {
  position: absolute;
  bottom: calc(100% + 2px); left: 20px; right: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 14px 16px;
  display: flex;
  flex-direction: column; gap: 8px;
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  /* visibility 是离散属性：给非 step 曲线时它会在曲线越过 0.5 的那一刻翻转（ease-out 约 10% 处），
     于是「收起」在 30ms 就硬切消失、剩下的淡出根本看不见。收起必须显式延迟到淡出结束。
     收起另用 exit 档 + 中段发力的曲线：320ms 的 expo-out 在前 90ms 就走完九成，等于没淡出。 */
  transition: opacity var(--duration-exit) var(--ease-smooth),
              transform var(--duration-exit) var(--ease-smooth),
              visibility 0s linear var(--duration-exit);
}
.composer-pop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity var(--duration-indicator) var(--ease-out),
              transform var(--duration-indicator) var(--ease-out),
              visibility 0s;
}
/* 配置面板（模型 + 比例）在矮窗口下可能顶出视口 —— 给一条滚动兜底（内容更短时完全无感）。
   chip 组自带 position:relative，滚动不会错位它的指示器。 */
#popConfig { max-height: min(64vh, 540px); overflow-y: auto; overscroll-behavior: contain; }
.pop-label {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 1px; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}

/* ============================================
   📜 历史记录 · 侧边栏内容
   ============================================ */
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; flex-shrink: 0;
}
.history-title {
  font-family: var(--font-body); font-size: var(--text-xs); font-weight: 500;
  color: var(--text-tertiary); letter-spacing: 1.2px; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.history-title svg { width: 13px; height: 13px; color: var(--accent); opacity: 0.6; }

.history-count {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-tertiary); opacity: 0.7;
  padding: 1px 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}
.history-count:empty { display: none; }

.history-manage {
  font-size: 11px; color: var(--text-tertiary); cursor: pointer;
  padding: 3px 10px; border-radius: var(--radius-full);
  border: 1px solid transparent; background: transparent;
  font-family: var(--font-body); transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.history-manage:hover {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}

/* 对比模式开关（底部工具栏 tool-chip 激活态，仅 PC 端显示） */
.compare-chip.active {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: var(--accent-soft) !important;
  box-shadow: var(--shadow-glow);
}
.compare-chip.active svg { opacity: 1; }

/* 对比模式工具条（浮在展示区右上角） */
.compare-toolbar {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  display: flex; gap: 8px;
}
.compare-toolbar button {
  font-size: 11px; font-family: var(--font-body);
  padding: 5px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
}
.compare-toolbar button:hover {
  border-color: var(--accent); color: var(--accent);
}

/* 卡位移除按钮（对比模式 / 同时生成多张共用） */
.main-slot .compare-remove,
.main-slot .slot-remove {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  width: 26px; height: 26px; border-radius: 50%;
  background: oklch(0.09 0.008 75 / 0.55); color: oklch(0.974 0.011 85);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--duration-micro) var(--ease-out);
}
.main-slot:hover .compare-remove,
.main-slot:hover .slot-remove { opacity: 1; }
.main-slot .compare-remove svg,
.main-slot .slot-remove svg { width: 12px; height: 12px; }
/* 生成结果仅在多卡位并排时显示 X（单张不显示，避免误移除唯一结果） */
.main-slots:not(.multi) .main-slot .slot-remove { display: none; }

/* 移动端隐藏对比按钮 */
@media (max-width: 768px) {
  .compare-chip { display: none; }
}

.history-scroll {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-content: start;
  overflow-y: auto; overflow-x: hidden;
  padding: 2px 2px 8px;
}

/* ── 历史卡片 · 侧边栏自适应宽度 ── */
.history-item {
  width: auto;
  cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-out);
  position: relative;
  /* 不加 content-visibility：侧栏最多 12 条，省下的渲染微不足道，
     而缩略图是「原图 URL / 本地 thumb」异步加载、比例各不相同，
     contain-intrinsic-size 只能给一个猜的高（180×200），滚动条与下方条目会跟着跳 */
  contain: content;
}
html.boot-ready .history-item { animation: cardIn 0.4s var(--ease-out) backwards; }
.history-item:hover { transform: translateY(-2px); }

.history-thumb {
  width: 100%; height: auto;
  display: block;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
  /* 占位比例由内联 aspect-ratio 给出（见 buildHistoryItem）：
     图片未到之前盒子就是最终尺寸，加载完成不再把下方条目推一下 */
  object-fit: contain;
  background: var(--bg-surface);
  transition: border-color var(--duration-micro) var(--ease-smooth), box-shadow var(--duration-micro) var(--ease-smooth);
}
.history-item:hover .history-thumb {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.history-thumb svg { width: 18px; height: 18px; }

.history-prompt-label {
  font-size: 10px; color: var(--text-tertiary);
  margin-top: 4px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  text-align: center; line-height: var(--leading-snug);
  font-weight: 400; letter-spacing: 0.1px;
}

/* 历史缩略图完整提示走 title；行内 tooltip 节点已移除 */

/* 历史删除按钮（危险操作 · 红色语义与取消/查看类按钮区分）
   注意：.history-item 有 contain: content，按钮不得越出盒子（负偏移会被裁切） */
.history-delete {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%; border: 1px solid oklch(0.585 0.11 25 / 0.4);
  background: var(--bg-elevated);
  color: var(--danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; opacity: 0;
  transition: opacity var(--duration-micro) var(--ease-out), transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out);
  z-index: 5;
}
.history-delete svg { width: 11px; height: 11px; }
.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover {
  background: var(--danger); color: oklch(0.974 0.011 85);
  border-color: var(--danger); transform: scale(1.15);
}

.history-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 88px; font-size: 12px; color: var(--text-tertiary);
  text-align: center; line-height: 1.5; width: 100%;
  grid-column: 1 / -1;
}
.history-empty svg { width: 20px; height: 20px; opacity: 0.6; }

/* ── 历史生成中占位卡片 ── */
.history-pending-placeholder {
  width: 100%; aspect-ratio: 1/1; /* JS 内联覆盖为实际比例 */
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 2px solid var(--accent-medium);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
/* 与主展示区同理：窄列 + 横屏比例下，列向 flex 会压扁行高，三行文字叠在一起 */
.history-pending-placeholder > * { flex: none; }
.history-pending-placeholder::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--accent-soft) 40%, var(--accent-soft) 60%, transparent 100%);
  animation: shimmer 1.8s ease-in-out infinite;
  transform: translateX(-100%);
}

.pending-timer {
  position: relative; z-index: 1;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.pending-eta {
  position: relative; z-index: 1;
  font-family: var(--font-mono);
  font-size: 9px; color: var(--text-tertiary);
  opacity: 0.85;
}
.pending-label {
  position: relative; z-index: 1;
  font-size: 8px; color: var(--text-tertiary);
}
.generating-eta {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--text-tertiary);
  margin-top: 2px;
}

/* 生成中占位的取消按钮（悬停显示；同样收进 contain 边界内） */
.history-cancel {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%; border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-tertiary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; opacity: 0;
  transition: opacity var(--duration-micro) var(--ease-out), transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out);
  z-index: 6;
}
.history-cancel svg { width: 11px; height: 11px; }
.history-item.pending:hover .history-cancel { opacity: 1; }
.history-cancel:hover {
  background: var(--danger); color: oklch(0.974 0.011 85);
  border-color: var(--danger); transform: scale(1.15);
}

/* 主展示区等待卡位的取消按钮 */
.slot-cancel-btn {
  font-size: 12px; color: var(--text-tertiary); cursor: pointer;
  min-height: var(--touch);
  padding: 5px 16px; border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  font-family: var(--font-body); transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.slot-cancel-btn:hover {
  border-color: var(--danger); color: var(--danger); background: var(--danger-soft);
}

/* 历史失败态 */
.history-item.failed .history-thumb,
.history-failed-placeholder {
  width: 100%; aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 2px solid oklch(0.585 0.11 25 / 0.3);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  box-shadow: var(--shadow-sm);
}
.failed-icon {
  font-size: 18px; color: var(--danger); line-height: 1;
}
.failed-label {
  font-size: 8px; color: var(--danger); opacity: 0.8;
}

/* ── 失败/删除卡片淡出动画（选择器与门控进场同级，确保覆盖 fadeInUp） ── */
.history-item.fade-out,
html.boot-ready .history-item.fade-out {
  animation: historyFadeOut 0.5s var(--ease-smooth) forwards;
}
@keyframes historyFadeOut {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9); }
}

/* ── 失败任务详情弹窗 ── */
.fail-modal-overlay {
  position: fixed; inset: 0; z-index: 950;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-indicator) var(--ease-smooth);
}
.fail-modal-overlay.active { opacity: 1; pointer-events: all; }
.fail-modal {
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), var(--hl-inset);
  padding: 20px;
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: transform var(--duration-indicator) var(--ease-out), opacity var(--duration-indicator) var(--ease-smooth);
}
.fail-modal-overlay.active .fail-modal { opacity: 1; transform: scale(1) translateY(0); }
.fail-modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.fail-modal-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 15px; font-weight: 600;
  color: var(--danger);
}
.fail-modal-close {
  width: 28px; height: 28px; flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: transparent; color: var(--text-tertiary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.fail-modal-close:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.fail-modal-close svg { width: 14px; height: 14px; }
.fail-modal-error {
  font-size: 12px; color: var(--danger); line-height: 1.6;
  background: var(--danger-soft);
  border: 1px solid oklch(0.585 0.11 25 / 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.fail-modal-label-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.fail-modal-meta {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap; flex-shrink: 0;
}
.fail-modal-label {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  letter-spacing: 0.5px;
}
.fail-modal-prompt {
  font-size: 13px; color: var(--text-primary); line-height: 1.7;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  max-height: 180px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
  user-select: text;
}
.fail-modal-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.fail-modal-btn {
  flex: 1; min-width: 100px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), box-shadow var(--duration-micro) var(--ease-out);
}
.fail-modal-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.fail-modal-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.fail-modal-btn.primary {
  border: none;
  background: linear-gradient(180deg, var(--accent), var(--accent-ink));
  color: var(--text-inverse);
  font-weight: 600;
  box-shadow: var(--shadow-sm), inset 0 1px 0 oklch(0.99 0.007 89 / 0.28);
}
.fail-modal-btn.primary:hover {
  color: var(--text-inverse);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.fail-modal-btn.danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ============================================
   🔍 图片查看器 · 全屏
   ============================================ */
/* 查看器 = 幕布（::before，只它自己淡入淡出）+ 舞台（大图、控件）。
   两者分离是硬要求：整层 opacity 过渡会把飞行中的大图一起拖淡，
   快速开关时「幕布淡、大图也在淡」，看起来就是那下闪。
   可见性用离散切换：打开即时可见；关闭延后到飞行落位之后才隐藏（整层不做透明度过渡，
   飞行中的大图不会被父级拖淡）；每个子层各自管自己的进出手势。 */
.viewer-overlay {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px calc(96px + min(380px, 30vw)) 96px 160px;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s var(--duration-enter) linear;
}
.viewer-overlay.active {
  visibility: visible; pointer-events: all;
  transition: none;
}
/* 幕布独立成层：backdrop-filter 全程保留到收层那一帧（display:none 一并摘掉）。
   中途摘掉模糊 = 背后页面瞬间由糊变锐，快速开关时正是那下刺眼的白闪。
   关闭时长由 JS 按实际飞行时长写入 --viewer-flight，幕布与大图同一段手势、同时落定 */
.viewer-overlay::before {
  content: '';
  position: absolute; inset: 0;
  background: oklch(0.09 0.008 75 / var(--viewer-veil, 0.88));
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-enter) var(--ease-out-soft);
}
.viewer-overlay.active::before {
  opacity: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* 幕布回收（回位飞行中途又被打开）与打开共用同一时长：--viewer-flight 由 JS 按实际飞行写，
     缺省才用进场时长。幕布与大图必须在同一条时间线上，不允许幕布自己慢慢淡 450ms */
  transition: opacity var(--viewer-flight, var(--duration-enter)) var(--ease-out-soft);
}
/* is-closing 必须保留到浮层隐藏之后，否则幕布会在淡出期反向淡回来，闪出详情页一帧 */
.viewer-overlay.is-closing::before {
  opacity: 0;
  transition: opacity var(--viewer-flight, var(--duration-exit)) var(--ease-out-expo);
}
.viewer-overlay.is-closing { pointer-events: none; }

/* 查看器控件：跟着飞行后段浮出（不跟大图抢镜头），关闭时先让位。
   只动 opacity —— 位移/缩放留给共享变形，控件不做二次演出 */
.viewer-overlay :where(.viewer-toolbar, .viewer-info, .viewer-strip, .viewer-nav, .viewer-close) {
  opacity: 0;
  transition: opacity var(--duration-micro) var(--ease-out-soft);
}
.viewer-overlay.active :where(.viewer-toolbar, .viewer-info, .viewer-strip, .viewer-close) {
  opacity: 1;
  transition: opacity var(--duration-indicator) var(--duration-micro) var(--ease-out-soft);
}
.viewer-overlay.active :where(.viewer-nav) {
  opacity: 1;
  transition: opacity var(--duration-indicator) var(--duration-enter) var(--ease-out-soft);
}
/* 末位禁用态（选择器权重压在 :where() 选中态之上） */
.viewer-overlay .viewer-nav.disabled { opacity: 0.25; pointer-events: none; }
.viewer-overlay.is-closing :is(.viewer-toolbar, .viewer-info, .viewer-strip, .viewer-nav, .viewer-close) {
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-micro) var(--ease-out-soft);
}
.viewer-overlay.is-closing .viewer-image-container img { box-shadow: none; }

/* 查看器 · 竖屏图片（9:16 / 3:4）：在视口内水平居中 */
.viewer-overlay.is-portrait {
  padding-left: calc(96px + min(380px, 30vw));
}

/* 舞台：整块随浮层揭开淡入。飞行途中它是半透明的，正好与触发缩略图交叉溶入——
   几何已经像素级重合，这层交叉只做兜底，抹平任何亚像素误差，不让边缘「跳一下」 */
.viewer-image-container {
  position: relative; cursor: grab;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: transform var(--duration-instant) var(--ease-out), opacity var(--duration-micro) var(--ease-out-soft);
}
.viewer-overlay.active .viewer-image-container {
  opacity: 1;
  transition: transform var(--duration-instant) var(--ease-out), opacity var(--duration-indicator) var(--ease-out-soft);
}
.viewer-image-container:active { cursor: grabbing; }
/* 飞行期间解除窄屏舞台的裁切：否则大图飞出容器会被 overflow 剪掉，变形看不全 */
.viewer-overlay.is-flying .viewer-image-container { overflow: visible; }

.viewer-image-container img {
  max-width: 100%;
  max-height: calc(var(--vh100) - 160px);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px oklch(0.09 0.008 75 / 0.5);
  user-select: none; -webkit-user-drag: none;
  transform-origin: center center;
  opacity: 1;
  transition: transform var(--duration-instant) var(--ease-out), opacity var(--duration-micro) var(--ease-out);
}
.viewer-overlay.is-switching .viewer-image-container img {
  opacity: 0;
  transition: opacity var(--duration-micro) var(--ease-out);
}

/* 查看器内子层不再各自挂 backdrop-filter：遮罩已全局模糊，实底即可，守住同帧 ≤2 合成层预算 */
.viewer-toolbar {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px; padding: 8px 14px;
  background: oklch(0.235 0.018 75 / 0.94);
  border-radius: var(--radius-full);
  border: 1px solid oklch(0.97 0.009 85 / 0.08);
}

.viewer-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: transparent;
  color: oklch(0.858 0.014 84); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
}
.viewer-btn svg { width: 18px; height: 18px; }
.viewer-btn:hover {
  background: oklch(0.97 0.009 85 / 0.1); color: oklch(0.974 0.011 85); transform: scale(1.1);
}


.viewer-close {
  position: fixed; top: 20px; right: 24px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid oklch(0.97 0.009 85 / 0.1);
  background: oklch(0.235 0.018 75 / 0.9);
  color: oklch(0.858 0.014 84); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
}
.viewer-close svg { width: 18px; height: 18px; }
.viewer-close:hover {
  background: oklch(0.585 0.11 25 / 0.4);
  border-color: oklch(0.585 0.11 25 / 0.5);
  color: oklch(0.974 0.011 85); transform: scale(1.08);
}

/* 查看器 · 提示词信息卡片（右侧） */
.viewer-info {
  position: fixed; top: 20px; right: 88px; left: auto;
  display: flex; flex-direction: column; gap: 8px;
  width: min(380px, 30vw);
  max-width: min(380px, 30vw);
  padding: 14px 16px;
  background: oklch(0.21 0.016 75 / 0.94);
  border: 1px solid oklch(0.97 0.009 85 / 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px oklch(0.09 0.008 75 / 0.35), inset 0 1px 0 oklch(0.97 0.009 85 / 0.06);
}
.viewer-info-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.viewer-info-title {
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  color: oklch(0.858 0.014 84 / 0.5); text-transform: uppercase;
}
.viewer-info-date {
  font-family: var(--font-mono); font-size: 11px;
  color: oklch(0.858 0.014 84 / 0.45);
  white-space: nowrap; flex-shrink: 0;
}
.viewer-info-prompt {
  font-size: 13px; color: oklch(0.858 0.014 84 / 0.9);
  line-height: 1.65;
  max-height: 38vh; overflow-y: auto;
  word-break: break-word;
}
.viewer-info-meta {
  font-family: var(--font-mono); font-size: 11px;
  color: oklch(0.858 0.014 84 / 0.45);
}
.viewer-info-actions { display: flex; gap: 8px; margin-top: 2px; }
.viewer-copy-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid oklch(0.97 0.009 85 / 0.12);
  background: oklch(0.97 0.009 85 / 0.06);
  color: oklch(0.858 0.014 84 / 0.75);
  font-size: 11px; font-family: var(--font-body);
  cursor: pointer; transition: background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out);
  display: inline-flex; align-items: center; gap: 5px;
  width: fit-content;
}
.viewer-copy-btn:hover {
  background: oklch(0.97 0.009 85 / 0.12);
  color: oklch(0.974 0.011 85); border-color: oklch(0.97 0.009 85 / 0.25);
}
.viewer-copy-btn svg { width: 12px; height: 12px; }

/* 查看器 · 左侧历史预览条 */
.viewer-strip {
  position: fixed; left: 12px; top: 50%;
  transform: translateY(-50%);
  max-height: 72vh; width: 76px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; overflow-x: hidden;
  padding: 8px;
  background: oklch(0.21 0.016 75 / 0.92);
  border: 1px solid oklch(0.97 0.009 85 / 0.08);
  border-radius: var(--radius-md);
  /* 细滚动条：贴合暗色浮层，不突兀且保留可滚动提示 */
  scrollbar-width: thin;
  scrollbar-color: oklch(0.97 0.009 85 / 0.22) transparent;
}
.viewer-strip::-webkit-scrollbar { width: 4px; }
.viewer-strip::-webkit-scrollbar-track { background: transparent; }
.viewer-strip::-webkit-scrollbar-thumb {
  background: oklch(0.97 0.009 85 / 0.22);
  border-radius: 4px;
}
.viewer-strip::-webkit-scrollbar-thumb:hover { background: oklch(0.97 0.009 85 / 0.35); }
.viewer-strip-item {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 2px solid transparent; cursor: pointer;
  padding: 0; background: oklch(0.97 0.009 85 / 0.04);
  color: oklch(0.858 0.014 84 / 0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0.6; transition: opacity var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out);
}
.viewer-strip-item svg { width: 16px; height: 16px; }
.viewer-strip-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.viewer-strip-item:hover { opacity: 1; }
.viewer-strip-item.current { border-color: var(--accent); opacity: 1; }

/* 查看器 · 左右切换按钮 */
.viewer-nav {
  position: fixed; top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid oklch(0.97 0.009 85 / 0.1);
  background: oklch(0.235 0.018 75 / 0.9);
  color: oklch(0.858 0.014 84); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
  z-index: 2;
}
.viewer-nav svg { width: 22px; height: 22px; }
.viewer-nav:hover {
  background: oklch(0.97 0.009 85 / 0.12); color: oklch(0.974 0.011 85);
  transform: translateY(-50%) scale(1.08);
}
.viewer-nav.prev { left: 104px; }
.viewer-nav.next { right: 24px; }

/* ============================================
   ✨ 通用动画
   ============================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
/* 列表 / 卡片入场：小位移，且用完即放。
   注意 fill 必须是 backwards 而不是 both —— 动画一旦 forwards/both 填充，transform 就被动画
   永久接管（动画声明在级联里压过普通声明），卡片 :hover 的抬升会整条失效。
   而结束帧本来就等于自然态，所以 backwards 视觉上完全等价，还顺手解决 content-visibility
   休眠子树里动画不跑时元素卡在 opacity:0 的风险。 */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ============================================
   ⚡ 性能兜底
   ============================================ */
/* 主题切换抑制窗：只杀 transition（颜色补间是风暴源）。
   禁止写 animation: none —— 抑制窗卸下时进场关键帧会被当作「取消后再应用」从头重播，
   循环动画 currentTime 也会归零。溶入本身由 View Transitions（或下方实底遮罩）一次性完成。 */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}
/* 无 View Transitions 时的根级溶入：1 层实底遮罩，只动画该层 opacity */
.theme-mask {
  position: fixed; inset: 0; z-index: 2500;
  pointer-events: none; opacity: 0;
}
/* 根级溶入时长：主题切换的体感来源只有这一个动画。
   走 exit 档（220ms）而不是 micro —— 全视口级别的换色淡入，150ms 会显得「闪」而不是「溶」 */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--duration-exit);
  animation-timing-function: var(--ease-out-expo);
}
/* 模态浮层打开时，常驻毛玻璃（侧栏/输入胶囊/顶栏）已被实底遮罩盖住：
   卸掉它们的 backdrop-filter，同帧合成模糊节点保持 ≤ 遮罩 1 层。
   几个浮层都用 is-veiled：等幕布真正盖实（280ms / 查看器 420ms）才卸，否则打开头几帧
   会看见顶栏「由糊变锐」。关闭则反过来 —— 幕布仍实的那一刻先装回去，两次变化都发生在幕布后面，肉眼无感 */
body:has(.hpanel-overlay.is-veiled) :is(.composer-capsule, .history-sidebar, .nav-header),
body:has(.set-overlay.is-veiled) :is(.composer-capsule, .history-sidebar, .nav-header),
body:has(.viewer-overlay.is-veiled) :is(.composer-capsule, .history-sidebar, .nav-header),
body:has(.fail-modal-overlay.is-veiled) :is(.composer-capsule, .history-sidebar, .nav-header),
body:has(.confirm-overlay.is-veiled) :is(.composer-capsule, .history-sidebar, .nav-header) {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
/* 页面切到后台时暂停循环动画，省电省 CPU */
html.bg-paused .bg-decoration *,
html.bg-paused .bg-decoration::before,
html.bg-paused .bg-decoration::after,
html.bg-paused .empty-icon,
html.bg-paused .generating-orb,
html.bg-paused .generating-orb::before,
html.bg-paused .generate-btn.breathing::after,
html.bg-paused .api-status-dot.active,
html.bg-paused .history-pending-placeholder::before {
  animation-play-state: paused !important;
}
@media (prefers-reduced-transparency: reduce) {
  .nav-header, .history-sidebar, .composer-capsule,
  .toast, .viewer-overlay::before, .hpanel-overlay, .set-overlay,
  .fail-modal-overlay, .confirm-overlay, .viewer-toolbar,
  .viewer-info, .viewer-strip, .viewer-nav, .viewer-close,
  .img-action-btn, .compare-toolbar button {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .composer-capsule, .nav-header, .history-sidebar {
    background: var(--bg-elevated);
  }
}

/* ── 减动态：大位移 / 缩放 / 视差 / 连续漂浮降为淡入与静态分层 ──
   保留状态反馈（按下 squash、hover 描边、颜色），也保留滑动指示器那段位移 ——
   「点了哪一项、从哪滑到哪」是空间线索，砍掉等于让用户重新找当前项。
   循环氛围只停不停帧：所有循环都是 opacity/transform，停掉后画面即静帧。 */
@keyframes prmFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  /* 1 · 常驻循环（环境呼吸、光晕漂浮、旋转环、Toast 计时条不动画） */
  .bg-glow-tr, .bg-orb, .boot-mark, .empty-icon,
  .generating-orb, .generating-orb::before,
  .api-status-dot.active, .history-pending-placeholder::before,
  .vw-empty-play, .vw-gen__orb, .vw-spinner { animation: none !important; }
  .generate-btn.breathing::after { animation: none !important; opacity: 0; }

  /* 2 · 进场：位移与缩放降为纯淡入，落点与版式与动效版一致 */
  html.boot-ready .app-container,
  html.boot-ready .panel-right,
  html.boot-ready .empty-state,
  html.boot-ready .error-state,
  html.boot-ready .main-slot,
  html.boot-ready .history-item,
  html.boot-ready .result-container,
  html.boot-ready .generating-state { animation: prmFade 220ms linear both; }

  /* 3 · 悬停位移取消（抬升/放大不是状态反馈，只留颜色与描边） */
  .result-image-wrap:hover, .result-image-wrap:hover img,
  .history-item:hover, .option-chip:hover, .tool-chip:hover,
  .nav-pill-btn:hover, .empty-cta:hover, .generate-btn:hover,
  .nav-logo:hover, .theme-toggle:hover, .theme-toggle:hover svg,
  .nav-icon-btn:hover svg, .vw-clip:hover, .vw-generate:hover:not(:disabled),
  .vw-center-btn:hover, .vw-btn:hover, .vw-frame-view__close:hover { transform: none !important; }

  /* 4 · 布局级位移：侧栏折叠一次到位（每帧重排 320ms 在大列表上是纯亏） */
  .main-content { transition: none; }

  /* 5 · 揭幕：字标与幕布只淡出，不上移 */
  .boot-curtain { transition: opacity 200ms linear; }
  .boot-curtain.lift { transform: none; }
  .boot-curtain.lift .boot-inner { transform: none; }

  /* 6 · 浮层只淡入，不再从下方推入 */
  .composer-pop, .composer-pop.open, .fail-modal,
  .fail-modal-overlay.active .fail-modal { transform: none; }
}

/* ============================================
   🔔 Toast 通知
   ============================================ */
.toast-container {
  position: fixed; top: 80px; right: 24px;
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 12px 14px 12px 16px;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px; line-height: 1.5; color: var(--text-primary);
  animation: toastIn 0.4s var(--ease-out);
  transition: opacity var(--duration-indicator) var(--ease-smooth), transform var(--duration-indicator) var(--ease-smooth);
  max-width: 340px;
}
.toast.hide { opacity: 0; transform: translateX(30px); pointer-events: none; }
/* scaleX 线性倒计时条：时长与自动关闭一致，悬停暂停 */
.toast::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: currentColor; opacity: 0.22;
  transform-origin: left;
  animation: toastProgress var(--toast-ms, 3s) linear forwards;
  pointer-events: none;
}
/* 同文案复现（bump）时把倒计时条拉回满格：去掉动画再装回来才会重新开始 */
.toast.no-bar::after { animation: none; }
.toast:hover::after { animation-play-state: paused; }
@keyframes toastProgress { to { transform: scaleX(0); } }
.toast-icon { flex-shrink: 0; margin-top: 2px; display: inline-flex; }
.toast-icon svg { width: 15px; height: 15px; display: block; }
.toast-msg { flex: 1; word-break: break-word; }
.toast-close {
  flex-shrink: 0; border: none; background: none; cursor: pointer;
  color: inherit; opacity: 0.5; line-height: 1; padding: 2px 0 0 4px;
  display: inline-flex;
}
.toast-close svg { width: 13px; height: 13px; display: block; }
.toast-close:hover { opacity: 1; }
/* 实心配色：旧版用 11% 透明度的 -soft 当底、同色系当中/深色文字，整条看着是「空心」的，
   小字+半透明底可读性差。改成实心底 + 反主题色文字（亮色下是白字、暗色下是近黑字），
   对比度跟着主题一起翻，两种主题都够看。倒计时条用 currentColor，落在实心底上同样清晰。 */
.toast.error { border-color: var(--danger); background: var(--danger); color: var(--text-inverse); }
.toast.success { border-color: var(--success); background: var(--success); color: var(--text-inverse); }
.toast.warning { border-color: var(--warning); background: var(--warning); color: var(--text-inverse); }

@keyframes toastIn { from { opacity: 0; transform: translateX(24px) translateY(-6px); } to { opacity: 1; transform: translateX(0) translateY(0); } }

/* 应用内确认弹窗（替代浏览器 confirm） */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-indicator) var(--ease-smooth);
}
.confirm-overlay.active { opacity: 1; pointer-events: all; }
.confirm-dialog {
  width: min(400px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), var(--hl-inset);
  padding: 22px 22px 18px;
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: transform var(--duration-indicator) var(--ease-out), opacity var(--duration-indicator) var(--ease-smooth);
}
.confirm-overlay.active .confirm-dialog { opacity: 1; transform: scale(1) translateY(0); }
.confirm-title {
  font-family: var(--font-display); font-size: 17px; font-weight: 600;
  color: var(--text-primary); margin-bottom: 8px;
}
.confirm-desc {
  font-size: 13px; color: var(--text-secondary); line-height: 1.65;
  margin-bottom: 18px;
}
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-btn {
  min-height: var(--touch); min-width: 88px;
  padding: 8px 16px; border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: var(--bg-surface); color: var(--text-primary);
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), filter var(--duration-micro) var(--ease-out);
}
.confirm-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.confirm-btn.danger {
  border: none;
  background: var(--danger); color: oklch(0.974 0.011 85);
}
.confirm-btn.danger:hover { filter: brightness(1.06); color: oklch(0.974 0.011 85); }

/* ============================================
   📱 响应式
   ============================================ */
/* ============================================
   ⚙️ 移动端设置抽屉
   ── 原先顶栏右侧把「API Key 胶囊 + 主题按钮」一起塞进 overflow-x 的横条里，
      结果是半截露在屏幕外、底下还挂着一条可左右拖的滚动条。设置属于「低频、
      一次性」，不该占顶栏常驻位；改为底部抽屉：一颗按钮入场，内容走纵向。
   ============================================ */
.set-overlay {
  position: fixed; inset: 0; z-index: 880;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-indicator) var(--ease-smooth);
}
.set-overlay.active { opacity: 1; pointer-events: all; }
.set-card {
  width: min(520px, 100%);
  max-height: 88dvh; max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-xl), var(--hl-inset);
  padding: 6px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform var(--duration-indicator) var(--ease-out);
}
.set-overlay.active .set-card { transform: translateY(0); }

/* 抓握条 + 头部：整条都可拖动下拽关闭（见 JS bindSheetDrag） */
.set-grab {
  width: 38px; height: 4px; border-radius: var(--radius-full);
  background: var(--border-medium);
  margin: 8px auto 2px;
  flex-shrink: 0;
}
.set-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 0 4px;
  touch-action: none;
}
.set-grab { touch-action: none; }
.set-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  color: var(--text-primary);
}
.set-title svg { width: 16px; height: 16px; color: var(--accent); }
.set-close {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
  transition: color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.set-close svg { width: 15px; height: 15px; }
.set-close:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.set-sec { padding: 14px 0; border-top: 1px solid var(--border-subtle); }
.set-sec:first-of-type { border-top: none; padding-top: 8px; }
.set-sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.set-sec-title { font-size: 13px; font-weight: 600; color: var(--text-primary); letter-spacing: 0.2px; }
.set-sec-note { font-size: 11px; color: var(--text-tertiary); line-height: 1.4; }

/* 从侧栏移入的 API Key 胶囊：铺满整行，输入框放到 16px 防 iOS 聚焦缩放 */
.set-api-host .api-key-capsule { width: 100%; padding: 6px 6px 6px 12px; }
.set-api-host .api-key-input { flex: 1; min-width: 0; width: auto; font-size: 16px; }
.set-api-host .api-key-input::placeholder { font-size: 14px; }

/* 主题分段：轨道 + 滑动指示器（复用 chip-group 机制，选中态由 applyTheme 统一同步） */
.theme-seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
}
.theme-seg .option-chip {
  flex: 1; min-width: 0;
  padding: 9px 6px;
  text-align: center;
  border-color: transparent;
  font-family: var(--font-body); font-size: 13px;
  white-space: nowrap;
}

/* 快捷入口：移动端侧栏整体隐藏后，把 V API / 支持作者 收进抽屉，不再无处可去 */
.set-links { display: flex; flex-direction: column; gap: 8px; }
.set-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: var(--touch);
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body); font-size: 13px;
  text-align: left; cursor: pointer; text-decoration: none;
  transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.set-row > svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent); opacity: 0.85; }
.set-row:hover { border-color: var(--accent); color: var(--accent); }
.set-row .set-row-arrow { margin-left: auto; width: 14px; height: 14px; color: var(--text-tertiary); }


/* 桌面端顶栏不存在 → 抽屉只在移动端成立 */
@media (min-width: 901px) {
  .set-overlay { display: none; }
}

/* ============================================
   🗂️ 历史记录面板 · 全屏 + 批量管理
   ============================================ */
.hpanel-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-indicator) var(--ease-smooth);
}
.hpanel-overlay.active { opacity: 1; pointer-events: all; }
.hpanel {
  width: min(1080px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), var(--hl-inset);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: transform var(--duration-indicator) var(--ease-out), opacity var(--duration-indicator) var(--ease-smooth);
}
.hpanel-overlay.active .hpanel { opacity: 1; transform: scale(1) translateY(0); }
.hpanel-header {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
}
.hpanel-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 15px; font-weight: 600;
  color: var(--text-primary);
}
.hpanel-title svg { width: 16px; height: 16px; color: var(--accent); }
.hpanel-count {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-tertiary);
  padding: 1px 8px; border-radius: var(--radius-full);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
}
.hpanel-actions { display: flex; align-items: center; gap: 8px; }

/* ── 面板搜索：默认收起为工具栏里的一个图标，点开才变输入 ──
   输入框绝对定位覆盖头部，展开/收起不牵动栅格（否则板头高度会跳一下）。
   收起态用 visibility: hidden 而不是只把透明度压到 0 —— 后者输入框仍在 Tab 序列里，
   键盘用户会 Tab 进一个看不见的框。 */
.hpanel-search {
  position: absolute; inset: 10px 20px 10px 20px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  opacity: 0; visibility: hidden;
  transform: translateY(-4px);
  /* visibility 用 0s 时长 + 一个延迟：淡出先走完，才真正摘出 Tab 序列；
     反过来（展开）延迟为 0，立刻可聚焦。末尾的 linear 是占位，0s 时长下缓存无关紧要 */
  transition: opacity var(--duration-micro) var(--ease-out),
              transform var(--duration-micro) var(--ease-out),
              visibility 0s linear var(--duration-micro);
}
.hpanel-header.is-searching .hpanel-search {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity var(--duration-micro) var(--ease-out),
              transform var(--duration-micro) var(--ease-out),
              visibility 0s linear;
}
/* 只在视觉上让位：标题必须留在无障碍树里，它是这个 dialog 的 aria-labelledby，
   连 visibility 一起藏掉的话，搜索态的面板就成了一个没有名字的对话框。
   工具栏里有按钮，那个必须真隐藏，否则键盘会 Tab 进一串看不见的按钮。 */
.hpanel-header.is-searching .hpanel-title { opacity: 0; pointer-events: none; }
.hpanel-header.is-searching .hpanel-actions { opacity: 0; visibility: hidden; pointer-events: none; }
.hpanel-title, .hpanel-actions { transition: opacity var(--duration-micro) var(--ease-out), visibility 0s linear var(--duration-micro); }
.hpanel-search:focus-within { border-color: var(--accent); box-shadow: var(--shadow-sm), 0 0 0 3px var(--accent-soft); }
.hpanel-search-ico { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-tertiary); }
.hpanel-search:focus-within .hpanel-search-ico { color: var(--accent); }
/* 16px 是硬要求：触屏聚焦会自己把整页放大，低于 16px 的输入框必被 iOS / Android 顶起来。
   指针精准的设备没有这个问题，可以收回紧凑的 13px —— 面板本身密度高 */
.hpanel-search-input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: transparent; outline: none;
  font-family: var(--font-body); font-size: 16px;
  color: var(--text-primary);
}
.hpanel-search-input::placeholder { color: var(--text-tertiary); }
/* 自带的清除按钮各平台长相不一，统一关掉，换成自己的一个，形状与旁边一致 */
.hpanel-search-input::-webkit-search-cancel-button,
.hpanel-search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.hpanel-search-clear, .hpanel-search-exit {
  position: relative;            /* ::after 的命中区锚点 */
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--text-tertiary); cursor: pointer;
  transition: background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
}
.hpanel-search-clear svg, .hpanel-search-exit svg { width: 14px; height: 14px; }
.hpanel-search-clear:hover, .hpanel-search-exit:hover { background: var(--accent-soft); color: var(--accent); }
.hpanel-search-clear[hidden] { display: none; }
/* 命中区补到 44px，视觉仍是 26px 的小圆 */
.hpanel-search-clear::after, .hpanel-search-exit::after {
  content: ''; position: absolute; inset: -9px;
}
@media (pointer: fine) {
  .hpanel-search-input { font-size: 13px; }
}
@media (max-width: 640px) {
  .hpanel-search { inset: 8px 12px; }
  .hpanel-title { font-size: 14px; }
}
/* 本地存储占用显示（批量管理旁） */
.hpanel-storage {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-tertiary); white-space: nowrap;
  padding: 1px 8px; border-radius: var(--radius-full);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
}
.hpanel-storage:empty { display: none; }
.hpanel-btn {
  padding: 6px 14px; border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface); color: var(--text-secondary);
  font-family: var(--font-body); font-size: 12px; cursor: pointer;
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out);
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.hpanel-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.hpanel-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* 危险操作（删除）常态即与普通按钮区分：红色文字 + 淡红边框，悬停加深 */
.hpanel-btn.danger {
  color: var(--danger);
  border-color: oklch(0.585 0.11 25 / 0.35);
  background: var(--danger-soft);
}
.hpanel-btn.danger:hover { border-color: var(--danger); color: oklch(0.974 0.011 85); background: var(--danger); }
.hpanel-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; pointer-events: none; }
.hpanel-btn.icon-only { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 50%; }
.hpanel-btn.icon-only svg { width: 15px; height: 15px; }
.hpanel-bulkbar {
  display: none; align-items: center; gap: 14px;
  padding: 10px 20px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  animation: fadeInScale 0.25s var(--ease-out);
}
.hpanel-bulkbar.show { display: flex; }
.hp-selectall { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.hp-selectall input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.hp-selcount { font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }
.hp-bulk-btns { margin-left: auto; display: flex; gap: 8px; }
.hp-day-header {
  grid-column: 1 / -1;
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  padding: 6px 2px 2px; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}
.hpanel-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; align-content: start;
}
.hpanel-grid[data-preview="portrait"] { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.hpanel-grid[data-preview="landscape"] { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.hpanel-grid[data-preview="square"] { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.hp-preview-switch {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
}
.hp-preview-switch .hpanel-btn {
  width: 30px; height: 28px; padding: 0;
  border: none; background: transparent;
  border-radius: var(--radius-full);
  justify-content: center;
}
.hp-preview-switch .hpanel-btn:hover { transform: none; }
.hp-preview-switch .hpanel-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.hp-preview-ico {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.55;
}
.hp-preview-switch .hpanel-btn.active .hp-preview-ico,
.hp-preview-switch .hpanel-btn:hover .hp-preview-ico { opacity: 1; }
.hp-preview-ico.portrait { width: 8px; height: 13px; }
.hp-preview-ico.landscape { width: 13px; height: 8px; }
.hp-preview-ico.square { width: 10px; height: 10px; }
.hp-item {
  position: relative; cursor: pointer;
  border-radius: var(--radius-md); overflow: hidden;
  background: var(--bg-surface);
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-smooth), box-shadow var(--duration-micro) var(--ease-smooth);
  /* 长列表按需渲染：视口外的卡片跳过布局与绘制 */
  content-visibility: auto;
  contain-intrinsic-size: 200px 220px;
  contain: content;
}
.hpanel-grid[data-preview="portrait"] .hp-item { contain-intrinsic-size: 160px 340px; }
.hpanel-grid[data-preview="landscape"] .hp-item { contain-intrinsic-size: 240px 190px; }
.hpanel-grid[data-preview="square"] .hp-item { contain-intrinsic-size: 200px 220px; }
.hp-item:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow-md), var(--shadow-glow); }
.hp-item img, .hp-item .hp-thumb-fallback {
  display: block; width: 100%; aspect-ratio: 1;
  object-fit: cover; background: var(--bg-surface);
}
.hpanel-grid[data-preview="portrait"] .hp-item img,
.hpanel-grid[data-preview="portrait"] .hp-item .hp-thumb-fallback { aspect-ratio: 9 / 16; }
.hpanel-grid[data-preview="landscape"] .hp-item img,
.hpanel-grid[data-preview="landscape"] .hp-item .hp-thumb-fallback { aspect-ratio: 16 / 9; }
.hpanel-grid[data-preview="square"] .hp-item img,
.hpanel-grid[data-preview="square"] .hp-item .hp-thumb-fallback { aspect-ratio: 1; }
.hp-thumb-fallback { display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); }
.hp-thumb-fallback svg { width: 22px; height: 22px; }
.hp-item-label {
  padding: 7px 9px 2px; font-size: 11px; color: var(--text-secondary);
  line-height: 1.4; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  min-height: 30px;
}
.hp-item-meta { padding: 0 9px 8px; font-size: 9px; color: var(--text-tertiary); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-item-del {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid oklch(0.585 0.11 25 / 0.4);
  background: var(--bg-elevated);
  color: var(--danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; opacity: 0; transition: opacity var(--duration-micro) var(--ease-out), transform var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out); z-index: 3;
}
.hp-item-del svg { width: 12px; height: 12px; }
.hp-item:hover .hp-item-del { opacity: 1; }
.hp-item-del:hover { background: var(--danger); color: oklch(0.974 0.011 85); border-color: var(--danger); transform: scale(1.12); }
.hp-check {
  position: absolute; top: 6px; left: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid oklch(0.97 0.009 85 / 0.85);
  background: oklch(0.09 0.008 75 / 0.35);
  display: none; align-items: center; justify-content: center;
  color: oklch(0.974 0.011 85); z-index: 3;
  box-shadow: 0 1px 4px oklch(0.09 0.008 75 / 0.3);
}
.hp-check svg { width: 13px; height: 13px; }
.hpanel-grid.select-mode .hp-check { display: flex; }
.hpanel-grid.select-mode .hp-item-del { display: none; }
.hp-item.selected { border-color: var(--accent); }
.hp-item.selected .hp-check { background: var(--accent); border-color: var(--accent); }
/* 入场由「新节点」自己带 is-entering 决定，不用父级开关。
   父级开关（no-anim）一旦在重绘时被摘掉，animation 会被重新应用到全部已有卡片 ——
   整面板重播入场，图片明明没变却集体闪一下。复用的卡片永不带这个类，刷新即静默。 */
.hp-item.is-entering { animation: cardIn 0.34s var(--ease-out) backwards; }
.hpanel-empty {
  grid-column: 1 / -1; text-align: center;
  padding: 60px 20px; color: var(--text-tertiary);
  font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.hpanel-empty svg { width: 28px; height: 28px; opacity: 0.5; }
.hpanel-empty[data-empty="nomatch"] { gap: 12px; }
/* 搜索词单独提一档对比：它是这句话里唯一的变量，也是用户要核对的字 */
.hp-nomatch-q { color: var(--text-secondary); font-weight: 500; overflow-wrap: anywhere; }
/* 侧边栏 · 查看全部 磁贴 */
.history-viewall {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px; margin-top: 2px;
  border: 1px dashed var(--border-medium); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-tertiary);
  font-size: 11px; cursor: pointer; transition: border-color var(--duration-micro) var(--ease-out), color var(--duration-micro) var(--ease-out), background var(--duration-micro) var(--ease-out);
}
.history-viewall:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.history-viewall svg { width: 13px; height: 13px; }

@media (max-width: 900px) {
  .app-container { height: 100dvh; }
  .main-content {
    display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
  }
  /* 历史栏移到底部，改为横向滑动 */
  .history-sidebar {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
    padding: 8px 14px 6px;
    max-height: 118px;
  }
  .history-header { margin-bottom: 6px; }
  .history-scroll {
    display: flex; gap: 10px;
    overflow-x: auto; overflow-y: hidden;
    align-items: flex-start;
    padding: 2px 0 6px;
  }
  .history-item { flex-shrink: 0; width: 64px; }
  .history-thumb { width: 64px; height: 64px; aspect-ratio: auto; object-fit: contain; background: var(--bg-surface); }
  .history-pending-placeholder,
  .history-item.failed .history-thumb,
  .history-failed-placeholder { width: 64px; height: 64px; aspect-ratio: auto; }
  .history-empty { height: 48px; }
  .panel-right { order: 1; flex: 1; min-height: 0; }
  .image-display { min-height: 0; }
  .composer { padding: 0 12px 10px; }
  .composer-pop { left: 12px; right: 12px; max-height: 46vh; overflow-y: auto; }
  .nav-header { padding: 0 16px; }
  /* 顶栏右侧只剩一颗设置按钮；API Key / 主题 / 快捷入口全部收进设置抽屉 */
  .nav-right { flex: none; gap: 0; }
  .result-image-wrap img {
    max-height: 46vh;
    max-height: 100cqh;
  }
  .result-images-row { gap: 8px; }
  .result-images-row.dual .result-image-wrap { max-width: calc(50% - 4px); }
  .result-images-row.dual .result-image-wrap img { max-height: 40vh; max-height: 100cqh; }
  .main-slots { gap: 8px; }
  .main-slots.multi .main-slot { max-width: calc(50% - 4px); }
  .main-slots.multi .result-image-wrap img { max-height: 40vh; max-height: 100cqh; }
  /* 移动端生成按钮去除图标装饰，仅保留文字 */
  .generate-btn .btn-icon { display: none; }
  /* 底部配置 chip：移动端合并为单个「配置」按钮 */
  .tool-chip.chip-model, .tool-chip.chip-param { display: none; }
  .tool-chip.chip-config { display: inline-flex; }
  /* 移动端：隐藏内嵌历史栏，历史统一通过面板查看 */
  .history-sidebar { display: none; }
  .hpanel-overlay { padding: 0; }
  .hpanel { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .hpanel-header { padding-top: max(16px, env(safe-area-inset-top, 0px)); }
  .hpanel-grid { padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }
  .hpanel-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 14px; }
  .hpanel-grid[data-preview="portrait"] { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .hpanel-grid[data-preview="landscape"] { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .hpanel-grid[data-preview="square"] { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  /* 历史管理面板移动端优化：头部允许换行不挤压，卡片文字单行省略，避免强行换行互相遮挡 */
  .hpanel-header { flex-wrap: wrap; gap: 8px 12px; }
  .hpanel-title { white-space: nowrap; }
  .hpanel-actions { flex-wrap: wrap; gap: 6px; margin-left: auto; }
  .hpanel-storage { order: 3; flex-basis: 100%; text-align: right; }
  .hp-item-label { min-height: 0; }
  .hp-item-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hp-item-del, .hp-check { width: 22px; height: 22px; }
  .hp-bulk-btns { flex-wrap: wrap; }

  /* 触控：去掉 300ms 点击延迟，弱化点击高亮 */
  html { -webkit-tap-highlight-color: transparent; }
  button, a, .tool-chip, .option-chip, .inspiration-tag { touch-action: manipulation; }

  /* 顶栏避开刘海。右侧不再横滑 —— 内容已收进设置抽屉，常驻的只有一颗按钮 */
  .nav-header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  }

  /* 输入框 16px，避免 iOS 聚焦时强制放大页面 */
  .prompt-textarea { font-size: 16px; min-height: 44px; }

  /* 底部输入区避开 Home 指示条 */
  .composer { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }

  /* 悬停才出现的操作，触屏上常显 */
  .image-actions { opacity: 1; transform: none; }
  .main-slot .compare-remove,
  .main-slot .slot-remove { opacity: 0.9; }
  .hp-item-del { opacity: 0.92; }
  .history-item:hover .history-delete,
  .history-item.pending:hover .history-cancel { opacity: 1; }
  .history-delete, .history-cancel { width: 28px; height: 28px; opacity: 0.92; }
  .img-action-btn { width: 44px; height: 44px; }
  .tool-chip, .option-chip, .nav-pill-btn, .hpanel-btn, .empty-cta {
    min-height: var(--touch);
  }
  .theme-toggle, .api-key-toggle { width: 44px; height: 44px; }
  .sidebar-toggle { width: 44px; height: 44px; }
  .composer-refbar-add { width: 44px; height: 44px; }
  .ref-thumb-remove { width: 24px; height: 24px; }

  /* 失败弹窗：贴底全宽，更易点按 */
  .fail-modal-overlay {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }
  .fail-modal { width: 100%; max-height: min(88dvh, 88vh); overflow-y: auto; }
  .fail-modal-btn { min-height: 44px; }
  .confirm-overlay {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }
  .confirm-dialog { width: 100%; }
  .confirm-actions { flex-direction: column-reverse; }
  .confirm-btn { width: 100%; justify-content: center; }

  /* ── 查看器 · 移动端：纵向分区，图片居中占满剩余空间 ── */
  .viewer-overlay,
  .viewer-overlay.is-portrait {
    padding: max(52px, calc(env(safe-area-inset-top, 0px) + 44px)) 12px 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overscroll-behavior: none;
    touch-action: none;
  }
  .viewer-image-container {
    order: 1;
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    touch-action: none;
  }
  .viewer-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }
  .viewer-info {
    order: 2;
    position: relative;
    top: auto; bottom: auto; left: auto; right: auto;
    width: auto; max-width: none;
    margin: 8px 0 0;
    padding: 10px 14px;
    gap: 6px;
    flex-shrink: 0;
    touch-action: pan-y;
    z-index: 3;
  }
  .viewer-info-prompt {
    max-height: 72px;
    font-size: 13px;
    line-height: 1.55;
    -webkit-overflow-scrolling: touch;
  }
  .viewer-info-actions {
    margin-top: 0;
    flex-wrap: wrap;
    gap: 6px;
  }
  .viewer-copy-btn {
    padding: 8px 12px;
    min-height: 36px;
    flex: 1 1 auto;
    justify-content: center;
  }
  .viewer-toolbar {
    order: 3;
    position: relative;
    bottom: auto; left: auto;
    transform: none;
    margin: 8px auto max(10px, env(safe-area-inset-bottom, 0px));
    padding: 6px 10px;
    gap: 6px;
    flex-shrink: 0;
    z-index: 3;
    touch-action: manipulation;
  }
  .viewer-btn { width: 42px; height: 42px; }
  .viewer-close {
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    width: 42px; height: 42px;
    z-index: 5;
  }
  .viewer-strip { display: none !important; }
  /* 移动端改用左右滑动切图，隐藏易挡图的箭头 */
  .viewer-nav { display: none !important; }
}

/* 矮屏 / 横屏：压缩详情卡，把空间留给图片 */
@media (max-width: 900px) and (max-height: 520px) {
  .viewer-overlay,
  .viewer-overlay.is-portrait {
    padding-top: max(40px, calc(env(safe-area-inset-top, 0px) + 32px));
  }
  .viewer-info { margin-top: 4px; padding: 8px 12px; gap: 4px; }
  .viewer-info-title { display: none; }
  .viewer-info-prompt { max-height: 36px; font-size: 12px; }
  .viewer-info-meta { display: none; }
  .viewer-toolbar { margin: 4px auto max(8px, env(safe-area-inset-bottom, 0px)); }
  .viewer-btn { width: 36px; height: 36px; }
}

@media (max-width: 600px) {
  .toast-container { left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top, 0px)); }
  .toast { max-width: none; }
  .nav-header { padding: env(safe-area-inset-top, 0px) 10px 0; }
  .nav-left { gap: 8px; }
  .nav-logo { width: 30px; height: 30px; }
  .nav-brand .nav-title { font-size: 14px; }
  /* 手机窄屏：设置按钮给到 40px，是顶栏唯一的手指点按目标 */
  .nav-icon-btn { width: 40px; height: 40px; }
  .nav-icon-btn svg { width: 18px; height: 18px; }
  .set-card { padding-left: 16px; padding-right: 16px; }
  .theme-toggle { width: 32px; height: 32px; }
  .api-key-capsule { padding: 5px 5px 5px 8px; }
  .model-chips { grid-template-columns: 1fr; gap: 6px; }
  .model-chips .option-chip { text-align: left; padding: 9px 12px; }
  .image-display { padding: 12px; }
  .history-sidebar { padding: 6px 10px 4px; max-height: 104px; }
  .history-thumb { width: 56px; height: 56px; }
  .history-item { width: 56px; }
  .viewer-info-prompt { max-height: 56px; font-size: 12px; }
  .viewer-copy-btn { padding: 7px 10px; font-size: 12px; }
  .result-image-wrap img { max-height: 42vh; max-height: 100cqh; }
  .history-pending-placeholder,
  .history-failed-placeholder { width: 56px; height: 56px; }
  .composer { padding: 0 8px max(8px, env(safe-area-inset-bottom, 0px)); }
  .composer-pop { left: 8px; right: 8px; }
  .composer-capsule { padding: 4px 8px 6px 12px; }
  .composer-input-row .generate-btn { padding: 9px 14px; font-size: 13px; min-height: 44px; }
  .tool-chip { padding: 5px 8px; font-size: 11px; }
  .hpanel-header { padding: max(12px, env(safe-area-inset-top, 0px)) 14px 12px; gap: 6px 10px; }
  .hpanel-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; padding: 12px; }
  .hpanel-grid[data-preview="portrait"] { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .hpanel-grid[data-preview="landscape"] { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .hpanel-grid[data-preview="square"] { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .hpanel-btn { padding: 5px 10px; font-size: 11px; }
  .hpanel-bulkbar { padding: 8px 14px; gap: 10px; flex-wrap: wrap; }
  .hp-bulk-btns { width: 100%; }
  .hp-bulk-btns .hpanel-btn { flex: 1; justify-content: center; padding: 6px 8px; }
  .hp-item-label { font-size: 10px; -webkit-line-clamp: 2; line-clamp: 2; }
  /* 灵感提示 tooltip：移动端弹出层在输入胶囊上方，提示改为向下展开，避免被弹出层顶部裁切 */
  .inspiration-tag .tag-tooltip {
    bottom: auto; top: calc(100% + 8px);
    transform: translateX(-50%) translateY(-4px);
  }
  .inspiration-tag .tag-tooltip::after {
    top: auto; bottom: 100%;
    border-top-color: transparent; border-bottom-color: var(--border-medium);
  }
  .inspiration-tag:hover .tag-tooltip { transform: translateX(-50%) translateY(0); }
}

/* 无悬停设备：不弹出灵感 tooltip，避免点击后残留 */
@media (hover: none) {
  .inspiration-tag .tag-tooltip { display: none !important; }
  .history-item:hover { transform: none; }
  .hp-item:hover { transform: none; }
}

/* ============================================
   🎬 视频工坊（MiniMax-H3 · /video 全屏独立视图）
   沿用 Vellum 主题 token；仅播放器舞台走影院近黑影调，明暗两态共用。
   路由到 /video 时显示（html.route-video），生图主视图整块让位。
   ============================================ */
.vw {
  position: fixed; inset: 0; z-index: 200;
  /* iOS 键盘弹起只收缩视觉视口：--vv-offset 由 JS 按 visualViewport 算出，
     整块工坊收进键盘之上，否则钉底的「生成视频」键与成片轨会停在键盘底下点不到 */
  bottom: var(--vv-offset, 0px);
  display: none; flex-direction: column;
  background: var(--bg-primary);
  color: var(--text-primary);
  /* 播放器舞台专用局部 token：近黑、与主色解耦的暖灰底 */
  --stage: oklch(0.16 0.009 70);
  --stage-deep: oklch(0.11 0.007 70);
  --stage-glow: oklch(0.24 0.014 70 / 0.7);
  /* 深色舞台上的控件文字：近白按规范取 L ≥ 0.96，压到 ~0.16 的黑底上对比约 9:1 */
  --ctl-ink: oklch(0.977 0.009 85);
  --track: oklch(1 0 0 / 0.18);
  --buffered: oklch(1 0 0 / 0.40);
  --ctl-hover: oklch(1 0 0 / 0.12);
  --vw-grad: linear-gradient(to top, oklch(0.08 0.01 70 / 0.9), oklch(0.08 0.01 70 / 0.5) 58%, transparent);
  /* 工坊真正可用的高度：整屏扣掉键盘占位（--vv-offset 由 JS 按 visualViewport 写），
     窄屏分栏比例与提示词框都按它算，不按 vh——键盘弹起时 vh 是不变的 */
  --vw-h: calc(var(--vh100) - var(--vv-offset, 0px));
}
/* 浅色主题下舞台外圈不再是近黑：播放器本体仍走影院深底（letterbox 需要），
   但它四周那圈「黑边」跟着页面底色走，避免米色页面上贴一块黑洞 */
html[data-theme="light"] .vw {
  --stage-deep: oklch(0.925 0.012 85);
  --stage-glow: oklch(0.99 0.007 89 / 0.85);
}
html.route-video .vw { display: flex; }
/* 路由到 /video 时整个生图视图让位（含背景装饰，影院舞台自持深色底） */
html.route-video .app-container,
html.route-video .bg-decoration,
html.route-video .skip-link { display: none !important; }

.vw-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── 顶栏（稳定壳层：切页不卸载，与正文解耦） ── */
.vw-top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  /* 覆盖 iOS 刘海/安卓状态栏：顶栏始终是最上块，安全区直接补到 padding-top */
  padding: calc(10px + env(safe-area-inset-top)) clamp(12px, 2vw, 22px) 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  flex: none;
}
.vw-back {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px 0 10px; border-radius: var(--radius-full);
  color: var(--text-secondary); text-decoration: none; font-size: var(--text-md); font-weight: 500;
  border: 1px solid var(--border-subtle); background: var(--bg-primary);
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear, background-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-back:hover { color: var(--text-primary); border-color: var(--border-medium); }

.vw-back svg { width: 17px; height: 17px; }
.vw-brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
/* 顶栏品牌图标用真·双主题 Logo（与侧栏 .nav-logo 同一套亮/暗位图，见 HTML 的 js-theme-logo） */
.vw-brand-logo {
  width: 26px; height: 26px; flex: none;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: linear-gradient(145deg, oklch(0.994 0.007 89), oklch(0.921 0.025 83));
  box-shadow: inset 0 0 0 1px oklch(0.585 0.107 84 / 0.25);
}
[data-theme="dark"] .vw-brand-logo { background: oklch(0.17 0.004 75); }
.vw-badge {
  font-family: var(--font-body); font-size: var(--text-xs); font-weight: 500;
  color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid var(--accent-medium);
  padding: 2px 9px; border-radius: var(--radius-full); white-space: nowrap;
}
.vw-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.vw-key-wrap {
  display: flex; align-items: center;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  background: var(--bg-primary); overflow: hidden;
  transition: border-color var(--duration-micro) linear;
}
.vw-key-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.vw-key-input {
  border: none; outline: none; background: transparent;
  padding: 8px 2px 8px 14px; width: clamp(130px, 20vw, 180px);
  /* 触屏唤起键盘不自动放大：≥16px */
  font-size: 16px; font-family: var(--font-mono); color: var(--text-primary);
}
.vw-key-toggle { border: none; background: transparent; padding: 8px 12px; color: var(--text-tertiary); cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; }
.vw-key-toggle svg { width: 16px; height: 16px; }
.vw-key-toggle:hover { color: var(--text-primary); }
.vw-quota {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 13px;
  border-radius: var(--radius-full); border: 1px solid var(--border-subtle); background: var(--bg-primary);
  color: var(--text-secondary); font-size: var(--text-sm); cursor: pointer;
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear;
}
.vw-quota:hover { color: var(--text-primary); border-color: var(--border-medium); }
.vw-quota svg { width: 15px; height: 15px; }
.vw-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: var(--radius-full); border: 1px solid var(--border-subtle); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer;
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-theme-toggle:hover { color: var(--text-primary); border-color: var(--border-medium); }

.vw-theme-toggle svg { width: 16px; height: 16px; }

/* ── 主体：舞台优先 + 左配置栏 ── */
.vw-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); }
.vw-rail {
  --rail-pad-x: clamp(14px, 1.6vw, 20px);
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 12px var(--rail-pad-x) 0;
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 10px;
}
.vw-center { min-height: 0; min-width: 0; display: flex; flex-direction: column; }

/* ── 影院舞台 ── */
.vw-stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: grid; place-items: center;
  padding: clamp(10px, 2vw, 20px);
  background:
    radial-gradient(130% 90% at 50% -18%, var(--stage-glow), transparent 60%),
    var(--stage-deep);
  overflow: hidden;
}
.vw-player {
  position: relative; width: 100%; height: 100%; max-width: 100%; max-height: 100%; min-height: 0;
  border-radius: var(--radius-lg); overflow: hidden;
  background: var(--stage); box-shadow: 0 2px 8px oklch(0 0 0 / 0.35), 0 24px 60px oklch(0 0 0 / 0.4), inset 0 0 0 1px oklch(1 0 0 / 0.06);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  container-type: size;
}
.vw-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; z-index: 1; }
/* 模糊背景层：镜像主视频，铺满并虚化，把竖屏/4:3 两侧的纯黑 letterbox 变成柔和的画面延展 */
.vw-video-bg {
  position: absolute; inset: -14%; width: 128%; height: 128%; object-fit: cover;
  filter: blur(46px) saturate(1.35) brightness(0.5);
  opacity: 0; z-index: 0; pointer-events: none; transition: opacity var(--duration-enter) var(--ease-out-soft);
}
.vw-player.has-media .vw-video-bg { opacity: 1; }
/* 空态不再是一块纯黑：底层柔光晕 + 中间胶片画框插画 + 双行说明，视觉重量落在舞台中央 */
.vw-empty-hint {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: oklch(0.72 0.017 78); text-align: center; padding: 24px; pointer-events: none;
}
.vw-empty-glow {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(38% 32% at 50% 46%, oklch(0.54 0.098 83 / 0.20), transparent 65%),
    radial-gradient(60% 50% at 50% 50%, oklch(0.28 0.02 70 / 0.55), transparent 70%);
}
.vw-empty-art {
  position: relative; width: clamp(120px, 26%, 190px); height: auto; color: oklch(0.72 0.017 78 / 0.55);
  filter: drop-shadow(0 6px 24px oklch(0 0 0 / 0.35));
}
.vw-empty-play { color: var(--accent); animation: vw-empty-pulse 2.6s var(--ease-smooth) infinite; }
@keyframes vw-empty-pulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}
.vw-empty-t { position: relative; font-size: var(--text-md); font-weight: 500; letter-spacing: -0.01em; color: oklch(0.88 0.012 78); }
.vw-empty-s { position: relative; font-size: var(--text-sm); color: oklch(0.74 0.015 78); max-width: 40ch; line-height: 1.55; }
.vw-player.has-media .vw-empty-hint { opacity: 0; visibility: hidden; transition: opacity var(--duration-micro) linear, visibility 0s linear var(--duration-micro); }
/* 生成中占位：柔光底 + 旋转环 + 计时，顶掉空态插画；有媒体在播时让位给画面 */
.vw-gen {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: radial-gradient(42% 36% at 50% 46%, oklch(0.54 0.098 83 / 0.18), transparent 66%);
}
.vw-gen[hidden] { display: none; }
.vw-gen__orb { width: 46px; height: 46px; border-radius: 50%; border: 2px solid oklch(1 0 0 / 0.18); border-top-color: var(--accent); animation: vw-spin 900ms linear infinite; }
.vw-gen__t { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; color: oklch(0.9 0.012 78); font-variant-numeric: tabular-nums; }
.vw-gen__s { font-size: var(--text-sm); color: oklch(0.74 0.015 78); max-width: 42ch; line-height: 1.55; text-wrap: pretty; }
.vw-player.gen-on .vw-empty-hint { opacity: 0; visibility: hidden; transition: opacity var(--duration-micro) linear, visibility 0s linear var(--duration-micro); }
.vw-hit { position: absolute; inset: 0; z-index: 3; }

/* UI 层：网格三行（顶栏 / 中央 / 控制），指针穿透、仅控件命中 */
.vw-ui { position: absolute; inset: 0; z-index: 4; pointer-events: none; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; container-type: inline-size; }
.vw-ui > * { pointer-events: none; grid-column: 1; }
.vw-ui button, .vw-ui .vw-scrub { pointer-events: auto; }

.vw-titlebar {
  grid-row: 1; display: flex; align-items: center; gap: 10px; padding: 14px 16px 0;
  color: var(--ctl-ink); text-shadow: 0 1px 10px oklch(0 0 0 / 0.5);
  opacity: 0; transform: translateY(-6px);
  transition: opacity var(--duration-micro) linear, transform var(--duration-enter) var(--ease-out-expo);
}
.vw-player.tb-on .vw-titlebar { opacity: 1; transform: none; }
.vw-titlebar__idx { font-size: 11px; letter-spacing: 0.06em; padding: 3px 9px; border-radius: 999px; flex: none; background: oklch(0.12 0.01 70 / 0.5); border: 1px solid oklch(1 0 0 / 0.16); font-variant-numeric: tabular-nums; }
.vw-titlebar__t { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.vw-center-btn {
  grid-row: 2; justify-self: center; align-self: center; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ctl-ink); border: 1px solid oklch(1 0 0 / 0.24);
  background: oklch(0.18 0.012 70 / 0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transform: scale(0.92); visibility: hidden;
  transition: opacity var(--duration-micro) linear, transform var(--duration-enter) var(--ease-out-expo), background-color var(--duration-micro) linear, visibility 0s linear var(--duration-micro);
}
.vw-player.big-on .vw-center-btn { opacity: 1; pointer-events: auto; transform: none; visibility: visible; transition: opacity var(--duration-micro) linear, transform var(--duration-enter) var(--ease-out-expo), background-color var(--duration-micro) linear, visibility 0s; }
.vw-center-btn svg { width: 32px; height: 32px; }
.vw-center-btn:hover { background: var(--accent); color: var(--text-inverse); transform: scale(1.06); }


.vw-spinner {
  position: absolute; left: 50%; top: 50%; z-index: 5; margin: -20px 0 0 -20px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid oklch(1 0 0 / 0.18); border-top-color: var(--accent);
  animation: vw-spin 900ms linear infinite; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity var(--duration-micro) linear, visibility 0s linear var(--duration-micro);
}
.vw-player.is-buffering .vw-spinner { opacity: 1; visibility: visible; transition: opacity var(--duration-micro) linear, visibility 0s; }
@keyframes vw-spin { to { transform: rotate(360deg); } }

.vw-pipflag {
  grid-row: 2; justify-self: center; align-self: end; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px; padding: 5px 11px 5px 9px; border-radius: 999px;
  font-size: var(--text-sm); color: var(--ctl-ink); text-shadow: 0 1px 8px oklch(0 0 0 / 0.45);
  background: oklch(0.12 0.012 70 / 0.62); border: 1px solid oklch(1 0 0 / 0.16);
  opacity: 0; transition: opacity var(--duration-micro) linear; pointer-events: none;
}
.vw-pipflag svg { width: 14px; height: 14px; flex: none; }
.vw-player.pip-on .vw-pipflag { opacity: 1; }
.vw-player.big-on .vw-pipflag { opacity: 0; }

/* 控制条 */
.vw-controls {
  grid-row: 3; position: relative; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--vw-grad);
  opacity: 0; transform: translateY(8px); visibility: hidden;
  transition: opacity var(--duration-micro) linear, transform var(--duration-enter) var(--ease-out-expo), visibility 0s linear var(--duration-micro);
}
.vw-player.ui-on .vw-controls { opacity: 1; transform: none; visibility: visible; transition: opacity var(--duration-micro) linear, transform var(--duration-enter) var(--ease-out-expo), visibility 0s; }
.vw-player:not(.ui-on) { cursor: none; }
.vw-player:not(.ui-on) .vw-center-btn { opacity: 0; visibility: hidden; pointer-events: none; }
.vw-player:not(.ui-on) .vw-ui * { pointer-events: none; }
.vw-player.is-buffering .vw-center-btn { opacity: 0; visibility: hidden; pointer-events: none; }
.vw-player.err-on .vw-controls, .vw-player.err-on .vw-titlebar { opacity: 0; visibility: hidden; pointer-events: none; }
/* 报错卡片上场后，舞台中央的大播放键与缓冲环也必须退场。它们是状态类驱动的，
   而 pause / waiting / play() 的 rejected Promise 都可能在 error 事件之后才落地，
   把 big-on / is-buffering 重新贴回来——所以 err-on 必须在 CSS 层无条件压制（末位同权覆盖） */
.vw-player.err-on .vw-center-btn, .vw-player.err-on .vw-spinner { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--duration-micro) linear, visibility 0s linear var(--duration-micro); }
/* 报错卡片登场时，空态那套胶片插画（含脉动的播放三角）必须一起退场——
   两块叠着会出现「文案后面透出一个大播放键」的鬼影，像坏掉的暂停图标 */
.vw-player.err-on .vw-empty-hint { opacity: 0; visibility: hidden; transition: opacity var(--duration-micro) linear, visibility 0s linear var(--duration-micro); }

.vw-scrub { position: relative; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.vw-scrub-track { position: relative; width: 100%; height: 4px; border-radius: 999px; background: var(--track); transform: scaleY(1); transition: transform var(--duration-micro) var(--ease-out-soft); }
.vw-scrub:hover .vw-scrub-track, .vw-player.is-scrub .vw-scrub-track { transform: scaleY(1.75); }
.vw-scrub-buf, .vw-scrub-fill { position: absolute; inset: 0; border-radius: 999px; transform-origin: left center; }
.vw-scrub-buf { background: var(--buffered); transform: scaleX(var(--b, 0)); }
.vw-scrub-fill { background: var(--accent); transform: scaleX(var(--p, 0)); }
.vw-scrub-head {
  position: absolute; top: 50%; left: 0; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px oklch(1 0 0 / 0.22);
  transform: translate(calc(var(--p, 0) * var(--tw, 100px) - 6.5px), -50%) scale(var(--hs, 0));
  transition: transform var(--duration-micro) var(--ease-out-soft);
}
.vw-scrub:hover .vw-scrub-head, .vw-player.is-scrub .vw-scrub-head { --hs: 1; }
.vw-bubble {
  position: absolute; bottom: 26px; left: 0; transform: translateX(calc(var(--bx, 0px) - 50%));
  padding: 3px 8px; border-radius: 7px; font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: oklch(0.14 0.014 70 / 0.94); color: var(--ctl-ink); border: 1px solid oklch(1 0 0 / 0.14);
  opacity: 0; transition: opacity var(--duration-micro) linear; pointer-events: none;
}
.vw-scrub:hover .vw-bubble, .vw-player.is-scrub .vw-bubble { opacity: 1; }

.vw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding-top: 4px; }
.vw-cbtn {
  height: 38px; min-width: 38px; padding: 0 7px; border-radius: var(--radius-sm); position: relative; border: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; color: var(--ctl-ink); background: transparent; cursor: pointer;
  transition: color var(--duration-micro) linear, background-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-cbtn svg { width: 20px; height: 20px; }
.vw-cbtn:hover { background: var(--ctl-hover); }

.vw-cbtn[aria-pressed="true"] { color: var(--accent-bright); }
.vw-cbtn .vw-dot { position: absolute; bottom: 5px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent-bright); opacity: 0; transition: opacity var(--duration-micro) linear; }
.vw-cbtn[aria-pressed="true"] .vw-dot { opacity: 1; }
.vw-cbtn--main svg { width: 23px; height: 23px; }
.vw-cbtn::after { content: ""; position: absolute; top: 50%; left: 1px; right: 1px; height: 44px; transform: translateY(-50%); }
.vw-time { font-size: 12.5px; padding: 0 8px; font-variant-numeric: tabular-nums; color: var(--ctl-ink); white-space: nowrap; }
.vw-time .vw-tot { opacity: 0.5; }
.vw-spacer { flex: 1 1 auto; }
.vw-wrap { position: relative; }
.vw-rate-lbl { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 22px; text-align: left; }

@container (max-width: 320px) {
  .vw-row { gap: 1px; }
  .vw-controls { padding-left: 8px; padding-right: 8px; }
  .vw-cbtn { min-width: 34px; padding: 0 4px; }
  .vw-spacer { display: none; }
  .vw-time { padding: 0 3px; margin-left: auto; }
}
@container (max-width: 190px) { .vw-cbtn--rare { display: none; } }

/* 控制层浮层：渲染在 .vw 根内（作用域内），定位由 JS 写视口坐标 */
.vw-pop {
  position: fixed; left: 0; top: 0; z-index: 260;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-medium); border-radius: 14px;
  box-shadow: 0 2px 6px oklch(0 0 0 / 0.18), 0 18px 44px oklch(0 0 0 / 0.24);
  padding: 12px; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--duration-micro) linear, visibility 0s linear var(--duration-micro);
}
.vw-pop.is-show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--duration-micro) linear, visibility 0s; }
.vw-pop[hidden] { display: none; }

/* 音量：竖直浮层，锚在静音键上方（对齐 Videoplay 参考）；跨域成片不接 WebAudio 增益，故 0–100% */
.vw-vol-wrap { position: relative; display: inline-flex; }
.vw-vol-pop { width: 46px; padding: 12px 0 9px; display: grid; justify-items: center; gap: 9px; --vol-h: 92px; }
/* 命中桥：浮层与静音键之间留了缝，指针压到缝上会被判「离开」而收起，这块透明延伸盖住缝 */
.vw-vol-pop::after { content: ""; position: absolute; left: -10px; right: -10px; top: 100%; height: 18px; }
.vw-vol-track { position: relative; width: 4px; height: var(--vol-h); border-radius: 999px; background: var(--track); cursor: pointer; touch-action: none; }
.vw-vol-track::before { content: ""; position: absolute; left: 50%; top: -8px; bottom: -8px; width: 26px; transform: translateX(-50%); }
.vw-vol-fill { position: absolute; inset: 0; border-radius: 999px; background: var(--accent); transform-origin: center bottom; transform: scaleY(var(--v, 1)); }
.vw-vol-knob {
  position: absolute; left: 50%; bottom: 0; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--bg-elevated);
  transform: translate(-50%, 50%) translateY(calc(var(--v, 1) * (0px - var(--vol-h))));
  transition: transform var(--duration-micro) var(--ease-out-soft);
}
.vw-vol-num { font-size: 10.5px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
/* 浮层居中锚定：JS 量好视口坐标写 left/top，居中层用独立 translate 回中，不与动画互压 */
.vw-pop--center { translate: -50% 0; }

/* 倍速面板：预设芯片（等宽免测量滑块）+ 数字输入（不做拖动滑杆） */
.vw-rate-pop { width: 232px; }
.vw-chips { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin-bottom: 10px; }
.vw-chip { height: 30px; border: none; background: transparent; border-radius: 8px; font-size: 11.5px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; position: relative; z-index: 1; cursor: pointer; transition: color var(--duration-micro) linear; }
.vw-chip:hover { color: var(--text-primary); }
.vw-chip[aria-checked="true"] { color: var(--text-inverse); font-weight: 600; }
/* 滑块盒保持整格宽度（translateX(100%) 必须等于格距），可见色块交给 ::before 内缩 2px：
   五格连排时实心块才不会互相贴成一条，也不用为此放弃免测量方案 */
.vw-chip__ind { position: absolute; top: 0; left: 0; width: 20%; height: 30px; transform: translateX(calc(var(--ci, 2) * 100%)); transition: transform var(--duration-slide) var(--ease-slide), opacity var(--duration-micro) linear; pointer-events: none; --jelly-a: .05; }
.vw-chip__ind::before { content: ""; position: absolute; inset: 0 2px; border-radius: 8px; background: var(--accent); }
/* 换格果冻：视觉层在 ::before 上缩放，位移层（父级 translateX）不受影响 */
.vw-chip__ind.is-jelly-x::before { animation: chipJellyX var(--duration-jelly) linear; }
.vw-chips.off .vw-chip__ind { opacity: 0; }
.vw-rate-row { display: flex; align-items: center; gap: 7px; }
.vw-rate-input {
  flex: 1 1 auto; min-width: 0; height: 32px; padding: 0 6px;
  border: 1px solid var(--border-subtle); border-radius: 9px;
  background: var(--bg-primary); color: var(--text-primary);
  font-family: var(--font-body); font-size: 13px; font-variant-numeric: tabular-nums; text-align: center;
  transition: border-color var(--duration-micro) linear, box-shadow var(--duration-micro) linear;
}
.vw-rate-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.vw-rate-unit { flex: none; font-size: 12px; color: var(--text-tertiary); margin-left: -2px; }
.vw-rate-reset {
  height: 30px; padding: 0 9px; border-radius: 8px; font-size: 11.5px; flex: none; cursor: pointer;
  border: 1px solid var(--border-subtle); background: transparent; color: var(--text-secondary); font-family: var(--font-body);
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear;
}
.vw-rate-reset:hover { color: var(--text-primary); border-color: var(--accent); }

/* 详情面板：当前成片的生成参数，键值两列 + 底部动作 */
.vw-info-pop { width: min(320px, calc(100vw - 24px)); padding: 14px; display: grid; gap: 11px; }
.vw-info-prompt { font-size: var(--text-sm); line-height: 1.5; color: var(--text-primary); word-break: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty; }
.vw-info-prompt:empty { display: none; }
.vw-info-kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: var(--text-xs); margin: 0; }
.vw-info-kv dt { color: var(--text-tertiary); }
.vw-info-kv dd { margin: 0; color: var(--text-primary); font-variant-numeric: tabular-nums; word-break: break-word; }
.vw-info-acts { display: flex; gap: 8px; padding-top: 2px; border-top: 1px solid var(--border-subtle); }
.vw-info-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--bg-primary);
  color: var(--text-secondary); font-family: var(--font-body); font-size: var(--text-xs); cursor: pointer; text-decoration: none;
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear, background var(--duration-micro) linear;
}
.vw-info-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.vw-info-btn svg { width: 14px; height: 14px; flex: none; }

/* 配额面板：顶栏「配额」按钮弹出的浮层，展示令牌池摘要 + 每枚令牌状态 */
.vw-quota-pop { width: min(360px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; padding: 14px; }
.vw-quota-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.vw-quota-title { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.vw-quota-title svg { color: var(--accent); }
.vw-quota-refresh { border: none; background: transparent; color: var(--text-tertiary); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; align-items: center; transition: color var(--duration-micro) linear, background var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft); }
.vw-quota-refresh:hover { color: var(--accent); background: var(--accent-soft); }

.vw-quota-refresh.busy svg { animation: vw-spin 900ms linear infinite; }
.vw-quota-summary { margin: 0 0 10px; font-size: var(--text-sm); line-height: 1.55; color: var(--text-secondary); white-space: pre-line; }
.vw-quota-summary.err { color: var(--danger); }
.vw-quota-tokens { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.vw-quota-tokens:empty { display: none; }
.vw-quota-token {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
}
/* 首行：令牌掩码 + 刷新时间同排（刷新时间紧跟令牌右侧），状态徽章吃满余量顶到最右 */
.vw-quota-token__top { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.vw-quota-token__id { flex: 0 1 auto; min-width: 0; font-family: var(--font-mono); color: var(--text-primary); letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-quota-token__state { flex: none; margin-left: auto; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--border-subtle); color: var(--text-tertiary); white-space: nowrap; }
.vw-quota-token.ok .vw-quota-token__state { background: oklch(0.72 0.14 155 / 0.18); color: oklch(0.55 0.14 155); }
.vw-quota-token.warn .vw-quota-token__state { background: var(--accent-soft); color: var(--accent); }
.vw-quota-token.bad .vw-quota-token__state { background: oklch(0.63 0.2 25 / 0.15); color: var(--danger); }
.vw-quota-token__meta { grid-column: 1 / -1; font-variant-numeric: tabular-nums; color: var(--text-tertiary); }
.vw-quota-token__refresh { flex: none; font-variant-numeric: tabular-nums; color: var(--text-tertiary); white-space: nowrap; }
.vw-quota-token__reason { grid-column: 1 / -1; color: var(--danger); font-size: 11px; }
.vw-quota-note { margin: 0; font-size: 11px; line-height: 1.5; color: var(--text-tertiary); }

/* ── 挑号：负载均衡 / 手动勾选 ──
   开关做成参数区同款的 chip，面板里一眼分的出「这是模式」而不是「这是状态」。
   勾选框只在手动模式出现：自动模式下它们是纯噪音，反而会让人以为勾了就一定用那枚。 */
.vw-quota-mode { display: flex; gap: 6px; margin: 0 0 7px; }
.vw-quota-mode__opt {
  flex: 1; padding: 5px 8px; font: inherit; font-size: var(--text-sm); color: var(--text-secondary);
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 8px; cursor: pointer;
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear, background var(--duration-micro) linear;
}
.vw-quota-mode__opt:hover { border-color: var(--border-medium); color: var(--text-primary); }
.vw-quota-mode__opt.is-on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.vw-quota-modehint { margin: 0 0 9px; font-size: 11px; line-height: 1.5; color: var(--text-tertiary); }
.vw-quota-modehint.warn { color: var(--accent); }
/* 这一单的用量：勾选框旁边的「够 / 不够」全靠它，所以直接把算式写在面板上，别让用户心算 */
.vw-quota-cost { margin: 0 0 7px; font-size: 11px; line-height: 1.5; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.vw-quota-cost b { color: var(--text-secondary); font-weight: 600; }
.vw-quota-pick { flex: none; display: inline-flex; align-items: center; cursor: pointer; }
.vw-quota-pick input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.vw-quota-token.is-picked { border-color: var(--accent); }
.vw-quota-token__fit { flex: none; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-tertiary); }
.vw-quota-token__fit.yes { color: oklch(0.55 0.14 155); }
.vw-quota-token__fit.no { color: var(--danger); }

/* 播放失败兜底：影院舞台本就是深色，报错态用暗角渐变做出层次，不再是纯黑空洞，
   也不再是浅色主题下那块发灰的米色板；文字固定浅色高对比，按钮沿用舞台控件的深底亮字，两主题都清晰。
   这里不挂 backdrop-filter：渐变已经盖到 0.9 不透明度，模糊既看不见又要为整块舞台逐帧重栅格化 */
.vw-err {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  text-align: center; padding: 28px;
  background: radial-gradient(135% 120% at 50% 40%, oklch(0.24 0.014 70 / 0.9), oklch(0.11 0.009 70 / 0.96));
}
.vw-err[hidden] { display: none; }
.vw-err svg { width: 30px; height: 30px; color: var(--danger); opacity: 0.95; }
.vw-err__msg { font-size: 14px; line-height: 1.65; max-width: 30ch; color: oklch(0.95 0.006 85); letter-spacing: 0.01em; text-wrap: balance; }
.vw-err__acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
/* 影院舞台的标题/时间/报错文字常年压在深色底上：选中态固定为「强调底 + 反色字」，两主题下都清晰 */
.vw-player ::selection { background: var(--accent); color: var(--text-inverse); }
.vw-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  /* 一颗是 <button> 一颗是 <a>：不锁死字体与行高，两者基线会差 1px 而看着「没对齐」 */
  font-family: var(--font-body); font-size: var(--text-sm); line-height: 1;
  border-radius: var(--radius-full); border: 1px solid oklch(1 0 0 / 0.22); background: oklch(0.2 0.014 70 / 0.6);
  color: var(--ctl-ink); text-decoration: none; cursor: pointer;
  transition: background-color var(--duration-micro) linear, border-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-btn:hover { background: oklch(0.28 0.016 70 / 0.7); border-color: oklch(1 0 0 / 0.34); }

.vw-btn svg { width: 16px; height: 16px; }

/* ── 历史成片轨（舞台下方） ── */
.vw-strip { flex: none; border-top: 1px solid var(--border-subtle); background: var(--bg-surface); padding-bottom: env(safe-area-inset-bottom); }
.vw-strip-head { display: flex; align-items: center; gap: 8px; padding: 9px clamp(12px, 1.6vw, 18px) 4px; font-size: var(--text-sm); color: var(--text-secondary); }
.vw-strip-head .vw-strip-count { font-variant-numeric: tabular-nums; color: var(--text-tertiary); }
.vw-strip-list { display: flex; gap: 8px; padding: 4px clamp(12px, 1.6vw, 18px) clamp(10px, 1.5vw, 14px); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.vw-clip {
  position: relative; flex: none; width: 132px; height: 82px; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border-subtle); background: var(--bg-elevated); cursor: pointer; padding: 0; color: var(--text-primary);
  scroll-snap-align: start; text-align: left;
  transition: border-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft), box-shadow var(--duration-micro) linear;
}
.vw-clip:hover { border-color: var(--accent-medium); transform: translateY(-2px); }
.vw-clip.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.vw-clip__thumb { position: absolute; inset: 0; background: var(--stage); display: grid; place-items: center; }
.vw-clip__thumb svg { width: 22px; height: 22px; color: oklch(0.6 0.02 78); opacity: 0.6; }
/* 真实首帧预览：懒加载的静音 video，铺满缩略位；没加载出来时下面的胶片图标兜底 */
.vw-clip__vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--stage); opacity: 0; transition: opacity var(--duration-micro) linear; }
.vw-clip__vid.is-on { opacity: 1; }
/* 本地存的这一帧（生成时从舞台视频上抓的 JPEG）：回放地址过期/漂走也还有预览图，
   有它就不再为这张卡片去拉一遍懒加载视频 */
.vw-clip__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--stage); }
.vw-clip__ar { position: absolute; inset: 0; display: grid; place-items: center; }
.vw-clip__ratio { width: calc(100% - 14px); height: calc(100% - 14px); max-height: 56px; border: 1.5px solid oklch(0.55 0.04 78 / 0.5); border-radius: 4px; }
.vw-clip__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 8px 5px; display: flex; align-items: center; gap: 6px; background: linear-gradient(to top, oklch(0.1 0.01 70 / 0.82), transparent); }
.vw-clip__dur { font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--ctl-ink); }
.vw-clip__prompt { position: absolute; top: 6px; left: 7px; right: 32px; font-size: 10.5px; line-height: 1.35; color: var(--ctl-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 4px oklch(0 0 0 / 0.5); }
.vw-strip-empty { padding: 14px clamp(12px, 1.6vw, 18px) 16px; color: var(--text-tertiary); font-size: var(--text-sm); display: flex; align-items: center; gap: 8px; }
.vw-strip-empty svg { width: 18px; height: 18px; opacity: 0.5; }

/* ── 窄屏历史入口与抽屉 ──
   桌面端成片轨常驻舞台下方，这两件都不出现。窄屏轨收进底部抽屉后，顶栏那颗「历史」
   是唯一开关，日常态与「配额」同族的胶囊；有任务在跑就亮强调色 + 呼吸点，
   抽屉关着也知道去哪看进度、去哪取消 */
.vw-hist-btn {
  display: none; align-items: center; gap: 6px;
  height: 38px; padding: 0 13px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  background: var(--bg-primary); color: var(--text-secondary);
  font-family: var(--font-body); font-size: var(--text-sm); cursor: pointer;
  transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear, background-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-hist-btn svg { width: 15px; height: 15px; flex: none; }
.vw-hist-btn__n { font-variant-numeric: tabular-nums; opacity: 0.72; }
.vw-hist-btn:hover { color: var(--text-primary); border-color: var(--border-medium); }

/* 有任务在跑：胶囊前头一颗呼吸的强调点 */
.vw-hist-btn.is-busy { color: var(--accent); border-color: var(--accent-medium); }
.vw-hist-btn.is-busy::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--accent); animation: vw-empty-pulse 1.6s var(--ease-smooth) infinite; }
/* 抽屉里的收起键：只在窄屏出现，抽屉的显式出口（遮罩、Esc、再点按钮也都收） */
.vw-sheet-close {
  display: none; margin-left: auto; width: 30px; height: 30px; border: none; border-radius: var(--radius-full);
  align-items: center; justify-content: center; cursor: pointer;
  background: transparent; color: var(--text-tertiary);
  transition: color var(--duration-micro) linear, background-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-sheet-close svg { width: 16px; height: 16px; }
.vw-sheet-close:hover { color: var(--text-primary); background: var(--border-subtle); }


/* 占位/运行中的任务卡（在轨最前） */
.vw-clip--pending { cursor: default; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.vw-clip--pending:hover { transform: none; border-color: var(--border-subtle); }
.vw-clip--pending .vw-spinner { position: static; margin: 0; width: 26px; height: 26px; border-width: 2px; opacity: 1; visibility: visible; }
.vw-clip--pending .vw-clip-timer { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.vw-clip--pending .vw-clip-cancel { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border: none; border-radius: var(--radius-full); background: oklch(0.2 0.02 70 / 0.6); color: var(--ctl-ink); display: grid; place-items: center; cursor: pointer; }
.vw-clip--pending .vw-clip-cancel svg { width: 12px; height: 12px; }

/* ── 配置栏控件 ── */
.vw-field { display: flex; flex-direction: column; gap: 8px; }
/* 画面描述是唯一该吃剩余高度的字段：只许长大、不许缩小。flex-shrink 配 min-height:0
   会让它在栏内放不下时一路缩到 0，字段盒归零后里面的标签、输入框、灵感整段溢出，
   直接压在关键帧、画幅上（窗口一矮就是一片叠印）。放不下让配置栏自己滚，不缩 */
.vw-field--prompt { flex: 1 0 auto; gap: 6px; }
.vw-field--prompt > .vw-label, .vw-field--prompt > .vw-inspo { flex: none; }
.vw-label { display: flex; align-items: baseline; gap: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.vw-label-sub { font-weight: 400; font-size: var(--text-xs); color: var(--text-tertiary); }
.vw-textarea {
  width: 100%; resize: none; flex: 1 1 auto; min-height: clamp(104px, calc(var(--vw-h) * 0.155), 240px);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--bg-primary); color: var(--text-primary);
  padding: 11px 13px; font-size: var(--text-md); line-height: 1.6; font-family: var(--font-body); outline: none;
  transition: border-color var(--duration-micro) linear, box-shadow var(--duration-micro) linear;
}
.vw-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.vw-textarea::placeholder { color: var(--text-tertiary); }

/* 灵感标签：复用生图工坊的 .inspiration-tag 外观。这里不用 .tag-tooltip 浮层，
   配置栏本身是滚动容器，绝对定位的浮层会被裁掉并撑出横向滚动条，改用原生 title 摘要 */
.vw-inspo { display: flex; flex-wrap: wrap; gap: 6px; }

/* 画幅六格一排（含 360 窄屏）：比例标签都是 4 字以内的等宽短语，六格一排仍读得清，
   却比两排省下约一排芯片的钱——配置栏高度是先省出来、再谈不滚动的 */
.vw-canvas { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
/* 复用全局 .option-chip 视觉与 .chip-slider 滑块，这里只把芯片铺满各自网格 */
.vw-canvas .option-chip { justify-self: stretch; text-align: center; padding: 8px 2px; }
/* 关键帧锁定画幅时收起芯片组。.vw-canvas 自己声明了 display:grid，会盖掉 UA 的
   [hidden]{display:none}，所以 hidden 属性必须在这里显式兑现，否则藏不住 */
.vw-canvas[hidden] { display: none; }
.vw-canvas-lock {
  margin: 0; font-size: var(--text-xs); line-height: 1.6; color: var(--text-secondary);
  font-family: var(--font-mono); padding: 8px 10px;
  border: 1px dashed var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-primary);
}

/* 清晰度：两段连体分段控件（单外框 + 内嵌滑块，不再是两颗各自独立的胶囊） */
.vw-quality-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.vw-quality-hint { font-size: var(--text-xs); color: var(--text-tertiary); font-family: var(--font-mono); }
.vw-seg {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  padding: 2px; border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
}
.vw-seg .option-chip {
  border: none; background: transparent; box-shadow: none;
  padding: 6px 10px; border-radius: 999px; text-align: center;
  justify-self: stretch; transform: none;
  color: var(--text-secondary);
}
.vw-seg .option-chip:hover { background: transparent; border: none; color: var(--text-primary); transform: none; }
.vw-seg .option-chip.selected { color: var(--text-inverse); font-weight: 600; }
.vw-seg .chip-slider::before { background: var(--accent); border-color: var(--accent); }

.vw-param-lbl { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: 6px; }
.vw-param-lbl b { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.vw-range { width: 100%; accent-color: var(--accent); margin-top: 2px; }
/* 时长与步数并排一行：两条滑杆都是「标签 + 16px 轨道」的矮字段，各占一行纯属浪费栏高 */
.vw-params { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vw-seed {
  width: 100%; border: 1px solid var(--border-subtle); border-radius: var(--radius-xs);
  background: var(--bg-primary); color: var(--text-primary);
  padding: 8px 10px; font-size: 16px; font-family: var(--font-mono); outline: none;
  transition: border-color var(--duration-micro) linear, box-shadow var(--duration-micro) linear;
}
.vw-seed:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.vw-seed::-webkit-outer-spin-button, .vw-seed::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.vw-frames { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vw-frame {
  position: relative; aspect-ratio: 16 / 9; min-height: 62px; max-height: 116px;
  border: 1.5px dashed var(--border-medium); border-radius: var(--radius-md);
  display: grid; place-items: center; overflow: hidden; cursor: pointer; color: var(--text-tertiary); font-size: var(--text-sm); background: var(--bg-primary);
  transition: border-color var(--duration-micro) linear, color var(--duration-micro) linear, background-color var(--duration-micro) linear;
}
.vw-frame:hover, .vw-frame:focus-visible { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); outline: none; }
.vw-frame.dragover { border-color: var(--accent); border-style: solid; color: var(--accent-ink); background: var(--accent-soft); }
.vw-frame__empty { display: flex; align-items: center; gap: 7px; }
.vw-frame__empty svg { width: 16px; height: 16px; opacity: 0.75; }
.vw-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vw-frame__del { position: absolute; top: 6px; right: 6px; z-index: 2; width: 26px; height: 26px; border: none; border-radius: var(--radius-full); display: grid; place-items: center; cursor: pointer; background: oklch(0.2 0.02 70 / 0.68); color: var(--ctl-ink); }
.vw-frame__del svg { width: 14px; height: 14px; }
/* 帧里已有图时是「点开看大图」，不是再开一次文件选择：光标给出提示 */
.vw-frame:has(img) { cursor: zoom-in; }

/* 关键帧预览：全屏大图。默认整图适配，滚轮 / 双指 / 双击缩放，拖拽平移；
   点图外或 ✕ 关闭，Esc 关闭，键盘 +/-/0 缩放复位（空帧点击仍是文件选择） */
.vw-frame-view {
  position: fixed; inset: 0 0 var(--vv-offset, 0px) 0; z-index: 270;
  display: grid; grid-template-columns: 100%; grid-template-rows: 100%;
  place-items: center; padding: clamp(18px, 4vw, 48px);
  background: oklch(0.11 0.009 70 / 0.74);
  overflow: hidden; touch-action: none; overscroll-behavior: contain;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--duration-exit) linear, visibility 0s linear var(--duration-exit);
}
.vw.frame-view-open .vw-frame-view { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--duration-enter) linear, visibility 0s; }
/* 显式给宽高 + object-fit：auto 网格行里百分比 max-height 存在循环依赖，会让竖图顶出屏幕 */
.vw-frame-view img {
  width: 100%; height: 100%; max-width: min(100%, 1080px);
  object-fit: contain; border-radius: var(--radius-md);
  filter: drop-shadow(0 22px 60px oklch(0 0 0 / 0.5));
  user-select: none; -webkit-user-drag: none; cursor: zoom-in; will-change: transform;
}
/* 双击 / 键盘这类程序化缩放走短暂过渡；拖拽与双指期间必须即时响应，由 JS 摘掉 */
.vw-frame-view.is-anim img { transition: transform var(--duration-enter) var(--ease-out-expo); }
.vw-frame-view__close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid oklch(1 0 0 / 0.24); background: oklch(0.18 0.012 70 / 0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: var(--ctl-ink); cursor: pointer;
  transition: background-color var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft);
}
.vw-frame-view__close svg { width: 22px; height: 22px; }
.vw-frame-view__close:hover { background: var(--accent); color: var(--text-inverse); transform: scale(1.06); }


/* 底部操作区：种子在左、生成键在右，一条钉在配置栏底边的操作条——内容再长也从它下方滑过，
   主操作挤不出屏幕。桌面与手机同一个布局，窄屏只是把内边距收紧一档（见响应式块） */
.vw-rail-actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  margin: 0 calc(-1 * var(--rail-pad-x));
  padding: 8px var(--rail-pad-x) 12px;
  background: linear-gradient(to top, var(--bg-primary) 78%, transparent);
}
.vw-rail-actions .vw-field--seed { flex: 1 1 auto; min-width: 0; flex-direction: row; align-items: center; gap: 8px; }
.vw-rail-actions .vw-field--seed > .vw-label { flex: none; flex-direction: column; align-items: flex-start; gap: 1px; }
.vw-rail-actions .vw-seed { width: auto; flex: 1 1 auto; min-width: 0; }
/* 生成键的包围盒：钉底与渐变交给操作条，这里只保证不被压缩 */
.vw-rail-foot { flex: none; }
.vw-rail-actions .vw-generate { padding: 13px 18px; }
/* 抽屉遮罩只在窄屏存在：桌面端不建盒子，别在配置栏尾部留个空 flex 成员 */
.vw-sheet-scrim { display: none; }
.vw-generate {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-full); cursor: pointer;
  padding: 13px; font-size: 0.92rem; font-weight: 600; font-family: var(--font-body);
  color: var(--text-inverse); background: var(--accent); box-shadow: var(--shadow-sm);
  transition: background var(--duration-micro) linear, transform var(--duration-micro) var(--ease-out-soft), box-shadow var(--duration-micro) linear, opacity var(--duration-micro) linear;
}
.vw-generate:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.vw-generate:active:not(:disabled) { transform: translateY(0); }
.vw-generate:disabled { opacity: 0.55; cursor: not-allowed; }
.vw-generate .btn-icon { display: flex; }
.vw-generate .btn-icon svg { width: 17px; height: 17px; }

.vw-clip-del { position: absolute; top: 5px; right: 5px; z-index: 3; width: 24px; height: 24px; border: none; border-radius: var(--radius-full); display: grid; place-items: center; cursor: pointer; background: oklch(0.2 0.02 70 / 0.6); color: var(--ctl-ink); opacity: 1; transition: opacity var(--duration-exit) linear, background-color var(--duration-micro) linear; }
.vw-clip-del svg { width: 13px; height: 13px; }
/* 删除键只在「真能用鼠标点」的环境藏进 hover：触屏按不准隐藏目标，一律常驻。
   pointer:fine 是必须的第二个条件——Windows 触屏笔记本是 hover:hover + pointer:coarse，
   只判 hover 会把键藏起来，用户根本点不到 */
@media (hover: hover) and (pointer: fine) {
  .vw-clip-del { opacity: 0; }
  .vw-clip:hover .vw-clip-del, .vw-clip:focus-within .vw-clip-del { opacity: 1; }
}
.vw-clip-del:hover { background: var(--danger); }

/* 入场：视图揭示（挂在揭幕 / 路由切入手势上；route-video 与 boot-ready 同在 html 上） */
@keyframes vw-fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
html.boot-ready.route-video .vw-top { animation: vw-fade-up var(--duration-enter) var(--ease-out-expo) backwards; }
html.boot-ready.route-video .vw-rail { animation: vw-fade-up var(--duration-enter) var(--ease-out-expo) 60ms backwards; }
html.boot-ready.route-video .vw-stage { animation: vw-fade-up var(--duration-enter) var(--ease-out-expo) 40ms backwards; }
html.boot-ready.route-video .vw-strip { animation: vw-fade-up var(--duration-enter) var(--ease-out-expo) 90ms backwards; }
.vw-clip { animation: vw-fade-up 0.4s var(--ease-out-expo) backwards; }

/* ── 响应式：窄屏单列，舞台在上，配置栏顺延 ──
   两个高度写成同一把尺子的比例（54 : 46），不再给舞台加固定比例的地板：
   地板 + 46% 的配置栏 + 成片轨的固定高度，三者相加必然超过可用高度，舞台和配置栏
   会直接叠印在一起（窗口一矮必现）。成片轨在窄屏彻底离开纵向排布、收进底部抽屉，
   舞台吃满整行；配置栏内容永远高于 46%，栏内滚动，生成键与种子钉在栏底 */
@media (max-width: 860px) {
  .vw-main { grid-template-columns: 1fr; grid-template-rows: 54fr 46fr; }
  .vw-center { order: 1; }
  .vw-rail { order: 2; border-right: none; border-top: 1px solid var(--border-subtle); }

  /* 成片轨 = 底部抽屉：固定贴底（跟随键盘补偿），关闭时整条移出视口并停掉可见性，
     免得投影残留在屏幕下缘；开合只动 transform，不碰高度、不做布局 */
  .vw-strip {
    position: fixed; left: 0; right: 0; bottom: var(--vv-offset, 0px);
    z-index: 240;
    max-height: calc(var(--vw-h) * 0.64);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -16px 44px oklch(0 0 0 / 0.3);
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
    overflow: hidden;
    transform: translateY(103%);
    visibility: hidden;
    transition: transform var(--duration-enter) var(--ease-out-expo), visibility 0s linear var(--duration-enter);
  }
  .vw.sheet-open .vw-strip { transform: none; visibility: visible; transition: transform var(--duration-enter) var(--ease-out-expo), visibility 0s; }
  /* 抓手条：一眼认出这是可以按下去的抽屉 */
  .vw-strip::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 999px; background: var(--border-medium); margin: 8px auto 0; }
  .vw-sheet-close { display: inline-flex; }
  .vw-hist-btn { display: inline-flex; }
  /* 顶栏窄屏本来就要换行：与其让操作组被挤到第二行右端、左边空出一大片，不如主动分工——
     第一行 返回 + Vellum 徽标，主题键钉在这一行的**右端**（右上角那颗在任何屏宽都在原位，
     不会跟着操作行掉到第二排），第二行整行排开 Key / 历史 / 配额。
     摊平用 display:contents：四个操作键直接成为顶栏这个 flex 容器的项，order 才管得到它们 */
  .vw-top { row-gap: 8px; }
  .vw-head-actions { display: contents; }
  .vw-top > .vw-back { order: 0; }
  .vw-top > .vw-brand { order: 1; }
  .vw-head-actions .vw-theme-toggle { order: 2; margin-left: auto; }
  /* Key 的基宽写成「整行减去历史+配额那一档」：它一定放不下第一行（第一行还有返回 + 徽标 + 主题），
     于是自己顶到第二行开头，把历史、配额一起带下来——这才叫强制换行，而不是靠 flex-wrap 贪心填。
     按 150px 这种小基宽写会让 Key 留在第一行右侧，主题键就被挤到中间（560~700 实测会散架）。 */
  .vw-head-actions .vw-key-wrap { flex: 1 1 calc(100% - 200px); min-width: 0; order: 3; }
  .vw-head-actions .vw-hist-btn { order: 4; }
  .vw-head-actions .vw-quota { order: 5; }
  /* 字号跟同排胶囊（历史/配额）对齐，顶栏才紧凑；代价是 iOS 聚焦时会有一次视口缩放 */
  .vw-head-actions .vw-key-input { width: auto; min-width: 0; flex: 1 1 auto; font-size: 13px; }
  /* 手机上没有这些的意义：上/下一条改用抽屉选片，倍速与画中画在触屏上形同虚设 */
  #vwPrev, #vwNext, #vwRate, #vwPip { display: none; }
  /* 抽屉是「藏起来」的元素，不走揭幕的上浮动画——否则揭幕那 450ms 会把它顶进屏幕 */
  html.boot-ready.route-video .vw-strip { animation: none; }

  /* 抽屉遮罩：点它收起；桌面端这条规则不存在，div 已被上层 display:none 摘掉 */
  .vw-sheet-scrim {
    display: block;
    position: fixed; inset: 0 0 var(--vv-offset, 0px) 0; z-index: 235;
    background: oklch(0.11 0.009 70 / 0.46);
    opacity: 0; pointer-events: none;
    transition: opacity var(--duration-exit) linear;
  }
  .vw.sheet-open .vw-sheet-scrim { opacity: 1; pointer-events: auto; transition: opacity var(--duration-enter) linear; }
}
/* ≤560px：主题键要和返回、徽标同排站在右上角，这一行放不下「返回生图」四个字。
   让位的是文字标签而不是徽标——「视频工坊 · MiniMax-H3」是这一行的身份，
   箭头 + href 仍然认得出是返回。 */
@media (max-width: 560px) {
  .vw-back span { display: none; }
  .vw-back { padding: 0 10px; }
}
@media (max-width: 400px) {
  .vw-top { padding: 9px 12px; gap: 8px; }
  .vw-brand { font-size: 1rem; }
  .vw-rail { --rail-pad-x: 12px; }
  /* 320 这一档：让徽标先省略号收尾，把主题键留在右上角。徽标是身份说明，截掉尾字符不丢功能；
     主题键一旦掉到第二行，「右上角那颗」就找不到了。
     上限要给徽标写死（max-width），不能只靠 flex 收缩：flex-wrap 先按**假想主轴宽**断行，
     收缩只发生在断行之后 —— 只写 min-width 的话徽标永远轮不到收缩，主题键先被顶去第二行。 */
  .vw-brand { flex: 0 1 auto; min-width: 0; max-width: calc(100% - 112px); }
  .vw-brand > span:not(.vw-badge) { flex: none; }
  .vw-badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  /* 排法沿用 ≤860 那一套（主题键在标题行右端、Key / 历史 / 配额 在第二行），
     这里只把字号与内边距再收一档，360 屏也不会在末尾挤出一个孤零零的配额键 */
}

/* 宽屏（真·桌面双栏）的矮窗口：描述框保底高度收进 13vh / 88px——
   1366×768 这类窗口（内容视口 ~690px）配置栏也能整栏放下、不出现滚动条；
   余量充足时 flex 仍会把描述框撑满，只有真放不下时才压到下限 */
@media (min-width: 861px) {
  .vw-textarea { min-height: clamp(88px, calc(var(--vw-h) * 0.13), 240px); }
}

/* ── 排版：孤字悬挂 ──
   居中的短文案用 balance 等分（读不出留白）；左对齐的动态长文案只做「尾行不留孤字」的 pretty，
   绝不 balance——它会把首行从满行削掉一大截，凭空造出一条空白带 */
.vw-empty-t, .vw-empty-s { text-wrap: balance; }
.vw-strip-empty, .vw-quota-note, .vw-clip__prompt { text-wrap: pretty; }

/* ── 触屏热区：命中盒补到 44px，桌面（fine 指针）保持原来的紧凑视觉尺寸 ── */
@media (pointer: coarse) {
  .vw-key-wrap { min-height: 44px; }
  .vw-key-toggle { min-width: 44px; min-height: 44px; }
  .vw-back, .vw-quota, .vw-theme-toggle { height: 44px; }
  .vw-theme-toggle { width: 44px; }
  .vw-inspo { gap: 8px; }
  .vw-inspo .inspiration-tag { min-height: 44px; display: inline-flex; align-items: center; }
  /* 画幅芯片在触屏撑到 44px 命中盒；六格一排的排法在基础规则里，各宽度一致 */
  .vw-canvas .option-chip { min-height: 44px; padding: 8px 2px; }
  .vw-seg .option-chip { min-height: 44px; }
  .vw-seed { min-height: 44px; }
  /* 触屏：描述框抬到 16px 避免 iOS 聚焦时强制放大页面；桌面（fine 指针）统一 14px，见基础规则 */
  .vw-textarea { font-size: 16px; }
  /* 顶栏胶囊跟「配额」同高才齐整：命中盒往外扩到 44 的线，不靠撑高破坏这一行 */
  .vw-hist-btn { position: relative; }
  .vw-hist-btn::after { content: ""; position: absolute; left: -3px; right: -3px; top: -3px; bottom: -3px; }
  .vw-sheet-close { width: 44px; height: 44px; }
  /* 卡内小删除键向外只扩到卡片边缘、向内补足 44px：不会侵占邻卡与播放区的点击 */
  .vw-clip-del::after, .vw-clip--pending .vw-clip-cancel::after { content: ""; position: absolute; top: -5px; right: -5px; bottom: -15px; left: -15px; }
  .vw-frame__del::after { content: ""; position: absolute; top: -6px; right: -6px; bottom: -12px; left: -12px; }
}
/* 排队卡：转圈占第一行、落在文字正上方，整块随内容垂直居中（不再绝对定位钉在左上角） */
.vw-clip--pending { display: grid; align-content: center; justify-items: center; gap: 4px; padding: 6px 7px; }
.vw-clip--pending .vw-spinner { position: static; margin: 0; width: 14px; height: 14px; border-width: 1.5px; }
.vw-clip--pending .vw-clip-status { max-width: 100%; font-size: 13px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-clip--pending .vw-clip-timer { white-space: nowrap; font-size: 12px; line-height: 16px; }
.vw-frame__preview { position: absolute; bottom: 6px; left: 6px; z-index: 2; padding: 3px 8px; border: 1px solid var(--border-subtle); border-radius: var(--radius-full); background: oklch(0.2 0.02 70 / 0.8); color: var(--ctl-ink); font: inherit; font-size: 11px; cursor: pointer; }
.vw-frame__preview:focus-visible { outline: 2px solid var(--ctl-ink); outline-offset: 2px; }
.vw-clip--pending .vw-spinner[hidden], .vw-clip--pending [data-retry][hidden] { display: none; }
/* 重查按钮：卡片底色是主题表面，不能用舞台那套深色底 + 近白字（--ctl-ink），
   否则浅色主题下像个糊上去的黑块，hover 还会把文字洗成看不见。改成描边幽灵态 */
.vw-clip--pending [data-retry] { appearance: none; padding: 3px 11px; font: inherit; font-size: 11px; line-height: 1.5; color: var(--text-secondary); background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius-full); cursor: pointer; transition: color var(--duration-micro) linear, border-color var(--duration-micro) linear, background var(--duration-micro) linear; }
.vw-clip--pending [data-retry]:hover { color: var(--accent); border-color: var(--accent-medium); background: var(--accent-soft); }
.vw-clip--pending [data-retry]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================
   👆 按压手感 · 全站唯一一套
   ============================================
   手感来自「按下立刻塌、抬起弹回来」，不是把 scale 调大：
   · 按下 90ms 到位（端到端 <100ms 才算跟手，长于此会觉得在拖橡皮筋）
   · 抬起 260ms 走 --ease-spring-soft，落点自带 2–3% 过冲再收住
   · 用独立的 scale 属性而不是 transform：不少控件在 hover 上已经用 transform 做纵向抬升，
     写进同一层会把抬升量一起缩放，读成抖动
   · 颜色类过渡原样保留（transition 是单值属性，重写时必须列全，不能丢） */
:is(.theme-toggle,.nav-icon-btn,.option-chip,.tool-chip,.inspiration-tag,.nav-pill-btn,
     .hpanel-btn,.hpanel-search-clear,.hpanel-search-exit,.empty-cta,.error-retry-btn,
     .generate-btn,.img-action-btn,.viewer-btn,.viewer-close,.viewer-copy-btn,.confirm-btn,
     .fail-modal-btn,.fail-modal-close,.set-row,.set-close,.slot-cancel-btn,.ref-add-btn,
     .composer-refbar-add,.history-manage,.history-delete,.history-cancel,.toast-close,
     .sidebar-toggle,.sb-rail-btn,.api-key-toggle,
     .vw-back,.vw-theme-toggle,.vw-center-btn,.vw-cbtn,.vw-quota-refresh,.vw-btn,
     .vw-hist-btn,.vw-sheet-close,.vw-frame-view__close,.vw-generate) {
  scale: 1;
  transition:
    scale var(--duration-release) var(--ease-spring-soft),
    transform var(--duration-micro) var(--ease-out),
    border-color var(--duration-micro) var(--ease-out),
    background var(--duration-micro) var(--ease-out),
    color var(--duration-micro) var(--ease-out),
    box-shadow var(--duration-micro) var(--ease-smooth),
    opacity var(--duration-micro) var(--ease-out);
}
:is(.theme-toggle,.nav-icon-btn,.option-chip,.tool-chip,.inspiration-tag,.nav-pill-btn,
     .hpanel-btn,.hpanel-search-clear,.hpanel-search-exit,.empty-cta,.error-retry-btn,
     .generate-btn,.img-action-btn,.viewer-btn,.viewer-close,.viewer-copy-btn,.confirm-btn,
     .fail-modal-btn,.fail-modal-close,.set-row,.set-close,.slot-cancel-btn,.ref-add-btn,
     .composer-refbar-add,.history-manage,.history-delete,.history-cancel,.toast-close,
     .sidebar-toggle,.sb-rail-btn,.api-key-toggle,
     .vw-back,.vw-theme-toggle,.vw-center-btn,.vw-cbtn,.vw-quota-refresh,.vw-btn,
     .vw-hist-btn,.vw-sheet-close,.vw-frame-view__close,.vw-generate):active {
  scale: var(--press-scale, 0.94);
  transition:
    scale var(--duration-press) var(--ease-out),
    transform var(--duration-press) var(--ease-out),
    border-color var(--duration-press) var(--ease-out),
    background var(--duration-press) var(--ease-out),
    color var(--duration-micro) var(--ease-out),
    box-shadow var(--duration-micro) var(--ease-smooth);
}
/* 大块面少缩一点：面积越大，同样的比例在视觉上位移越多 */
.generate-btn, .vw-generate { --press-scale: 0.972; }
/* 统一列表接不住的三类专属过渡（对比改前 computed 得到，见 _tools/tdiff.mjs）：
   · .confirm-btn 的 danger 态靠 filter: brightness 做 hover 反馈，丢了 filter 就变成硬跳
   · .vw-center-btn 用 visibility 0s + 延迟做「淡出后再隐藏」，丢了就是先消失后淡出
   · .vw-* 控件原本过渡的是 background-color 长写，这里按原样补回，避免和 shorthand 混淆 */
.confirm-btn {
  transition: scale var(--duration-release) var(--ease-spring-soft),
    border-color var(--duration-micro) var(--ease-out),
    color var(--duration-micro) var(--ease-out),
    background var(--duration-micro) var(--ease-out),
    filter var(--duration-micro) var(--ease-out);
}
.confirm-btn:active {
  transition: scale var(--duration-press) var(--ease-out),
    border-color var(--duration-press) var(--ease-out),
    color var(--duration-press) var(--ease-out),
    background var(--duration-press) var(--ease-out),
    filter var(--duration-micro) var(--ease-out);
}
:is(.vw-back, .vw-cbtn, .vw-btn) {
  transition: scale var(--duration-release) var(--ease-spring-soft),
    background-color var(--duration-micro) var(--ease-out),
    border-color var(--duration-micro) var(--ease-out),
    color var(--duration-micro) var(--ease-out),
    transform var(--duration-micro) var(--ease-out);
}
:is(.vw-back, .vw-cbtn, .vw-btn):active {
  transition: scale var(--duration-press) var(--ease-out),
    background-color var(--duration-press) var(--ease-out),
    border-color var(--duration-press) var(--ease-out),
    color var(--duration-press) var(--ease-out),
    transform var(--duration-press) var(--ease-out);
}
.vw-center-btn {
  transition: scale var(--duration-release) var(--ease-spring-soft),
    opacity var(--duration-micro) linear,
    transform var(--duration-enter) var(--ease-out-expo),
    background-color var(--duration-micro) linear,
    visibility 0s linear var(--duration-micro);
}
.vw-center-btn:active {
  transition: scale var(--duration-press) var(--ease-out),
    opacity var(--duration-micro) linear,
    transform var(--duration-enter) var(--ease-out-expo),
    background-color var(--duration-micro) linear,
    visibility 0s linear var(--duration-micro);
}
/* 进入大播放态时 visibility 必须立刻可见，否则「按下即显」会被延迟 150ms */
.vw-player.big-on .vw-center-btn {
  transition: scale var(--duration-release) var(--ease-spring-soft),
    opacity var(--duration-micro) linear,
    transform var(--duration-enter) var(--ease-out-expo),
    background-color var(--duration-micro) linear,
    visibility 0s;
}
/* 对比工具条的按钮单独成规：它原本写作「.compare-toolbar button」，
   带元素名会把整段 :is() 的特异性抬到 0,1,1，压过所有单类名组件自己的 transition
   —— 实测正是这一条造成了 5 处 transition 属性丢失。拆出来后才与其它规则等权。 */
.compare-toolbar button {
  scale: 1;
  transition: scale var(--duration-release) var(--ease-spring-soft),
    transform var(--duration-micro) var(--ease-out),
    border-color var(--duration-micro) var(--ease-out),
    background var(--duration-micro) var(--ease-out),
    color var(--duration-micro) var(--ease-out),
    box-shadow var(--duration-micro) var(--ease-smooth),
    opacity var(--duration-micro) var(--ease-out);
}
.compare-toolbar button:active {
  scale: var(--press-scale, 0.94);
  transition: scale var(--duration-press) var(--ease-out),
    transform var(--duration-press) var(--ease-out),
    border-color var(--duration-press) var(--ease-out),
    background var(--duration-press) var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .compare-toolbar button { transition: scale 120ms linear; }
  .compare-toolbar button:active { scale: 0.97; }
}
/* 减动态：保留「按下去看得见」的状态反馈，去掉过冲，直线到位 */
@media (prefers-reduced-motion: reduce) {
  :is(.theme-toggle,.nav-icon-btn,.option-chip,.tool-chip,.inspiration-tag,.nav-pill-btn,
     .hpanel-btn,.hpanel-search-clear,.hpanel-search-exit,.empty-cta,.error-retry-btn,
     .generate-btn,.img-action-btn,.viewer-btn,.viewer-close,.viewer-copy-btn,.confirm-btn,
     .fail-modal-btn,.fail-modal-close,.set-row,.set-close,.slot-cancel-btn,.ref-add-btn,
     .composer-refbar-add,.history-manage,.history-delete,.history-cancel,.toast-close,
     .sidebar-toggle,.sb-rail-btn,.api-key-toggle,
     .vw-back,.vw-theme-toggle,.vw-center-btn,.vw-cbtn,.vw-quota-refresh,.vw-btn,
     .vw-hist-btn,.vw-sheet-close,.vw-frame-view__close,.vw-generate) { transition: scale 120ms linear, transform 120ms linear, border-color 120ms linear, background 120ms linear, color 120ms linear, box-shadow 120ms linear, opacity 120ms linear; }
  :is(.theme-toggle,.nav-icon-btn,.option-chip,.tool-chip,.inspiration-tag,.nav-pill-btn,
     .hpanel-btn,.hpanel-search-clear,.hpanel-search-exit,.empty-cta,.error-retry-btn,
     .generate-btn,.img-action-btn,.viewer-btn,.viewer-close,.viewer-copy-btn,.confirm-btn,
     .fail-modal-btn,.fail-modal-close,.set-row,.set-close,.slot-cancel-btn,.ref-add-btn,
     .composer-refbar-add,.history-manage,.history-delete,.history-cancel,.toast-close,
     .sidebar-toggle,.sb-rail-btn,.api-key-toggle,
     .vw-back,.vw-theme-toggle,.vw-center-btn,.vw-cbtn,.vw-quota-refresh,.vw-btn,
     .vw-hist-btn,.vw-sheet-close,.vw-frame-view__close,.vw-generate):active { scale: 0.97; }
}

/* ============================================
   🪂 浮层落位 · 轻柔 + 弹性
   ============================================
   · 三个居中浮层共用 panelLand，抽屉用 sheetLand（起点在屏幕外，靠位移表达重量）
   · 每段单独给 timing-function：起手段快（先看见），过冲段缓（回压要慢）
   · animation-fill-mode: both，动画结束后停在 transform:none，退出仍走原来的 transition */
@keyframes panelLand {
  0%   { opacity: 0; transform: scale(0.965) translateY(10px); animation-timing-function: cubic-bezier(0.2, 0.9, 0.3, 1); }
  30%  { opacity: 1; }
  55%  { transform: scale(1.006) translateY(-1.2px); animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1); }
  80%  { transform: scale(0.9994) translateY(0.3px); animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes sheetLand {
  0%   { transform: translateY(100%); animation-timing-function: cubic-bezier(0.16, 0.84, 0.28, 1); }
  55%  { transform: translateY(-6px); animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1); }
  82%  { transform: translateY(2px); animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1); }
  100% { transform: translateY(0); }
}
.fail-modal-overlay.active .fail-modal,
.confirm-overlay.active .confirm-dialog,
.hpanel-overlay.active .hpanel {
  animation: panelLand 380ms both;
}
.set-overlay.active .set-card {
  animation: sheetLand 460ms both;
}
/* 减动态：这三个浮层原本只降级了 transform，动画会盖掉那句 transform:none，必须把动画关掉 */
@media (prefers-reduced-motion: reduce) {
  .fail-modal-overlay.active .fail-modal,
  .confirm-overlay.active .confirm-dialog,
  .hpanel-overlay.active .hpanel,
  .set-overlay.active .set-card { animation: none; }
  .confirm-dialog, .hpanel, .set-card,
  .set-overlay.active .set-card { transform: none; transition: opacity 180ms linear; }
}

/* ============================================
   🎬 首屏编排 · 三级落位
   ============================================
   总时长控制在 490ms 内（与幕布上提 450ms 基本同步收尾），再长就变成「等动画」。
   · 壳层 shellFade：只改 opacity —— 位移交给子元素，避免两层位移叠加（8px+10px 会读成抖）
   · 舞台 stageRise：40ms 起手，380ms 到位
   · 输入区 stageRise：120ms 起手，420ms 到位，压在最上面收尾
   · 所有 delay 都配 animation-fill-mode: both，否则延迟期间元素会先按原样闪一下再变透明 */
@keyframes shellFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes stageRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
html.boot-ready .app-container { animation: shellFade 320ms var(--ease-out) both; }
html.boot-ready .panel-right { animation: none; }
html.boot-ready .image-display { animation: stageRise 380ms var(--ease-out-expo) 40ms both; }
html.boot-ready .composer { animation: stageRise 420ms var(--ease-out-expo) 120ms both; }
/* 减动态：三级压成一次淡入，不留位移 */
@media (prefers-reduced-motion: reduce) {
  html.boot-ready .app-container,
  html.boot-ready .image-display,
  html.boot-ready .composer { animation: prmFade 220ms linear both; }
}

/* ============================================
   👆 触摸热区 · 灵感标签
   ============================================
   · 只在 pointer:coarse 生效，桌面保持 25px 的精致密度
   · 用 min-height + 居中而不是加 padding：行高随字体浮动，算不准 44 */
@media (pointer: coarse) {
  .inspiration-tag {
    min-height: 44px;
    display: inline-flex; align-items: center;
    padding-block: 0; padding-inline: 14px;
  }
  /* 这两个在触摸下量到 40 / 39px：顶栏图标按钮与「添加参考图」虚线块。
     只补最小边，不改视觉尺寸来源，桌面端仍是细分格 */
  .nav-icon-btn { min-width: 44px; min-height: 44px; }
  .ref-add-btn { min-height: 44px; }
}
