/* 简洁风格，沿用你 Gradio 版的紫色主题 */
/* ===== 主题变量（MeeCo 品牌洋红 + 深色） ===== */
:root{
  --primary:#e2107e; --primary-hover:#c20d6c;
  --bg:#f4f5f7; --surface:#ffffff; --surface-2:#fafafb; --surface-3:#f1f2f5;
  --accent-soft:#fbe9f3;
  --border:#e7e8ec; --text:#1b1f27; --text-muted:#8a8f9a;
  /* ── 状态色四件套: 主色 / 浅底 / 文字 / 边框 ──────────────────────────
     ★ 为什么一个状态要四个变量: 做一个提示框需要「底 + 字 + 边」三样, 只给主色的
       话每次都得现从 Tailwind 调色板抄一组 hex —— 全站已经这么抄了 4 组、60 多处
       (#fef2f2/#991b1b/#fecaca 这类)。有了四件套才不用再抄。
     ★ 浅色值就是原来散在各处的那些, 只是收拢到这里, 视觉零变化。
     ★ 深色值见下面 dark 块, 用 color-mix 从主色和当前表面调出来 —— 原来这些浅底
       在深色主题下【一条覆盖都没有】, 成功/错误/警告框全是刺眼的浅色块。 */
  --error:#ef4444;   --error-bg:#fef2f2;   --error-text:#991b1b;   --error-border:#fecaca;
  --success:#10b981; --success-bg:#d1fae5; --success-text:#065f46; --success-border:#a7f3d0;
  --warning:#f59e0b; --warning-bg:#fffbeb; --warning-text:#92400e; --warning-border:#fde68a;
  --info:#3b82f6;    --info-bg:#eff6ff;    --info-text:#1e40af;    --info-border:#bfdbfe;
  /* 侧边栏（深底，浅深主题下都一致） */
  --side-bg:#11131a; --side-text:#c7cad3; --side-muted:#5c606b; --side-hover:rgba(255,255,255,.06);
  --nav-active-bg:var(--primary); --nav-active-text:#fff; --nav-active-shadow:none;
}
[data-theme="dark"]{
  --primary:#ff2d96; --primary-hover:#ff52a8;
  --bg:#0e0f14; --surface:#16181f; --surface-2:#1c1f28; --surface-3:#222632;
  --accent-soft:rgba(255,45,150,.14);
  --border:#272b35; --text:#e9eaf0; --text-muted:#888da0;
  /* 状态色的深色版: --error/--success 的主色沿用浅色那套(不动现有观感), 只把
     「底/字/边」换成深色能看的。底和边用 color-mix 从主色掺进当前表面色, 主色以后
     怎么调, 底和边自动跟着走, 不用维护第二套硬编码。 */
  --warning:#fbbf24; --info:#60a5fa;
  --error-text:#fca5a5; --success-text:#6ee7b7; --warning-text:#fcd34d; --info-text:#93c5fd;
  --error-bg:   color-mix(in srgb, var(--error) 14%, var(--surface));
  --success-bg: color-mix(in srgb, var(--success) 14%, var(--surface));
  --warning-bg: color-mix(in srgb, var(--warning) 14%, var(--surface));
  --info-bg:    color-mix(in srgb, var(--info) 14%, var(--surface));
  --error-border:   color-mix(in srgb, var(--error) 38%, var(--surface));
  --success-border: color-mix(in srgb, var(--success) 38%, var(--surface));
  --warning-border: color-mix(in srgb, var(--warning) 38%, var(--surface));
  --info-border:    color-mix(in srgb, var(--info) 38%, var(--surface));
  --side-bg:#0a0b0f; --side-text:#9aa0b2; --side-muted:#565b6b; --side-hover:rgba(255,255,255,.05);
  --nav-active-bg:rgba(255,45,150,.14); --nav-active-text:#ff52a8; --nav-active-shadow:inset 0 0 0 1px rgba(255,45,150,.3);
}
/* ── 别名: 数字人/工作台组件用的一套变量名(--text-primary/--surface-1/--accent…)映射到官方变量。
   靠 var() 惰性解析: 别名引用 --text/--surface-3 等, 明暗主题各自覆盖后自动跟随, 一处补全全部组件。
   ★ 修暗色下"深字压深底看不清": 之前这些名字没定义→退回硬编码浅色 fallback(#222 深字)撞暗底。 */
:root, [data-theme="dark"]{
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
  --surface-1: var(--surface-3);
  --accent: var(--primary);
  --border-strong: var(--text-muted);
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  /* ── 字体与字号 ────────────────────────────────────────────────────────
     ★字号收成 6 级。原来全站 14 个字号, 光 9.5-12.5 之间就挤了 7 个
       (9.5/10/10.5/11/11.5/12/12.5) —— 那不是层级, 是噪音: 相邻两级差 0.5px
       人眼分辨不出主次, 只觉得"乱"。半像素值在 1x 屏上还压不到像素网格, 笔画
       糊一层。10px 的中文更是压根读不动。
     ★中文行高要比西文松: 汉字是满字身, 1.5 会显得挤。正文 1.65, 密集区 1.5。 */
  --font-sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  --fs-xs: 11px;    /* 角标、图注、次要说明 */
  --fs-sm: 12px;    /* 表格内文字、密集列表 */
  --fs-md: 13px;    /* 正文 */
  --fs-lg: 15px;    /* 小标题 */
  --fs-xl: 18px;    /* 区块标题 */
  --fs-2xl: 22px;   /* 页面标题 */
  --lh-tight: 1.45;
  --lh-body: 1.65;
}
html,body{transition:background .25s,color .25s;}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  /* ★macOS Chrome 默认次像素渲染, 中文笔画发糊发重 —— Mac 上"字体丑"最常见的
     单一原因。这两行是全站唯一的开关, 原来一处都没有。 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 数字一律等宽: 计数/进度/成本会随轮询跳动, 比例字宽会让它们左右抖。 */
.sr-facts dd, .ep-chip, .ep-state, .ep-master-copy span,
.bt-mini, .q-pct, [class*="-count"] { font-variant-numeric: tabular-nums; }

/* ──── Login ──── */
.login-wrap {
  max-width: 360px; margin: 10vh auto;
  padding: 32px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  text-align: center;
}
.login-form {
  display: flex; flex-direction: column; gap: 12px; margin-top: 20px;
}
.login-form input {
}

/* ──── Main layout ──── */
.app-wrap { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .logo {
  width: 40px; height: 40px;        /* 1:1 方框 */
  flex: 0 0 auto;
  object-fit: contain;                /* 保持原比例,  留空白 */
  padding: 2px;
}
.login-logo {
  width: 72px; height: 72px;        /* 登录页也 1:1 */
  object-fit: contain;
  margin-bottom: 12px;
}
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  padding: 8px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: var(--fs-lg);
  transition: background 0.15s;
}
.tab:hover:not(.disabled) { background: var(--surface-3); color: var(--text); }
.tab.active { background: var(--primary); color: white; }
.tab.disabled { opacity: 0.4; cursor: not-allowed; }
.user-info { font-size: var(--fs-md); color: var(--text-muted); }
.btn-link {
  background: none; border: none; color: var(--primary); cursor: pointer;
  margin-left: 8px; font-size: var(--fs-md);
}

main { flex: 1; padding: 24px; }
.loading { text-align: center; color: var(--text-muted); padding: 40px; }

/* Tab 切换瞬时反馈: 点击 tab 立刻把 #main 替成这个, HTMX 拿到响应再覆盖 */
.tab-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; min-height: 60vh; color: var(--text-muted);
}
.tab-loading .spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--primary);
  animation: tab-spin .8s linear infinite;
}
@keyframes tab-spin { to { transform: rotate(360deg); } }

/* ──── Tab panel ──── */
.tab-panel { max-width: 1400px; margin: 0 auto; }
.info-bar {
  padding: 12px 16px;
  background: var(--accent-soft);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  margin-bottom: 20px;
  /* 顶部那条提示是背景信息, 不该比正文大 */
  font-size: var(--fs-md);
}
.two-col { display: grid; grid-template-columns: 360px 1fr; gap: 24px; }
.col { background: var(--surface); padding: 20px; border-radius: 12px; border: 1px solid var(--border); }
/* 一行放下 .sub-tabs 导航 + 右侧的我的/团队切换(也是 .sub-tabs), 两端对齐;
   窄屏自动换行。避免每个页面各自重复写一份这几行 flex 规则。 */
.nav-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 16px; }

/* ──── Upload form ──── */
.upload-form { display: flex; flex-direction: column; gap: 16px; }
.file-drop {
  display: block;
  padding: 32px; text-align: center;
  border: 2px dashed var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.file-drop:hover { border-color: var(--primary); }
.file-drop.is-dragover {
  border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.file-drop input { display: none; }
.file-drop span { color: var(--text-muted); font-size: var(--fs-lg); }

.btn {
  padding: 10px 20px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px;
  /* ★按钮跟正文同级(13px), 不能更大。原来是 14px, 归并后被抬到 15 —— 比正文
     还大一号, 一屏里最抢眼的就成了"确定/取消"这种功能件, 而不是内容本身。 */
  cursor: pointer; font-size: var(--fs-md); line-height: var(--lh-tight);
  transition: all 0.15s;
  /* .btn 经常直接扣在 <a> 标签上("← 返回模板库"这类跳转按钮),
     <a> 浏览器默认会带下划线, 而 <button class="btn"> 不会——
     同一批"按钮"里一半带下划线一半不带, 这正是"按钮没对齐"观感的根源之一。
     全站 32 个模板里有 52 处 <a class="btn">, 统一在基类上关掉下划线。 */
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: var(--fs-sm); }

.hint { margin-top: 16px; font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }

/* HTMX loading indicator：仅当请求进行中才显示 */
.htmx-indicator { display: none; text-align: center; color: var(--primary); font-size: var(--fs-lg); }
.htmx-request .htmx-indicator { display: block; }
.htmx-request.htmx-indicator { display: block; }

/* ──── Gallery ──── */
.gallery-grid {
  display: grid; grid-template-columns: 1fr; gap: 20px;
  max-height: 70vh; overflow-y: auto;
}
.gallery-item { border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.img-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* min-height 锁死: 轮询 outerHTML 替换时, 图片重新解码过程中不让 img-box 坍缩到 0,
   否则 window.scrollY 会被浏览器 clamp 到底部再被恢复脚本设成顶部 */
.img-box { text-align: center; position: relative; min-height: 320px; }
.img-box img { max-width: 100%; max-height: 280px; border-radius: 6px; }
.img-box .img-label { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 6px; }
.transparent-bg {
  background-image: linear-gradient(45deg, var(--border) 25%, transparent 25%), linear-gradient(-45deg, var(--border) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--border) 75%), linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.item-caption { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 8px; }
.error-box { padding: 40px 16px; background: var(--error-bg); color: var(--error); border-radius: 6px; text-align: center; font-size: var(--fs-md); }
.placeholder { padding: 40px; text-align: center; color: var(--text-muted); font-size: var(--fs-lg); }
.error { color: var(--error); font-size: var(--fs-md); margin-top: 8px; }

/* ──── 爆款拆解 ──── */
.analysis-layout {
  display: grid; grid-template-columns: 260px 1fr; gap: 24px;
}
.history-sidebar {
  background: var(--surface); padding: 16px; border-radius: 12px;
  border: 1px solid var(--border);
  max-height: 75vh; overflow-y: auto; overflow-x: hidden;
  min-width: 0;
}
.history-sidebar h4 { margin: 0 0 12px; font-size: var(--fs-lg); }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-item {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.history-item form { flex-shrink: 0; display: flex; }
.history-item .btn-delete { flex-shrink: 0; }
.history-link {
  flex: 1; min-width: 0; display: block; padding: 8px 10px;
  background: var(--surface-2); border-radius: 6px;
  text-decoration: none; color: var(--text);
  font-size: var(--fs-sm); transition: background 0.15s;
  overflow: hidden;
}
.history-link:hover { background: var(--accent-soft); }
.history-time { color: var(--text-muted); font-size: var(--fs-xs); }
.history-title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.btn-delete {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px 6px;
  border-radius: 4px; font-size: var(--fs-lg);
}
.btn-delete:hover { background: var(--error-bg); color: var(--error); }
.hint-small { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }

.analysis-main {
  background: var(--surface); padding: 20px; border-radius: 12px;
  border: 1px solid var(--border);
}
.analysis-form {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.url-input {
  flex: 1;
}
.loading-box {
  padding: 12px; background: var(--accent-soft);
  border-radius: 8px; text-align: center; font-size: var(--fs-lg);
}

.analysis-result { margin-top: 8px; }
.result-header { margin-bottom: 16px; }
.result-header h3 { margin: 0 0 4px; }
.result-meta { font-size: var(--fs-sm); color: var(--text-muted); }
.url-link { color: var(--primary); text-decoration: none; word-break: break-all; }
.url-link:hover { text-decoration: underline; }

.report-block { margin: 16px 0; }
.report-block h4 { margin: 0 0 8px; font-size: var(--fs-lg); color: var(--text); }
.report-text {
  background: var(--surface-2); padding: 16px; border-radius: 8px;
  font-family: -apple-system, sans-serif; font-size: var(--fs-md);
  line-height: 1.7; white-space: pre-wrap; word-wrap: break-word;
}
.style-prompt {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 12px; background: var(--accent-soft); border-radius: 8px;
}
.style-prompt code {
  flex: 1; font-size: var(--fs-md); word-break: break-all;
  background: transparent;
}
.frames-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.frame-thumb {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
}
.error-box-full {
  padding: 20px; background: var(--error-bg); color: var(--error);
  border-radius: 8px; border-left: 3px solid var(--error);
}
.error-title { font-weight: bold; margin-bottom: 8px; }
.error-detail { font-size: var(--fs-md); }

/* ──── 批量生成 ──── */
.batch-layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 24px;
}
.batch-form { display: flex; flex-direction: column; gap: 14px; }
.batch-form .field { display: flex; flex-direction: column; gap: 6px; }
.batch-form select,
.batch-form input[type=text],
.batch-form textarea {
  font-family: inherit;
  background: var(--surface);
}
.field-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.mini-link { font-size: var(--fs-sm); color: var(--primary); text-decoration: none; }
.mini-link:hover { text-decoration: underline; }
.tpl-preview-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.tpl-preview {
  margin: 0; font-size: var(--fs-xs); line-height: 1.5;
  max-height: 120px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; color: var(--text-muted);
}

.progress-header { margin-bottom: 14px; }
.progress-text { font-size: var(--fs-lg); margin-bottom: 6px; }
.progress-bar-wrap {
  width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--primary); transition: width 0.3s ease;
}
.batch-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
/* 外层稳定容器 — HTMX swap 只动内部,  所以 scroll 位置不会被重置 */
.batch-scroll {
  max-height: 75vh; overflow-y: auto;
  border-radius: 8px;
  overflow-anchor: none;   /* DOM 替换时不让浏览器自动"锚定"到底部元素 */
}
/* 整页也关掉 scroll anchoring, 避免 #batch-progress outerHTML swap 时窗口滚动被浏览器二次校正 */
html, body { overflow-anchor: none; }
.batch-gallery {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
.batch-item { padding: 12px; background: var(--surface-2); border-radius: 8px; border-bottom: none; }
.loading-cell {
  padding: 60px 16px; background: var(--accent-soft); color: var(--primary);
  border-radius: 6px; text-align: center; font-size: var(--fs-md);
}
.cancelled-box {
  padding: 40px 16px; background: var(--surface-3); color: var(--text-muted);
  border-radius: 6px; text-align: center; font-size: var(--fs-md);
}
.batch-item.cancelled { opacity: 0.65; }
.tile-row { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.retry-btn { margin-top: 8px; }
.error-box { display: flex; flex-direction: column; gap: 4px; }

/* ──── 分镜反推 ──── */
.v2p-layout {
  display: grid; grid-template-columns: 260px 1fr; gap: 24px;
}
.v2p-main {
  background: var(--surface); padding: 20px; border-radius: 12px;
  border: 1px solid var(--border);
}
.v2p-form { margin-bottom: 16px; }
.v2p-inputs { display: flex; gap: 8px; margin-bottom: 12px; }
.v2p-inputs .url-input { flex: 1; min-width: 0; }
.file-drop-inline {
  flex: 0 0 auto; padding: 10px 16px; font-size: var(--fs-md);
  border: 1px dashed var(--border); border-radius: 8px; cursor: pointer;
}
.file-drop-inline input { display: none; }
.file-drop-inline span { color: var(--text-muted); }
.v2p-options { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.field-inline { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.tiny-input {
  width: 70px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px; font-size: var(--fs-md);
}
.history-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

.v2p-header { margin: 16px 0 10px; }
.v2p-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.v2p-status-line { font-size: var(--fs-lg); margin: 4px 0 6px; }
.v2p-actions { display: flex; gap: 8px; margin: 8px 0 16px; flex-wrap: wrap; }

/* .v2p-scroll: 让页面自然滚动(document scroll), 不搞内层 scroll。
   内层 scroll 在 HTMX outerHTML swap 后,因视频/图片 lazy-load 高度崩塌,
   scrollTop 被 clamp 到 0 导致"被硬控拉回顶"。document scroll 不受 swap 影响。 */
.v2p-scroll { }
.v2p-views { margin-top: 14px; }
.v2p-view { display: none; padding: 8px 0; }
.v2p-view.active { display: block; }

.v2p-shots-grid { display: flex; flex-direction: column; gap: 18px; }
.v2p-shot-row {
  background: var(--surface-2); padding: 12px; border-radius: 8px; border: 1px solid var(--border);
}
.v2p-shot-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: var(--fs-md); }
.v2p-prompt-box {
  margin-top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px;
}
.v2p-prompt-box summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-muted); }
.v2p-prompt-box pre {
  margin: 8px 0 0; font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word;
}
.v2p-video { width: 100%; max-height: 70vh; border-radius: 8px; background: #000; }

/* 图库分页 sentinel */
.gallery-loadmore {
  grid-column: 1 / -1;
  padding: 20px; text-align: center;
  color: var(--text-muted); font-size: var(--fs-sm);
}

/* ──── 模板管理 ──── */
.tpl-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.col-title { margin: 0 0 16px; font-size: var(--fs-lg); }
.tpl-list { list-style: none; padding: 0; margin: 0 0 12px; }
.tpl-item { padding: 12px; margin-bottom: 8px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.tpl-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.tpl-name { font-weight: 600; font-size: var(--fs-lg); }
.tag {
  display: inline-block; padding: 1px 6px; background: #e0e7ff; color: #4f46e5;
  border-radius: 3px; font-size: var(--fs-xs); font-weight: normal; margin-left: 4px;
}
.tpl-actions { display: flex; gap: 4px; }
.btn-danger { background: var(--error-bg); border-color: var(--error-border); color: var(--error); }
.btn-danger:hover { background: var(--error-border); }
.tpl-prompt-preview {
  margin: 0; font-size: var(--fs-xs); line-height: 1.5; color: var(--text-muted);
  max-height: 90px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.tpl-form { display: flex; flex-direction: column; gap: 12px; }
.tpl-form input, .tpl-form textarea {
  font-family: inherit;
}
.tpl-form textarea { resize: vertical; min-height: 200px; }
/* 窄屏(弹窗宽度有限时也会走到这条)把列表/表单两栏收成一栏, 原来独立页面
   没配这条纯属遗漏——现在塞进批量生成的弹窗里, 遗漏就更容易露出来。 */
@media (max-width: 640px) {
  .tpl-layout { grid-template-columns: 1fr; }
}

/* ──── 模板管理弹窗(嵌进批量生成页) ────
   ★ 原来「模板管理」是侧栏独立一个 tab, 点「管理模板 →」要整页跳到 /templates/。
   但 template_store.py 只被这个页面和 batch.py 引用——它其实是批量生成的附属
   工具, 单独占一个顶级导航位置没必要。现在改成弹窗, 复用同一套
   partials/prompt_templates_list.html + partials/prompt_template_form.html,
   保存/删除后台还是打 /templates/save、/templates/delete, 只是响应里多带一份
   hx-swap-oob 片段, 顺手把批量生成表单自己的下拉框和预览也刷新掉, 全程不用
   离开批量生成页。弹窗外壳照抄 .permission-dialog 那一套, 只是换个前缀。 */
.tpl-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 70px rgba(15,23,42,.24);
}
.tpl-dialog::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(3px); }
.tpl-dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 22px 0;
}
.tpl-dialog-head h2 { margin: 3px 0 0; font-size: var(--fs-2xl); }
/* 效果产线的 .ep-kicker 长得一模一样, 但那条规则在 effect_pipeline.css 里,
   batch 页从来不加载那份样式表——这正是这次开工前才修过的"跨样式表依赖"
   同一种坑(sr-only 那次), 这里直接照抄属性建一份本地的, 不跨表引用。 */
.tpl-kicker {
  color: var(--primary); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.tpl-dialog-close {
  width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: var(--surface-2); color: var(--text-muted);
  font-size: var(--fs-2xl); line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.tpl-dialog-close:hover { background: var(--surface-3); }
.tpl-dialog-body { padding: 18px 22px 22px; overflow-y: auto; }
.tpl-dialog-lead { margin: 0 0 16px; color: var(--text-muted); font-size: var(--fs-md); line-height: 1.6; }
/* .mini-link 原本只给 <a> 用(color + 去下划线)。「管理模板 →」现在改成
   <button>(要触发 showModal(), <a> 语义不对), 补一条 button 专属 reset,
   否则会露出浏览器默认的按钮边框/背景, 跟旁边纯文字链接风格的
   「field-label」不搭。 */
button.mini-link { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }

/* ──── 参考图预览（batch tab）──── */
.ref-preview {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
}
.ref-thumb {
  position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden;
  background: var(--surface-3);
}
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-idx {
  position: absolute; top: 2px; left: 2px;
  background: rgba(0,0,0,0.6); color: white;
  font-size: var(--fs-xs); padding: 1px 5px; border-radius: 3px;
}
.ref-del {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; padding: 0;
  background: rgba(0,0,0,0.55); color: white;
  border: none; border-radius: 50%;
  font-size: var(--fs-xs); line-height: 1; cursor: pointer;
  display: none;
}
.ref-thumb:hover .ref-del { display: block; }
.ref-del:hover { background: var(--error); }

/* ──── Lightbox ──── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 15, 20, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; gap: 14px;
}
.lightbox.hidden { display: none; }
.lightbox-body {
  display: flex; gap: 14px; flex-wrap: wrap;
  max-width: 100%; max-height: calc(100vh - 140px);
  align-items: center; justify-content: center;
}
.lightbox-col {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-height: 100%;
}
.lightbox-label { color: var(--border); font-size: var(--fs-md); }
.lightbox-col img {
  max-width: min(600px, 45vw); max-height: calc(100vh - 180px);
  object-fit: contain; border-radius: 6px; background: #222;
}
.lightbox-caption { color: #d1d5db; font-size: var(--fs-sm); font-family: monospace; word-break: break-all; max-width: 90vw; text-align: center; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.12); color: white; border: none;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: var(--fs-lg); cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }
.zoomable { cursor: zoom-in; }
@media (max-width: 720px) {
  .lightbox-col img { max-width: 90vw; }
}

/* ──── 图库 ──── */
.gallery-toolbar {
  display: flex; gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
  align-items: center;
}
.sub-tabs { display: flex; gap: 4px; background: var(--surface-3); padding: 3px; border-radius: 8px; }
.sub-tab {
  padding: 6px 14px; border: none; background: transparent;
  color: var(--text-muted); font-size: var(--fs-md); cursor: pointer;
  border-radius: 6px; transition: all 0.15s;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.04); font-weight: 500; }

.view-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.view-chip {
  padding: 5px 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: var(--fs-sm); cursor: pointer;
  border-radius: 14px;
}
.view-chip:hover { border-color: var(--primary); color: var(--primary); }
.view-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ──── 生成记录 / 成本记录 ──── */
.record-section-row {
  display: flex; align-items: center; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.record-section-row .sub-tab { min-width: 88px; }
.cost-preview-flag {
  display: inline-flex; margin-left: 8px; padding: 2px 7px;
  border-radius: 99px; background: var(--surface); color: var(--primary);
  font-size: var(--fs-xs); font-weight: 600;
}
.cost-record-toolbar { justify-content: flex-start; }
.cost-currency-switch {
  display: flex; gap: 3px; padding: 3px; border-radius: 8px;
  background: var(--surface-3);
}
.cost-currency-switch button {
  border: 0; background: transparent; color: var(--text-muted);
  border-radius: 6px; padding: 6px 12px; font-size: var(--fs-sm); cursor: pointer;
}
.cost-currency-switch button.active {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.cost-export { margin-left: auto; text-decoration: none; }
.cost-empty {
  min-height: 320px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; padding: 36px; text-align: center;
  border: 1px dashed var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text-muted); font-size: var(--fs-md);
}
.cost-empty b { color: var(--text); font-size: var(--fs-lg); }
.cost-empty a { color: var(--primary); text-decoration: none; font-weight: 600; }
.cost-empty-icon {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; background: var(--accent-soft); color: var(--primary);
  font-size: var(--fs-xl); font-weight: 700; margin-bottom: 4px;
}
.cost-selection-bar {
  position: sticky; top: 8px; z-index: 12;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  min-height: 48px; padding: 9px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 5px 18px rgba(0,0,0,.05); backdrop-filter: blur(10px);
  font-size: var(--fs-sm);
}
.cost-selected-copy { color: var(--text-muted); }
.cost-selected-copy b { color: var(--primary); }
.cost-selection-sum { margin-left: auto; color: var(--text-muted); }
.cost-selection-sum strong { color: var(--text); font-size: var(--fs-xl); margin-left: 5px; }
.cost-selection-sum small { color: var(--text-muted); margin-left: 7px; }
.cost-record-list { display: flex; flex-direction: column; gap: 12px; }
.cost-task-card {
  overflow: hidden; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface);
}
.cost-task-head {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  min-height: 66px; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.cost-task-title { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 3px 9px; align-items: center; }
.cost-task-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); }
.cost-task-title small { grid-column: 2; color: var(--text-muted); font-size: var(--fs-xs); }
.cost-module-tag {
  grid-row: 1 / span 2; padding: 4px 7px; border-radius: 5px;
  background: var(--accent-soft); color: var(--primary); font-size: var(--fs-xs); font-weight: 650;
}
.cost-task-total { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; }
.cost-task-total span, .cost-task-total small { color: var(--text-muted); font-size: var(--fs-xs); }
.cost-task-total strong { font-size: var(--fs-lg); line-height: 1.4; }
.cost-asset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px; padding: 14px;
}
.cost-asset-card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  padding: 7px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.cost-asset-card:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.cost-asset-card:has(.cost-asset-check:checked) {
  border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary);
}
.cost-asset-check { position: absolute; opacity: 0; pointer-events: none; }
.cost-check-mark {
  position: absolute; z-index: 3; top: 13px; left: 13px;
  display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: 6px; border: 1px solid color-mix(in srgb, var(--surface) 75%, var(--border));
  background: color-mix(in srgb, var(--surface) 87%, transparent); color: transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,.12); font-size: var(--fs-sm); font-weight: 700;
}
.cost-asset-check:checked + .cost-check-mark { background: var(--primary); border-color: var(--primary); color: white; }
.cost-media-wrap {
  position: relative; display: grid; place-items: center; aspect-ratio: 1;
  overflow: hidden; border-radius: 7px; background: var(--surface-3);
}
.cost-media-wrap img { width: 100%; height: 100%; object-fit: cover; }
.cost-media-missing { color: var(--text-muted); font-size: var(--fs-xs); }
.cost-retained-badge {
  position: absolute; right: 6px; top: 6px; padding: 3px 6px; border-radius: 5px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text-muted); font-size: var(--fs-xs); box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.cost-asset-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 2px 2px; }
.cost-model {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-size: var(--fs-xs); font-weight: 650;
}
.cost-asset-meta strong { flex: 0 0 auto; color: var(--primary); font-size: var(--fs-sm); }
.cost-asset-sub { padding: 1px 2px 2px; color: var(--text-muted); font-size: var(--fs-xs); }

/* 生成页任务内的轻量成本标记 */
.q-cost { color: var(--primary); font-weight: 650; }
.task-cost-pill {
  display: inline-flex; align-items: center; padding: 4px 9px;
  border-radius: 99px; background: var(--accent-soft); color: var(--primary);
  font-size: var(--fs-xs); font-weight: 650;
}
.asset-cost-badge {
  position: absolute; z-index: 4; top: 14px; right: 14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  padding: 5px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text); box-shadow: 0 2px 7px rgba(0,0,0,.11);
  font-size: var(--fs-xs); line-height: 1.2;
}
.asset-cost-badge b { color: var(--primary); font-size: var(--fs-xs); }
.imagegen-tile { position: relative; }

@media (max-width: 720px) {
  .cost-task-head { align-items: flex-start; }
  .cost-task-title { display: flex; flex-wrap: wrap; }
  .cost-task-title small { width: 100%; }
  .cost-asset-grid { grid-template-columns: repeat(2, minmax(0,1fr)); padding: 10px; gap: 8px; }
  .cost-selection-sum { width: 100%; margin-left: 0; }
}

/* 批量选择工具栏 */
.batch-toolbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: var(--fs-md); flex-wrap: wrap;
}
.check-all-wrap { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check-all-wrap input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.batch-count { color: var(--text-muted); }
.batch-count b { color: var(--primary); font-weight: 600; }
.batch-toolbar .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.batch-toolbar .btn:disabled:hover { background: var(--error-bg); }

/* 每张图左上角的 checkbox overlay */
.tile-select {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.85); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.tile-select input[type=checkbox] {
  width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--primary);
}
/* 选中时整个 tile 高亮 */
.gallery-tile:has(.tile-checkbox:checked) {
  outline: 2px solid var(--primary); outline-offset: -2px;
}

.gallery-thumbs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.gallery-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow 0.15s;
}
.gallery-tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.gallery-tile.rated-star { border-color: var(--warning); }
.gallery-tile.rated-good { border-color: var(--success); }
.gallery-tile.rated-bad { opacity: 0.55; }

.tile-img-wrap { position: relative; overflow: hidden; }
.gallery-tile img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
.rating-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.6); color: white;
  padding: 2px 6px; border-radius: 4px; font-size: var(--fs-md);
  z-index: 2;
}
/* 团队视图的归属用户徽标 */
.owner-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(124,58,237,0.85); color: white;
  padding: 2px 7px; border-radius: 10px;
  font-size: var(--fs-xs); font-weight: 500;
  z-index: 2;
  max-width: calc(100% - 40px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.readonly-row {
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
/* 悬停删除移到底右,  不跟 badge 撞 */
.tile-del-form { top: auto; right: 6px; bottom: 6px; }
.tile-del-form { position: absolute; top: 6px; right: 6px; margin: 0; display: none; }
.tile-img-wrap:hover .tile-del-form { display: block; }
.tile-del {
  width: 24px; height: 24px; padding: 0;
  background: rgba(0,0,0,0.6); color: white;
  border: none; border-radius: 50%;
  font-size: var(--fs-sm); line-height: 1; cursor: pointer;
}
.tile-del:hover { background: var(--error); }

.rating-row {
  display: flex; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border);
  align-items: center;
}
.rating-btn {
  flex: 1; padding: 4px 0; border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-md); border-radius: 4px; cursor: pointer;
  transition: all 0.12s;
}
.rating-btn:hover { background: var(--surface-3); }
.rating-btn.active { background: #fef3c7; border-color: var(--warning); }
.tile-dl {
  padding: 3px 8px; font-size: var(--fs-sm); text-decoration: none;
  line-height: 1.4;
}

.tile-time { padding: 4px 10px 8px; color: var(--text-muted); font-size: var(--fs-xs); }

/* tile 上的 prompt 折叠区 — 点 summary 展开 */
.tile-prompt {
  margin: 0 8px 8px; padding: 6px 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  font-size: var(--fs-sm);
}
.tile-prompt > summary {
  cursor: pointer; user-select: none; list-style: none;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  color: var(--text-muted);
}
.tile-prompt > summary::-webkit-details-marker { display: none; }
.tile-prompt > summary::before {
  content: '▸'; transition: transform 120ms; display: inline-block; font-size: var(--fs-xs);
}
.tile-prompt[open] > summary::before { transform: rotate(90deg); }
.tile-prompt-badge {
  background: var(--primary); color: #fff;
  padding: 1px 6px; border-radius: 4px; font-size: var(--fs-xs); font-weight: 600;
}
.tile-prompt-meta {
  background: var(--accent-soft); color: #3730a3;
  padding: 1px 6px; border-radius: 4px; font-size: var(--fs-xs);
}
.tile-prompt-text {
  margin: 6px 0; padding: 6px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs);
  color: var(--text);
}
.tile-prompt-copy { margin-top: 4px; }

.gallery-footer { margin-top: 16px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }

/* ──── 图库 — 移动到目标相册的弹窗 ──── */
.lib-modal {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.lib-modal.hidden { display: none; }
.lib-modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 15, 20, 0.55);
}
.lib-modal-body {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: 10px;
  width: min(480px, 100%);
  /* 用 height (不是 max-height) 锁死, 让里面的 flex 子项有定义好的空间去填 */
  height: min(640px, 90vh);
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  overflow: hidden;
}
/* form 在 modal-body 里, 占满 head 之后剩余空间, 让里面 list (flex:1 + overflow) 能正常滚动,
   foot (取消/确认按钮) 始终钉在底部 */
.lib-modal-body > form {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.lib-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.lib-modal-head h4 { margin: 0; font-size: var(--fs-lg); }
.lib-modal-list {
  flex: 1; overflow-y: auto; padding: 6px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.lib-move-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: var(--fs-md); transition: background 80ms;
}
.lib-move-item:hover { background: var(--surface-3); }
.lib-move-item input[type="radio"] { accent-color: var(--primary); margin: 0; }
.lib-move-item:has(input:checked) {
  background: var(--accent-soft); outline: 1px solid var(--primary);
}
.lib-move-icon { width: 22px; flex-shrink: 0; }
.lib-move-name {
  flex: 1; word-break: break-all;
  /* 路径长时省略号; hover 时 title 展示完整路径 */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-move-meta {
  display: inline-flex; gap: 6px; align-items: center;
  color: var(--text-muted); font-size: var(--fs-xs); flex-shrink: 0;
}
.lib-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

/* ──── 图库（相册管理）──── */
.lib-project-bar {
  display: grid; grid-template-columns: minmax(260px, 1fr) minmax(260px, 360px) auto;
  align-items: end; gap: 16px; margin-bottom: 12px; padding: 15px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.lib-project-intro { display: flex; flex-direction: column; min-width: 0; }
.lib-project-intro strong {
  margin-top: 2px; color: var(--text); font-size: var(--fs-xl); line-height: var(--lh-tight);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-project-intro small { margin-top: 3px; color: var(--text-muted); font-size: var(--fs-sm); }
.lib-project-kicker {
  color: var(--primary); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.lib-project-select-form { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lib-project-select-form label { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.lib-project-select-form select { width: 100%; min-width: 0; }
.lib-project-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.lib-project-actions .btn { white-space: nowrap; }
.lib-current-project-chip {
  display: inline-flex; align-items: center; max-width: 260px; min-width: 0;
  padding: 4px 9px; border: 1px solid var(--success-border); border-radius: 999px;
  background: var(--success-bg); color: var(--success-text); font-size: var(--fs-xs);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-project-dialog {
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 70px rgba(15,23,42,.24);
}
.lib-project-dialog::backdrop { background: rgba(15,23,42,.42); backdrop-filter: blur(3px); }
.lib-project-dialog-shell { display: flex; flex-direction: column; min-height: 0; margin: 0; }
.lib-project-dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--border);
}
.lib-project-dialog-head h3 { margin: 3px 0 0; font-size: var(--fs-xl); }
.lib-project-dialog-close {
  width: 32px; height: 32px; flex: 0 0 auto; border: 0; border-radius: 9px;
  background: var(--surface-2); color: var(--text-muted); cursor: pointer;
  font-size: var(--fs-2xl); line-height: 1;
}
.lib-project-dialog-close:hover { background: var(--surface-3); color: var(--text); }
.lib-project-dialog-body { padding: 18px 22px; overflow-y: auto; }
.lib-project-dialog-body > p { margin: 0 0 15px; color: var(--text-muted); font-size: var(--fs-sm); }
.lib-project-dialog-body > label { display: block; margin-top: 12px; font-size: var(--fs-sm); font-weight: 600; }
.lib-project-dialog-body > label span { color: var(--text-muted); font-weight: 400; }
.lib-project-dialog-body > label input { width: 100%; margin-top: 5px; }
.lib-project-dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px;
  border-top: 1px solid var(--border);
}
.lib-project-basket-dialog { width: min(920px, calc(100vw - 32px)); }
.lib-project-basket-body { max-height: min(620px, calc(100vh - 170px)); }
.lib-project-basket-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lib-project-basket-item {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px;
  padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.lib-project-basket-preview {
  grid-row: span 2; width: 76px; height: 76px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-radius: 8px; background: var(--surface-3); color: var(--text-muted); font-size: var(--fs-xs);
}
.lib-project-basket-preview img, .lib-project-basket-preview video { width: 100%; height: 100%; object-fit: cover; }
.lib-project-basket-meta { min-width: 0; align-self: end; }
.lib-project-basket-meta strong, .lib-project-basket-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-project-basket-meta strong { font-size: var(--fs-sm); }
.lib-project-basket-meta small { margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.lib-project-basket-item form { align-self: start; }
.lib-project-basket-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 16px; text-align: center; }
.lib-project-basket-empty span { color: var(--text-muted); font-size: var(--fs-sm); }
.lib-usage-badge {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; max-width: calc(100% - 16px);
  padding: 4px 8px; border: 1px solid transparent; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 650; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(15,23,42,.16);
}
.lib-usage-badge.is-current { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.lib-usage-badge.is-other { background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--text); border-color: var(--border); }
.lib-usage-badge-secondary { left: auto; right: 8px; max-width: 46%; }

.library-layout {
  display: grid; grid-template-columns: 220px 1fr; gap: 0;
  min-height: calc(100vh - 140px);
}
.library-sidebar {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px 0 0 10px;
  border-right: none; padding: 16px 12px;
  overflow-y: auto; max-height: calc(100vh - 140px);
}
.library-main {
  background: var(--surface); border: 1px solid var(--border); border-radius: 0 10px 10px 0;
  padding: 20px; overflow-y: auto; max-height: calc(100vh - 140px);
}
.lib-sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.lib-sidebar-title { font-size: var(--fs-md); font-weight: 600; color: var(--text-muted); }
.lib-album-list { list-style: none; padding: 0; margin: 0; }
.lib-album-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: var(--fs-md); margin-bottom: 2px; transition: background 0.12s;
}
.lib-album-item:hover { background: var(--surface-3); }
.lib-album-item.active { background: var(--accent-soft); color: var(--primary); }
.lib-album-icon { font-size: var(--fs-lg); flex-shrink: 0; }
.lib-album-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-album-count {
  font-size: var(--fs-xs); color: var(--text-muted); background: var(--surface-3);
  padding: 1px 6px; border-radius: 10px; flex-shrink: 0;
}
.lib-album-item.active .lib-album-count { background: var(--accent-soft); color: var(--primary); }
.lib-album-del {
  background: none; border: none; cursor: pointer;
  color: transparent; padding: 2px 4px; border-radius: 4px;
  font-size: var(--fs-sm); flex-shrink: 0;
}
.lib-album-item:hover .lib-album-del { color: var(--text-muted); }
.lib-album-del:hover { background: var(--error-bg); color: var(--error) !important; }
.lib-no-albums { font-size: var(--fs-sm); color: var(--text-muted); padding: 12px 4px; }
.new-album-form {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px; padding: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.new-album-form input {
  width: 100%;
  box-sizing: border-box;
}
.new-album-actions { display: flex; gap: 6px; }

.lib-empty-hint {
  display: flex; align-items: center; justify-content: center;
  height: 200px; color: var(--text-muted); font-size: var(--fs-lg);
}
.lib-album-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.lib-album-title { margin: 0; font-size: var(--fs-lg); }
.lib-upload-btn { cursor: pointer; }
.lib-toolbar { margin-bottom: 14px; }
.lib-uploading {
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--accent-soft); border-radius: 6px; font-size: var(--fs-md);
  color: var(--primary); text-align: center;
}
.lib-drop-hint {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  padding: 60px 20px; color: var(--text-muted); font-size: var(--fs-lg);
}
.lib-drop-icon { font-size: 40px; }

/* 面包屑 */
.lib-breadcrumb {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  font-size: var(--fs-md); margin-bottom: 14px; color: var(--text-muted);
}
.lib-bc-item { color: var(--primary); }
.lib-bc-item:hover { text-decoration: underline; }
.lib-bc-current { color: var(--text); font-weight: 500; cursor: default; }
.lib-bc-sep { color: var(--text-muted); }

/* 创建者标签 */
.lib-owner-tag {
  font-size: var(--fs-xs); font-weight: normal; color: var(--text-muted);
  margin-left: 8px;
}

/* 区块标签 */
.lib-section-label {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* 子文件夹网格 */
.lib-subfolder-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 8px;
}
.lib-subfolder-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; position: relative; transition: background 0.12s;
  text-align: center;
}
.lib-subfolder-card:hover { background: var(--accent-soft); border-color: var(--primary); }
.lib-sf-icon { font-size: 28px; }
.lib-sf-name {
  font-size: var(--fs-md); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  width: 100%;
}
.lib-sf-count { font-size: var(--fs-xs); color: var(--text-muted); }
.lib-sf-del {
  position: absolute; top: 4px; right: 4px;
  background: none; border: none; cursor: pointer;
  color: transparent; font-size: var(--fs-sm); padding: 2px 4px; border-radius: 4px;
}
.lib-subfolder-card:hover .lib-sf-del { color: var(--text-muted); }
.lib-sf-del:hover { background: var(--error-bg); color: var(--error) !important; }
.lib-subfolders { margin-bottom: 4px; }

@media (max-width: 1180px) {
  .lib-project-bar { grid-template-columns: minmax(220px, 1fr) minmax(240px, 320px); }
  .lib-project-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 760px) {
  .lib-project-bar { grid-template-columns: 1fr; align-items: stretch; }
  .lib-project-actions { grid-column: auto; }
  .lib-project-actions .btn { flex: 1; }
  .lib-project-basket-grid { grid-template-columns: 1fr; }
  .library-layout { grid-template-columns: 1fr; }
  .library-sidebar { border-right: 1px solid var(--border); border-radius: 10px; max-height: 230px; }
  .library-main { border-radius: 10px; margin-top: 10px; max-height: none; }
}

/* ──── Admin 面板 ──── */
.tab-admin {
  margin-left: auto;
  color: var(--primary);
  font-weight: 500;
}
.admin-panel { padding: 0 24px 24px; }
.admin-section { margin-top: 24px; }
.admin-section h3 { margin: 0 0 8px; font-size: var(--fs-lg); }
.admin-subtitle { font-size: var(--fs-md); color: var(--text-muted); margin: 12px 0 6px; }
.admin-form {
  display: flex; gap: 8px; margin-top: 8px;
  padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
}
.admin-form input {
  flex: 1;
}
.admin-form input[name="username"] { max-width: 200px; }
.admin-table-wrap {
  width: 100%; overflow-x: auto; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface);
}
.admin-table {
  width: 100%; min-width: 1040px; border-collapse: collapse;
  background: var(--surface);
  border: 0;
}
.admin-table th, .admin-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); font-size: var(--fs-lg);
}
.admin-table th { background: var(--surface-2); font-weight: 600; font-size: var(--fs-md); color: var(--text-muted); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-actions { display: flex; gap: 6px; }
.admin-actions form { margin: 0; }
.activity-tab { display: block; font-size: var(--fs-md); font-weight: 600; white-space: nowrap; }
.activity-tab + small { display: block; margin-top: 3px; white-space: nowrap; }
.permission-summary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 5px 4px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface-2); white-space: nowrap;
}
.permission-summary.is-admin { padding-right: 10px; }
.permission-count { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.permission-hint { font-size: var(--fs-xs); color: var(--text-muted); }
.permission-open {
  border: 0; border-radius: 999px; padding: 4px 10px;
  background: var(--surface); color: var(--primary); cursor: pointer;
  font-size: var(--fs-xs); font-weight: 650; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.permission-open:hover { background: var(--primary); color: #fff; }
.permission-dialog {
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 70px rgba(15,23,42,.24);
}
.permission-dialog::backdrop {
  background: rgba(15,23,42,.42); backdrop-filter: blur(3px);
}
.permission-dialog > form { padding: 22px; }
.permission-dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.permission-dialog-head h4 { margin: 3px 0 0; font-size: var(--fs-2xl); }
.permission-eyebrow {
  color: var(--primary); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.permission-close {
  width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: var(--surface-2); color: var(--text-muted);
  font-size: var(--fs-2xl); line-height: 1; cursor: pointer;
}
.permission-close:hover { background: var(--surface-3); color: var(--text); }
.permission-help { margin: 10px 0 18px; color: var(--text-muted); font-size: var(--fs-sm); }
.permission-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px; margin-bottom: 20px;
}
.permission-grid label {
  position: relative; display: flex; align-items: center; gap: 9px;
  min-width: 0; min-height: 42px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
  font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, transform .15s;
}
.permission-grid label:hover { border-color: color-mix(in srgb,var(--primary) 40%,var(--border)); }
.permission-grid input {
  position: absolute; opacity: 0; pointer-events: none;
}
.permission-checkmark {
  display: flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: transparent;
  font-size: var(--fs-sm); font-weight: 800; flex: 0 0 auto;
}
.permission-grid label:has(input:checked) {
  border-color: color-mix(in srgb,var(--primary) 45%,var(--border));
  background: color-mix(in srgb,var(--primary) 7%,var(--surface));
}
.permission-grid input:checked + .permission-checkmark {
  border-color: var(--primary); background: var(--primary); color: #fff;
}
.permission-module { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: normal; }
.permission-module small {
  display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: normal; line-height: 1.35;
  color: var(--text-muted); font-size: var(--fs-xs); font-weight: 400;
}
.permission-dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 16px; border-top: 1px solid var(--border);
}
@media (max-width: 560px) {
  .permission-dialog > form { padding: 18px; }
  .permission-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1500px) {
  .admin-table { min-width: 700px; }
  .admin-table .col-created,
  .admin-table .col-creator { display: none; }
}

/* 💾 磁盘管理 */
.flash-success { padding: 8px 12px; background: var(--success-bg); color: var(--success-text);
  border: 1px solid var(--success-border); border-radius: 6px; font-size: var(--fs-md); }
.flash-error { padding: 8px 12px; background: var(--error-bg); color: var(--error-text);
  border: 1px solid var(--error-border); border-radius: 6px; font-size: var(--fs-md); }
.disk-summary {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 12px;
}
.disk-bar-wrap { width: 100%; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.disk-bar { height: 100%; background: linear-gradient(90deg, var(--success), var(--warning) 70%, var(--error) 95%);
  transition: width 0.3s; }
.disk-summary-text { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); }
.disk-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.disk-table th, .disk-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: var(--fs-md); vertical-align: top;
}
.disk-table th { background: var(--surface-2); font-weight: 600; color: var(--text-muted); font-size: var(--fs-sm); }
.disk-table tr:last-child td { border-bottom: none; }
.disk-row.safety-safe       { border-left: 3px solid var(--success); }
.disk-row.safety-caution    { border-left: 3px solid var(--warning); }
.disk-row.safety-dangerous  { border-left: 3px solid var(--error); }
.btn-clean-safe       { background: var(--success); color: #fff; border: none; }
.btn-clean-safe:hover { background: #059669; }
.btn-clean-caution       { background: var(--warning); color: #fff; border: none; }
.btn-clean-caution:hover { background: #d97706; }
.btn-clean-dangerous       { background: var(--error); color: #fff; border: none; }
.btn-clean-dangerous:hover { background: #dc2626; }

/* 🎨 封面合成 tab */
.cover-page { padding: 16px 24px; }
.cover-layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 20px; margin-top: 12px;
}
.cover-templates { background: var(--surface); padding: 14px; border-radius: 10px;
                   border: 1px solid var(--border); max-height: calc(100vh - 200px); overflow-y: auto; }
.cover-templates h3 { margin: 0 0 10px; font-size: var(--fs-lg); }
.cover-tpl-list { list-style: none; padding: 0; margin: 0; }
.cover-tpl-item { display: flex; gap: 10px; padding: 8px; border-radius: 6px;
                  border: 1px solid var(--border); margin-bottom: 8px; }
.cover-tpl-item:hover { background: var(--surface-2); }
.cover-tpl-thumb { width: 60px; height: 60px; flex-shrink: 0; background: var(--surface-3);
                   border-radius: 4px; overflow: hidden; display: flex;
                   align-items: center; justify-content: center; }
.cover-tpl-thumb img { max-width: 100%; max-height: 100%; }
.cover-tpl-noimg { font-size: var(--fs-xs); color: var(--text-muted); }
.cover-tpl-info { flex: 1; min-width: 0; }
.cover-tpl-name { font-weight: 600; font-size: var(--fs-md); overflow: hidden;
                  text-overflow: ellipsis; white-space: nowrap; }

.cover-creator { background: var(--surface); padding: 18px; border-radius: 10px;
                 border: 1px solid var(--border); }
.cover-creator h3 { margin: 0 0 12px; font-size: var(--fs-lg); }
.creator-upload-form { display: flex; gap: 10px; align-items: center;
                       padding: 12px; background: var(--surface-2); border-radius: 8px;
                       margin-bottom: 16px; }
.creator-summary { padding: 10px 12px; background: var(--accent-soft); border: 1px solid #bfdbfe;
                   border-radius: 6px; font-size: var(--fs-md); margin-bottom: 12px; }
.creator-meta-row { display: flex; gap: 16px; margin: 12px 0;
                    flex-wrap: wrap; }
.creator-meta-row label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); }
.creator-meta-row input[type="text"] {
  min-width: 200px;
}

/* 候选清单表格: 每行一个 PSD 图层, 用户选 role + label + 文字微调 */
.creator-candidates-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm);
                            background: var(--surface); border: 1px solid var(--border);
                            border-radius: 6px; overflow: hidden; }
.creator-candidates-table th, .creator-candidates-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.creator-candidates-table th { background: var(--surface-2); font-weight: 600; font-size: var(--fs-xs); }
.creator-candidates-table tr:last-child td { border-bottom: none; }
.creator-candidates-table input[type="text"], .creator-candidates-table input[type="number"],
.creator-candidates-table select {
  padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: var(--fs-sm);
}
/* 不同 role 不同视觉提示: image=蓝, text=绿, skip=灰淡 */
.cand-row.cand-role-image td:nth-child(2) { border-left: 3px solid var(--info); }
.cand-row.cand-role-text  td:nth-child(2) { border-left: 3px solid var(--success); }
.cand-row.cand-role-color td:nth-child(2) { border-left: 3px solid var(--warning); }
.cand-row.cand-role-skip { opacity: 0.55; }
/* "文字设置" 列: 紧凑横排 4 个控件; 非 text 行整列变灰禁用 */
.cand-text-row { display: flex; gap: 4px; align-items: center; }
.cand-text-input { flex: 1; min-width: 0; }
.cand-text-size { width: 60px; flex: 0 0 auto; }
.cand-text-color { width: 28px; height: 24px; padding: 0; border: 1px solid var(--border);
                   border-radius: 4px; cursor: pointer; flex: 0 0 auto; }
.cand-row:not(.cand-role-text) .cand-text-settings { opacity: 0.35; pointer-events: none; }
/* 创建模板布局: 表单(左) + 实时预览(右, sticky 跟着滚动) */
.creator-edit-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.creator-edit-layout > form { min-width: 0; }
.creator-preview-pane { position: sticky; top: 12px; }
.creator-preview-head { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: 6px;
                         display: flex; justify-content: space-between; align-items: center; }
.creator-preview-box { background: var(--surface-3); border: 1px solid var(--border);
                       border-radius: 6px; padding: 6px; min-height: 280px;
                       display: flex; align-items: center; justify-content: center; }
.creator-preview-box img.preview-img { max-width: 100%; height: auto; border-radius: 4px;
                                         display: block; }
/* 拖拽编辑器 stage: 跟图片同尺寸的相对容器, overlay 绝对定位在上面 */
.cover-preview-stage { position: relative; display: inline-block; max-width: 100%;
                       line-height: 0; user-select: none; touch-action: none; }
.cover-preview-stage img.preview-img { display: block; max-width: 100%; height: auto; }
.cover-overlay-layer { position: absolute; inset: 0; pointer-events: none; }
.cover-overlay-box { position: absolute; box-sizing: border-box;
                     border: 2px solid rgba(0,0,0,0.55); cursor: move;
                     pointer-events: auto; font-size: var(--fs-xs); line-height: 1.1;
                     color: #fff; padding: 2px 4px; overflow: hidden;
                     text-shadow: 0 0 2px rgba(0,0,0,0.9);
                     transition: box-shadow 0.12s ease; }
.cover-overlay-box:hover { box-shadow: 0 0 0 2px rgba(255,255,255,0.7); }
.cover-overlay-box.is-dragging { box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(0,0,0,0.4); opacity: 0.9; }
.cover-overlay-box.is-resizing { box-shadow: 0 0 0 3px var(--info), 0 4px 12px rgba(59,130,246,0.4); opacity: 0.9; }
.cover-overlay-box.is-focused { box-shadow: 0 0 0 3px var(--error), 0 0 12px rgba(239,68,68,0.6); }
/* 8 个缩放手柄: 4 角 + 4 边中点 */
.cover-overlay-box .resize-handle { position: absolute; width: 11px; height: 11px;
                                     background: var(--surface); border: 1px solid var(--text); border-radius: 2px;
                                     box-shadow: 0 1px 2px rgba(0,0,0,0.3);
                                     pointer-events: auto; z-index: 5; }
.cover-overlay-box .resize-handle:hover { background: var(--info); border-color: #fff; }
.cover-overlay-box .resize-handle.nw { top: -6px; left: -6px;  cursor: nw-resize; }
.cover-overlay-box .resize-handle.n  { top: -6px; left: calc(50% - 6px); cursor: n-resize; }
.cover-overlay-box .resize-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.cover-overlay-box .resize-handle.e  { top: calc(50% - 6px); right: -6px; cursor: e-resize; }
.cover-overlay-box .resize-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.cover-overlay-box .resize-handle.s  { bottom: -6px; left: calc(50% - 6px); cursor: s-resize; }
.cover-overlay-box .resize-handle.sw { bottom: -6px; left: -6px;  cursor: sw-resize; }
.cover-overlay-box .resize-handle.w  { top: calc(50% - 6px); left: -6px; cursor: w-resize; }
.cover-overlay-box.role-image { background: rgba(59,130,246,0.18); border-color: var(--info); }
.cover-overlay-box.role-text  { background: rgba(16,185,129,0.18); border-color: var(--success); }
.cover-overlay-box.role-color { background: rgba(245,158,11,0.18); border-color: var(--warning); }
.cover-overlay-box.role-skip  { display: none; }
.cover-overlay-box .ovl-label { font-weight: 600; }
.cover-preview-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 4px; }

/* 模板布局编辑页 */
.cover-edit-page { padding: 16px; }
.cover-edit-page .edit-head { display: flex; justify-content: space-between; align-items: flex-start;
                              gap: 12px; margin-bottom: 16px; }
.cover-edit-page .edit-actions { display: flex; gap: 8px; }
.cover-edit-page .edit-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px;
                                align-items: start; }
.cover-edit-page .edit-preview-pane { background: var(--surface-3); border: 1px solid var(--border);
                                       border-radius: 8px; padding: 8px; display: flex;
                                       flex-direction: column; align-items: center; min-width: 0; }
.cover-edit-page .edit-preview-pane .cover-preview-stage { max-width: 100%; }
.cover-edit-page .edit-fields-pane { background: var(--surface); border: 1px solid var(--border);
                                      border-radius: 8px; padding: 12px; position: sticky; top: 12px; }
.cover-edit-page .edit-field-group { margin-bottom: 12px; }
.cover-edit-page .edit-group-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
                                      text-transform: uppercase; letter-spacing: 0.04em;
                                      margin-bottom: 4px; }
.cover-edit-page .edit-field-row { display: flex; justify-content: space-between; align-items: center;
                                    gap: 8px; padding: 4px 6px; border-radius: 4px;
                                    background: rgba(0,0,0,0.02); margin-bottom: 3px; font-size: var(--fs-sm);
                                    cursor: pointer; transition: background 0.1s ease; }
.cover-edit-page .edit-field-row:hover { background: rgba(0,0,0,0.06); }
.cover-edit-page .edit-field-row.is-active { background: rgba(239,68,68,0.12);
                                              outline: 1px solid var(--error); }
.cover-edit-page .edit-field-name { font-weight: 500; }
.cover-edit-page .edit-field-pos { font-family: ui-monospace, SFMono-Regular, monospace; }
.cover-edit-page .edit-buttons { margin-top: 12px; display: flex; justify-content: flex-end; }
@media (max-width: 1100px) {
  .cover-edit-page .edit-layout { grid-template-columns: 1fr; }
  .cover-edit-page .edit-fields-pane { position: static; }
}

/* 批量页头部右侧操作栏 (编辑按钮 + 缩略图) */
.batch-tpl-head .batch-tpl-actions { display: flex; align-items: center; gap: 10px; }

/* v2 图层面板 (创建模板 + 编辑布局共用) */
.layer-panel { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto;
               padding: 4px; }
.layer-row { background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
             padding: 8px 10px; font-size: var(--fs-sm); }
.layer-row.layer-kind-type        { border-left: 3px solid var(--success); }
.layer-row.layer-kind-smartobject { border-left: 3px solid var(--info); }
.layer-row.layer-kind-shape,
.layer-row.layer-kind-solidcolorfill,
.layer-row.layer-kind-gradientfill,
.layer-row.layer-kind-patternfill { border-left: 3px solid var(--warning); }
.layer-row.layer-kind-pixel       { border-left: 3px solid var(--text-muted); opacity: 0.7; }
.layer-row .layer-head { display: flex; align-items: center; gap: 6px; }
.layer-row .layer-vis { cursor: pointer; user-select: none; }
.layer-row .layer-icon { font-size: var(--fs-lg); }
.layer-row .layer-name { font-weight: 600; flex: 1; min-width: 0;
                         overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .layer-kind-tag { font-family: ui-monospace, SFMono-Regular, monospace; opacity: 0.6; }
.layer-row .layer-controls { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.layer-row .layer-row-2 { display: flex; gap: 4px; align-items: center; }
.layer-row .layer-input { padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px;
                          font-size: var(--fs-sm); flex: 1; min-width: 0; }
.layer-row textarea.layer-input { resize: vertical; min-height: 24px; }
.layer-row .layer-size { width: 60px; flex: 0 0 auto; }
.layer-row .layer-font, .layer-row .layer-align { flex: 1 1 auto; }
.layer-row .layer-color { width: 28px; height: 24px; padding: 0; border: 1px solid var(--border);
                          border-radius: 4px; cursor: pointer; flex: 0 0 auto; }
.layer-row .layer-toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.layer-row .layer-meta { margin-top: 4px; font-family: ui-monospace, SFMono-Regular, monospace;
                         font-size: var(--fs-xs); color: var(--text-muted); display: flex; gap: 8px; }
.layer-row .layer-meta span { font-weight: 600; color: var(--text); }

/* 创建模板布局: 左面板 + 右预览 (v2 版, 跟旧 .creator-edit-layout 共存; 旧的还在用) */
.creator-result .creator-edit-layout { grid-template-columns: 1fr 360px; }

/* overlay role 颜色补一下 v2 kind */
.cover-overlay-box.role-type           { background: rgba(16,185,129,0.18); border-color: var(--success); }
.cover-overlay-box.role-smartobject    { background: rgba(59,130,246,0.18); border-color: var(--info); }
.cover-overlay-box.role-shape,
.cover-overlay-box.role-solidcolorfill,
.cover-overlay-box.role-gradientfill,
.cover-overlay-box.role-patternfill    { background: rgba(245,158,11,0.18); border-color: var(--warning); }
.cover-overlay-box.role-pixel          { background: rgba(107,114,128,0.18); border-color: var(--text-muted);
                                          display: none; /* pixel 不显示 overlay (一般是底图) */ }
@media (max-width: 1100px) {
  /* 窄屏退化为上下排, 预览跟着内容滚 */
  .creator-edit-layout { grid-template-columns: 1fr; }
  .creator-preview-pane { position: static; }
}

.cover-layers-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm);
                      background: var(--surface); border: 1px solid var(--border);
                      border-radius: 6px; overflow: hidden; }
.cover-layers-table th, .cover-layers-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.cover-layers-table th { background: var(--surface-2); font-weight: 600; font-size: var(--fs-xs); }
.cover-layers-table tr:last-child td { border-bottom: none; }
.cover-layers-table input[type="text"], .cover-layers-table input[type="number"],
.cover-layers-table select {
  padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: var(--fs-sm);
}
.layer-preview-text { max-width: 240px; overflow: hidden; text-overflow: ellipsis;
                       white-space: nowrap; color: var(--text-muted); }
.badge-kind { display: inline-block; padding: 1px 6px; background: var(--border);
              border-radius: 3px; font-size: var(--fs-xs); color: var(--text-muted); }
.tab-mini { display: inline-block; padding: 4px 10px; font-size: var(--fs-sm);
            border: 1px solid var(--border); border-radius: 16px;
            color: var(--text-muted); cursor: pointer; margin-right: 4px; }
.tab-mini.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.cover-tpl-header { display: flex; align-items: center; gap: 8px; }
.cover-tpl-link { display: flex; gap: 8px; flex: 1; text-decoration: none; color: inherit; }
.cover-tpl-item.selected { background: var(--accent-soft); border-color: var(--primary); }
.btn-tiny { padding: 2px 6px; font-size: var(--fs-sm); line-height: 1; border: 1px solid var(--border);
             border-radius: 4px; background: var(--surface); cursor: pointer; }
.cover-main { background: var(--surface); padding: 18px; border-radius: 10px;
              border: 1px solid var(--border); }

/* 创建器 modal */
.cover-creator-modal { display: none; }
.cover-creator-modal[open] { display: block; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; }
.cover-creator-modal-content { background: var(--surface); max-width: 700px; margin: 60px auto;
  padding: 24px; border-radius: 12px; max-height: 80vh; overflow-y: auto; }
.cover-creator-modal-head { display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px; }
.auto-detected-grid { display: flex; flex-direction: column; gap: 8px; }
.ad-field { display: flex; gap: 12px; padding: 10px 12px; background: var(--surface-2);
  border-radius: 6px; border-left: 3px solid var(--border); align-items: center; }
.ad-field.ad-image { border-left-color: var(--info); background: var(--accent-soft); }
.ad-field.ad-title { border-left-color: var(--success); background: var(--success-bg); }
.ad-field.ad-subtitle { border-left-color: var(--warning); background: var(--warning-bg); }
.ad-field.ad-missing { border-left-color: var(--error); background: var(--error-bg); color: var(--error-text); }
.ad-icon { font-size: var(--fs-2xl); }

/* 批量套图 */
.batch-tpl-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.batch-tpl-preview { width: 80px; height: 80px; object-fit: contain; border: 1px solid var(--border); border-radius: 4px; }
.cover-batch-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.cover-batch-table th { background: var(--surface-2); padding: 8px; font-weight: 600; font-size: var(--fs-sm);
  text-align: left; border-bottom: 1px solid var(--border); }
.cover-batch-table td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.batch-row-idx { color: var(--text-muted); font-weight: 600; text-align: center; }
.batch-text-input { width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 4px; font-size: var(--fs-md); box-sizing: border-box; }
.batch-text-input:focus { outline: none; border-color: var(--primary); }
.batch-image-input { font-size: var(--fs-sm); }
.batch-font-input { margin-top: 4px; width: 100%; padding: 3px 4px; border: 1px solid var(--border);
  border-radius: 4px; font-size: var(--fs-xs); color: var(--text-muted); background: var(--surface-2);
  box-sizing: border-box; }
.lang-badge { display: inline-block; padding: 2px 8px; background: var(--primary);
  color: white; border-radius: 4px; font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; }
.batch-tint-input { margin-top: 4px; width: 100%; padding: 3px 4px; border: 1px solid var(--border);
  border-radius: 4px; font-size: var(--fs-xs); color: var(--text-muted); background: var(--surface-2);
  box-sizing: border-box; }

/* 批量套图结果 */
.cover-batch-result-block { background: var(--surface-2); padding: 16px; border-radius: 8px; }
.batch-result-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.batch-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 320px));
  gap: 12px; justify-content: start; }
/* 只有一张时拉大居中, 不然 1 张孤零零卡在左上角看着像 bug */
.batch-result-grid:has(.batch-result-item:only-child) { justify-content: center; }
.batch-result-grid:has(.batch-result-item:only-child) .batch-result-item { max-width: 480px; width: 100%; }
.batch-result-item { background: var(--surface); padding: 8px; border: 1px solid var(--border);
  border-radius: 6px; }
.batch-result-num { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: 6px; }
.batch-result-item img { width: 100%; height: auto; border-radius: 4px; cursor: pointer; }
.batch-result-error { font-size: var(--fs-sm); color: var(--error-text); padding: 12px; background: var(--error-bg);
  border-radius: 4px; }

/* QC 启发式角标 — 给批量结果每张图标"溢出/缺字/重叠"等问题 */
.qc-summary-chips { display: inline-flex; gap: 6px; margin-left: 8px; }
.qc-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: var(--fs-xs);
  font-weight: 500; line-height: 1.6; }
.qc-chip-ok    { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.qc-chip-warn  { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.qc-chip-error { background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border); }

/* cell 整体外框配色 — 一眼看出哪几张需要返工 */
.batch-result-item.qc-has-warn  { border-color: var(--warning-border); box-shadow: 0 0 0 1px var(--warning-border) inset; }
.batch-result-item.qc-has-error { border-color: var(--error-border); box-shadow: 0 0 0 1px var(--error-border) inset; }

.qc-row-badge { font-size: var(--fs-xs); padding: 1px 6px; border-radius: 8px; margin-left: 6px;
  vertical-align: 1px; }

/* 模板级提示条 — 重叠之类的全行通病 */
.qc-template-flags { background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 12px; font-size: var(--fs-sm); }
.qc-template-flags strong { color: var(--warning-text); display: block; margin-bottom: 4px; }
.qc-template-flags ul { margin: 0; padding-left: 18px; }
.qc-template-flags li { color: var(--warning-text); }

/* 每张 cell 底下的层级 flag 列表 */
.qc-cell-flags { list-style: none; margin: 8px 0 0 0; padding: 0;
  font-size: var(--fs-xs); line-height: 1.4; }
.qc-cell-flags .qc-flag { display: flex; align-items: flex-start; gap: 4px;
  padding: 3px 6px; border-radius: 4px; margin-bottom: 3px; }
.qc-cell-flags .qc-flag-error { background: var(--error-bg); color: var(--error-text); }
.qc-cell-flags .qc-flag-warn  { background: var(--warning-bg); color: var(--warning-text); }
.qc-flag-icon { flex-shrink: 0; }
.qc-flag-layer { font-weight: 600; opacity: 0.85; }
.qc-flag-msg { flex: 1; word-break: break-word; }

/* API 支出 — 顶部大卡 (仿 Google billing 样式) */
.budget-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 24px; margin-bottom: 20px;
}
.budget-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.budget-title { font-size: var(--fs-md); color: var(--text-muted); }
.budget-sub { font-size: var(--fs-sm); color: var(--text-muted); }
.budget-sub code { background: var(--surface-3); padding: 2px 5px; border-radius: 3px; font-size: var(--fs-xs); }
.budget-number {
  font-size: 32px; font-weight: 600; color: var(--text);
  letter-spacing: -0.8px; line-height: 1.2; margin-bottom: 12px;
}
.budget-slash { color: #9ca3af; font-weight: 400; }
.budget-bar {
  height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden;
  margin-bottom: 10px;
}
.budget-bar-fill {
  height: 100%; background: linear-gradient(90deg, #7c3aed 0%, #a78bfa 100%);
  transition: width 0.3s;
  border-radius: 3px;
}
.budget-bar-fill.warn { background: linear-gradient(90deg, var(--warning) 0%, var(--warning) 100%); }
.budget-bar-fill.danger { background: linear-gradient(90deg, #dc2626 0%, var(--error) 100%); }
.budget-footer { font-size: var(--fs-xs); }

/* 时间筛选 + 总计行 */
.costs-range-row {
  display: flex; justify-content: space-between; align-items: center;
  margin: 20px 0 10px;
}
.costs-total-line {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 12px 0 18px;
}
.costs-total-label { font-size: var(--fs-md); color: var(--text-muted); }
.costs-total-usd {
  font-size: var(--fs-2xl); font-weight: 600; color: var(--text); letter-spacing: -0.5px;
}

/* CSS 柱状图 */
.cost-chart {
  position: relative;              /* tooltip 以此定位 */
  display: flex; align-items: flex-end;
  height: 220px; gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.bar-col {
  flex: 1; min-width: 0; height: 100%;
  display: flex; align-items: flex-end;
  cursor: default;
}
.bar-fill {
  width: 100%;
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  border-radius: 2px 2px 0 0;
  min-height: 1px;
  transition: opacity 0.12s;
}
/* 仿 Google billing 的 hover focus 效果:
   chart 被悬停时, 所有 bar 变淡 → 被悬停的那根 bar 保持正色, 像聚光灯一样 */
.cost-chart:hover .bar-fill { opacity: 0.28; }
.cost-chart .bar-col:hover .bar-fill { opacity: 1; }
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: var(--fs-xs); color: var(--text-muted); padding-top: 6px;
  margin-bottom: 20px;
}

/* 柱状图 hover tooltip (仿 Google billing 样式) */
.cost-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);  /* 以 bar 中心为锚, 往上浮 */
  margin-top: -6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  font-size: var(--fs-sm);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  transition: opacity 0.1s;
}
.cost-tooltip.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
.cost-tt-date { color: var(--text-muted); margin-bottom: 6px; }
.cost-tt-row { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.cost-tt-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4f46e5; display: inline-block;
}
.cost-tt-label { color: var(--text-muted); font-weight: 400; }
.cost-tt-usd { margin-left: auto; font-variant-numeric: tabular-nums; }

.costs-breakdown {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin-top: 10px;
}
.costs-col h4 { margin: 0 0 8px; font-size: var(--fs-md); color: var(--text); }
.costs-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; font-size: var(--fs-sm);
}
.costs-table th, .costs-table td {
  padding: 6px 10px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.costs-table th { background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.costs-table td.right, .costs-table th.right { text-align: right; }
.costs-table tr:last-child td { border-bottom: none; }

/* 人物三视图区块 */
.character-views-box {
  margin: 10px 0 18px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.character-views-header {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-md); color: var(--text);
  margin-bottom: 10px; font-weight: 600;
}
.character-views-img {
  display: block; width: 100%; max-width: 900px;
  border-radius: 8px; background: var(--surface);
  cursor: zoom-in;
}

/* ⭐ 保留按钮: 历史条目旁边, 点一下切换 keep 状态 */
.btn-keep {
  background: none; border: none; cursor: pointer;
  padding: 4px 6px; font-size: var(--fs-lg); line-height: 1;
  color: var(--text-muted); border-radius: 4px;
}
.btn-keep:hover { background: var(--warning-bg); color: var(--warning-text); }
.btn-keep.active {
  color: var(--warning);
  text-shadow: 0 0 4px rgba(245,158,11,0.4);
}

/* 管理员删除按钮 (团队视图下删别人的东西) — 红橙色,比普通删除更"烫手",
   提醒自己这不是自己的东西,手滑风险更高 */
.tile-del-admin, .btn-delete-admin {
  color: #c2410c !important;                   /* 深橙 */
  background: rgba(251, 146, 60, 0.12) !important;
  border: 1px solid rgba(194, 65, 12, 0.35) !important;
}
.tile-del-admin:hover, .btn-delete-admin:hover {
  background: #fb923c !important;
  color: #fff !important;
}

/* 在线状态指示灯 */
.status-cell { white-space: nowrap; }
.status-cell .status-dot { margin-right: 8px; vertical-align: middle; }
.status-cell .muted { vertical-align: middle; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}
.status-dot.online {
  background: #22c55e;                             /* 绿 */
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);      /* 柔和光晕 */
  animation: status-pulse 2s ease-in-out infinite;
}
.status-dot.offline { background: #d1d5db; }       /* 灰 (而非红 — 离线不是错误) */
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0.05); }
}
.badge-admin {
  display: inline-block; padding: 1px 7px; margin-left: 4px;
  background: var(--primary); color: white;
  border-radius: 10px; font-size: var(--fs-xs); font-weight: 500;
}
.alert {
  padding: 10px 14px; border-radius: 8px; margin: 12px 0;
  font-size: var(--fs-lg);
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success); }
.alert-error { background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error); }
.pw-reveal {
  padding: 14px; margin: 12px 0;
  background: #fef3c7; border: 2px solid var(--warning); border-radius: 8px;
}
.pw-title { font-weight: 600; margin-bottom: 8px; color: var(--warning-text); }
.pw-row { display: flex; gap: 24px; margin-bottom: 10px; font-size: var(--fs-lg); }
.pw-row code {
  background: var(--surface); padding: 2px 8px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: var(--fs-md);
}
.muted { color: var(--text-muted); font-size: var(--fs-sm); font-weight: normal; }

/* ──── 图像生成 (文生图 / 图生图) ──── */
.batch-form .field-row { display: flex; gap: 12px; }
.batch-form .field-row .field { flex: 1; min-width: 0; }
.batch-form .field-row .field select { width: 100%; max-width: 100%; min-width: 0; }
.batch-form .imagegen-model-row .field:first-child { flex: 1.55; }
.batch-form .imagegen-model-row .field:last-child { flex: 1; }

/* ──── 任务队列：批量生成 / 图像生成右栏 ──── */
.queue-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; min-width: 0;
}
.q-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.q-title { font-size: var(--fs-md); font-weight: 650; }
.q-count, .q-toolbar-note { font-size: var(--fs-sm); color: var(--text-muted); }
.q-toolbar-note { margin-left: auto; }
.queue-list { min-height: 160px; }
.queue-list .placeholder { min-height: 160px; border: 0; border-radius: 0; }
.queue-job {
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.queue-job:last-child { border-bottom: 0; }
.queue-job > summary {
  list-style: none; cursor: pointer; user-select: none;
}
.queue-job > summary::-webkit-details-marker { display: none; }
.q-row {
  display: grid; gap: 12px; align-items: center;
  padding: 11px 16px; font-size: var(--fs-sm); min-width: 0;
}
.q-row--batch { grid-template-columns: 76px minmax(180px,1fr) 130px 88px 66px; }
.q-row--gen { grid-template-columns: 70px minmax(180px,1fr) 120px 88px 66px; }
.q-row.q-hd {
  font-size: var(--fs-xs); color: var(--text-muted); font-weight: 650;
  letter-spacing: .04em; padding: 9px 16px; background: var(--surface-2);
}
.queue-job > summary:hover,
.queue-job[open] > summary {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}
.q-id {
  font: 11.5px ui-monospace, Menlo, monospace;
  color: var(--text-muted); white-space: nowrap;
}
.q-pm, .q-prwrap { min-width: 0; }
.q-pm b { display: block; font-weight: 650; font-size: var(--fs-sm); }
.q-pm small {
  display: block; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px;
}
.q-pr {
  display: block; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text);
}
.q-prwrap small {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  color: var(--text-muted); font-size: var(--fs-xs); margin-top: 3px;
  overflow: hidden; white-space: nowrap;
}
.q-mode {
  display: inline-flex; align-items: center; padding: 1px 7px;
  border-radius: 99px; font-size: var(--fs-xs); font-weight: 650; flex: 0 0 auto;
}
.q-mode.t2i { background: color-mix(in srgb,#2563eb 12%,transparent); color:#2563eb; }
.q-mode.i2i { background: color-mix(in srgb,#7c3aed 12%,transparent); color:#7c3aed; }
.q-prog { display: flex; align-items: center; gap: 8px; min-width: 0; }
.q-pbar {
  flex: 1; height: 5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 99px; overflow: hidden;
}
.q-pbar i {
  display: block; height: 100%; background: var(--primary);
  border-radius: 99px; transition: width .3s ease;
}
.q-pbar i.ok { background: var(--success); }
.q-pbar i.warn { background: #e9a800; }
.q-pct {
  font: 11px ui-monospace, Menlo, monospace;
  color: var(--text-muted); white-space: nowrap;
}
.q-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px; font-size: var(--fs-xs);
  font-weight: 600; width: fit-content; white-space: nowrap;
}
.q-badge .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}
.q-badge.run { background: var(--accent-soft); color: var(--primary); }
.q-badge.ok { background: color-mix(in srgb,var(--success) 13%,transparent); color: var(--success); }
.q-badge.warn { background: color-mix(in srgb,#e9a800 15%,transparent); color:#9a7100; }
.q-badge.pause { background: var(--surface-3); color: var(--text-muted); }
.q-toggle { color: var(--primary); font-size: var(--fs-sm); font-weight: 550; white-space: nowrap; }
.q-toggle .when-open { display: none; }
.queue-job[open] .q-toggle .when-closed { display: none; }
.queue-job[open] .q-toggle .when-open { display: inline; }
.q-expand {
  padding: 14px 16px 16px; background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.q-expand .progress-header { margin-bottom: 10px; }
.q-expand .batch-gallery { margin-top: 12px; }

@media (max-width: 1180px) {
  .batch-layout { grid-template-columns: 1fr; }
  .batch-scroll { max-height: none; }
  .q-row--batch, .q-row--gen {
    grid-template-columns: 70px minmax(150px,1fr) 88px 66px;
  }
  .q-row--batch > :nth-child(3),
  .q-row--gen > :nth-child(3) { display: none; }
}
@media (max-width: 760px) {
  .q-toolbar-note { display: none; }
  .q-row--batch, .q-row--gen {
    grid-template-columns: 64px minmax(120px,1fr) 62px;
    gap: 8px; padding-left: 10px; padding-right: 10px;
  }
  .q-row--batch > :nth-child(4),
  .q-row--gen > :nth-child(4) { display: none; }
  .q-expand { padding: 12px 10px; }
}
.batch-form textarea {
  resize: vertical; min-height: 110px; font-family: inherit; line-height: 1.5;
}
.batch-form .count-field { border: none; padding: 0; margin: 0; }
.batch-form .count-field legend { padding: 0; margin-bottom: 6px; }
.radio-row { display: flex; gap: 8px; }
.radio-pill {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 8px 0; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-size: var(--fs-lg); background: var(--surface);
  transition: all 0.15s;
}
.radio-pill:hover { border-color: var(--primary); }
.radio-pill input { display: none; }
.radio-pill:has(input:checked) {
  background: var(--primary); color: white; border-color: var(--primary);
}

.imagegen-results {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border-radius: 10px; padding: 16px;
  border: 1px solid var(--border); min-height: 200px;
}
.imagegen-meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: var(--fs-sm); color: var(--text-muted);
}
.imagegen-meta .badge {
  background: var(--primary); color: white; padding: 2px 8px;
  border-radius: 4px; font-weight: 600; font-size: var(--fs-xs);
}
.imagegen-meta .meta-item {
  background: var(--surface-3); padding: 2px 8px; border-radius: 4px;
}
.imagegen-ref-shown {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px; background: var(--surface-2); border-radius: 6px;
  max-width: max-content;
}
.imagegen-ref-shown .ref-label {
  font-size: var(--fs-xs); color: var(--text-muted);
}
.imagegen-ref-shown .ref-thumbs-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.imagegen-ref-shown img {
  width: 140px; height: 140px; object-fit: contain;
  background: var(--surface); border-radius: 4px; cursor: zoom-in;
}
.imagegen-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.imagegen-tile {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px;
}
.imagegen-tile img {
  width: 100%; height: auto; border-radius: 6px; cursor: zoom-in;
  background: var(--surface-3);
}
.imagegen-tile .tile-actions {
  display: flex; align-items: center; justify-content: space-between;
}
.imagegen-tile .tile-idx {
  font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600;
}
.imagegen-prompt-echo {
  font-size: var(--fs-sm); color: var(--text-muted);
  border-top: 1px dashed var(--border); padding-top: 8px;
}
.imagegen-prompt-echo summary { cursor: pointer; user-select: none; }
.imagegen-prompt-echo pre {
  margin: 6px 0 0 0; padding: 8px; background: var(--surface-2);
  border-radius: 4px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, monospace; font-size: var(--fs-sm);
}

/* 保存到图库 — 每张结果 tile 底部 */
.save-row {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 4px; padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.save-form {
  display: flex; gap: 4px; align-items: center;
}
.save-select {
  flex: 1; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 4px; font-size: var(--fs-sm); background: var(--surface);
  min-width: 0;
}
.save-msg {
  font-size: var(--fs-sm); padding: 4px 8px; border-radius: 4px; display: inline-block;
}
.save-msg-ok { background: var(--success-bg); color: var(--success-text); }
.save-msg-err { background: var(--error-bg); color: var(--error-text); }
.hint-mini { font-size: var(--fs-xs); color: var(--text-muted); }

/* 批量 tab 全局保存条 — 横向布局, 覆盖 .save-row 的 column 默认 */
.save-row-batch {
  flex-direction: row; align-items: center; gap: 8px;
  border-top: none; padding-top: 0; margin-top: 8px;
}
.save-row-batch .save-select { max-width: 260px; }
/* 保存动作 flash 横幅 — 进度区顶部 */
.save-flash {
  padding: 6px 10px; border-radius: 6px; font-size: var(--fs-md);
  margin-bottom: 8px;
}
.save-flash.save-msg-ok { background: var(--success-bg); color: var(--success-text); }
.save-flash.save-msg-err { background: var(--error-bg); color: var(--error-text); }
/* 每张已入库小角标 */
.saved-badge {
  font-size: var(--fs-xs); color: var(--success-text); background: var(--success-bg);
  padding: 2px 6px; border-radius: 4px; align-self: flex-start;
  margin-top: 4px;
}

/* 参考图 picker — 上传 / 从图库选 两 tab */
.ref-picker {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin: 0;
}
.ref-picker legend { padding: 0 4px; }
.ref-tabs {
  display: flex; gap: 4px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.ref-tab {
  padding: 6px 12px; border: none; background: transparent;
  font-size: var(--fs-md); color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ref-tab:hover { color: var(--text); }
.ref-tab.active {
  color: var(--primary); border-bottom-color: var(--primary); font-weight: 600;
}
.ref-pane.hidden { display: none; }
.ref-pane-library { display: flex; flex-direction: column; gap: 6px; }

.ref-library-thumbs {
  max-height: 240px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px; min-height: 80px;
}
.picker-hint {
  text-align: center; color: var(--text-muted);
  font-size: var(--fs-sm); padding: 24px 8px;
}
.picker-thumbs {
  display: grid; gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
}
.picker-thumb {
  position: relative; padding: 0; border: 2px solid transparent;
  border-radius: 4px; background: var(--surface); cursor: pointer;
  aspect-ratio: 1; overflow: hidden;
  transition: border-color 0.15s;
}
.picker-thumb:hover { border-color: var(--border); }
.picker-thumb.selected { border-color: var(--primary); }
.picker-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}


/* ============ 侧边栏外壳（顶部 tab → 左侧栏） ============ */
.app-shell{display:grid;grid-template-columns:228px 1fr;min-height:100vh;}
.app-shell > main#main{flex:initial;padding:24px 28px;min-width:0;}
.side{background:var(--side-bg);display:flex;flex-direction:column;padding:18px 14px;gap:4px;position:sticky;top:0;height:100vh;overflow-y:auto;transition:background .25s;}
.side-brand{display:flex;align-items:center;gap:10px;padding:6px 8px 14px;}
.side-brand .badge{width:34px;height:34px;border-radius:9px;background:#fff;display:flex;align-items:center;justify-content:center;flex:0 0 auto;}
.side-brand .badge img{width:26px;height:26px;object-fit:contain;}
.side-brand .wm{font-size: var(--fs-lg);font-weight:650;color:#fff;letter-spacing:.2px;}
.side-brand .wm small{display:block;font-size: var(--fs-xs);font-weight:500;color:var(--side-muted);}
.nav-label{font-size: var(--fs-xs);color:var(--side-muted);font-weight:600;letter-spacing:.08em;text-transform:uppercase;padding:12px 10px 6px;}
.nav{display:flex;flex-direction:column;gap:2px;}
.nav a{display:flex;align-items:center;gap:11px;padding:9px 10px;border-radius:9px;color:var(--side-text);text-decoration:none;font-size: var(--fs-md);cursor:pointer;transition:background .12s,color .12s;}
.nav a svg{width:17px;height:17px;flex:0 0 auto;opacity:.82;}
.nav a:hover{background:var(--side-hover);color:#fff;}
.nav a.active{background:var(--nav-active-bg);color:var(--nav-active-text);font-weight:600;box-shadow:var(--nav-active-shadow);}
.nav a.active svg{opacity:1;}
.nav a.disabled{opacity:.4;pointer-events:none;}
.side-foot{margin-top:auto;display:flex;flex-direction:column;gap:12px;padding-top:14px;border-top:1px solid rgba(255,255,255,.08);}
.theme-switch{display:flex;background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:3px;gap:2px;}
.theme-switch button{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;border:none;background:none;color:var(--side-text);cursor:pointer;font-size: var(--fs-xs);padding:6px 4px;border-radius:7px;transition:background .15s,color .15s;}
.theme-switch button svg{width:14px;height:14px;}
.theme-switch button:hover{color:#fff;}
.theme-switch button.active{background:var(--primary);color:#fff;font-weight:600;}
.side-user{display:flex;align-items:center;gap:10px;padding:2px 4px;}
.side-user .avatar{width:30px;height:30px;border-radius:50%;background:var(--primary);color:#fff;display:flex;align-items:center;justify-content:center;font-size: var(--fs-sm);font-weight:600;flex:0 0 auto;}
.side-user .who{font-size: var(--fs-sm);color:var(--side-text);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.side-user .out{background:none;border:none;color:var(--side-muted);cursor:pointer;font-size: var(--fs-sm);flex:0 0 auto;}
@media(max-width:900px){.app-shell{grid-template-columns:64px 1fr;}.side-brand .wm,.nav a span,.nav-label,.side-user .who,.theme-switch button span{display:none;}}


/* ============ 侧边栏改造后的微调覆盖 ============ */
.side .nav .tab-admin{margin-left:0;color:var(--side-text);font-weight:inherit;}
.side .nav .tab-admin.active{color:var(--nav-active-text);}
.nav a{white-space:nowrap;}
/* tab 内的分段/筛选控件不要换行 */
.sub-tab,.ref-tab,.view-chip,.tab-mini{white-space:nowrap;}

/* 全站通用的"仅供屏幕阅读器"视觉隐藏类。
   ★ 2026-08-09 前不存在这个全局类, 有 4 处特效产线模板借用了 collector.css 里
     同名的 .collector-sr-only —— 但那份定义只在加载 collector.css 的页面生效,
     特效产线自己的页面根本没引入那份样式表, 于是这些"应该隐藏"的辅助文字
     (搜索框的"搜索模板"标签、"输入槽位"/"质量规则"这类跟在可见 <h3> 后面的
     冗余 label 文字) 全部原样露出来: 既破坏视觉对齐, 也造成标题文字重复一遍。 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* === 表单控件默认外观基准(2026-08-09 由"列举 class 名单"升级为元素级基准) ===
   ★ 这里以前只有一条"深色模式文字色"的补丁(color:var(--text)), 真正的
   padding/border/圆角/底色全靠下面那份「表单控件基准」列举选择器——新增一个
   表单时, 如果忘了把 class 写进那份名单, 这个控件就会裸奔成浏览器原生外观
   (黑框、无圆角)。这学期已经在"生产订单"下拉框、图库两处保存下拉、图片
   本地化四处控件上抓到过同一个模式的 bug, 每次都是"忘了写进名单"。

   改成元素级选择器做兜底基准, 而不是继续加长名单: 新增的输入框/下拉框/
   文本域不用再记得"去 app.css 报个到", 默认就是好看的; 已经有专属 class
   的地方(下面的列举选择器、effect_pipeline.css/collector.css/
   intern_sandbox.css 里的具体规则、数字人产线各页面自带的 <style> 块)
   靠类选择器优先级天然覆盖回自己的数值, 不会被这条基准值顶掉——CSS 里
   同一属性永远是「选择器更具体的那条赢」, 跟这条规则写在文件哪个位置无关。

   排除的 input 类型都是浏览器原生渲染、不适合套方框样式的: checkbox/radio/
   range 有自己的原生控件外观, file/color/hidden/submit/button/image/reset
   要么本来就该长成按钮样子、要么根本不可见。
   ★ 特意不在这里设 min-height —— 密集表格/行内的紧凑输入框(细节见下面
   「表单控件基准」注释)要用 3–4px 内距才塞得进去, 全局定死高度会把那些
   行撑爆; 高度还是交给需要它的场景自己指定。 */
select,
input:not([type=checkbox]):not([type=radio]):not([type=range])
      :not([type=file]):not([type=color]):not([type=hidden])
      :not([type=submit]):not([type=button]):not([type=image]):not([type=reset]),
textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-md);
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
/* 原生下拉展开的 option 列表 (浏览器渲染), 深色也要适配 */
select option,
select optgroup {
  background: var(--surface);
  color: var(--text);
}

/* ──────── workbench ──────── */
/* 模板参考 .v2p-layout / .v2p-main / .v2p-scroll / .history-sidebar / .gallery-thumbs / .lib-subfolder-grid */
.workbench-layout {
  display: grid; grid-template-columns: 260px 1fr; gap: 24px;
}
.workbench-main {
  background: var(--surface); padding: 20px; border-radius: 12px;
  border: 1px solid var(--border);
}
.workbench-scroll {
  max-height: 75vh; overflow-y: auto;
  overflow-anchor: none;
}

/* 表单 (左侧 persona / 顶部录入) */
.workbench-form,
.workbench-persona-form {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.workbench-form input[type=text],
.workbench-form input[type=number],
.workbench-form select,
.workbench-form textarea,
.workbench-persona-form input[type=text],
.workbench-persona-form input[type=number],
.workbench-persona-form select,
.workbench-persona-form textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: var(--fs-md); font-family: inherit; background: var(--surface); color: var(--text);
}

/* persona / history 列表 (跟 .history-list 一脉相承) */
.workbench-persona-list,
.workbench-history {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.workbench-persona-list > li,
.workbench-history > li {
  padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  font-size: var(--fs-sm); color: var(--text);
}
.workbench-persona-list > li:hover,
.workbench-history > li:hover {
  background: var(--accent-soft); border-color: var(--primary);
}

/* 区块切换 (参考 .sub-tabs) */
.workbench-section-switch {
  display: flex; gap: 4px;
  background: var(--surface-3); padding: 3px; border-radius: 8px;
  margin-bottom: 12px;
}
.workbench-section-switch button,
.workbench-section-switch a {
  padding: 6px 14px; border: none; background: transparent;
  color: var(--text-muted); font-size: var(--fs-md); cursor: pointer;
  border-radius: 6px; transition: all 0.15s;
  text-decoration: none;
}
.workbench-section-switch button:hover,
.workbench-section-switch a:hover { color: var(--text); }
.workbench-section-switch button.active,
.workbench-section-switch a.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); font-weight: 500;
}

/* 分镜表 */
.workbench-shot-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; font-size: var(--fs-md);
}
.workbench-shot-table th,
.workbench-shot-table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
.workbench-shot-table th {
  background: var(--surface-2); font-weight: 600; font-size: var(--fs-sm);
  color: var(--text-muted);
}
.workbench-shot-table tr:last-child td { border-bottom: none; }
.workbench-shot-table tbody tr:nth-child(even) { background: var(--surface-2); }
.workbench-shot-table tbody tr:hover { background: var(--surface-3); }
.row-active {
  background: var(--accent-soft) !important;
  box-shadow: inset 3px 0 0 var(--primary);
}

/* 最终成片区 */
.workbench-final {
  margin-top: 16px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.workbench-final-video {
  max-width: 100%; width: 100%; border-radius: 8px;
  background: #000; display: block;
}

/* 3 视图网格 (正面 / 侧面 / 背面) */
.workbench-views-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.workbench-view-box {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px; text-align: center; background: var(--surface);
}
.workbench-view-box img {
  max-width: 100%; height: auto; border-radius: 4px; display: block; margin: 0 auto;
}
.workbench-view-label {
  font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px;
}

/* 服装 / 场景 参考图行 */
.workbench-refs-grid {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* 缩略图 */
.thumb-64 {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border);
  background: var(--surface-3);
}
.thumb-clip {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
  background: #000;
}
.thumb-avatar {
  width: 24px; height: 24px; object-fit: cover;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-3);
}

@media (max-width: 900px) {
  .workbench-layout { grid-template-columns: 1fr; }
  .workbench-views-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════
   全局「点击即反馈」——任何 htmx 请求进行中: 触发的按钮/表单/下拉
   立刻转圈+变灰+禁再点, 让人知道"点到了", 不再干等。
   HTMX 请求期间会给触发元素加 .htmx-request 类, 这里全局接住。
   ══════════════════════════════════════════════════════════════════ */

/* 1) 直接带 hx-* 的按钮 & 表单提交按钮(表单上带 hx-* 时是 form 拿到 .htmx-request) */
button.htmx-request,
a.htmx-request[hx-post], a.htmx-request[hx-get],
form.htmx-request button[type="submit"],
form.htmx-request .btn:not([type="button"]) {
  opacity: .6 !important;
  pointer-events: none;          /* 防手抖重复点 → 不重复烧钱/重复起任务 */
  cursor: progress;
  /* ★这里【不能】写 position: relative。下面那个转圈的环是 inline-block 跟在
     文字后面的, 本来就不需要定位上下文; 而 button.htmx-request 的特异性(0,1,1)
     压得过组件自己的单类名(0,1,0) —— 写了就会把 .ep-row-del 这种
     position:absolute 的图标按钮从定位里踢出来, 请求一开始整行就塌了。 */
}
/* 在按钮文字后面追一个转圈的小环(currentColor → 任何底色都自适应) */
button.htmx-request::after,
form.htmx-request button[type="submit"]::after,
form.htmx-request .btn:not([type="button"])::after {
  content: "";
  display: inline-block;
  width: .85em; height: .85em;
  margin-left: 6px;
  vertical-align: -.15em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: tab-spin .7s linear infinite;
}

/* 2) 改就存的下拉/输入(hx-trigger=change): 请求期间淡一下 + 进度光标 */
select.htmx-request, textarea.htmx-request, input.htmx-request {
  opacity: .6;
  cursor: progress;
}


/* ═══════════════════════════════════════════════════════════════════════
   公用组件 —— 全站共用一份定义, 各模块只叠自己的布局, 不再各造一份。
   依据 DESIGN_MEMORY §7.2(卡片) / §7.7(标签与胶囊)。
   模块样式表在 app.css 之后加载, 需要微调直接覆盖即可。
   ═══════════════════════════════════════════════════════════════════════ */

/* 标准卡片: 只负责「表面」—— 底色 / 描边 / 圆角 / 内距。
   卡片内部的栅格或弹性布局由各模块自己叠加, 不要写进这里。
   ★ min-width:0 是刻意的: 卡片常作为 grid/flex 子项, 而这类子项默认
     min-width:auto 会拒绝收缩到比内容窄, 导致里层的 text-overflow:ellipsis
     和 flex-wrap 双双失效 —— 特效产线的主题卡就是这么溢出的。写进公用组件
     里, 以后每张卡都自带这个保护。 */
.card {
  min-width: 0;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

/* 胶囊: 标签 / 关键词 / 状态词。圆角一律 999px, 不要手算半高(容易写成 13px)。 */
.pill {
  min-height: 24px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/* 表单控件基准(高度专用) —— 上面 2062 行那条元素级选择器已经把 padding/border/
   圆角/底色定成全站默认基准, 这份列举法现在只用来发 min-height:40px(高度贴近
   .btn 约 37px 那档), 因为高度不能全局定死: 密集表格/行内的紧凑输入框
   (.batch-font-input、.creator-candidates-table input 等)靠 3–4px 内距才塞得进
   密集行, 套 40px 会把行撑爆, 所以只给点名的这些"需要跟按钮一样高"的场景发。
   ★ 2026-08-09 之前这里的旧注释说"数字人几页本轮明确不动, 所以不能用元素选择器"——
   查证后发现站内路径都反过来: dhv/workbench/tune/bt/bench 每个页面自己嵌了一段
   <style>, 用的是同一套「.页面前缀 input/select/textarea{...}」写法, 选择器优先级
   天然高于元素级选择器, 不会被上面那条基准值覆盖。所以这份名单不再是"故意漏掉
   数字人几页", 单纯只是这批控件需要比默认更高的 min-height。 */
.login-form input,
.url-input,
.batch-form select,
.batch-form input[type=text],
.batch-form input[type=number],
.tpl-form input,
.tpl-form textarea,
.new-album-form input,
.admin-form input,
.creator-meta-row input[type="text"],
.batch-form textarea,
.ep-field input,
.ep-field select,
.ep-field textarea,
#ep-album-select,
.collector-filter-control input,
.collector-filter-control select,
.collector-batch-actions select,
.collector-dialog textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-md);
  font-family: inherit;
  /* 同类筛选框(.collector-filter-control input)都是这两条 —— 没写会保留浏览器
     默认白底, 深色模式下"白底 + var(--text) 浅字"完全看不清。 */
  background: var(--surface);
  color: var(--text);
}

/* 高度只给单行控件。★ 不能把 textarea 一起写进来:
   本规则位于 app.css 末尾, 与 .batch-form textarea(110px)、.tpl-form textarea(200px)
   特异度相同而位置更后, 会把它们压成 40px 高。文本域的高度仍归各自的规则管。 */
.login-form input,
.url-input,
.batch-form select,
.batch-form input[type=text],
.tpl-form input,
.new-album-form input,
.admin-form input,
.creator-meta-row input[type="text"],
.ep-field input,
.ep-field select,
#ep-album-select,
.collector-filter-control input,
.collector-filter-control select,
.collector-batch-actions select {
  min-height: 40px;
}


/* 出血型卡片: 内容(封面图/预览图)顶到边缘, 因此不带内距, 靠 overflow:hidden 裁圆角。
   内距放在卡内的 body 层。圆角与 .card 一致 —— §7.2 要求同层级卡片圆角统一。 */
.card-flush {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

/* 数字人项目头部成本摘要。弹层只承载核账明细，不挤压产线主区。 */
.dhv-project-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dhv-project-head > :first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.dhv-project-head-side {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dhv-cost-summary {
  position: relative;
}

.dhv-cost-summary > summary {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.dhv-cost-summary > summary::-webkit-details-marker {
  display: none;
}

.dhv-cost-summary > summary:hover,
.dhv-cost-summary[open] > summary {
  border-color: var(--primary);
  color: var(--text);
}

.dhv-cost-summary > summary b {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 650;
}

.dhv-cost-summary > summary i {
  width: 1px;
  height: 14px;
  background: var(--border);
}

.dhv-cost-chevron {
  color: var(--text-muted);
  transition: transform 160ms ease;
}

.dhv-cost-summary[open] .dhv-cost-chevron {
  transform: rotate(180deg);
}

.dhv-cost-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: min(370px, calc(100vw - 48px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .20);
}

.dhv-cost-popover-head,
.dhv-cost-used-head,
.dhv-cost-lines > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dhv-cost-popover-head {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
}

.dhv-cost-popover-head span,
.dhv-cost-plan > span,
.dhv-cost-used-head > span {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.dhv-cost-plan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.dhv-cost-plan strong,
.dhv-cost-used-head strong,
.dhv-cost-lines b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.dhv-cost-plan small {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.55;
}

.dhv-cost-used-head {
  padding: 10px 0 6px;
}

.dhv-cost-used-head strong {
  font-size: var(--fs-lg);
}

.dhv-cost-lines {
  padding: 2px 0 6px;
}

.dhv-cost-lines > div {
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.dhv-cost-lines span {
  min-width: 0;
}

.dhv-cost-lines small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.dhv-cost-empty,
.dhv-cost-note {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.55;
}

.dhv-cost-empty {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.dhv-cost-note {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .dhv-project-head {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .dhv-project-head-side {
    justify-content: space-between;
  }
  .dhv-cost-popover {
    right: auto;
    left: 0;
  }
}

/* ─────────── 主体替换 ─────────── */
/* 布局跟随 effect_pipeline 既有约定: 区块用 .ep-section + .ep-section-head,
   正文统一 .sr-body 内边距, 不再自造标题层级。 */
.sr-body{padding:16px 18px}

/* 模板卡: 封面用 4:5 而不是 9:16 —— 9:16 在 190px 宽下会拉到 338px 高,
   四张卡就把整屏占满, 页面读起来像一堵墙。4:5 够看清画面, 又能一屏放下一排。 */
.sr-card-grid{display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(168px,1fr))}
.sr-card{display:flex;flex-direction:column;border:1px solid var(--border);border-radius:10px;
  background:var(--surface);overflow:hidden;transition:border-color .15s,box-shadow .15s}
.sr-card:hover:not(.is-off){border-color:var(--primary);box-shadow:0 2px 10px rgba(0,0,0,.05)}
.sr-card.is-off{opacity:.5}
.sr-card-pick{position:relative;display:block;cursor:pointer}
.sr-card-pick input{position:absolute;top:8px;left:8px;z-index:2;width:17px;height:17px;cursor:pointer}
.sr-card-pick input:checked~.sr-card-cover{outline:2px solid var(--primary);outline-offset:-2px}
.sr-card-cover{position:relative;display:block;aspect-ratio:4/5;background:var(--surface-3)}
.sr-card-cover img{width:100%;height:100%;object-fit:cover;display:block}
.sr-cover-none{display:grid;place-items:center;height:100%;color:var(--text-muted);font-size: var(--fs-sm)}
.sr-card-dur{position:absolute;right:6px;bottom:6px;padding:1px 6px;border-radius:4px;
  background:rgba(0,0,0,.65);color:#fff;font-size: var(--fs-xs);font-weight:600}
.sr-card-body{padding:9px 10px;flex:1;display:flex;flex-direction:column;gap:5px}
.sr-card-title{display:flex;align-items:center;justify-content:space-between;gap:6px}
.sr-card-title strong{font-size: var(--fs-md)}
.sr-card-meta{display:flex;flex-wrap:wrap;gap:4px 8px;margin:0;font-size: var(--fs-xs);color:var(--text-muted)}
.sr-card-desc{margin:0;font-size: var(--fs-xs);color:var(--text-muted);line-height:1.5;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.sr-card-foot{display:flex;flex-wrap:wrap;gap:5px;padding:8px 10px;border-top:1px solid var(--border)}
.sr-src{padding:1px 5px;border-radius:4px;background:var(--surface-3);font-weight:600;font-size: var(--fs-xs)}
.sr-src-insp{background:var(--accent-soft);color:var(--primary)}

.sr-generate{display:flex;flex-direction:column;gap:14px}
.sr-form-grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(190px,1fr))}
.sr-generate-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;
  padding-top:14px;border-top:1px solid var(--border)}
.sr-generate-foot .ep-note{margin:0;flex:1;min-width:220px}
.ep-field small{display:block;font-weight:400;color:var(--text-muted);font-size: var(--fs-xs);margin-top:1px}

/* 任务行: 一行 = 一次转换。三栏并排(参考 → 主体 → 成品) + 右侧信息与操作。
   卡片网格看不出"什么进去、什么出来", 这个布局把审核所需的对比摆在同一视线上。
   同一套结构也适用于出图任务: 参考图 → 主体图 → 效果图。 */
.sr-batch-bar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;
  padding:9px 12px;margin-bottom:12px;border-radius:8px;background:var(--surface-3)}
.sr-batch-bar span{margin-left:10px;font-size: var(--fs-sm);color:var(--text-muted)}

.sr-rows{display:flex;flex-direction:column;gap:10px}
.sr-row{display:grid;grid-template-columns:minmax(0,1fr) 232px;gap:16px;
  padding:12px 14px;border:1px solid var(--border);border-radius:10px;background:var(--surface)}
.sr-row.succeeded{border-left:3px solid var(--success)}
.sr-row.failed{border-left:3px solid var(--error)}
.sr-row.running,.sr-row.submitting{border-left:3px solid var(--primary)}
.sr-row.queued,.sr-row.cancelled{border-left:3px solid var(--border)}

.sr-flow{display:flex;align-items:flex-start;gap:10px;min-width:0}
.sr-slot{margin:0;flex:1;min-width:0;display:flex;flex-direction:column;gap:5px}
.sr-slot figcaption{font-size: var(--fs-xs);color:var(--text-muted);font-weight:600}
/* 媒体按原始比例显示: 定高不定宽, 竖屏就窄高、横屏就宽扁。
   原来用 width:100%+object-fit:cover 塞进固定横框, 竖屏参考视频被裁得只剩半截
   身子, 成品左右还挂两条黑边 —— 审核要看的正是画面构图, 裁掉就没法判断了。 */
.sr-media{height:190px;display:flex;align-items:center;justify-content:center}
.sr-slot video,.sr-slot img{height:100%;width:auto;max-width:100%;
  object-fit:contain;border-radius:7px;display:block}
.sr-slot small{font-size: var(--fs-xs);color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;text-align:center}
.sr-slot-none,.sr-slot-wait{display:flex;align-items:center;justify-content:center;gap:6px;
  width:100%;height:100%;border:1px dashed var(--border);border-radius:7px;
  color:var(--text-muted);font-size: var(--fs-xs)}
.sr-arrow{align-self:center;margin-top:20px;color:var(--text-muted);font-size: var(--fs-lg);flex:none}

.sr-side{display:flex;flex-direction:column;gap:8px;min-width:0}
.sr-side-top{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
.sr-facts{display:grid;grid-template-columns:1fr 1fr;gap:2px 10px;margin:0;font-size: var(--fs-xs)}
.sr-facts div{display:flex;justify-content:space-between;gap:6px}
.sr-facts dt{color:var(--text-muted)}
.sr-facts dd{margin:0;font-weight:600;font-variant-numeric:tabular-nums}
.sr-err{margin:0;padding:6px 8px;border-radius:6px;background:var(--surface-3);
  color:var(--error);font-size: var(--fs-xs);line-height:1.5;
  display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.sr-acts{display:flex;flex-wrap:wrap;gap:5px;margin-top:auto}

@media (max-width:900px){
  .sr-row{grid-template-columns:1fr}
  .sr-arrow{display:none}
  .sr-flow{display:grid;grid-template-columns:repeat(3,1fr)}
}

/* 三栏对照 */
.sr-detail-src{margin:6px 0 0;font-size: var(--fs-sm);color:var(--text-muted)}
.sr-detail-src a{color:var(--primary)}
.sr-detail-desc{margin:8px 0 0;color:var(--text-muted);font-size: var(--fs-md)}
.sr-triptych{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin:16px 0}
.sr-triptych figure{margin:0;display:flex;flex-direction:column;gap:7px}
.sr-triptych figcaption{font-size: var(--fs-sm);font-weight:600}
.sr-triptych figcaption small{display:block;font-weight:400;color:var(--text-muted);font-size: var(--fs-xs);margin-top:1px}
.sr-triptych video,.sr-triptych img{width:100%;aspect-ratio:4/5;object-fit:contain;
  background:#000;border-radius:8px}
.sr-slot-empty{display:grid;place-items:center;aspect-ratio:4/5;border:1px dashed var(--border);
  border-radius:8px;color:var(--text-muted);font-size: var(--fs-sm)}
.sr-caveats,.sr-lock{margin-top:14px;padding:11px 13px;border-radius:8px;font-size: var(--fs-sm);line-height:1.6}
.sr-caveats{background:var(--accent-soft)}
.sr-lock{background:var(--surface-3);border:1px solid var(--border)}
.sr-lock small,.sr-caveats small{display:block;color:var(--text-muted);margin-top:2px;font-size: var(--fs-xs)}
.sr-lock pre{margin:8px 0 0;white-space:pre-wrap;font-size: var(--fs-xs);line-height:1.7;font-family:inherit}
.sr-admin-edit{margin-top:14px;border-top:1px solid var(--border);padding-top:12px}
.sr-admin-edit summary{cursor:pointer;font-weight:600;font-size: var(--fs-md)}
.sr-admin-edit form{display:flex;flex-direction:column;gap:13px;margin-top:12px}
/* 「让 AI 读一遍视频」那个按钮在 label 外面(label 会转发点击, 不能包 button),
   所以这一格自己要撑成一列, 否则按钮的 align-self 没有 flex 父级可依。 */
#sr-lock-field{display:flex;flex-direction:column;gap:7px}
#sr-lock-field .ep-note{margin:0}
.sr-lock-ok{margin:0;font-size: var(--fs-xs);line-height:1.6;color:var(--text-muted)}
.sr-detail-history{margin-top:14px;font-size: var(--fs-sm)}
.sr-history-strip{display:flex;flex-wrap:wrap;gap:5px;margin-top:7px}
/* effect_pipeline.css 在本文件之后加载, 同特异性下 .ep-dialog 的 width 会赢,
   所以这里必须写成两个类叠加才盖得住。 */
dialog.ep-dialog.ep-dialog-wide{width:min(880px,calc(100vw - 32px))}

@media (max-width:760px){
  .sr-triptych{grid-template-columns:1fr}
  .sr-card-grid,.sr-task-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
}
.sr-card-desc{-webkit-line-clamp:1}
.sr-danger{display:flex;align-items:center;justify-content:space-between;gap:12px;
  margin-top:14px;padding:11px 13px;border-radius:8px;border:1px solid var(--error);
  background:color-mix(in srgb,var(--error) 6%,transparent)}
.sr-danger strong{font-size: var(--fs-sm)}
.sr-danger small{display:block;color:var(--text-muted);font-size: var(--fs-xs);margin-top:1px}
.sr-danger .btn{color:var(--error);border-color:var(--error)}
/* 弹窗结构沿用 .ep-dialog-head / .ep-dialog-body / .ep-dialog-actions,
   本文件只补这里独有的两处。 */
.sr-more{margin-top:4px;border-top:1px solid var(--border);padding-top:12px}
.sr-more summary{cursor:pointer;font-size: var(--fs-sm);font-weight:600;color:var(--text-muted)}
.sr-more summary:hover{color:var(--text)}
.sr-more>*+*{margin-top:13px}
.sr-detail-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.sr-detail-top h3{margin:0 0 4px;font-size: var(--fs-lg)}

/* 请求失败的兜底提示。见 base.html 里的 htmx:responseError —— htmx 对 4xx/5xx
   默认不换内容, 不弹这一条的话后端炸了页面纹丝不动, 表现成"点了没反应"。 */
.htmx-error-toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);
  z-index:9999;max-width:min(560px,92vw);padding:11px 16px;border-radius:10px;
  background:var(--error);color:#fff;font-size: var(--fs-md);line-height:1.5;
  box-shadow:0 8px 28px rgba(0,0,0,.24);cursor:pointer}
