:root {
  /* 多图展示（生成记录 / 本次生成结果）统一约束的最大高度，避免竖图把整行撑得过高 */
  --nb-img-max-h: 480px;
  --nb-img-h: 350px;          /* 结果网格统一图片高度 */
  --bg: #0f172a;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-light: #eef2ff;
  --bg-secondary: #f8fafc;
  --text-secondary: #475569;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  min-height: 100vh;
}

/* 顶栏 */
.nb-header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  padding: 14px 24px; background: var(--bg); color: #fff;
  position: sticky; top: 0; z-index: 50;
}
.nb-logo { color: #fff; font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: .5px; justify-self: start; }
.nb-nav { display: flex; gap: 14px; }
.nb-nav a { color: #c7d2fe; text-decoration: none; font-size: 14px; }
.nb-nav a:hover { color: #fff; }
.nb-topnav { justify-self: center; }
.nb-userbox { justify-self: end; font-size: 14px; color: #e2e8f0; }
.nb-userbox a { color: #a5b4fc; text-decoration: none; margin-left: 8px; }

/* 布局 */
.nb-main {
  display: grid; grid-template-columns: 360px 456px 1fr; gap: 20px;
  padding: 20px 24px; max-width: 1496px; margin: 0 auto; align-items: start;
}
.nb-history-panel { max-height: calc(100vh - 110px); overflow-y: auto; }
.nb-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.nb-func-title { margin: 0 0 16px; font-size: 20px; }
.nb-panel-title { margin: 0 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* 表单 */
.nb-form { display: flex; flex-direction: column; gap: 16px; }
.nb-field { display: flex; flex-direction: column; gap: 6px; }
.nb-label { font-size: 13px; color: var(--muted); }
.nb-textarea, .nb-select, .nb-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
.nb-textarea { resize: vertical; }
.nb-ref-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.nb-ref-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.nb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 14px; cursor: pointer; text-decoration: none;
}
.nb-btn:hover { background: #f8fafc; }
.nb-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.nb-btn-primary:hover { background: var(--primary-d); }
.nb-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.nb-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 结果区 */
.nb-result { min-height: 200px; display: block; text-align: center; }
.nb-result-empty { color: var(--muted); font-size: 14px; padding: 80px 0; text-align: center; }
.nb-result-panel { display: flex; flex-direction: column; gap: 22px; }
/* 功能页右侧面板里的结果容器要改为 block，否则 flex 居中会让内部 grid 的百分比宽度
   被解析为 min-content，导致图片挤在一侧、出现大片空白间隔（同主图页之前的修复） */
.nb-result-panel .nb-result { display: block; text-align: center; }
.nb-gen-loading { text-align: center; color: var(--muted); }
.nb-result-error { color: #dc2626; padding: 12px; text-align: center; font-size: 13px; line-height: 1.5; }
.nb-spinner {
  width: 42px; height: 42px; margin: 0 auto 12px;
  border: 4px solid #e5e7eb; border-top-color: var(--primary);
  border-radius: 50%; animation: nb-spin .8s linear infinite;
}
@keyframes nb-spin { to { transform: rotate(360deg); } }
.nb-result-wrap { width: 100%; text-align: center; position: relative; }
.nb-result-img {
  max-width: 100%; max-height: 70vh; border-radius: 12px; border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.nb-result-prompt { color: var(--muted); font-size: 13px; margin: 12px 0; }
.nb-result-actions { margin-top: 12px; }

/* 历史 - 左栏列表 */
.nb-history { min-height: 60px; }
.nb-history-empty { color: var(--muted); font-size: 13px; }
.nb-history-list { display: flex; flex-direction: column; gap: 10px; }
.nb-history-row {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer;
  background: #fff; transition: border-color .12s ease, box-shadow .12s ease;
  position: relative; overflow: hidden;
}
.nb-history-row:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.nb-history-row.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.15); }
.nb-history-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; background: #f1f5f9; }
/* 同任务多张图：缩略图外包一层用于叠放张数角标 */
.nb-history-thumb-wrap { position: relative; flex: none; }
.nb-history-count {
  position: absolute; right: 2px; bottom: 2px;
  background: rgba(15, 23, 42, .72); color: #fff;
  font-size: 11px; line-height: 1; font-weight: 600;
  padding: 2px 6px; border-radius: 9px; pointer-events: none;
}
/* 视频类历史缩略图：<video> 抓首帧当封面，中间叠播放角标 */
.nb-history-thumb-wrap video.nb-history-thumb { display: block; background: #0f172a; }
.nb-history-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15, 23, 42, .6); color: #fff; font-size: 10px;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
/* 尚无结果（排队 / 生成中 / 失败）时的缩略图占位 */
.nb-history-thumb-ph {
  width: 72px; height: 72px; border-radius: 8px; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 18px; flex: none;
}
.nb-history-status.is-pending,
.nb-history-status.is-processing { background: rgba(79, 70, 229, .85); }
.nb-history-status.is-failed { background: rgba(220, 38, 38, .85); }
.nb-history-row.is-failed { border-color: #fecaca; }
.nb-history-err { font-size: 11px; color: #dc2626; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-history-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.nb-history-time { font-size: 12px; color: var(--muted); }
.nb-history-params { font-size: 12px; color: #6b7280; line-height: 1.4; word-break: break-word; }
.nb-history-prompt { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-history-tag { display: inline-block; align-self: flex-start; font-size: 11px; line-height: 1.6; padding: 0 7px; border-radius: 4px; background: #eef2ff; color: #4338ca; font-weight: 600; }
.nb-history-tag-other { background: #f1f5f9; color: #64748b; font-weight: 500; }
/* 示例记录（管理后台配置的演示记录）：底部展示，样式与正常记录一致，行带虚线分隔；左上角红底白字「示例」角标 */
.nb-history-demo-flag {
  position: absolute; top: 0; left: 0; z-index: 2;
  background: #dc2626; color: #fff;
  font-size: 11px; line-height: 1; font-weight: 600;
  padding: 4px 8px; border-radius: 10px 0 10px 0;
  pointer-events: none;
}
.nb-history-row.is-demo { border-style: dashed; border-color: #fca5a5; background: #fef6f6; }
.nb-history-row.is-demo:hover { border-color: #dc2626; box-shadow: 0 4px 12px rgba(220,38,38,.10); }

/* === 顶部级联菜单（三个主菜单 + 子菜单） === */
.nb-topnav { display: flex; align-items: stretch; gap: 2px; }
.nb-menu-group { position: relative; }
.nb-menu-group-label {
  display: flex; align-items: center; gap: 4px;
  background: transparent; border: none; color: #c7d2fe;
  font-size: 14px; cursor: pointer; padding: 8px 12px; border-radius: 8px;
  font-family: inherit; line-height: 1; white-space: nowrap;
}
.nb-menu-group-label:hover, .nb-menu-group:hover .nb-menu-group-label { background: rgba(255,255,255,.1); color: #fff; }
.nb-caret { font-size: 10px; opacity: .8; }
.nb-menu-sub {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(15,23,42,.18); padding: 6px;
  min-width: 168px; display: none; flex-direction: column; z-index: 100;
}
.nb-menu-group:hover .nb-menu-sub,
.nb-menu-group.open .nb-menu-sub { display: flex; }
.nb-menu-link {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap;
}
.nb-menu-link:hover { background: #eef2ff; color: var(--primary); }
.nb-menu-link.active { background: var(--primary); color: #fff; }
.nb-menu-link.disabled { color: var(--muted); cursor: not-allowed; font-style: italic; }
.nb-menu-link.disabled:hover { background: transparent; color: var(--muted); }
/* 顶部菜单第一个「生成记录」直链（跳首页），视觉与分组标签一致 */
.nb-menu-home {
  display: flex; align-items: center;
  background: transparent; border: none; color: #c7d2fe;
  font-size: 14px; cursor: pointer; padding: 8px 12px; border-radius: 8px;
  font-family: inherit; line-height: 1; white-space: nowrap; text-decoration: none;
}
.nb-menu-home:hover { background: rgba(255,255,255,.1); color: #fff; }
.nb-menu-home.active { background: var(--primary); color: #fff; }

/* === 首页：本账号全部生成历史（仿插件结果页排版 + 无限滚动） === */
.nb-hist-wrap { max-width: 880px; margin: 0 auto; padding: 22px 24px 48px; }
.nb-hist-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.nb-hist-title { font-size: 22px; margin: 0; }
.nb-hist-stats { font-size: 13px; color: var(--muted); margin: 0 0 16px; min-height: 18px; }
.nb-hist-list { display: flex; flex-direction: column; gap: 20px; }
.nb-hist-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 0; }
.nb-hist-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.nb-hist-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nb-feature-badge {
  display: inline-block; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 4px 10px; border-radius: 999px; color: #fff; background: var(--primary); white-space: nowrap;
}
.nb-hist-params { font-size: 12px; color: var(--muted); }
.nb-hist-time { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.nb-hist-prompt { font-size: 13px; color: var(--text); padding: 10px 16px 0; line-height: 1.5; word-break: break-all; }
.nb-hist-imgwrap { padding: 12px 16px 16px; }
.nb-hist-imgwrap img { width: 100%; max-height: 440px; object-fit: contain; border-radius: 10px; cursor: zoom-in; background: #f8fafc; display: block; }
.nb-hist-sentinel { min-height: 1px; }
.nb-hist-sentinel .sentinel-loading { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; padding: 18px 0 6px; }
.nb-hist-sentinel .spinner { width: 20px; height: 20px; border-width: 2px; margin: 0; }

/* 灯箱 */
.nb-lightbox {
  position: fixed; inset: 0; background: rgba(15,23,42,.82);
  display: none; align-items: center; justify-content: center; z-index: 2147483647; padding: 24px;
}
.nb-lightbox.show { display: flex; }
.nb-lightbox img { max-width: 95vw; max-height: 95vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }


/* 登录页 */
.nb-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.nb-login {
  width: 360px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.nb-login h2 { margin: 0 0 4px; font-size: 22px; }
.nb-login p.tip { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.nb-login .nb-field { margin-bottom: 16px; }
.nb-login .nb-btn-primary { width: 100%; padding: 12px; margin-top: 6px; }
.nb-login .nb-err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 0; }
.nb-hidden { display: none !important; }
/* 弹窗初始 hidden 必须生效：压制 .nb-region-modal 等带 display 的类选择器（作者样式优先级高于 UA 的 [hidden]{display:none}） */
.nb-modal[hidden], .nb-modal-mask[hidden] { display: none !important; }
.nb-switch { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.nb-switch a { color: var(--primary); text-decoration: none; margin-left: 2px; }
.nb-switch a:hover { text-decoration: underline; }

/* 错误弹窗（普通网页固定遮罩，无 side-panel 裁剪问题） */
.nb-modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: none; align-items: center; justify-content: center; z-index: 2147483647;
}
.nb-modal-mask.show { display: flex; }
.nb-modal {
  width: 360px; max-width: 90vw; background: #fff; border-radius: 16px; padding: 26px 24px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: nb-pop .16s ease;
}
.nb-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; text-align: left; }
.nb-modal-head .nb-modal-title { margin: 0; }
.nb-modal .nb-drawer-close { font-size: 22px; line-height: 1; color: #9aa3b2; background: none; border: none; cursor: pointer; padding: 0 2px; }
.nb-modal .nb-drawer-close:hover { color: #475569; }
@keyframes nb-pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.nb-modal-icon {
  width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%;
  background: #fee2e2; color: var(--danger); font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.nb-modal-title { margin: 0 0 8px; font-size: 18px; }
.nb-modal-msg { color: #374151; font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-line; }
.nb-modal-code {
  margin-top: 10px; font-size: 12px; color: #b91c1c; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: 8px; padding: 6px 10px; word-break: break-all;
}
.nb-modal-ok { margin-top: 18px; width: 100%; padding: 10px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-size: 14px; cursor: pointer; }
.nb-modal-ok:hover { background: var(--primary-d); }

/* 顶部用户名下拉菜单（参照插件 authMenu） */
.nb-userbox { position: relative; display: flex; align-items: center; }
.nb-user-trigger {
  display: flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  background: transparent; border: none; padding: 6px 8px; border-radius: 10px; color: var(--text); font-size: 14px;
}
.nb-user-trigger:hover { background: var(--bg-secondary); }
.nb-user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.nb-user-avatar-icon { display: block; width: 16px; height: 16px; }
.nb-user-name { font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.nb-user-caret { font-size: 10px; color: var(--muted); }
.nb-user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.15);
  padding: 6px; z-index: 120; text-align: left;
}
.nb-user-menu[hidden] { display: none; }
.nb-user-menu-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.nb-user-menu-name { font-weight: 600; font-size: 14px; }
.nb-user-menu-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.nb-user-menu-item {
  display: block; padding: 9px 12px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--text);
  text-decoration: none;
}
.nb-user-menu-item:hover { background: var(--primary-light); color: var(--primary); }
.nb-user-menu-item.danger { color: #ef4444; }
.nb-user-menu-item.danger:hover { background: #fef2f2; color: #ef4444; }

/* 通用右侧抽屉（团队管理等设置弹窗） */
.nb-drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; opacity: 0; pointer-events: none; transition: opacity .25s; }
.nb-drawer-mask.show { opacity: 1; pointer-events: auto; }
.nb-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 92vw); background: #fff;
  box-shadow: -8px 0 40px rgba(0,0,0,.15); z-index: 501; transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column;
}
.nb-drawer.show { transform: translateX(0); }
/* 左侧抽屉（详情图模块设置等） */
.nb-drawer-left { left: 0; right: auto; transform: translateX(-100%); box-shadow: 8px 0 40px rgba(0,0,0,.15); }
.nb-drawer-left.show { transform: translateX(0); }
/* 修复：带 display:flex 的字段容器使用 hidden 时无法隐藏（被 display:flex 覆盖） */
.nb-field-inline[hidden], .nb-field-block[hidden] { display: none; }
.nb-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.nb-drawer-title { font-size: 15px; font-weight: 600; }
.nb-drawer-close { background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; width: 30px; height: 30px; }
.nb-drawer-body { padding: 16px; overflow: auto; }
.nb-team-balance { font-size: 14px; margin-bottom: 8px; }
.nb-team-balance b { color: var(--primary); }
.nb-team-err { color: #ef4444; font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.nb-team-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.nb-team-row { display: flex; gap: 8px; align-items: center; }
.nb-team-row .nb-input { flex: 1; }
.nb-team-members-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.nb-team-members { display: flex; flex-direction: column; gap: 8px; }
.nb-team-member { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; gap: 8px; }
.nb-tm-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nb-tm-name { font-weight: 500; }
.nb-tm-phone { font-size: 12px; color: var(--muted); }
.nb-tm-tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--bg-secondary); color: var(--muted); }
.nb-tm-tag.owner { background: #fef3c7; color: #b45309; }
.nb-tm-tag.on { background: #dcfce7; color: #15803d; }
.nb-tm-tag.off { background: #fee2e2; color: #b91c1c; }
.nb-tm-tag.pending { background: #fef9c3; color: #a16207; }
.nb-tm-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 账户明细抽屉 */
.nb-acc-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.nb-acc-tab { flex: 1; padding: 8px 0; border: 1px solid var(--line); background: var(--bg-secondary); color: var(--muted); border-radius: 8px; font-size: 13px; cursor: pointer; transition: all .15s; }
.nb-acc-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.nb-acc-filters { margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.nb-acc-frow { display: flex; gap: 8px; align-items: center; }
.nb-acc-frow .nb-input { flex: 1; }
.nb-acc-drow { display: flex; gap: 8px; align-items: center; }
.nb-acc-date-label { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.nb-acc-drow .nb-input { flex: 1; min-width: 0; }
.nb-acc-sep { color: var(--muted); font-size: 13px; }
.nb-acc-table { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.nb-acc-row { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; gap: 8px; }
.nb-acc-row:last-child { border-bottom: none; }
.nb-acc-row-head { background: var(--bg-secondary); font-weight: 600; color: var(--muted); position: sticky; top: 0; z-index: 1; }
.nb-acc-c-time { flex: 0 0 124px; }
.nb-acc-c-feat { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-acc-c-pts { flex: 0 0 64px; text-align: right; font-weight: 600; }
.nb-acc-c-pts.deduct { color: #dc2626; }
.nb-acc-c-pts.recharge { color: #16a34a; }
.nb-acc-c-bal { flex: 0 0 76px; text-align: right; color: var(--muted); }
.nb-acc-list { min-height: 120px; }
.nb-acc-empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.nb-acc-loading { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.nb-acc-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 12px; flex-shrink: 0; }
.nb-acc-pageinfo { font-size: 13px; color: var(--muted); }

/* 修改密码抽屉 */
.nb-field { display: block; margin-bottom: 14px; }
.nb-field .nb-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.nb-pwd-err { color: #ef4444; font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.nb-pwd-submit { width: 100%; padding: 11px; margin-top: 4px; }

/* 轻提示 */
.nb-toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: all .25s ease; z-index: 2147483647; pointer-events: none;
}
.nb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.nb-toast-warn { background: #b45309; }

/* === 自定义生图操作面板细节 === */
.nb-block { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.nb-block:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.nb-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.nb-block-title { font-size: 15px; font-weight: 600; color: var(--text); }
.nb-block-actions { display: flex; gap: 8px; }
.nb-badge { font-size: 12px; color: var(--muted); background: #f1f5f9; border-radius: 999px; padding: 2px 8px; font-weight: 500; }

.nb-upload {
  border: 1.5px dashed #cbd5e1; border-radius: 12px; background: #f8fafc;
  padding: 18px; text-align: center; cursor: pointer; transition: border-color .12s, background .12s;
}
.nb-upload:hover { border-color: var(--primary); background: #eef2ff; }
.nb-upload-sub { padding: 12px; }
.nb-upload-hint { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; align-items: center; }
.nb-upload-icon { font-size: 22px; line-height: 1; color: var(--primary); }
/* 参考图上传区：生成搭配方案时的忙碌态（覆盖上传提示，显示生成中） */
.nb-upload-loading { display: none; flex-direction: column; gap: 8px; align-items: center; color: var(--primary); font-size: 13px; }
.nb-upload-loading .spinner { width: 22px; height: 22px; border-width: 3px; }
.nb-upload.is-busy { border-color: var(--primary); background: #eef2ff; cursor: default; pointer-events: none; }
.nb-upload.is-busy .nb-upload-hint { display: none; }
.nb-upload.is-busy .nb-upload-loading { display: flex; }
.nb-upload.is-busy .nb-upload-plans { display: none; }

/* 参考图上传区：已选搭配方案展示态（确认方案后替换上传提示，只显示标签 chip） */
.nb-upload-plans { display: none; }
.nb-upload.has-plans .nb-upload-hint { display: none; }
.nb-upload.has-plans .nb-upload-plans { display: block; }
.nb-upload-plans-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 8px; }
.nb-upload-plans-icon { font-size: 16px; }
.nb-upload-plans-count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; background: #f0f0f0; border-radius: 10px; padding: 1px 8px; }
.nb-upload-plans-list { display: flex; flex-wrap: wrap; gap: 8px; }
.nb-plan-tag-chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; color: var(--primary); background: #eef2ff; border: 1px solid #c5d0ff; border-radius: 14px; padding: 4px 12px; white-space: nowrap; }

/* 已选方案时：隐藏"生成搭配方案"，显示"重新选择方案" */
#refBlock.has-plans #genPlanBtn { display: none !important; }
#refBlock.has-plans #reselectPlanBtn { display: inline-flex !important; }
#refBlock.has-plans #refAdd { display: none !important; }

/* 主图生成专用 */
.nb-func-desc { color: var(--muted); font-size: 13px; margin: 4px 0 14px; line-height: 1.6; }
.nb-count-badge { font-size: 12px; color: var(--primary); background: #eef2ff; border-radius: 10px; padding: 2px 8px; font-weight: 600; }
.nb-upload-actions { display: flex; gap: 8px; margin-top: 10px; }
.nb-hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 6px; }
.nb-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.nb-toggle-row input:disabled { cursor: not-allowed; }
.nb-toggle-row:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.nb-toggle-label { font-size: 14px; color: var(--text); font-weight: 600; }
.nb-toggle-hint { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 旋钮开关（左关右开）：隐藏原生 checkbox，用轨道 + 滑块绘制 */
.nb-knob { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.nb-knob input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 2; }
.nb-knob-track { position: absolute; inset: 0; border-radius: 999px; background: #d0d5dd; transition: background .2s; pointer-events: none; }
.nb-knob-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .28); transition: transform .2s; }
.nb-knob input:checked ~ .nb-knob-track { background: var(--primary); }
.nb-knob input:checked ~ .nb-knob-track::after { transform: translateX(18px); }
.nb-knob input:disabled { cursor: not-allowed; }
.nb-knob input:disabled ~ .nb-knob-track { opacity: .5; }

/* 主图生成：上传预览（仿插件 image-preview-item） */
.image-preview-item { position: relative; width: 64px; height: 64px; flex: none; }
.image-preview-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; background: #f1f5f9; }
.image-preview-item .remove-btn {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 1;
  border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 11px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}

/* 主图生成：结果网格 */
.nb-result-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.nb-result-card { width: 150px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.nb-result-thumb { width: 150px; height: 150px; object-fit: cover; display: block; background: #f1f5f9; }
.nb-result-label { font-size: 12px; color: var(--text); padding: 6px 8px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-result-card .nb-result-actions { padding: 0 8px 8px; }

/* 参考图画廊：大缩略图卡片网格（仿插件版 image-preview-item 网格） */
.nb-ref-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.nb-ref-item {
  position: relative;
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: default;
}
.nb-ref-item .nb-ref-thumb { display: block; width: 100%; height: 100%; object-fit: cover; background: #f1f5f9; cursor: zoom-in; }
/* 未上传参考图时的占位槽位：始终展示指向标签位置，点击槽位触发上传 */
.bgswap-ref-placeholder {
  display: flex; align-items: center; justify-content: center;
  border-style: dashed;
  background: #f8fafc;
  cursor: pointer;
}
.bgswap-ref-placeholder .bgswap-ref-ph-hint {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding-bottom: 34px; /* 底部留出角色标记条空间 */
  color: var(--muted); font-size: 12px; pointer-events: none;
}
.bgswap-ref-placeholder .bgswap-ref-ph-hint .nb-upload-icon { font-size: 22px; }
/* 实拍图素材上传后抠图中遮罩 */
.nb-ref-item.is-seg-loading::after {
  content: '识别中…';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 13px; border-radius: 10px;
}
.nb-ref-item.is-seg-error { opacity: .55; }
/* 识别中遮罩铺满整图，移除按钮必须浮到遮罩之上，否则这 5 秒里删不掉这张图 */
.nb-ref-item.is-seg-loading .nb-remove { z-index: 3; }
.nb-ref-item .nb-seg-tag {
  position: absolute; bottom: 4px; left: 4px;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(16,185,129,.9); color: #fff; font-size: 11px;
}
.nb-ref-item .nb-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; line-height: 1;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 13px;
  cursor: pointer; opacity: 0; transition: opacity .2s;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.nb-ref-item:hover .nb-remove { opacity: 1; }
.nb-ref-item .nb-super {
  position: absolute; top: 4px; left: 4px;
  padding: 2px 8px; border: none; border-radius: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px;
  cursor: pointer; opacity: 0; transition: opacity .2s;
}
.nb-ref-item:hover .nb-super { opacity: 1; }
.nb-ref-enlarge {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  padding: 2px 10px; border: none; border-radius: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px; white-space: nowrap;
  cursor: pointer; opacity: 0; transition: opacity .2s;
}
.nb-ref-item:hover .nb-ref-enlarge { opacity: 1; }
/* 换装换背景页：底部角色标签条占位，放大按钮上移避免重叠 */
body[data-function="image-bgswap"] .nb-ref-enlarge { bottom: 28px; }
.nb-ref-badge {
  position: absolute; top: 4px; left: 4px;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(16,185,129,.9); color: #fff; font-size: 11px;
}

/* 细节补充抽屉：每张 = 大图 + 图下文字说明输入（覆盖 nb-ref-item 的方形卡片） */
#nbDetailSuppDrawer { width: min(520px, 94vw); }
.nb-detail-supp-item {
  width: 100% !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  box-sizing: border-box;
  border-width: 1px;
  overflow: hidden;
  margin-bottom: 12px;
}
.nb-detail-supp-item .nb-detail-supp-img {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid var(--line);
}
.nb-detail-supp-item .nb-detail-supp-img img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #f1f5f9;
}
.nb-detail-supp-item .nb-detail-supp-text {
  width: 100%;
  box-sizing: border-box;
  min-height: 54px;
  padding: 6px 8px;
  font-size: 13px;
}
.nb-detail-supp-item .nb-remove {
  position: absolute !important;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  opacity: 1;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
}
.nb-detail-supp-item .nb-remove:hover { background: rgba(0,0,0,.75); }

/* 内联「添加参考图」按钮：紧跟在已上传参考图旁边，做成小按钮样式 */
.nb-ref-add {
  position: relative;
  flex: 0 0 auto;
  min-width: 130px;
  max-width: 180px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  transition: border-color .12s, background .12s, color .12s;
}
.nb-ref-add:hover, .nb-ref-add:focus { border-color: var(--primary); background: var(--primary-light); color: var(--primary); outline: none; }
.nb-ref-add.nb-dragover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.nb-ref-add-icon { font-size: 16px; line-height: 1; font-weight: 400; }
.nb-ref-add-text { font-size: 13px; }

/* === 放大 / 超分 右侧抽屉（参考图，仿插件 upscale-overlay） === */
.nb-upscale-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 400; display: none; }
.nb-upscale-overlay.show { display: block; }
.nb-upscale-panel {
  position: fixed; top: 0; left: 0; bottom: 0; right: auto;
  width: 440px; max-width: 92vw;
  background: #fff; box-shadow: 8px 0 40px rgba(0,0,0,.15);
  z-index: 401; display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.nb-upscale-overlay.show .nb-upscale-panel { transform: translateX(0); }
.nb-upscale-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  border-bottom: 1px solid var(--line); background: var(--bg-secondary); flex-shrink: 0;
}
.nb-upscale-close {
  background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer;
  padding: 0; line-height: 1; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; border-radius: 6px;
}
.nb-upscale-close:hover { background: var(--line); color: var(--text); }
.nb-upscale-body { padding: 16px; overflow-y: auto; flex: 1; }
.nb-upscale-ref { width: 100%; max-height: 320px; object-fit: contain; border-radius: 6px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--bg-secondary); }
/* 编辑参考图抽屉：图片容器（相对定位承载裁剪选区层） */
.nb-upscale-ref-wrap { position: relative; margin-bottom: 8px; }
.nb-upscale-ref-wrap .nb-upscale-ref { margin-bottom: 0; pointer-events: none; }
.nb-upscale-ref-wrap.cropping { cursor: crosshair; }
.nb-upscale-ref-wrap.cropping .nb-upscale-ref { user-select: none; -webkit-user-select: none; }
.nb-upscale-crop-layer { position: absolute; inset: 0; pointer-events: none; }
.nb-upscale-crop-box { position: absolute; display: none; border: 2px dashed #2563eb; background: rgba(37, 99, 235, 0.18); box-sizing: border-box; }
.nb-upscale-crop-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.nb-upscale-crop-toolbar .nb-btn { flex: 0 0 auto; }
.nb-upscale-crop-toolbar .nb-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.nb-upscale-crop-hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.nb-upscale-status { padding: 8px 0; font-size: 12px; text-align: center; border-radius: 4px; margin-bottom: 8px; display: none; }
.nb-upscale-status.show { display: block; }
.nb-upscale-status.error { background: #fee2e2; color: #b91c1c; }
.nb-upscale-body .nb-field { margin-bottom: 12px; }
.nb-upscale-body .nb-field .nb-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.nb-upscale-field-row { display: flex; gap: 12px; }
.nb-upscale-field-row .nb-field { flex: 1; margin-bottom: 12px; }
.nb-upscale-body textarea, .nb-upscale-body .nb-select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: #fff; color: var(--text); outline: none; transition: border-color .2s;
}
.nb-upscale-body textarea:focus, .nb-upscale-body .nb-select:focus { border-color: var(--primary); }
.nb-upscale-body textarea { height: 72px; resize: vertical; }
.nb-upscale-footer { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg-secondary); flex-shrink: 0; }
.nb-upscale-footer .nb-btn { width: 100%; }
/* 文件列表旧样式（已弃用，保留避免其它页面告警） */
.nb-ref-meta { flex: 1; min-width: 0; }
.nb-ref-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-ref-sub { font-size: 11px; color: var(--muted); }
.nb-ref-actions { display: flex; gap: 6px; flex: none; }

/* 换装换背景：参考图卡片底部角色标记（与高级设置相关联，可左右箭头切换指派） */
.bgswap-role-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 10;                      /* 必须盖住参考图 img（img[data-full] 带 zoom-in 灯箱），否则点击箭头/标签会误触全局灯箱 */
  display: flex; flex-wrap: wrap; gap: 3px; justify-content: center;
  padding: 6px 4px 6px;
  background: linear-gradient(to top, rgba(0,0,0,.6), rgba(0,0,0,0));
}
/* 占位坑位（空上传区）内的角色条不可交互：点击直接穿透到坑位 = 上传该坑位；
   否则该 absolute 层（z-index:10）会"挡住"坑位点击（旧逻辑下被 role-bar 分支拦截，文件框不弹，2026-08-13） */
.bgswap-ref-placeholder .bgswap-role-bar { pointer-events: none; }
.role-tag { display: inline-flex; align-items: center; gap: 2px; background: #6b7280; color: #fff; border: 1px solid transparent; border-radius: 999px; padding: 1px 6px; font-size: 11px; position: relative; z-index: 2; }
.role-label { font-weight: 600; cursor: default; }
/* 「服装」标签可点击换搭配：hover 高亮 + 手型（文字切换由 JS 处理，2026-08-13） */
.role-tag-outfit { background: #8a4dff; cursor: pointer; }
.role-tag-outfit:hover { background: #7a3df0; box-shadow: 0 2px 6px rgba(138,77,255,.4); }
.role-tag-outfit .role-label { cursor: pointer; }
/* 「模特」标签（2026-08-14）：hover 文字变「换模特」，点击打开换模特抽屉 */
.role-tag-model { background: #10b981; cursor: pointer; }
.role-tag-model:hover { background: #059669; box-shadow: 0 2px 6px rgba(16,185,129,.4); }
.role-tag-model .role-label { cursor: pointer; }
/* 服装标签禁用态：识别到仅一件衣服/识别中/失败 → 换搭配不可用 */
.role-tag-outfit.role-tag-disabled { background: #a5a5b0; cursor: not-allowed; }
.role-tag-outfit.role-tag-disabled:hover { background: #a5a5b0; box-shadow: none; }
.role-tag-outfit.role-tag-disabled .role-label { cursor: not-allowed; }
/* 服装标签文字右侧的 ✎ 编辑图标（换搭配入口） */
.role-edit { font-size: 10px; margin-left: 2px; opacity: .85; cursor: pointer; line-height: 1; transition: opacity .12s, transform .12s; }
.role-edit:hover { opacity: 1; transform: scale(1.2); }
.role-move { border: none; background: transparent; color: #fff; cursor: pointer; font-size: 14px; line-height: 1; padding: 4px 7px; z-index: 2; }
.role-move:hover { color: #e5e7eb; }


.nb-btn-sm { padding: 6px 12px; font-size: 13px; }
/* 换姿势按钮：常驻可见，未生成可轮换提示词时置灰禁用 */
#promptRefreshBtn:disabled { opacity: .45; cursor: not-allowed; }
/* 细节补充按钮：浅灰色（带一点蓝紫调，比纯灰稍鲜艳） */
#detailSuppBtn {
  background: #e4e8f2;
  border-color: #c9d2e4;
  color: #46536b;
}
#detailSuppBtn:hover { background: #d7deec; }
.nb-btn-xs { padding: 4px 9px; font-size: 12px; }
.nb-btn-block { width: 100%; margin-top: 18px; padding: 12px; font-size: 15px; }
.nb-btn.danger { color: var(--danger); border-color: var(--danger); }
.nb-btn.danger:hover { background: var(--danger); color: #fff; }
.nb-btn-cost { font-size: 11px; opacity: .85; margin-left: 4px; font-weight: 400; }
/* 积分铜钱图标：与插件版 POINTS_ICON 一致，所有积分数值前统一使用 */
.nb-coin-wrap { display: inline-flex; align-items: center; gap: 3px; }
.nb-coin { width: 12px; height: 12px; flex: none; vertical-align: middle; }
.nb-coin-num { font-weight: 600; }
.nb-btn-cost .nb-coin { width: 11px; height: 11px; }

.nb-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nb-row-between { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.nb-muted { color: var(--muted); font-size: 12px; }
.nb-gen-hint { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--primary); font-size: 13px; font-weight: 600; }
.nb-gen-hint.nb-hidden { display: none !important; }
.nb-gen-hint .spinner { width: 14px; height: 14px; border-width: 2px; }

.nb-details > summary { cursor: pointer; user-select: none; }
.nb-details[open] .nb-upload, .nb-details[open] .nb-ref-list, .nb-details[open] .nb-field { margin-top: 10px; }

.nb-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; font-size: 13px; color: var(--text); cursor: pointer; }

.nb-result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.nb-result-cell { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 0; background: #fff; overflow: visible; min-width: 0; }
.nb-result-cell .nb-result-img { display: block; width: auto; max-width: 100%; height: var(--nb-img-h) !important; margin: 0 auto; border-radius: 8px; cursor: zoom-in; background: var(--bg-secondary); object-fit: contain; }
.nb-result-cell:hover .img-edit-btn { opacity: 1; }
/* 生成中占位坑：aspect-ratio 由 createResultSlots 按生成比例注入，loading 文字水平垂直居中；
   无比例时 min-height 兜底避免高度塌陷；填图/报错后由 JS 移除该类恢复自然高度 */
.nb-result-cell.nb-result-cell-loading { min-height: 200px; background: var(--bg-secondary, #f1f5f9); }
.nb-result-cell.nb-result-cell-loading .nb-gen-loading { gap: 10px; }
/* 坑位 loading/error 状态撑满 cell/card */
.nb-result-cell > .nb-gen-loading,
.nb-result-cell > .nb-result-error,
.nb-result-card > .nb-gen-loading,
.nb-result-card > .nb-result-error { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.nb-result-cell .nb-result-actions { margin-top: 8px; }

/* 结果图片按张数自适应列数与最大宽度（操作面板 500 / 历史 200 后右侧收窄；2 张收敛到更合适尺寸） */
.nb-result-grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); max-width: 650px; --nb-img-h: 438px; }
.nb-result-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 680px; }
.nb-result-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 900px; }
.nb-result-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 680px; }
.nb-result-grid[data-count] { margin: 0 auto; }

@media (max-width: 860px) {
  .nb-main { grid-template-columns: 1fr; }
  .nb-result-img { height: var(--nb-img-h); max-height: 50vh; }
  .nb-header { grid-template-columns: 1fr; justify-items: center; gap: 10px; }
  .nb-logo, .nb-userbox { justify-self: center; }
  .nb-topnav { width: 100%; flex-wrap: wrap; justify-content: center; }
  /* 示例作品九宫格：窄屏降为 2 列，避免过挤 */
  .nb-demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== 首页历史：分组卡片（仿插件结果页：同任务ID聚合成一张卡） ===== */
.nb-hist-wrap { max-width: 820px; margin: 0 auto; padding: 0 24px 32px; }
.nb-hist-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 6px; flex-wrap: wrap; }
.nb-hist-title { font-size: 20px; margin: 0; }
.nb-hist-tabs { display: flex; align-items: flex-end; gap: 4px; flex: 1; border-bottom: 1px solid #ececec; }
.nb-hist-tab { padding: 8px 14px 9px; font-size: 15px; font-weight: 500; color: #9ca3af; background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color .15s, border-color .15s; line-height: 1.4; }
.nb-hist-tab:hover { color: #4b5563; }
.nb-hist-tab.active { color: #111827; font-weight: 700; border-bottom-color: var(--primary); }
.nb-hist-tab.disabled { color: #d5d7e0; cursor: not-allowed; }
.nb-hist-user { margin-left: 12px; font-size: 12px; font-weight: 500; color: var(--muted); background: #f3f4f6; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.nb-hist-stats { color: var(--muted); font-size: 13px; margin: 4px 0 14px; min-height: 18px; }
.nb-hist-list { display: flex; flex-direction: column; gap: 20px; }

/* 生成记录筛选栏（生成记录列表正上方）：选项变动直接查询，无查询按钮 */
.nb-hist-filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.nb-hist-filterbar .nb-select { width: auto; flex: 0 0 auto; }
.nb-hist-filterbar .nb-date { width: auto; }
.nb-date { padding: 8px 10px; font-size: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); font-family: inherit; }
.nb-filter-sep { font-size: 13px; color: var(--muted); white-space: nowrap; }
.nb-filter-reset { flex: 0 0 auto; margin-left: auto; padding: 8px 14px; font-size: 13px; color: var(--primary); background: transparent; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: background .15s, border-color .15s; }
.nb-filter-reset:hover { background: var(--bg-secondary); border-color: var(--primary); }

.nb-hist-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.nb-hist-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg-secondary); border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.nb-feature-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; background: var(--primary-light); color: var(--primary); border-radius: 4px; white-space: nowrap; }
.nb-hist-model { font-size: 12px; color: var(--text-secondary); }
.nb-hist-params { font-size: 12px; color: #6b7280; }
/* 任务ID徽标（首页卡片 / 功能页「当前结果」共用）：前6位+省略号+复制图标 */
.nb-hist-taskid, .nb-result-taskid {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: #4338ca; background: #eef2ff; padding: 2px 8px;
  border-radius: 4px; white-space: nowrap; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.nb-hist-taskid:hover, .nb-result-taskid:hover { background: #e0e7ff; }
.nb-taskid-copy { font-size: 12px; line-height: 1; opacity: .7; }
.nb-taskid-copy:hover { opacity: 1; }
/* 首页卡片：参数（比例/分辨率/超分/积分）单独第二行 */
.nb-hist-subhead { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--bg-secondary); border-bottom: 1px solid var(--line); font-size: 12px; flex-wrap: wrap; }
.nb-hist-count { font-size: 12px; color: var(--muted); }
.nb-hist-prompt-meta { font-size: 12px; color: #6b7280; flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-hist-time { font-size: 12px; color: var(--muted); margin-left: auto; }
.nb-download-all { margin-left: 12px; font-size: 12px; padding: 5px 12px; border: 1px solid #93c5fd; background: #bfdbfe; color: #fff; border-radius: 6px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.nb-download-all:hover { background: #93c5fd; }

/* 首页卡片：生成中 / 失败状态 */
.nb-hist-status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; color: #fff; white-space: nowrap; }
.nb-hist-status.is-pending { background: #4f46e5; }
.nb-hist-status.is-failed { background: #dc2626; }
.nb-hist-card.is-pending { border-color: #c7d2fe; }
.nb-hist-card.is-failed { border-color: #fecaca; }
/* 无结果占位格（生成中 / 失败）：与图片格等高，不可点开灯箱 */
.nb-hist-cell-ph { cursor: default; background: #f8fafc; border: 1px dashed var(--line); }
.nb-hist-cell-ph.is-failed { background: #fef2f2; border-color: #fecaca; }
.nb-hist-ph-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: var(--nb-img-h, 180px); min-width: 120px; padding: 8px; }
.nb-hist-ph-icon { font-size: 18px; line-height: 1; color: #dc2626; }
.nb-hist-cell-ph.is-pending .nb-hist-ph-icon { color: var(--primary); }
.nb-hist-ph-text { font-size: 12px; color: var(--text-secondary); }
.nb-hist-cell-ph.is-failed .nb-hist-ph-text { color: #dc2626; }
.nb-hist-ph-err { font-size: 11px; color: #b91c1c; text-align: center; line-height: 1.4; word-break: break-all; max-width: 160px; }

.nb-ref-thumbs { display: flex; gap: 6px; padding: 10px 14px 0; flex-wrap: wrap; }
.nb-ref-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-secondary); }
/* 参考视频缩略（视频复刻等参考素材为 mp4 时显示首帧，点击进视频灯箱播放） */
.nb-ref-video-thumb { position: relative; width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--line); overflow: hidden; cursor: pointer; background: #111; }
.nb-ref-video-thumb .nb-ref-video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.nb-ref-video-badge { position: absolute; left: 2px; bottom: 2px; font-size: 9px; line-height: 1; color: #fff; background: rgba(0,0,0,.55); padding: 2px 4px; border-radius: 3px; }

.nb-hist-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 8px; padding: 14px; width: fit-content; margin: 0 auto; max-width: 100%; }
.nb-hist-cell { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; background: #f1f5f9; }
.nb-hist-cell img.nb-hist-img { display: block; width: auto; max-width: 100%; height: var(--nb-img-h) !important; margin: 0 auto; border-radius: 8px; transition: transform .2s; object-fit: contain; }
.nb-hist-cell:hover img.nb-hist-img { transform: scale(1.02); }
/* 视频历史卡：与图片卡同高，点击一律交给外层开视频灯箱（禁用原生控件误触） */
.nb-hist-cell video.nb-hist-img { display: block; width: auto; max-width: 100%; height: var(--nb-img-h) !important; margin: 0 auto; border-radius: 8px; transition: transform .2s; object-fit: contain; background: #000; pointer-events: none; }
.nb-hist-cell:hover video.nb-hist-img { transform: scale(1.02); }
.nb-hist-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; font-size: 15px; line-height: 38px; text-align: center; pointer-events: none; }
.nb-img-tag { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.55); color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 11px; pointer-events: none; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 批量模板生图：每张结果图自己的模板参考图缩略图（图上方、左对齐） */
.nb-hist-cell-ref { padding: 6px 6px 0; text-align: left; }
.nb-hist-cell-ref-img { display: inline-block; width: 36px; height: 36px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background: var(--bg-secondary); cursor: zoom-in; margin-right: 4px; vertical-align: middle; }
.nb-hist-cell-ref-img:last-child { margin-right: 0; }

/* 结果图包装层：宽度跟随图片（fit-content），提示词浮层相对它定位，避免超出图片左右两侧 */
.nb-result-img-wrap {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

/* 悬停提示词浮层（仿插件结果页） */
.img-prompt-overlay { position: absolute; left: 0; right: 0; bottom: 0; max-height: 45%; background: linear-gradient(transparent, rgba(0,0,0,.72)); padding: 26px 10px 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 5; border-radius: 0 0 12px 12px; }
.nb-hist-cell:hover .img-prompt-overlay,
.nb-result-cell:hover .img-prompt-overlay,
.nb-result-card:hover .img-prompt-overlay,
.nb-result-wrap:hover .img-prompt-overlay { opacity: 1; }
.img-prompt-text { color: #fff; font-size: 12px; line-height: 1.5; word-break: break-all; user-select: text; }

/* 结果图提示词单行条：悬停浮出，单行省略 + 复制 + 标记可用 */
.img-prompt-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  background: rgba(17, 24, 39, 0.66);
  color: #fff; font-size: 12px; line-height: 1.2;
  opacity: 0; transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none; z-index: 6;
  border-radius: 0 0 8px 8px;
  backdrop-filter: blur(2px);
}
.nb-hist-cell:hover .img-prompt-bar,
.nb-result-cell:hover .img-prompt-bar,
.nb-result-card:hover .img-prompt-bar,
.nb-result-img-wrap:hover .img-prompt-bar { opacity: 1; transform: translateY(0); }
.img-prompt-bar .img-prompt-line {
  flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: default; user-select: text;
}
.img-prompt-bar button {
  flex: 0 0 auto; pointer-events: auto;
  display: inline-flex; align-items: center; gap: 3px;
  border: none; background: rgba(255, 255, 255, 0.14); color: #fff;
  border-radius: 6px; padding: 3px 6px; font-size: 12px; cursor: pointer;
  line-height: 1; transition: background .15s;
}
.img-prompt-bar button:hover { background: rgba(255, 255, 255, 0.28); }
.img-prompt-mark .thumb { width: 14px; height: 14px; display: block; }
.img-prompt-mark .thumb path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.img-prompt-mark.is-marked { background: rgba(22, 163, 74, 0.9); }
.img-prompt-mark.is-marked .thumb path { fill: currentColor; stroke: currentColor; }
.img-prompt-mark .mark-label { font-size: 11px; }
.img-prompt-mark:disabled { opacity: .55; cursor: default; }

/* 编辑按钮 + 操作菜单（仿插件结果页） */
.img-edit-btn { position: absolute; top: 6px; right: 6px; height: 26px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 4px; padding: 0 8px; opacity: 0; transition: opacity .15s; z-index: 6; }
.nb-hist-cell:hover .img-edit-btn { opacity: 1; }
.img-edit-btn:hover { background: rgba(0,0,0,.75); }
.action-menu { display: none; position: absolute; right: 6px; top: 38px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 50; min-width: 150px; padding: 4px 0; }

.action-menu-item { padding: 8px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.action-menu-item:hover { background: var(--primary-light); color: var(--primary); }
.action-menu-item.danger { color: #ef4444; }
.action-menu-item.danger:hover { background: #fef2f2; }
.action-menu-divider { height: 1px; background: var(--line); margin: 4px 0; }

/* 视频编辑按钮 + 菜单（2026-08-18 提升画质入口）：样式与图片编辑按钮完全一致 */
.vid-edit-btn { position: absolute; top: 6px; right: 6px; height: 26px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 4px; padding: 0 8px; opacity: 0; transition: opacity .15s; z-index: 7; }
.nb-result-card:hover .vid-edit-btn, .nb-result-video:hover .vid-edit-btn, .nb-hist-cell:hover .vid-edit-btn { opacity: 1; }
.vid-edit-btn:hover { background: rgba(0,0,0,.75); }
.vid-action-menu { display: none; position: absolute; right: 6px; top: 38px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 50; min-width: 150px; padding: 4px 0; }

.nb-hist-empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* 新用户空状态（方案B）：后台示例作品展示（数据源 /api/promo，与推广页共用示例管理） */
.nb-demo-empty { padding: 6px 0 2px; }
.nb-demo-head { font-size: 17px; font-weight: 700; color: var(--text); }
.nb-demo-sub { font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.nb-demo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.nb-demo-card { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; text-decoration: none; transition: border-color .15s; }
.nb-demo-card:hover { border-color: var(--primary); }
.nb-demo-thumb { position: relative; width: 100%; aspect-ratio: 1 / 1; background: #f1f5f9; overflow: hidden; }
.nb-demo-media { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-demo-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; font-size: 13px; line-height: 34px; text-align: center; pointer-events: none; }
.nb-demo-name { font-size: 13px; font-weight: 600; color: var(--text); padding: 0 10px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-demo-foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }
.nb-demo-loading { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; }

/* 灯箱 */
.nb-lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 900; align-items: center; justify-content: center; flex-direction: column; padding: 24px; }
.nb-lightbox.show { display: flex; }
.nb-lightbox-inner { max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; overflow: visible; }
/* -webkit-user-drag:none / user-select:none：关掉图片原生拖拽与选中，否则按住拖会启动浏览器拖图，
   吃掉 pointermove，灯箱平移完全失效（2026-09-07 修；JS 侧另加 draggable="false" 与 dragstart 拦截） */
.nb-lightbox-inner img { max-width: 92vw; max-height: 80vh; border-radius: 8px; cursor: zoom-in; transform-origin: center center; will-change: transform; touch-action: none; -webkit-user-drag: none; user-select: none; }
.nb-lightbox.zoomed .nb-lightbox-inner img { cursor: grab; }
.nb-lightbox-info { color: #e5e7eb; font-size: 13px; margin-top: 10px; text-align: center; }
/* 视频灯箱：点遮罩关闭，视频本体保留原生控件（z-index 高于抽屉 501，避免被抽屉盖住） */
.nb-lightbox-video { z-index: 950; }
.nb-lightbox-inner video { max-width: 92vw; max-height: 78vh; border-radius: 8px; background: #000; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
/* 视频灯箱·等待 COS 就绪时的加载提示 */
.nb-lightbox-loading { color: #cbd5e1; font-size: 14px; padding: 24px 8px; display: inline-block; }
.nb-lightbox-close { position: absolute; top: 18px; right: 22px; width: 38px; height: 38px; border: none; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; z-index: 2; }
.nb-lightbox-close:hover { background: rgba(255,255,255,.3); }
/* 灯箱下载按钮（图片/视频通用，右上角，比关闭按钮大） */
.nb-lightbox-download {
  position: absolute; top: 15px; right: 72px; z-index: 3;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 11px 18px; font-size: 16px; font-weight: 600; line-height: 1;
  color: #fff; background: var(--primary, #2563eb); border: none; border-radius: 10px;
  cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.nb-lightbox-download:hover { background: var(--primary-d, #1d4ed8); }
/* 图片灯箱：点击图片切换为原图尺寸(1:1)，遮罩内可滚动查看 */
.nb-lightbox.lb-original .nb-lightbox-inner { overflow: auto; max-width: 96vw; max-height: 90vh; }
.nb-lightbox.lb-original .nb-lightbox-inner img { max-width: none; max-height: none; cursor: zoom-out; }

/* 结果视频缩略图（点击灯箱播放） */
.nb-result-video { position: relative; display: inline-block; max-width: 100%; cursor: pointer; border-radius: 8px; overflow: hidden; background: transparent; align-self: center; }
.nb-result-video-poster { display: block; width: auto; max-width: 100%; height: var(--nb-img-h); object-fit: contain; border-radius: 8px; background: #000; }
/* 视频结果恒为单条：放大 25%（350 → 438px，区域 max-width 650px） */
.nb-result-card .nb-result-video { max-width: 650px; }
.nb-result-card .nb-result-video-poster { height: 438px; }
.nb-play-badge { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 46px; text-align: center; pointer-events: none; }
.nb-ref-link { color: #93c5fd; cursor: pointer; text-decoration: underline; }
.nb-ref-video:hover { color: #bfdbfe; }

/* 抽屉（仿插件：右侧滑出） */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 800; display: none; }
.drawer-backdrop.show { display: block; }
.drawer-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 92vw; background: #fff; box-shadow: -8px 0 40px rgba(0,0,0,.15); z-index: 801; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1); }
.drawer-panel.show { transform: translateX(0); }
.drawer-header { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.drawer-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-secondary); line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; min-height: 0; }
.drawer-body .form-group { margin-bottom: 14px; }
.drawer-body label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 5px; color: var(--text); }
.drawer-body textarea { width: 100%; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; min-height: 80px; box-sizing: border-box; line-height: 1.6; font-family: inherit; }
.drawer-body select { font-size: 13px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; }
.drawer-body .form-row { display: flex; gap: 12px; }
.drawer-body .form-group.half { flex: 1; }
.drawer-body .detail-section-label { font-size: 13px; font-weight: 600; color: var(--text); margin: 12px 0 6px; }
.drawer-body .detail-ref-box img { max-width: 100%; }
.drawer-body .detail-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-body .detail-preset-item { width: 72px; height: 72px; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; }
.drawer-body .detail-preset-item.selected { border-color: var(--primary); }
.drawer-body .detail-preset-item img { width: 100%; height: 100%; object-fit: cover; }
.drawer-result { text-align: center; margin-top: 14px; }
/* 细节图抽屉内灯箱式查看器：滚轮缩放 + 拖拽平移 + 下载 */
.nb-detail-viewer { margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0b0b0d; }
.nb-detail-viewer-stage { height: 360px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #0b0b0d; }
.nb-detail-viewer-img { max-width: 100%; max-height: 100%; transform-origin: center center; cursor: zoom-in; will-change: transform; user-select: none; -webkit-user-drag: none; touch-action: none; }
.nb-detail-viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border-top: 1px solid var(--line); }
.nb-detail-viewer-bar button { font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; line-height: 1.4; }
.nb-detail-viewer-bar button:hover { background: #f1f5f9; }
.nb-detail-zoom-label { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; }
.nb-detail-download { margin-left: auto; background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 600; }
.nb-detail-download:hover { background: #1d4ed8; }
.drawer-footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg-secondary); flex-shrink: 0; }
.btn { font-size: 13px; padding: 8px 16px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.drawer-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; }
/* 重新生成抽屉：参考图列表（160px 大图 + 放大/裁剪按钮 + 移除；顺序=记录参考图顺序） */
.regen-ref-list { display: flex; flex-wrap: wrap; gap: 10px; }
.regen-ref-item { position: relative; width: 160px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.regen-ref-item .regen-ref-thumb { width: 160px; height: 160px; object-fit: cover; display: block; cursor: zoom-in; background: var(--bg-secondary); }
.regen-ref-item .regen-ref-enlarge { display: block; width: 100%; padding: 6px 0; font-size: 12px; border: none; border-top: 1px solid var(--line); background: #f8fafc; color: var(--text); cursor: pointer; }
.regen-ref-item .regen-ref-enlarge:hover { background: var(--bg-secondary); color: var(--primary); }
.regen-ref-item .regen-ref-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; line-height: 18px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; cursor: pointer; }
.regen-ref-loading { font-size: 12px; color: var(--muted); padding: 4px 0; }
.upload-area-sm { border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); }
.crop-ratios .crop-ratio-btn { font-size: 12px; padding: 5px 10px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.crop-ratios .crop-ratio-btn.crm-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.2); border-top-color: var(--primary); border-radius: 50%; animation: nbspin .7s linear infinite; vertical-align: middle; }
@keyframes nbspin { to { transform: rotate(360deg); } }

/* 生成主图：参考图画廊容器（复用 .nb-ref-item 卡片） */
.nb-ref-preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.nb-upload.nb-dragover { border-color: var(--primary); background: var(--primary-light); }
.nb-ref-preview:empty { margin-top: 0; }

/* 生成主图：结果网格 */
.nb-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; max-width: 960px; margin: 0 auto; }
.nb-result-card { width: 100%; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.nb-result-card .nb-result-img { display: block; width: auto; max-width: 100%; height: var(--nb-img-h) !important; margin: 0 auto; aspect-ratio: auto; object-fit: contain; background: var(--bg-secondary); }
.nb-result-meta { font-size: 12px; color: var(--muted); padding: 6px 10px 0; }
.nb-result-card .nb-btn { margin: 8px 10px 10px; }
/* 所有图像生成功能页的右侧结果区：对齐「生成主图」页
   —— 缩窄历史/表单列 + 放宽整体 max-width，让结果栏（1fr）拿到与主图页一致的宽度，
   这样多图时两列大图的尺寸和主图页完全一致 */
body[data-function="main-image-gen"] .nb-main,
body[data-function="image-bgswap"] .nb-main,
body[data-function="image-custom"] .nb-main,
body[data-function="image-flatlay"] .nb-main,
body[data-function="detail-image-gen"] .nb-main,
body[data-function="template-gen"] .nb-main {
  grid-template-columns: 340px 500px 1fr;
  max-width: 1820px;
}
/* 主图结果卡：需 relative 定位锚点 + visible（默认 overflow:hidden 会裁掉编辑按钮/下拉菜单） */
body[data-function="main-image-gen"] .nb-result-card {
  position: relative;
  overflow: visible;
}
/* 编辑按钮悬停显示（首页用 .nb-hist-cell:hover，主图页用 .nb-result-card:hover） */
body[data-function="main-image-gen"] .nb-result-card:hover .img-edit-btn,
body[data-function="image-bgswap"] .nb-result-cell:hover .img-edit-btn,
body[data-function="image-custom"] .nb-result-cell:hover .img-edit-btn,
body[data-function="image-flatlay"] .nb-result-cell:hover .img-edit-btn { opacity: 1; }

/* ===== 详情图生成（还原插件详情图模块） ===== */
.nb-detail-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.nb-field-inline { display: flex; flex-direction: column; gap: 4px; }
.nb-field-inline .nb-label { font-size: 12px; color: var(--text-secondary); }
.nb-field-block { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.nb-field-block .nb-label { font-size: 12px; color: var(--text-secondary); }
.nb-input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); }
.nb-check { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.nb-btn-ghost { background: var(--bg-secondary); border: 1px solid var(--line); color: var(--text-secondary); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.nb-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* 细节图抽屉 · 系统细节图模板 */
.detail-sys-tpls { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.detail-sys-tpl { width: 60px; cursor: pointer; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #f1f5f9; }
.detail-sys-tpl.selected { border-color: var(--primary); }
.detail-sys-tpl img { width: 100%; display: block; aspect-ratio: 3 / 4; object-fit: cover; }
/* ===================== 模板批量生图 ===================== */
/* 顶部：选择模板按钮 + 封面站位 + 信息 */
.nb-tpl-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-secondary); margin-bottom: 14px; flex-wrap: wrap;
}
.nb-tpl-select { flex-shrink: 0; }
.nb-tpl-cover {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 10px; overflow: hidden;
  border: 1px dashed var(--line); background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.nb-tpl-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-tpl-cover-empty { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.3; padding: 0 4px; }
.nb-tpl-bar-info { flex: 1; min-width: 160px; }
.nb-tpl-name { font-size: 14px; font-weight: 600; color: var(--text); }
.nb-tpl-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.nb-tpl-save { flex-shrink: 0; }

/* 模板抽屉（左侧） */
#tplDrawer { width: min(520px, 94vw); }
.nb-tpl-drawer-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.nb-tpl-drawer-actions .nb-muted { font-size: 12px; }

/* 模板卡片列表 */
.nb-tpl-list { display: flex; flex-direction: column; gap: 8px; }
.nb-tpl-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }
.nb-tpl-card {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s;
}
.nb-tpl-card:hover { border-color: var(--primary); background: var(--primary-light); }
.nb-tpl-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.15); background: var(--primary-light); }
.nb-tpl-thumb {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  background: var(--bg-secondary); display: flex; align-items: center; justify-content: center;
}
.nb-tpl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-tpl-thumb span { font-size: 11px; color: var(--muted); }
.nb-tpl-meta { flex: 1; min-width: 0; }
.nb-tpl-card-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-tpl-card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nb-tpl-pick { flex-shrink: 0; }

/* 模板内图片管理 */
.nb-tpl-editor { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.nb-tpl-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.nb-tpl-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.nb-tpl-img {
  position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--bg-secondary); aspect-ratio: 3 / 4;
}
.nb-tpl-img > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-tpl-img.disabled > img { filter: grayscale(1); opacity: .45; }
.nb-tpl-img-toggle {
  position: absolute; left: 4px; bottom: 4px; padding: 2px 8px; font-size: 11px; line-height: 18px;
  border: none; border-radius: 999px; cursor: pointer; color: #fff; background: var(--primary);
}
.nb-tpl-img-toggle.off { background: rgba(15,23,42,.6); }
.nb-tpl-img-del {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; line-height: 18px;
  border: none; border-radius: 50%; background: rgba(15,23,42,.65); color: #fff; cursor: pointer; font-size: 14px; padding: 0;
}
.nb-tpl-img-del:hover { background: var(--danger); }
.nb-tpl-img-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px dashed var(--line); color: var(--muted); font-size: 12px; cursor: pointer; background: #fff;
}
.nb-tpl-img-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.nb-tpl-img-add .nb-upload-icon { font-size: 22px; line-height: 1; }
.nb-tpl-editor-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== 模板批量生图 · 顶部选择区（3:4 卡片样式） ===== */
.nb-tpl-pickzone {
  display: flex; justify-content: center; align-items: center;
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; background: #fff;
  transition: border-color .15s, background .15s;
}
.nb-tpl-pickzone:hover { border-color: var(--primary); background: #f7f8ff; }
/* 已选模板后整区不可点击（由右上角按钮负责），去掉 hover 高亮 */
.nb-tpl-pickzone.picked { cursor: default; }
.nb-tpl-pickzone.picked:hover { border-color: var(--line); background: #fff; }
.nb-tpl-pick-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 140px;
}
.nb-tpl-pick-card.picked { width: 100%; }
.nb-tpl-pick-cover {
  width: 140px; aspect-ratio: 3 / 4; flex: 0 0 auto; border-radius: 10px; overflow: hidden;
  background: var(--bg-secondary); display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.06);
  position: relative;
}
.nb-tpl-pick-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-tpl-cover-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 8px; line-height: 1.4; }
/* [hidden] 保护：.nb-tpl-pick-cover/.nb-tpl-picked/.tm-tpl-grid 显式 display 会覆盖 HTML hidden 属性（选中模板后占位卡片残留/抽屉 tab 不切换），须用 !important 兜底 */
.nb-tpl-pick-cover[hidden], .nb-tpl-picked[hidden], .tm-tpl-grid[hidden] { display: none !important; }
/* 选中模板后：封面区改为展示本次会生成的全部模板图（启用中的）缩略图网格（2026-08-15 缩小20%：64→51px） */
.nb-tpl-picked { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; }
.nb-tpl-picked-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: 100%; }
.nb-tpl-picked-item { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-secondary); cursor: zoom-in;
}
.nb-tpl-picked-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 每张模板图右上角关闭按钮：关闭后本次生成任务不参与 */
.nb-tpl-picked-close {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; line-height: 1;
  border: 0; border-radius: 50%; background: rgba(15,23,42,.55); color: #fff;
  font-size: 13px; cursor: pointer; z-index: 2; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.nb-tpl-picked-close:hover { background: rgba(220,38,38,.9); }
.nb-tpl-picked-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 12px 0; }
/* 模块标题行右侧「重新选择模板」按钮（正常大小，复用 nb-btn 基础样式） */
.tpl-reselect-btn { border-color: var(--primary); color: var(--primary); font-weight: 600; white-space: nowrap; }
.tpl-reselect-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.tpl-reselect-btn[hidden] { display: none !important; }
.nb-tpl-count {
  width: 100%; padding: 8px 0; border: 0; border-radius: 8px; cursor: pointer;
  background: rgba(79,70,229,.08); color: var(--primary); font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.nb-tpl-count:hover { background: rgba(79,70,229,.18); }
.nb-tpl-count:disabled { color: var(--muted); background: transparent; cursor: default; }

/* 模板选择 + 服装参考图 同一行：两块等宽 360px，标题与内容都水平居中 */
.nb-tpl-row { display: flex; gap: 16px; align-items: stretch; justify-content: center; flex-wrap: wrap; }
.nb-tpl-row > .nb-tpl-pickzone, .nb-tpl-row > .nb-block { flex: 0 0 360px; min-width: 0; }
.nb-tpl-row > .nb-block { border-top: 0; padding-top: 0; margin-top: 0; display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.nb-tpl-row .nb-block-head { justify-content: center; gap: 8px; }
/* 模板图选择块：标题「批量模板图」左对齐，「重新选择模板」按钮在标题行右侧 */
.nb-tpl-pick-block { text-align: left; }
.nb-tpl-pick-block .nb-block-head { justify-content: space-between; text-align: left; }
.nb-tpl-pick-block .nb-tpl-pickzone { flex: 1; }
.nb-tpl-row .nb-upload { flex: 1; min-height: 186px; display: flex; align-items: center; justify-content: center; }
.nb-tpl-row .nb-ref-list { flex: 1; margin-top: 0; display: flex; align-items: center; justify-content: center; }
.nb-tpl-row .nb-ref-item { width: 112px; aspect-ratio: 3 / 4; height: auto; flex-shrink: 0; }
/* 模板批量生图：细节补充图缩略图（复用 nb-ref-item，虚线边框+「细节」角标区分于服装图） */
.nb-tpl-row .nb-ref-item.nb-detail-supp-mini { border: 1.5px dashed var(--primary); }

/* ===== 模板抽屉：双 tab ===== */
#tplDrawer .nb-drawer-body { padding: 0; overflow-y: auto; }
.tm-drawer-tabs { display: flex; gap: 8px; padding: 12px 14px 0; }
.tm-tab {
  flex: 1; padding: 9px 0; border: 0; border-radius: 8px 8px 0 0; cursor: pointer;
  background: #eef0f5; color: var(--muted); font-size: 13px; font-weight: 600;
}
.tm-tab.active { background: #fff; color: var(--primary); box-shadow: 0 -2px 6px rgba(0,0,0,.05); }
/* 模板 grid 容器：直接放在 .nb-drawer-body 内，padding 由 .nb-drawer-body 统一管理 */
.tm-tpl-grid-wrap { padding: 12px 14px 24px; }

/* ===== 模板封面网格（3:4，一行3个） ===== */
.tm-tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tm-tpl-cell {
  position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden;
  background: var(--bg-secondary); cursor: pointer; border: 1px solid var(--line);
  transition: transform .12s, box-shadow .12s;
}
.tm-tpl-cell:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(79,70,229,.18); }
.tm-tpl-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-tpl-cover-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.tm-tpl-count {
  flex: 1; border: 0; padding: 7px 0; cursor: pointer;
  background: rgba(20,20,30,.62); color: #fff; font-size: 12px; font-weight: 600;
}
.tm-tpl-count:hover { background: rgba(20,20,30,.82); }
/* 模板卡片底部双按钮（查看详情 + 换模特，2026-08-16）：默认隐藏，hover 卡片时出现 */
.tm-tpl-actions {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex;
  opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility .15s ease;
}
.tm-tpl-cell:hover .tm-tpl-actions { opacity: 1; visibility: visible; }
.tm-tpl-swap {
  flex: 1; border: 0; padding: 7px 0; cursor: pointer;
  background: rgba(79,70,229,.9); color: #fff; font-size: 12px; font-weight: 600;
}
.tm-tpl-swap:hover { background: rgba(79,70,229,1); }
/* 团队模板角标（team_name 非空，2026-08-16） */
.tm-tpl-team-badge {
  position: absolute; top: 6px; left: 6px; z-index: 2; padding: 1px 7px; border-radius: 999px;
  background: rgba(16,185,129,.92); color: #fff; font-size: 10px; font-weight: 600;
}
/* 当前使用中的模板卡片（点击封面即选用，2026-08-28） */
.tm-tpl-cell.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.35); }
.tm-tpl-picked-badge {
  position: absolute; top: 6px; right: 6px; z-index: 2; padding: 1px 7px; border-radius: 999px;
  background: rgba(79,70,229,.92); color: #fff; font-size: 10px; font-weight: 600;
}
/* 模板卡片封面右上角删除按钮（2026-08-31，仅自定义模板） */
.tm-tpl-del {
  position: absolute; top: 6px; right: 6px; z-index: 3; width: 24px; height: 24px;
  border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: rgba(17,24,39,.55); color: #fff; font-size: 15px; line-height: 24px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.tm-tpl-del:hover { background: #dc2626; }
.tm-tpl-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
.tm-tpl-add:hover { border-color: var(--primary); color: var(--primary); background: #f7f8ff; }
.tm-tpl-empty { grid-column: 1 / -1; color: var(--muted); font-size: 12px; text-align: center; padding: 20px 0; }

/* ===== 子抽屉：查看模板内图片 ===== */
.nb-subdrawer {
  position: absolute; inset: 0; background: #fff; z-index: 5;
  transform: translateX(-100%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.nb-subdrawer.show { transform: translateX(0); }
/* 子抽屉内主内容区填满并独立滚动，底部按钮常驻 */
.nb-subdrawer > .nb-drawer-body { flex: 1; min-height: 0; }

/* 主图模板子抽屉：名称/提示词信息区 */
.mt-sub-info { margin-bottom: 4px; }
.mt-sub-info .nb-field { margin: 0 0 10px; }
.nb-drawer-back { background: none; border: none; font-size: 18px; color: var(--primary); cursor: pointer; line-height: 1; padding: 0 6px; }
.tm-sub-actions { padding: 10px 14px 0; flex-shrink: 0; }
.tm-sub-foot { padding: 12px 14px; border-top: 1px solid var(--line); flex-shrink: 0; }
.tm-img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 14px; overflow-y: auto; flex: 1; min-height: 0; align-content: start; }
.tm-img-cell { position: relative; display: flex; flex-direction: column; gap: 6px; border-radius: 10px; }
.tm-img-cell.off .tm-img-wrap { opacity: .42; }
.tm-img-wrap { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--bg-secondary); border: 1px solid var(--line); }
.tm-img-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-img-toggle { display: block; width: 100%; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text-secondary); font-size: 12px; font-weight: 500; cursor: pointer; padding: 0; transition: background .15s, color .15s, border-color .15s; }
.tm-img-toggle.is-on { background: #dbeafe; color: var(--primary); border-color: #bfdbfe; }
.tm-img-toggle.is-off { background: #f3f4f6; color: #9ca3af; border-color: #e5e7eb; }
.tm-img-toggle:hover { filter: brightness(0.97); }
.tm-img-del {
  position: absolute; top: 5px; left: 5px; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(15,23,42,.6); color: #fff; cursor: pointer; font-size: 12px; padding: 0; line-height: 1; z-index: 1;
}
.tm-img-del:hover { background: var(--danger); }
.tm-img-empty { grid-column: 1 / -1; color: var(--muted); font-size: 12px; text-align: center; padding: 20px 0; }

/* ===== 模板图灯箱 ===== */
.nb-lightbox-mask {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
}
.nb-lightbox-mask img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 8px; }
.nb-lightbox-close {
  position: absolute; top: 16px; right: 20px; font-size: 32px; color: #fff;
  cursor: pointer; line-height: 1; opacity: .85;
}
.nb-lightbox-close:hover { opacity: 1; }
.nb-lightbox-prev, .nb-lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 48px; color: #fff; cursor: pointer; opacity: .7;
  padding: 10px 14px; user-select: none;
}
.nb-lightbox-prev:hover, .nb-lightbox-next:hover { opacity: 1; }
.nb-lightbox-prev { left: 12px; }
.nb-lightbox-next { right: 12px; }
.nb-lightbox-counter {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px; background: rgba(0,0,0,.5); padding: 4px 12px; border-radius: 20px;
}

/* 服装解析多件点选弹窗：复用 nb-drawer-mask 半透明遮罩，居中卡片 */
/* [hidden] 保护：.cloth-picker-modal 显式 display:flex 会覆盖 HTML hidden 属性，须用 !important 兜底 */
.cloth-picker-modal[hidden],
.nb-drawer-mask[hidden] { display: none !important; }
.cloth-picker-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  z-index: 600;
  width: min(560px, 94vw); max-height: 86vh;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; overflow: hidden;
}
.cloth-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #e5e7eb;
}
.cloth-picker-title { font-size: 15px; font-weight: 500; color: #111827; }
.cloth-picker-hint { margin: 8px 18px 0; font-size: 12px; color: #6b7280; line-height: 1.6; }
.cloth-picker-grid {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px; padding: 16px 18px;
  background: #f9fafb;
}
.cloth-picker-cell {
  position: relative; cursor: pointer;
  border: 2px solid transparent; border-radius: 10px; overflow: hidden;
  background: #fff; transition: border-color .15s, transform .15s;
}
.cloth-picker-cell:hover { border-color: #93c5fd; transform: translateY(-1px); }
.cloth-picker-cell.selected { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.cloth-picker-cell img {
  display: block; width: 100%; height: 220px; object-fit: contain;
  background: repeating-conic-gradient(#f3f4f6 0 25%, #ffffff 0 50%) 0 0/16px 16px;
}
.cloth-picker-tag {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 8px; background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0));
  color: #fff; font-size: 12px; text-align: center;
}
.cloth-picker-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid #e5e7eb; background: #fff;
}

/* 右侧结果模块右上角「下载全部/下载」按钮（样式对齐首页 .nb-download-all） */
.nb-result-panel { position: relative; }
.nb-result-dlbar {
  position: absolute; top: 0; right: 0; z-index: 5;
  font-size: 12px; padding: 5px 12px;
  border: 1px solid #93c5fd; background: #bfdbfe; color: #fff;
  border-radius: 6px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.nb-result-dlbar:hover { background: #93c5fd; }

/* 局部修改抽屉（600px 右侧） */
.nb-inpaint-drawer { width: 600px; max-width: 96vw; }
.nb-inpaint-canvas-wrap { position: relative; background: repeating-conic-gradient(#f3f4f6 0 25%, #ffffff 0 50%) 0 0/16px 16px; border: 1px solid var(--line); border-radius: 8px; min-height: 280px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.nb-inpaint-canvas-wrap canvas { display: block; max-width: 100%; height: auto; }
.nb-inpaint-floatbar { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; z-index: 5; pointer-events: none; }
.nb-inpaint-floatbar .nb-btn { pointer-events: auto; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.nb-inpaint-toolbar { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; padding: 6px; background: var(--bg-secondary); border-radius: 8px; }
.nb-inpaint-toolbar label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.nb-inpaint-toolbar input[type=range] { width: 110px; }
.nb-inpaint-prompt { margin-top: 12px; }
.nb-inpaint-prompt textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; min-height: 54px; resize: vertical; font-size: 13px; font-family: inherit; box-sizing: border-box; }
.nb-inpaint-status { font-size: 13px; min-height: 20px; margin-top: 10px; line-height: 1.5; }
.nb-inpaint-result { margin-top: 12px; }
.nb-inpaint-result img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.nb-inpaint-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); flex-shrink: 0; }
.nb-inpaint-cost { font-size: 13px; color: var(--muted); }

/* 提示词保存行（textarea 下方：左=已保存提示词，右=保存提示词） */
.nb-prompt-save-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
/* 已保存提示词左侧抽屉 */
.nb-promptlib-drawer { width: min(420px, 92vw); }
.nb-promptlib-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; }
.nb-promptlib-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; cursor: pointer; transition: border-color .15s; }
.nb-promptlib-item:hover { border-color: var(--primary); }
.nb-promptlib-item-text { font-size: 13px; line-height: 1.6; color: var(--text); word-break: break-all; white-space: pre-wrap; }
.nb-promptlib-item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.nb-promptlib-item-time { font-size: 11px; color: var(--muted); }

/* 换装换背景：参考图放大 30%（150px → 195px），仅本功能页生效（body data-function 定位） */
body[data-function="image-bgswap"] .nb-ref-item { width: 195px; height: 195px; }

/* 换搭配修细节：待修改原图预览放大（高度 150px → 300px，翻倍），改用 contain 完整展示不裁切，便于审图 */
body[data-function="image-retouch"] .nb-ref-item-base { width: 220px; height: 300px; }
body[data-function="image-retouch"] .nb-ref-item-base .nb-ref-thumb { object-fit: contain; background: #f8fafc; }

/* ===== 换搭配修细节：模式切换（下划线 tab） ===== */
.nb-mode-tabs { display: flex; gap: 4px; margin: 14px 0 10px; border-bottom: 1px solid #e5e7eb; }
.nb-mode-tab {
  position: relative; padding: 8px 18px; font-size: 14px; color: #6b7280;
  background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px;
}
.nb-mode-tab:hover { color: #111827; }
.nb-mode-tab.nb-mode-tab-active { color: #111827; font-weight: 600; border-bottom-color: var(--primary); }

/* 识别横幅 */
.nb-mode-banner { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.6; }
.nb-mode-banner.nb-mode-banner-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.nb-mode-banner.nb-mode-banner-ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.nb-mode-banner.nb-mode-banner-warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.nb-ref-tag-ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

/* 换搭配：手动选择部位 */
.nb-outfit-choice-grid { display: flex; gap: 10px; margin-top: 12px; }
.nb-outfit-choice {
  flex: 1; padding: 10px 8px 12px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff;
  cursor: pointer; display: flex; flex-direction: column; gap: 5px; align-items: center;
  min-width: 0;
}
.nb-outfit-choice:hover { border-color: #93c5fd; transform: translateY(-1px); }
.nb-outfit-choice b { font-size: 15px; color: #111827; }
.nb-outfit-choice span { font-size: 12px; color: #6b7280; text-align: center; }
.nb-outfit-choice-hl { outline: 2px solid var(--primary); outline-offset: 3px; }
.nb-outfit-preview {
  width: 100%; height: 140px; object-fit: contain; background: #f8fafc; border-radius: 8px;
}

/* 局部修改：框选大窗 */
.nb-region-modal { width: 92vw; max-width: 1100px; text-align: left; padding: 18px 18px 14px; display: flex; flex-direction: column; max-height: 92vh; }
.nb-region-modal .nb-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.nb-region-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.nb-region-tools { display: flex; gap: 6px; }
.nb-region-tool { background: #f1f5f9; border: 1px solid #e2e8f0; color: #475569; }
.nb-region-tool.nb-region-tool-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.nb-region-size { font-size: 13px; color: #475569; display: flex; align-items: center; gap: 6px; }
.nb-region-viewport { position: relative; width: 100%; height: 62vh; min-height: 360px; overflow: hidden; background: #0f172a; border-radius: 10px; cursor: crosshair; }
.nb-region-stage { position: absolute; left: 0; top: 0; will-change: transform; }
.nb-region-img { display: block; user-select: none; -webkit-user-drag: none; }
.nb-region-canvas { display: block; }
.nb-region-hint { margin: 8px 0 12px; font-size: 12px; color: #6b7280; }
.nb-modal-foot { display: flex; justify-content: flex-end; gap: 10px; }

/* 提示词保存按钮：非必要操作，浅灰色背景（区别于 primary 蓝色） */
.nb-ps-save { background: #f1f5f9; border-color: #e2e8f0; color: #334155; }
.nb-ps-save:hover { background: #e2e8f0; }

/* 换装换背景「提取服装」按钮：与放大按钮同一行（右移让位），仅服装标签所在图显示 */
body[data-function="image-bgswap"] .nb-ref-enlarge { left: calc(50% - 62px); }
body[data-function="image-bgswap"] .nb-ref-extract {
  position: absolute; bottom: 28px; left: calc(50% + 2px);
  padding: 2px 10px; border: none; border-radius: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px; white-space: nowrap;
  cursor: pointer; opacity: 0; transition: opacity .2s; z-index: 2;
}
body[data-function="image-bgswap"] .nb-ref-item:hover .nb-ref-extract { opacity: 1; }
body[data-function="image-bgswap"] .nb-ref-item.is-extracting::after {
  content: '提取中…';
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; border-radius: 10px;
}

/* 提取服装：提取中遮罩（通用，所有功能页） */
.nb-ref-item.is-extracting::after {
  content: '提取中…';
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; border-radius: 10px;
}
/* 模板批量生图：服装素材图「放大」与「提取服装」按钮同行 */
body[data-function="template-gen"] .nb-ref-enlarge { left: calc(50% - 50px); }
body[data-function="template-gen"] .nb-ref-extract {
  position: absolute; bottom: 4px; left: calc(50% + 2px);
  padding: 2px 10px; border: none; border-radius: 10px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px; white-space: nowrap;
  cursor: pointer; opacity: 0; transition: opacity .2s; z-index: 2;
}
body[data-function="template-gen"] .nb-ref-item:hover .nb-ref-extract { opacity: 1; }

/* ===== 换搭配修细节：服装换色模式（颜色参考图 + 色盘） ===== */
.nb-color-layout { display: flex; gap: 22px; flex-wrap: wrap; }
.nb-color-col { flex: 1; min-width: 260px; }
.nb-color-palette-col { flex: 1; }
.nb-color-tip { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.nb-palette { display: flex; flex-direction: column; gap: 14px; max-height: 440px; overflow-y: auto; padding-right: 4px; }
.nb-palette-group-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.nb-palette-row { display: flex; flex-wrap: wrap; gap: 8px; }
.nb-color-chip {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; position: relative;
  border: 2px solid rgba(0,0,0,0.08); box-shadow: 0 1px 2px rgba(0,0,0,0.12); transition: transform .12s, box-shadow .12s;
}
.nb-color-chip:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.18); }
.nb-color-chip.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary); }
.nb-color-chip.is-selected::after {
  content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.nb-palette.is-disabled { opacity: .45; pointer-events: none; }

/* 服装换色：色盘按钮触发左侧抽屉 */
.nb-color-open-btn { display: flex; align-items: center; justify-content: center; gap: 8px; position: relative; }
.nb-color-open-ico { font-size: 16px; line-height: 1; }
.nb-color-open-txt { flex: 0 0 auto; }
.nb-color-selcount { margin-left: auto; background: var(--primary-light); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.nb-color-selprev { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; min-height: 22px; }
.nb-color-thumb-item { display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.nb-color-thumb { width: 56px; height: 56px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.08); box-shadow: 0 1px 3px rgba(0,0,0,0.12); object-fit: cover; background: #fff; }
.nb-color-thumb-name { font-size: 11px; color: var(--muted); line-height: 1; }
.nb-color-thumb-item .nb-remove { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; line-height: 1; padding: 0; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.nb-color-selprev.is-empty::after { content: '尚未选择颜色（点击上方按钮从色盘选择）'; font-size: 12px; color: var(--muted); }

/* 色盘抽屉：头部操作区 / 提示 / 底部按钮 */
.nb-drawer-head-actions { display: flex; align-items: center; gap: 8px; }
.nb-drawer-hint { margin: 0; padding: 10px 16px 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.nb-drawer-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); flex-shrink: 0; }
/* 抽屉内色盘用抽屉自身滚动，去掉内层 max-height，避免双重滚动条 */
.nb-palette-drawer .nb-palette { max-height: none; }

/* 超分抽屉：生成按钮上的本次积分扣除提示 */
.nb-upscale-cost { font-size: 12px; color: #b91c1c; text-align: center; margin-bottom: 8px; font-weight: 600; }

/* 视频结果坑位：生成中按已知比例预留展示区（骨架微光 + 图标 + spinner 文案，观感对齐图片生成等待） */
.nb-video-slot {
  position: relative;
  width: 100%; max-width: 560px; margin: 0 auto;
  border: 1px dashed var(--line, #d8dee6); border-radius: 10px;
  background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
/* 骨架微光底层：铺满坑位，横向流光，提示"正在处理"而非卡死 */
.nb-video-slot-skeleton {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(100deg, #eef2f7 28%, #f9fbfd 46%, #e6ecf4 64%);
  background-size: 220% 100%;
  animation: nb-slot-shimmer 1.6s linear infinite;
}
@keyframes nb-slot-shimmer { from { background-position: 220% 0; } to { background-position: -120% 0; } }
/* 内容层压在骨架之上 */
.nb-video-slot .nb-gen-loading {
  position: relative; z-index: 1;
  padding: 24px; gap: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.nb-video-slot-icon { color: var(--primary, #2563eb); opacity: .55; animation: nb-slot-pulse 1.8s ease-in-out infinite; }
@keyframes nb-slot-pulse { 0%, 100% { opacity: .35; transform: scale(.96); } 50% { opacity: .7; transform: scale(1); } }
.nb-video-slot-main {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text, #1f2937);
}
.nb-video-slot-sub { font-size: 12px; color: var(--muted, #6b7280); line-height: 1.6; max-width: 90%; }

/* 首页历史卡片功能名称徽章：蓝色圆角背景 + 白色加粗字体（覆盖 653 行浅蓝底蓝字） */
.nb-feature-badge {
  display: inline-block; font-size: 12px; font-weight: 700; line-height: 1;
  padding: 4px 10px; border-radius: 8px; color: #fff; background: var(--primary, #2563eb);
  white-space: nowrap;
}

/* 换装换背景：选择动作抽屉（中文动作翻译仅展示，生成用英文原提示词） */
.bgswap-pose-item { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.bgswap-pose-item:hover { border-color: var(--primary); }
.bgswap-pose-item input[type="checkbox"] { margin-top: 3px; accent-color: var(--primary); flex: 0 0 auto; }
.bgswap-pose-idx { flex: 0 0 auto; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; background: var(--bg-secondary); font-size: 12px; font-weight: 700; color: var(--muted); }
.bgswap-pose-item:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.bgswap-pose-item:has(input:checked) .bgswap-pose-idx { background: var(--primary); color: #fff; }
.bgswap-pose-text { font-size: 13px; line-height: 1.6; color: var(--text); }

/* ============ 换搭配：AI 搭配方案抽屉卡片 ============ */
.nb-plan-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 10px; }
.nb-plan-card:hover { border-color: var(--primary); }
.nb-plan-check { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--primary); }
.nb-plan-card:has(.nb-plan-check:checked) { border-color: var(--primary); background: #eff6ff; }
.nb-plan-body { flex: 1; min-width: 0; }
.nb-plan-index { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.nb-plan-text { font-size: 13px; line-height: 1.6; color: var(--text); }

/* ============ 生成详情图（detail-image-gen）2026-08-28 重构 ============ */
/* 右侧结果预览：按模块分组；图片区自身滚动，使右栏总高不超出操作面板 */
.dt-preview {
  display: flex; flex-direction: column; gap: 18px;
  flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px;
}
/* 关键：.dt-preview 是 flex column，子项默认 flex-shrink:1，空间不足时模块会被压扁挤成一团，
   压完刚好塞得下 → 既没有溢出也没有滚动条，鼠标滚不动。禁止收缩后由容器滚动。 */
.dt-mod { flex-shrink: 0; }
/* 右栏限高后兜底裁剪，避免极端情况下内容溢出盖到其它区块 */
#dtResultPanel { overflow: hidden; }
.dt-mod { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.dt-mod-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--line);
}
.dt-mod-idx { font-size: 13px; font-weight: 700; color: var(--primary); flex: 0 0 auto; }
.dt-mod-name { font-size: 14px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-mod-cnt { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.dt-mod-cnt .dt-mod-done { color: #16a34a; }
.dt-mod-acts { margin-left: auto; display: flex; gap: 8px; flex: 0 0 auto; }
/* 单列铺满：每张图按右侧板块的最大宽度完整展示（不做缩略图），高度随图片原始比例自适应 */
.dt-mod-grid {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 14px; padding: 12px;
}

/* 单个图片坑位：宽度撑满，高度由图片本身决定（不锁死 3:4，避免长图被裁/被压扁） */
.dt-cell {
  position: relative; min-height: 90px; border-radius: 10px; overflow: hidden;
  background: #f1f5f9; border: 1px solid var(--line);
}
.dt-cell-img {
  width: 100%; height: auto; max-height: 80vh; object-fit: contain;
  display: block; cursor: zoom-in; background: #f8fafc;
}
.dt-cell.is-done { border-color: #86efac; }
.dt-cell.is-done .dt-cell-img { background: #fff; }
/* 未生成：50% 白色遮罩（表示这张还是模板图，尚未替换生成）。默认不显示，鼠标移到图上才盖出来 */
.dt-cell-mask {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.dt-cell:hover .dt-cell-mask { opacity: 1; }
/* 已生成/已上传的图不渲染遮罩层（JS 端 done 就不输出 .dt-cell-mask，这里兜底双重保险） */
.dt-cell.is-done .dt-cell-mask { display: none; }
/* 生成中、排队中、失败：遮罩必须常驻，否则看不到进度与错误提示 */
.dt-cell.is-generating .dt-cell-mask,
.dt-cell.is-queued .dt-cell-mask,
.dt-cell.is-error .dt-cell-mask { opacity: 1; }
/* 排队中：静态时钟点，与「生成中」的转动 spinner 区分开 */
.dt-cell-clock {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); position: relative;
}
.dt-cell-clock::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 6px; height: 2px; background: var(--primary);
  transform-origin: 0 50%; transform: rotate(-90deg);
}
/* 排队中的文字用次要色，和「正在生成」的主色区分 */
.dt-cell.is-queued .dt-cell-loading { color: var(--muted); }
.dt-cell-acts {
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  opacity: 0; transition: opacity .15s;
}
.dt-cell:hover .dt-cell-acts { opacity: 1; }
.dt-cell-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.dt-cell-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.dt-cell-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.dt-cell-btn.primary:hover:not(:disabled) { background: var(--primary-d); color: #fff; }
.dt-cell-btn:disabled { opacity: .55; cursor: not-allowed; }
/* 生成中 */
.dt-cell-loading { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--primary); }
/* 失败 */
.dt-cell-err {
  position: absolute; left: 6px; right: 6px; bottom: 6px;
  background: rgba(220, 38, 38, .92); color: #fff; font-size: 11px;
  padding: 4px 6px; border-radius: 6px; line-height: 1.5; text-align: center;
}
/* 已生成图右上角操作（删除 / 编辑尺码表）：常驻显示，确保一眼能看到、点得到 */
.dt-cell-done-acts {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  display: flex; gap: 6px; opacity: 1;
}
.dt-cell:hover .dt-cell-done-acts { opacity: 1; }
.dt-cell-edit, .dt-cell-del {
  width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: rgba(17, 24, 39, .62); color: #fff;
  font-size: 15px; line-height: 24px; text-align: center; cursor: pointer;
}
.dt-cell-edit:hover { background: var(--primary); }
.dt-cell-del:hover { background: var(--danger); }
/* 坑位序号 */
.dt-cell-no {
  position: absolute; left: 6px; top: 6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 6px; background: rgba(17, 24, 39, .55); color: #fff;
  font-size: 11px; line-height: 20px; text-align: center;
}

/* ===== 服装素材图主体识别（detail-image-gen，2026-08-29）===== */
/* 卡片右下角主体标签：识别中 / 已识别(可点切换) / 识别失败(可点手选) */
.dt-seg-badge {
  position: absolute; left: 2px; bottom: 2px; z-index: 2;
  max-width: calc(100% - 4px); padding: 1px 6px; border-radius: 999px;
  border: 0; font-size: 11px; line-height: 16px; font-weight: 600;
  background: rgba(79, 70, 229, .92); color: #fff; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-seg-badge.is-loading { background: rgba(100, 116, 139, .92); cursor: default; }
.dt-seg-badge.is-fail { background: rgba(220, 38, 38, .9); }
.dt-seg-badge.is-ok:hover { background: rgba(67, 56, 202, .95); }
/* 细节补充图角标：与「服装主体」标签区分（琥珀色 + 不可点，它不参与主体识别） */
.dt-seg-badge.is-supp { background: rgba(180, 83, 9, .92); cursor: default; }
.nb-ref-item.is-supp .nb-ref-thumb { box-shadow: inset 0 0 0 2px rgba(180, 83, 9, .55); }
/* 搭配参考角标（detail-image-gen 第 2 张素材图，2026-09-01）：青绿色区分，不可点，不参与主体识别 */
.dt-seg-badge.is-styling { background: rgba(13, 148, 136, .92); cursor: default; }
.nb-ref-item.is-styling .nb-ref-thumb { box-shadow: inset 0 0 0 2px rgba(13, 148, 136, .55); }
/* 素材图列表拖拽高亮（大上传区收起后仍可拖拽加图） */
.nb-ref-list.drag { outline: 2px dashed var(--primary); outline-offset: 3px; border-radius: 8px; }
/* 素材图「描述补充」：面料描述 + 服装细节描述（2026-09-01）
   每张素材图下方两个紧凑输入框，内容作为权威补充写进 Gemini 生成提示词 */
.dt-cloth-cell { width: 150px; flex-shrink: 0; }
.dt-cloth-desc { display: flex; flex-direction: column; gap: 6px; margin-top: 5px; }
/* 每个字段独立成块：即使浏览器缓存了旧 CSS，块级 div 也会上下堆叠，绝不与相邻字段同排 */
.dt-cloth-field { display: block; width: 100%; }
.dt-cloth-label { display: block; font-size: 10px; line-height: 1.4; color: var(--muted); margin: 0 0 2px 1px; }
.dt-cloth-input {
  width: 100%; box-sizing: border-box;
  padding: 4px 7px; font-size: 11px; line-height: 1.5;
  color: var(--text, #0f172a); background: #fff;
  border: 1px solid var(--line); border-radius: 6px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.dt-cloth-input::placeholder { color: var(--muted); }
.dt-cloth-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, .12); }
/* 主体选择弹层 */
.dt-subject-preview {
  width: 100%; max-height: 220px; object-fit: contain;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg-secondary);
}
.dt-subject-tip { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.dt-subject-opts { display: flex; flex-direction: column; gap: 8px; }
.dt-subject-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; text-align: left; transition: border-color .12s, background .12s;
}
.dt-subject-opt:hover { border-color: var(--primary); background: #f7f8ff; }
.dt-subject-opt.is-on { border-color: var(--primary); background: var(--primary-light); }
.dt-subject-opt b { font-size: 14px; color: var(--text); }
.dt-subject-opt span { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* 兜底：万一缩略图网格里出现裸 img（无 .nb-tpl-picked-item 包裹），仍不许它按原图尺寸撑开列宽 */
.nb-tpl-picked-grid > img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; }

/* 模板子抽屉：模块管理 */
.dt-sub-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.dt-sub-loading, .dt-sub-empty { padding: 24px 8px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; }
.dt-sub-mod { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.dt-sub-mod-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--bg-secondary); border-bottom: 1px solid var(--line);
}
.dt-sub-mod-idx { font-size: 12px; font-weight: 700; color: var(--primary); }
.dt-sub-mod-name { font-size: 13px; font-weight: 600; }
.dt-sub-mod-cnt { font-size: 12px; color: var(--muted); }
.dt-sub-mod-acts { display: flex; gap: 6px; }
.dt-mini {
  border: 1px solid var(--line); background: #fff; color: var(--text-secondary);
  border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer;
}
.dt-mini:hover { border-color: var(--primary); color: var(--primary); }
.dt-mini.danger:hover { border-color: var(--danger); color: var(--danger); }
.dt-sub-mod-imgs { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
.dt-sub-img { position: relative; width: 104px; height: 104px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f8fafc; cursor: zoom-in; }
.dt-sub-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dt-sub-img-del {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0;
  border-radius: 50%; background: rgba(17, 24, 39, .6); color: #fff;
  font-size: 12px; line-height: 18px; cursor: pointer;
}
.dt-sub-img-del:hover { background: var(--danger); }
/* 图片左上角勾选框（批量合并/删除，2026-09-05） */
.dt-sub-img-check {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; margin: 0;
  background: rgba(255, 255, 255, .85); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2;
}
.dt-sub-img-check input { width: 13px; height: 13px; margin: 0; cursor: pointer; }
/* 模板图片 hover 编辑按钮（与删除按钮对称，底部居中） */
.dt-sub-img-edit {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  padding: 1px 8px; border: 0; border-radius: 10px;
  background: rgba(17, 24, 39, .66); color: #fff; font-size: 11px; line-height: 16px;
  cursor: pointer; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.dt-sub-img:hover .dt-sub-img-edit { opacity: 1; pointer-events: auto; }
.dt-sub-img-edit:hover { background: var(--primary); }
.dt-sub-mod-none { font-size: 12px; color: var(--muted); }
/* 后台重绘中：缩略图覆盖式遮罩 */
.dt-sub-img.is-editing img { filter: brightness(.5); }
.dt-sub-img-editmask {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; background: rgba(15, 23, 42, .55); color: #fff; font-size: 11px;
  pointer-events: none;
}
.dt-sub-edit-spin {
  width: 20px; height: 20px;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  border-radius: 50%; animation: nb-spin .8s linear infinite;
}
/* 失效图片（404/加载失败）兜底：显示「图片缺失」灰块，替代浏览器裂图 */
.dt-sub-img.dt-img-broken { background: #f1f5f9; }
.dt-sub-img.dt-img-broken img { display: none; }
.dt-sub-img.dt-img-broken::after {
  content: '图片缺失'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #94a3b8; letter-spacing: .5px;
}
/* 模块顺序：上移/下移箭头（图标，无文字） */
.dt-sub-mod-move { display: flex; gap: 4px; margin-left: auto; }
.dt-arrow {
  width: 22px; height: 20px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--text-secondary);
  border-radius: 6px; cursor: pointer;
}
.dt-arrow:hover { border-color: var(--primary); color: var(--primary); }
.dt-arrow.is-disabled, .dt-arrow.is-disabled:hover { opacity: .35; cursor: not-allowed; border-color: var(--line); color: var(--text-secondary); }
/* 图片左移/右移箭头（图标，无文字；hover 才显现，与编辑按钮一致） */
.dt-sub-img-arrow {
  position: absolute; left: 2px; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(17, 24, 39, .6); color: #fff;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 2;
}
.dt-sub-img-arrow svg { width: 11px; height: 11px; }
/* 左移=左下角、右移=右下角（左上角留给勾选框，编辑按钮保持底部居中） */
.dt-sub-img-left { bottom: 2px; }
.dt-sub-img-right { left: auto; right: 2px; bottom: 2px; }
.dt-sub-img:hover .dt-sub-img-arrow { opacity: 1; pointer-events: auto; }
.dt-sub-img-arrow:hover { background: var(--primary); }
.dt-sub-img-arrow.is-disabled, .dt-sub-img:hover .dt-sub-img-arrow.is-disabled { opacity: .35; pointer-events: none; }

/* 模板图片编辑弹层 */
.dt-edit-modal { display: flex; flex-direction: column; }

/* 模板图片编辑：右侧二级嵌套抽屉（2026-08-30 由居中弹层改为右滑抽屉，压在模板子抽屉之上） */
.dt-edit-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(460px, 94vw); height: 100vh; max-height: none;
  background: #fff; box-shadow: -10px 0 40px rgba(0,0,0,.18);
  z-index: 1300; transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.dt-edit-drawer.show { transform: translateX(0); }
.dt-edit-drawer .dt-modal-body { flex: 1; min-height: 0; overflow-y: auto; }
.dt-edit-stage { position: relative; width: 100%; max-height: 52vh; background: #f1f5f9; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; user-select: none; }
.dt-edit-stage img { max-width: 100%; max-height: 52vh; display: block; }
.dt-edit-stage canvas { position: absolute; left: 0; top: 0; cursor: crosshair; }
.dt-edit-hint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(17,24,39,.66); color: #fff; font-size: 11px; padding: 3px 10px; border-radius: 10px; pointer-events: none; white-space: nowrap; }
.dt-edit-ref-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.dt-edit-ref-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; min-height: 0; }
.dt-edit-ref { position: relative; width: 52px; height: 52px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.dt-edit-ref img { width: 100%; height: 100%; object-fit: cover; }
.dt-edit-ref .dt-edit-ref-x { position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; border: 0; border-radius: 50%; background: rgba(17,24,39,.6); color: #fff; font-size: 11px; line-height: 16px; cursor: pointer; }
.dt-edit-result { border-top: 1px solid var(--line); padding: 12px 16px; }
.dt-edit-result-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.dt-edit-result img { max-width: 100%; max-height: 38vh; display: block; border-radius: 8px; margin-bottom: 10px; }
.dt-edit-result-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 新建模块弹层 */
.dt-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 400px; max-width: calc(100vw - 32px); background: #fff; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 1201; display: none;
}
.dt-modal.show { display: block; }
.dt-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.dt-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.dt-modal-err { min-height: 16px; font-size: 12px; color: var(--danger); }
.dt-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* ===== 尺码表编辑抽屉（右侧滑出，2026-08-29）===== */
.sc-drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1300;
  display: flex; justify-content: flex-end;
}
.sc-drawer {
  width: 460px; max-width: 94vw; height: 100%;
  background: var(--color-background-primary, #fff);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 28px rgba(0, 0, 0, .14);
}
.sc-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.sc-drawer-title { font-size: 15px; font-weight: 500; }
.sc-drawer-sub { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 13px; }
.sc-drawer-close {
  border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted);
}
.sc-drawer-body { flex: 1; overflow: auto; padding: 14px 16px; scrollbar-gutter: stable; }
.sc-drawer-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.sc-tbl-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.sc-tbl-add { margin: 8px 0 14px; }
.sc-tbl-name { font-weight: 500; }
.sc-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sc-grid td { border: 1px solid var(--line); padding: 2px; vertical-align: middle; }
.sc-grid .sc-row-act { border: 0; width: 1%; white-space: nowrap; }
.sc-cell {
  width: 100%; box-sizing: border-box; border: 1px solid #ddd; border-radius: 4px;
  padding: 5px 6px; font-size: 13px; text-align: center;
}
.sc-cell:focus { border-color: var(--primary); outline: none; }

/* ===== 生成主图·AI替换：模板参考图 + 「去水印」勾选（2026-09-05）=====
   选中模板后在操作面板展示该模板参与生成的参考图，序号与模型看到的 Image N 一致；
   每张下方「去水印」复选框默认勾选，勾选后提示词追加「不出现品牌 Logo + 文案按新服装改写」。
   2026-09-05 二次调整：#mtTplRefList 移入选择卡片的 .nb-tpl-picked-grid（4 列，与生成详情图一致），
   选中后隐藏封面大图——不再「封面占一大块 + 下面又重复列一遍所有图」。 */
.mt-tpl-ref-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mt-tpl-ref-thumb {
  position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--line); background: #f1f5f9; cursor: zoom-in;
}
.mt-tpl-ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mt-tpl-ref-no {
  position: absolute; left: 0; top: 0; min-width: 18px; height: 18px; padding: 0 5px;
  background: rgba(17, 24, 39, .55); color: #fff; font-size: 11px; line-height: 18px;
  text-align: center; border-bottom-right-radius: 6px;
}
.mt-tpl-ref-wm {
  display: flex; align-items: center; gap: 5px; font-size: 12px; color: #374151;
  cursor: pointer; user-select: none;
}
.mt-tpl-ref-wm input { width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--primary); }
.mt-tpl-ref-item.is-off .mt-tpl-ref-thumb { opacity: .55; }
/* 本次不使用该模板图（2026-09-07）：右上角 ×，仅从本次生成列表移除，模板本身不受影响 */
.mt-tpl-ref-del {
  position: absolute; right: 0; top: 0; width: 22px; height: 22px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-bottom-left-radius: 6px; background: rgba(17, 24, 39, .55);
  color: #fff; font-size: 15px; line-height: 1; cursor: pointer; opacity: .9;
  transition: background .15s, opacity .15s;
}
.mt-tpl-ref-item:hover .mt-tpl-ref-del { opacity: 1; }
.mt-tpl-ref-del:hover { background: #dc2626; }
.mt-tpl-ref-tip { grid-column: 1/-1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.mt-tpl-ref-restore {
  border: 1px solid var(--line); background: #fff; color: var(--primary);
  border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer;
}
.mt-tpl-ref-restore:hover { background: #f3f4f6; }

/* ===== 生成主图·AI替换：服装描述区（面料/细节/穿着三输入，2026-09-05 从生成详情图移植）=====
   2026-09-05 二次调整：三输入从素材图卡片里拆出，独立成块放在「生成比例」上方（#mtDescList）。
   2026-09-05 三次调整：去掉缩略图（图片在上方素材图区已有，重复无意义）；行首为
   「素材图 N + 执行主体下拉 + 作为搭配参考勾选」（执行主体/搭配参考与生成详情图同语义），
   下面三列输入。字段类名 mt-cloth-* 保持不变（JS 复用 mtClothDescHtml）。 */
#mtDescList { display: flex; flex-direction: column; gap: 10px; }
.mt-desc-row {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff;
}
.mt-desc-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mt-desc-name { font-size: 13px; font-weight: 600; color: #334155; }
.mt-desc-ctrl { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #374151; cursor: pointer; user-select: none; }
.mt-desc-ctrl select {
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: 12px;
  background: #fff; color: inherit; cursor: pointer;
}
.mt-desc-ctrl input[type="checkbox"] { width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--primary); }
.mt-desc-ctrl select:disabled { opacity: .5; cursor: not-allowed; }
.mt-desc-fields { min-width: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.mt-cloth-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mt-cloth-label { font-size: 12px; color: #64748b; }
.mt-cloth-input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; font-size: 13px; background: #fff; color: inherit;
}
.mt-cloth-input:focus { border-color: var(--primary); outline: none; }

/* ===== 生成主图·AI替换：素材图/细节补充图合并网格（2026-09-05 三次调整）=====
   3 列网格，素材图与细节补充图同一行混排（补充图带「补充」角标区分）；
   传过素材图后大上传区隐藏，标题栏「＋ 上传素材图」小按钮接替入口。 */
.mt-img-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mt-img-grid .nb-ref-item { width: 100%; height: auto; aspect-ratio: 1 / 1; }
.mt-img-grid .nb-ref-thumb { width: 100%; height: 100%; }
.mt-supp-badge {
  position: absolute; left: 0; bottom: 0; padding: 1px 6px;
  background: rgba(180, 83, 9, .85); color: #fff; font-size: 11px; line-height: 18px;
  border-top-right-radius: 6px; pointer-events: none;
}

/* ===== 生成详情图·模板子抽屉：粘贴上传占位坑（2026-09-05）=====
   点「粘贴」按钮后按剪贴板图片数量预留 .dt-sub-img.is-uploading 坑位，上传成功原地填图。 */
.dt-sub-img.is-uploading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; cursor: default; border-style: dashed;
}
.dt-sub-img .dt-sub-uploading-txt { font-size: 11px; color: #64748b; }
.dt-sub-img.is-uploading .spinner { width: 18px; height: 18px; border-width: 2px; }
