/* ═══════════════════════════════════════════
   AB面生图 Demo — 前端样式
   对齐三笙AI 工具箱设计规范（见 /UI组件.html）
   Token 体系：浅色 + 深色模式统一
   ═══════════════════════════════════════════ */

:root {
  /* 品牌色 */
  --brand-blue: #0051d6;
  --brand-green: #12eea8;
  --brand-gradient: linear-gradient(90deg in oklch, var(--brand-green) -18%, var(--brand-blue) 118%);
  --brand-gradient-hover: linear-gradient(90deg in oklch, #10e4ad -18%, #1965dc 118%);
  --brand-border-gradient: linear-gradient(90deg in oklch, var(--brand-green) -12%, var(--brand-blue) 112%);
  --main: #15dbb0;

  /* 语义色 — 浅色模式 */
  --bg: #ffffff;
  --bg-alt: #f8f9fb;
  --surface: #ffffff;
  --fg: #1a1a1a;
  --fg-muted: #71717a;
  --border: #e4e4e7;
  --border-light: #f0f0f2;
  --destructive: #ef4444;
  --accent: #f4f4f5;
  --secondary: #f4f4f5;
  --secondary-fg: #1a1a1a;
  --code-bg: #f4f4f5;
  --input: #e4e4e7;
  --ring: #a1a1aa;
  --popover: #ffffff;
  --popover-fg: #1a1a1a;

  /* 语义别名（兼容旧代码） */
  --primary: var(--brand-blue);
  --primary-hover: #1965dc;
  --card: var(--surface);
  --text: var(--fg);
  --muted: var(--fg-muted);
  --success: #10b981;
  --warn: #f59e0b;
  --danger: var(--destructive);

  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Consolas, monospace;

  /* 圆角阶（对齐规范：6/8/10/14/18/22px） */
  --radius: 0.625rem; /* 10px 基准 */
  --radius-sm: calc(var(--radius) * 0.6);   /* 6px */
  --radius-md: calc(var(--radius) * 0.8);   /* 8px */
  --radius-lg: var(--radius);                /* 10px */
  --radius-xl: calc(var(--radius) * 1.4);   /* 14px */
  --radius-2xl: calc(var(--radius) * 1.8);  /* 18px */
  --radius-3xl: calc(var(--radius) * 2.2);  /* 22px */

  /* 阴影阶 */
  --shadow-sm: 0 0 1px rgba(0,0,0,0.16), 0 2px 12px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.06);
  --shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════
   深色模式 Token
   ═══════════════════════════════════════════ */
.dark {
  --bg: #09090b;
  --bg-alt: #18181b;
  --surface: #1c1c1f;
  --fg: #fafafa;
  --fg-muted: #a1a1aa;
  --border: rgba(255,255,255,0.1);
  --border-light: rgba(255,255,255,0.06);
  --destructive: #e5484d;
  --accent: #27272a;
  --secondary: #27272a;
  --secondary-fg: #fafafa;
  --code-bg: #27272a;
  --input: rgba(255,255,255,0.15);
  --ring: #52525b;
  --popover: #1c1c1f;
  --popover-fg: #fafafa;
  --shadow-sm: 0 0 1px rgba(255,255,255,0.08), 0 2px 12px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.35);
  --shadow: var(--shadow-sm);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg); color: var(--fg);
  font-size: 14px; line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

/* ═══════════════════════════════════════════
   顶部导航
   ═══════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: color-mix(in oklch, var(--bg), transparent 15%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand .logo { font-size: 1.75rem; }
.brand .brand-logo { width: 36px; height: 36px; object-fit: contain; display: inline-block; }
.brand h1 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.brand .sub { margin: 0; font-size: 0.75rem; color: var(--fg-muted); }
.chips-compact { gap: 0.375rem; flex-wrap: wrap; }
.chips-compact .chip { padding: 0.25rem 0.625rem; font-size: 0.75rem; border-radius: var(--radius-sm); }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.settings-menu { position: relative; }
.settings-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--popover); color: var(--popover-fg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 0.25rem;
  min-width: 320px; z-index: 60;
  display: flex; flex-direction: column;
}
.settings-dropdown.hidden { display: none; }
.settings-section { padding: 0.5rem; }
.settings-section-title {
  font-size: 0.75rem; color: var(--fg-muted); margin-bottom: 0.375rem;
}
.settings-sep { height: 1px; background: var(--border-light); margin: 0.25rem 0.5rem; }
.dropdown-item {
  background: transparent; border: 0; text-align: left;
  padding: 0.5rem 0.75rem; font-size: 0.8rem; cursor: pointer;
  color: var(--fg); border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.dropdown-item:hover { background: var(--accent); }
.provider-pills { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.provider-pills .pill {
  font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--fg-muted);
}
.provider-pills .pill.on {
  background: color-mix(in oklch, var(--main), transparent 75%);
  color: var(--main);
}

/* ═══════════════════════════════════════════
   按钮 — 对齐规范 7 变体 × 8 尺寸
   ═══════════════════════════════════════════ */
.btn, .ghost-btn, .primary-btn, .link-btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  font-family: var(--font-sans); font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s; white-space: nowrap; outline: none; user-select: none;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  height: 32px; padding: 0 0.625rem;
}
.btn:disabled, .ghost-btn:disabled, .primary-btn:disabled { opacity: 0.5; pointer-events: none; }

/* Variant — default 品牌渐变 */
.primary-btn {
  background: var(--brand-gradient);
  background-origin: border-box; background-clip: border-box;
  color: #fff;
  padding: 0 0.75rem;
}
.primary-btn:hover:not(:disabled) {
  background: var(--brand-gradient-hover);
  background-origin: border-box; background-clip: border-box;
}
.primary-btn.small { height: 28px; padding: 0 0.625rem; font-size: 0.8rem; border-radius: min(var(--radius-md), 12px); }

/* Variant — outline */
.ghost-btn {
  border-color: var(--border); background: var(--bg); color: var(--fg);
  height: 32px; padding: 0 0.75rem;
}
.ghost-btn:hover { background: var(--accent); }
.ghost-btn.small { height: 28px; padding: 0 0.625rem; font-size: 0.8rem; border-radius: min(var(--radius-md), 12px); }

/* Variant — link */
.link-btn {
  background: transparent; color: var(--fg); text-decoration: underline;
  text-underline-offset: 4px; height: auto; padding: 0.25rem 0;
  font-size: 0.75rem; border-radius: 0;
}
.link-btn:hover { text-decoration: underline; }

/* Variant — icon button */
.icon-btn {
  background: transparent; color: var(--fg-muted);
  width: 32px; height: 32px; padding: 0; font-size: 1.1rem;
  border-radius: var(--radius-lg);
}
.icon-btn:hover { background: var(--accent); color: var(--fg); }

/* 生成按钮 */
.submit-actions {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.78fr); gap: 0.5rem;
}
.submit-actions .primary-btn,
.submit-actions .ghost-btn {
  width: 100%; height: 40px; font-size: 0.9rem; font-weight: 600;
  border-radius: var(--radius-lg);
}

/* ═══════════════════════════════════════════
   布局 — 左右分栏
   ═══════════════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: 600px minmax(0, 1fr);
  gap: 1.125rem;
  padding: 1.125rem 1.5rem;
  max-width: 1720px; margin: 0 auto;
  align-items: stretch;
  height: calc(100vh - 60px);
}
.left {
  display: flex; flex-direction: column;
  min-height: 0;
  padding: 0.75rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.left-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.875rem;
  padding-right: 6px; scrollbar-gutter: stable;
}
#leftCollapsible { display: flex; flex-direction: column; gap: 0.75rem; }
.submit-bar {
  position: static;
  flex: 0 0 auto;
  padding: 0.75rem 0.25rem 0; margin-top: 0.625rem;
  background: var(--bg-alt);
  border-top: 1px solid var(--border-light);
}
.right {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .left, .right { overflow: visible; height: auto; }
  .left-scroll { overflow: visible; }
  .submit-bar { position: static; }
}

@media (min-width: 981px) and (max-width: 1240px) {
  .layout { grid-template-columns: 520px minmax(0, 1fr); }
}

.left.collapsed .left-scroll > #leftCollapsible { display: none; }

/* ═══════════════════════════════════════════
   卡片 — 对齐规范 Card 组件
   ═══════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h2 {
  margin: 0 0 0.75rem; font-size: 0.875rem; font-weight: 700;
  color: var(--fg);
}
.left .editor-section {
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: none;
}
.left .editor-section:hover { box-shadow: none; border-color: color-mix(in oklch, var(--brand-blue), var(--border) 78%); }
.editor-section h2 { display: flex; align-items: center; gap: 0.625rem; }
.section-index {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 22px; flex: 0 0 26px;
  border-radius: var(--radius-sm);
  background: var(--fg); color: var(--bg);
  font-size: 0.65rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.section-intro {
  margin: -0.25rem 0 0.875rem;
  padding: 0.55rem 0.625rem;
  border-left: 3px solid var(--brand-green);
  background: var(--bg-alt);
  line-height: 1.45;
}
.product-set-section { padding: 0.75rem 1rem !important; }
.product-set-section h2 { margin-bottom: 0.55rem; }
.product-set-switch {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem;
}
.product-set-option {
  min-width: 0; padding: 0.65rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-alt); color: var(--fg); cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem;
  text-align: left; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.product-set-option:hover { border-color: var(--main); }
.product-set-option.active {
  border-color: var(--main);
  background: color-mix(in oklch, var(--main), var(--surface) 92%);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--main), transparent 84%);
}
.product-set-option b { font-size: 0.82rem; }
.product-set-option small { color: var(--fg-muted); font-size: 0.66rem; line-height: 1.35; }
.product-set-option.active b { color: var(--main); }
.card h2 .muted { font-weight: 400; color: var(--fg-muted); font-size: 0.75rem; }

/* ═══════════════════════════════════════════
   上传区
   ═══════════════════════════════════════════ */
.upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.upload-grid.single-face { grid-template-columns: minmax(0, 1fr); }
.face-editor[hidden], .cross-face-actions[hidden] { display: none !important; }
.upload-cell { display: flex; flex-direction: column; min-width: 0; }
.face-editor {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-alt);
}
.face-editor > .cell-label {
  margin-bottom: 0.5rem;
  color: var(--fg);
  font-size: 0.8rem;
}
.source-kind-control,
.layout-mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  padding: 3px; margin-bottom: 0.45rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-alt);
}
.source-kind-control button,
.layout-mode-switch button {
  min-height: 26px; padding: 0 0.4rem;
  border: 0; border-radius: 4px; background: transparent;
  color: var(--fg-muted); font: 600 0.67rem/1.2 var(--font-sans); cursor: pointer;
}
.source-kind-control button.active,
.layout-mode-switch button.active {
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm);
}
.cross-face-actions { display: flex; justify-content: flex-end; margin-top: 0.625rem; }
.copy-pattern-btn { width: auto; margin: 0; }
.image-processing-control.is-swatch-locked { opacity: 0.48; }
.image-processing-control.is-swatch-locked button { cursor: not-allowed; }
.upload-cell.disabled { opacity: 0.45; pointer-events: none; }
.upload-cell.disabled .dropbox { background: var(--accent); border-style: dashed; }
.cell-label {
  font-size: 0.75rem; color: var(--fg-muted); margin-bottom: 0.375rem;
  display: flex; align-items: center; gap: 0.375rem;
  font-weight: 600;
}
.req { color: var(--destructive); font-size: 0.7rem; }
.opt { color: var(--fg-muted); font-size: 0.7rem; }
.dropbox {
  border: 2px dashed var(--input); border-radius: var(--radius-md);
  padding: 1.125rem 0.5rem; text-align: center; cursor: pointer;
  background: transparent;
  transition: all 0.15s; min-height: 112px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.dropbox:hover {
  border-color: var(--main);
  background: color-mix(in oklch, var(--main), transparent 92%);
}
.dropbox.has-image { padding: 0; border-style: solid; border-color: var(--main); }
.dropbox.has-image img {
  width: 100%; height: 112px; object-fit: cover; display: block;
}
.dropbox .remove-x {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: 0;
  cursor: pointer; font-size: 0.85rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  z-index: 2; backdrop-filter: blur(4px);
}
.dropbox .remove-x:hover { background: var(--destructive); }
.pattern-scale-control {
  margin-top: 8px; padding: 8px 9px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
}
.pattern-scale-control.disabled { opacity: 0.52; }
.pattern-scale-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: var(--fg-muted); font-size: 0.68rem; font-weight: 600;
}
.pattern-scale-head b {
  color: var(--fg); font-size: 0.68rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pattern-scale-control input[type="range"] {
  width: 100%; height: 18px; margin: 5px 0 1px;
  accent-color: var(--brand-blue); cursor: pointer;
}
.pattern-scale-control input[type="range"]:disabled { cursor: not-allowed; }
.pattern-scale-labels {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--fg-muted); font-size: 0.58rem;
}
.pattern-tile-entry {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  min-width: 0; margin-top: 7px;
}
.pattern-tile-open {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 28px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--fg);
  font: 600 0.68rem/1.2 var(--font-sans); cursor: pointer;
}
.pattern-tile-open:hover:not(:disabled) { border-color: var(--main); background: var(--accent); }
.pattern-tile-open:disabled { opacity: 0.48; cursor: not-allowed; }
.pattern-tile-open.tiled { border-color: #059669; background: #ecfdf5; color: #047857; }
.dark .pattern-tile-open.tiled { background: rgba(5,150,105,0.16); color: #6ee7b7; }
.pattern-tile-entry-status {
  min-width: 0; white-space: normal;
  color: var(--fg-muted); font-size: 0.63rem; line-height: 1.35;
}
.pattern-tile-icon { font-size: 0.86rem; line-height: 1; }
.dropbox-multi { min-height: 70px; }
.dropbox-placeholder { color: var(--fg-muted); font-size: 0.75rem; }
.thumbs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.375rem; margin-top: 0.5rem;
}
.thumbs .thumb {
  position: relative; aspect-ratio: 1;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
}
.thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .thumb .x {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,0.55); color: #fff; border: 0;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 0.7rem; line-height: 1; cursor: pointer;
}

/* ═══════════════════════════════════════════
   Color Panel — 从图取色 / 色卡（AB 面各一份）
   ═══════════════════════════════════════════ */
/* 让 display:flex / display:grid 的元素也能被 [hidden] 属性隐藏 */
.cp-tab-body[hidden],
.cp-actions[hidden],
.palette-chips[hidden],
.swatch-inputs [hidden],
.preset-swatches [hidden] { display: none !important; }

.color-panel { margin-top: 0.5rem; }
.color-panel details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent);
}
.color-panel summary {
  cursor: pointer;
  font-size: 0.72rem;
  min-height: 34px; padding: 0.4rem 0.55rem;
  color: var(--brand-blue);
  user-select: none;
  list-style: none;
}
.color-panel summary::-webkit-details-marker { display: none; }
.color-panel summary::before {
  content: '▸ '; display: inline-block; transition: transform 0.15s;
}
.color-panel details[open] summary::before { transform: rotate(90deg); }
.color-panel-body {
  padding: 0.5rem;
  display: flex; flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Tabs */
.cp-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: -0.25rem -0.25rem 0;
  padding: 0 0.25rem;
}
.cp-tab {
  padding: 0.3rem 0.55rem;
  font-size: 0.7rem;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}
.cp-tab:hover { color: var(--fg); }
.cp-tab.active {
  color: var(--main);
  border-bottom-color: var(--main);
  font-weight: 600;
}
.cp-tab-body {
  display: flex; flex-direction: column;
  gap: 0.4rem;
}

.cp-empty {
  font-size: 0.7rem;
  color: var(--fg-muted);
  padding: 0.4rem 0.25rem;
  line-height: 1.4;
}
.cp-actions {
  display: flex; flex-wrap: wrap;
  gap: 0.375rem; align-items: center;
}
.cp-actions .btn-mini {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--fg);
}
.cp-actions .btn-mini:hover { border-color: var(--main); }
.cp-actions .btn-mini.active {
  background: var(--main); color: #fff; border-color: var(--main);
}
.palette-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 22px;
}
.palette-chips:empty::before {
  content: '尚未取色';
  font-size: 0.7rem; color: var(--fg-muted);
}
.palette-chips .swatch {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px 2px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}
.palette-chips .swatch .dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  display: inline-block;
}
.palette-chips .swatch .rm {
  border: 0; background: transparent;
  color: var(--fg-muted); cursor: pointer;
  padding: 0 2px; font-size: 0.8rem; line-height: 1;
}
.palette-chips .swatch .rm:hover { color: var(--danger); }

/* 色卡 tab */
.swatch-inputs {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.375rem;
}
.swatch-inputs input[type="color"] {
  width: 32px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; background: transparent;
}
.swatch-inputs input[type="text"] {
  width: 92px; padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  text-transform: uppercase;
}
.swatch-inputs .btn-mini {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--fg);
}
.swatch-inputs .btn-mini:hover { border-color: var(--main); }
.swatch-inputs .btn-mini.primary-mini {
  background: var(--main); color: #fff; border-color: var(--main);
}
.swatch-inputs .btn-mini.primary-mini:hover {
  filter: brightness(1.05);
}
.preset-swatches {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.preset-swatch-chip {
  width: 20px; height: 20px;
  padding: 0;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.preset-swatch-chip:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 1px var(--main);
}
.swatch-hint {
  font-size: 0.66rem;
  color: var(--fg-muted);
  line-height: 1.4;
}

.fabric-select-control,
.scene-prompt-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.fabric-select-control select { height: 36px; }
.fabric-select-control > span { font-size: 0.72rem; font-weight: 600; color: var(--fg); }
.fabric-select-control select,
.scene-prompt-control textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.75rem;
  padding: 0.45rem 0.55rem;
  outline: none;
}
.fabric-select-control select:focus,
.scene-prompt-control textarea:focus {
  border-color: var(--main);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--main), transparent 82%);
}
.fabric-select-control small,
.scene-prompt-control small { color: var(--fg-muted); font-size: 0.66rem; line-height: 1.4; }
.scene-prompt-control { padding-top: 0.65rem; border-top: 1px solid var(--border-light); }
.scene-prompt-control textarea { resize: vertical; min-height: 74px; max-height: 180px; }

/* 色卡预览时的 dropbox：禁用点击打开文件选择 */
.dropbox.is-swatch { cursor: default; }
.dropbox.is-swatch:hover {
  border-color: var(--main);
  background: transparent;
}

.dropbox.picking { cursor: crosshair !important; }
.dropbox.picking img { cursor: crosshair; }

/* ═══════════════════════════════════════════
   Chips — 模型选择
   ═══════════════════════════════════════════ */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.left #modelChips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.left #modelChips .chip { min-width: 0; text-align: center; }
.chip {
  padding: 0.5rem 0.875rem; border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 0.8rem;
  user-select: none; transition: all 0.15s; color: var(--fg);
}
.chip:hover { border-color: var(--main); }
.chip.active {
  background: var(--brand-gradient);
  background-origin: border-box; background-clip: border-box;
  color: #fff; border-color: transparent;
  font-weight: 600;
}
.chip .chip-name { line-height: 1.2; }

/* ═══════════════════════════════════════════
   表单 — Input / Select
   ═══════════════════════════════════════════ */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem;
}
.output-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid label, .card label.full {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.75rem; color: var(--fg-muted); font-weight: 600;
}
select, input[type=text], input[type=password], input[type=search] {
  height: 32px; padding: 0 0.625rem;
  border: 1px solid var(--input); border-radius: var(--radius-lg);
  font-size: 0.875rem; background: transparent; color: var(--fg);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-sans);
}
select::placeholder, input::placeholder { color: var(--fg-muted); }
select:focus, input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring), transparent 50%);
}

.hint { font-size: 0.75rem; color: var(--fg-muted); margin-top: 0.5rem; }
.hint.center { text-align: center; }

/* ═══════════════════════════════════════════
   右侧任务区
   ═══════════════════════════════════════════ */
.right-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
.right-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.tasks-area { display: flex; flex-direction: column; gap: 0.875rem; }
.tasks-empty {
  background: var(--surface); border: 1px dashed var(--border);
  padding: 3.5rem 1.25rem; border-radius: var(--radius-3xl);
  text-align: center; color: var(--fg-muted);
  box-shadow: var(--shadow-lg);
}

.task-group {
  background: var(--surface); border-radius: var(--radius-xl);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.task-group:hover { box-shadow: var(--shadow-md); }
.task-group-head {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--bg-alt); font-size: 0.8rem;
}
.task-group-head > div { min-width: 0; }
.task-group-head > div:last-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task-group-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task-group-head .id { font-family: var(--font-mono); color: var(--fg-muted); margin-right: 0.5rem; }
.task-group-head .meta { color: var(--fg-muted); font-size: 0.75rem; }

.compare-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  gap: 0;
}
.model-col {
  border-right: 1px solid var(--border);
  padding: 0.75rem; min-width: 0;
}
.model-col:last-child { border-right: 0; }
.model-col-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.625rem; font-weight: 600; font-size: 0.8rem;
}
.model-col-head .model-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg);
}
.subgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.625rem;
}
.sub {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--surface); font-size: 0.7rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.sub:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.sub img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: var(--accent); cursor: zoom-in;
}
.sub .sub-meta { padding: 0.375rem 0.5rem; line-height: 1.5; color: var(--fg-muted); }
.sub .sub-meta b { color: var(--fg); }
.sub.failed { border-color: var(--destructive); }
.sub.failed .sub-meta { color: var(--destructive); }
.failed-card {
  width: 100%; aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.375rem; padding: 0.875rem; text-align: center;
  background: color-mix(in oklch, var(--destructive), transparent 94%);
}
.failed-icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in oklch, var(--destructive), transparent 85%);
  color: var(--destructive); font-weight: 800;
}
.failed-title { color: var(--destructive); font-weight: 700; font-size: 0.8rem; }
.failed-msg {
  color: var(--fg-muted); font-size: 0.72rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sub-status-line {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
}
.sub-status-line .muted { color: var(--fg-muted); font-size: 0.7rem; }
.sub-status-line .redo-sub { margin-left: auto; padding: 0 0.5rem; font-size: 0.75rem; line-height: 1.5; }
.sub-adjust-actions { display: flex; margin-top: 0.4rem; }
.sub-adjust-actions .adjust-a-open { width: 100%; }
.sub-adjust-label { margin-top: 0.35rem; color: var(--brand-blue); font-weight: 600; }
.sub-err { color: var(--destructive); margin-top: 0.25rem; font-size: 0.7rem; }

/* ═══════════════════════════════════════════
   Badge — 对齐规范 Badge 组件（高度 20px，全圆角）
   ═══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem; font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.queued, .badge.running {
  background: color-mix(in oklch, var(--warn), transparent 88%);
  color: var(--warn);
}
.badge.done {
  background: color-mix(in oklch, var(--success), transparent 85%);
  color: var(--success);
}
.badge.failed {
  background: color-mix(in oklch, var(--destructive), transparent 88%);
  color: var(--destructive);
}

/* ═══════════════════════════════════════════
   生成中动画 — 对齐规范 4 层 CSS 动画
   ═══════════════════════════════════════════ */
.loading-card {
  width: 100%; aspect-ratio: 1; position: relative;
  background: var(--bg-alt); border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.loading-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    color-mix(in oklch, var(--brand-green), transparent 75%),
    color-mix(in oklch, var(--brand-blue), transparent 75%),
    color-mix(in oklch, var(--brand-green), transparent 75%));
  background-size: 200% 100%;
  animation: color-flow 3.8s ease-in-out infinite;
}
.loading-text {
  position: relative; z-index: 1;
  font-size: 0.75rem; color: var(--fg-muted); letter-spacing: 0.5px;
  animation: soft-pulse 2.4s ease-in-out infinite;
}
@keyframes color-flow {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes soft-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ═══════════════════════════════════════════
   Modal / Dialog — 对齐规范 Dialog 组件
   ═══════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-mask {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative; background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  width: 92%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1rem 1.125rem; overflow: auto; }
.modal-foot {
  padding: 0.75rem 1.125rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
body.modal-open { overflow: hidden; }

/* 生成后 A 面花型局部调整 */
.adjust-a-panel { width: min(1080px, calc(100vw - 32px)); max-width: 1080px; max-height: 92vh; }
.adjust-a-body { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.25rem; min-height: 0; }
.adjust-a-flat-section { min-width: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.adjust-a-flat-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.82rem; }
.adjust-a-flat-stage { min-height: 300px; flex: 1; display: grid; place-items: center; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: repeating-conic-gradient(#f3f4f6 0 25%, #fff 0 50%) 50% / 18px 18px; }
.adjust-a-flat-stage canvas { display: block; max-width: 100%; max-height: min(60vh, 580px); height: auto; box-shadow: var(--shadow-sm); background: #fff; }
.adjust-a-controls { display: flex; flex-direction: column; gap: 1rem; overflow: auto; padding-right: 0.25rem; }
.adjust-a-scale-field { display: flex; flex-direction: column; gap: 0.5rem; }
.adjust-a-scale-field > span { display: flex; justify-content: space-between; gap: 0.5rem; }
.adjust-a-scale-field input { width: 100%; }
.adjust-a-mode-controls { display: flex; flex-direction: column; gap: 1rem; }
.adjust-a-actions { display: flex; gap: 0.5rem; margin-left: auto; }

@media (max-width: 760px) {
  .adjust-a-panel { width: calc(100vw - 16px); }
  .adjust-a-body { grid-template-columns: minmax(0, 1fr); }
  .adjust-a-controls { overflow: visible; }
}

/* 花稿接版模拟 */
#patternTileModal [hidden] { display: none !important; }
.pattern-tile-panel {
  width: min(980px, calc(100vw - 32px));
  max-width: 980px;
  height: min(760px, calc(100vh - 32px));
  max-height: 92vh;
}
.pattern-mode-switch {
  min-height: 52px;
  padding: 8px 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.pattern-mode-switch button {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg-muted);
  font: 600 0.78rem var(--font-sans);
  cursor: pointer;
}
.pattern-mode-switch button:hover { background: var(--bg-alt); color: var(--fg); }
.pattern-mode-switch button.active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}
.pattern-workflow-progress {
  min-height: 54px;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.pattern-workflow-step {
  display: flex; align-items: center; gap: 8px;
  color: var(--fg-muted);
  font-size: 0.76rem;
}
.pattern-workflow-step span {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--fg-muted);
  font-size: 0.72rem; font-weight: 700;
}
.pattern-workflow-step.active { color: var(--fg); }
.pattern-workflow-step.active span {
  border-color: var(--brand-blue);
  background: var(--brand-blue); color: #fff;
}
.pattern-workflow-step.done span {
  border-color: #059669;
  background: #059669; color: #fff;
}
.pattern-workflow-line {
  width: 92px; height: 1px; margin: 0 14px;
  background: var(--border);
}
.pattern-workflow-line.done { background: #059669; }
.pattern-tile-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.pattern-tile-preview-wrap {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  padding: 16px;
  background: var(--bg-alt);
}
.pattern-flat-preview {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.pattern-flat-card {
  min-width: 0; min-height: 0; margin: 0;
  display: flex; flex-direction: column;
}
.pattern-flat-card figcaption {
  height: 30px;
  display: flex; align-items: center;
  color: var(--fg-muted);
  font-size: 0.72rem; font-weight: 600;
}
.pattern-flat-image-stage {
  position: relative;
  flex: 1; min-height: 240px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #eef1f4;
}
.dark .pattern-flat-image-stage { background: #111827; }
.pattern-flat-image-stage img {
  display: block;
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
}
.pattern-flat-image-stage img:not([src]) { display: none; }
.pattern-flat-image-stage.busy img { opacity: 0.52; }
.pattern-flat-placeholder {
  color: var(--fg-muted);
  font-size: 0.75rem;
}
.pattern-flat-image-stage img[src] ~ .pattern-flat-placeholder { display: none; }
.pattern-tile-preview-stage {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #eef1f4;
}
.dark .pattern-tile-preview-stage { background: #111827; }
.pattern-tile-preview-stage img {
  display: block;
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
}
.pattern-tile-preview-stage.busy img { opacity: 0.58; }
.pattern-tile-status {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: 120px;
  color: #0f172a;
  font-size: 0.78rem; font-weight: 600; text-align: center;
  text-shadow: 0 1px 2px rgba(255,255,255,0.9);
  pointer-events: none;
}
.dark .pattern-tile-status { color: #f8fafc; text-shadow: 0 1px 2px rgba(0,0,0,0.9); }
.pattern-tile-status:empty { display: none; }
.pattern-tile-meta {
  min-height: 28px;
  padding-top: 9px;
  color: var(--fg-muted);
  font-size: 0.72rem; line-height: 1.35;
  text-align: center;
}
.pattern-tile-controls {
  min-width: 0;
  padding: 20px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
}
.pattern-flat-controls { gap: 18px; }
.pattern-flatten-model-field small {
  color: var(--fg-muted); font-size: 0.66rem; line-height: 1.45;
}
.pattern-stage-timers {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.pattern-stage-timers > div {
  min-width: 0; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-alt);
  display: flex; flex-direction: column; gap: 2px;
}
.pattern-stage-timers span { color: var(--fg-muted); font-size: 0.66rem; }
.pattern-stage-timers b {
  color: var(--fg); font-size: 0.75rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pattern-stage-timers b.done { color: var(--success); }
.pattern-stage-timers b.failed { color: var(--destructive); }
.pattern-single-controls {
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--border);
}
.pattern-flat-summary strong {
  display: block; margin-bottom: 8px;
  color: var(--fg); font-size: 0.86rem;
}
.pattern-flat-summary p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.75rem; line-height: 1.65;
}
.pattern-flat-rules {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.pattern-flat-rules span {
  min-height: 34px; padding: 8px;
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--fg); font-size: 0.7rem;
}
.pattern-flat-model {
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--border);
  color: var(--fg-muted); font-size: 0.72rem;
}
.pattern-flat-model b {
  color: var(--fg); font-size: 0.8rem; font-weight: 600;
}
.pattern-flat-meta {
  color: var(--fg-muted);
  font-size: 0.7rem; line-height: 1.5;
}
.pattern-tile-field {
  display: flex; flex-direction: column; gap: 8px;
  color: var(--fg-muted);
  font-size: 0.75rem; font-weight: 600;
}
.pattern-tile-field select,
.pattern-tile-field input[type="number"] {
  width: 100%; height: 36px;
  padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--bg); color: var(--fg);
  font: 500 0.82rem var(--font-sans);
  outline: none;
}
.pattern-tile-field select:focus,
.pattern-tile-field input[type="number"]:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring), transparent 50%);
}
.pattern-tile-number { position: relative; }
.pattern-tile-number input { padding-right: 42px !important; }
.pattern-tile-number > span {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: var(--fg-muted); font-size: 0.72rem; font-weight: 500;
  pointer-events: none;
}
.width-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.width-presets button {
  min-width: 0; height: 27px; padding: 0 4px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg-alt); color: var(--fg-muted);
  font: 600 0.68rem/1 var(--font-sans); cursor: pointer;
}
.width-presets button.active { background: var(--surface); color: var(--fg); border-color: var(--ring); }
.pattern-tile-scale-field b {
  float: right; color: var(--fg); font-variant-numeric: tabular-nums;
}
.pattern-tile-scale-field input[type="range"] {
  width: 100%; height: 20px; margin: 0;
  accent-color: var(--brand-blue); cursor: pointer;
}
.pattern-tile-range-labels {
  display: flex; justify-content: space-between;
  color: var(--fg-muted); font-size: 0.68rem; font-weight: 400;
}
.pattern-tile-mode {
  height: 36px; padding: 0 10px;
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--accent); color: var(--fg);
  font-size: 0.82rem;
}
.pattern-tile-foot-actions {
  display: flex; align-items: center; justify-content: flex-end;
  flex-wrap: wrap; gap: 8px;
}

@media (max-width: 720px) {
  .pattern-tile-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    max-height: none;
  }
  .pattern-tile-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 1fr) auto;
    overflow-y: auto;
  }
  .pattern-tile-preview-wrap { min-height: 300px; padding: 10px; }
  .pattern-flat-image-stage { min-height: 220px; }
  .pattern-tile-controls {
    border-left: 0; border-top: 1px solid var(--border);
    padding: 14px; gap: 14px;
  }
  .pattern-workflow-progress { min-height: 48px; padding: 0 12px; }
  .pattern-workflow-line { width: 44px; margin: 0 8px; }
  .pattern-tile-foot { align-items: flex-end; }
}
.msg { font-size: 0.75rem; color: var(--fg-muted); }
.msg.ok { color: var(--success); }
.msg.err { color: var(--destructive); }
.kv-row {
  display: grid; grid-template-columns: 1fr 2fr; gap: 0.625rem;
  align-items: center; margin-bottom: 0.625rem;
}
.kv-row label { font-size: 0.75rem; color: var(--fg-muted); }
.kv-row .saved { font-size: 0.7rem; color: var(--success); }
.kv-row input { width: 100%; }
details { margin-top: 0.75rem; }
details summary {
  cursor: pointer; font-size: 0.8rem; color: var(--brand-blue);
  padding: 0.375rem 0;
}

.task-detail-panel { max-width: 900px; width: 95%; height: 82vh; }
.task-detail-panel .modal-body { flex: 1; display: flex; flex-direction: column; gap: 0.875rem; min-height: 0; }
.detail-section { min-height: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.detail-section h4 { margin: 0; font-size: 0.8rem; color: var(--fg); font-weight: 600; }
.detail-pre {
  margin: 0; padding: 0.625rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--code-bg); color: var(--fg);
  white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow: auto;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.6;
}
#taskDetailEditData { flex: 0 0 auto; max-height: 220px; }
.detail-logs {
  flex: 1; min-height: 180px; overflow: auto;
  background: #0f172a; color: #e2e8f0;
  border-radius: var(--radius-md); padding: 0.5rem;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.55;
}
.detail-log-line { padding: 0.2rem 0.375rem; border-bottom: 1px solid rgba(255,255,255,0.05); white-space: pre-wrap; word-break: break-all; }
.detail-log-line .ts { color: #94a3b8; margin-right: 0.5rem; }
.detail-log-line .lv { display: inline-block; min-width: 44px; text-align: center; padding: 0 0.375rem; border-radius: 3px; font-size: 0.65rem; margin-right: 0.5rem; font-weight: 700; }
.detail-log-line .lv-info  { background: #0369a1; color: #fff; }
.detail-log-line .lv-warn  { background: #b45309; color: #fff; }
.detail-log-line .lv-error { background: #b91c1c; color: #fff; }
.detail-log-line .lv-raw   { background: #475569; color: #fff; }
.detail-log-line .msg { color: #f1f5f9; font-weight: 600; }
.detail-log-line .meta { color: #94a3b8; margin-left: 0.5rem; }

/* ═══════════════════════════════════════════
   Lightbox 图片查看器 — 对齐规范 Image Viewer
   ═══════════════════════════════════════════ */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.88);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.lightbox .lb-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: zoom-out;
}
.lightbox img {
  max-width: 92vw; max-height: 92vh;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  cursor: zoom-in; user-select: none; touch-action: none;
  will-change: transform; transform-origin: center center;
  transition: transform 0.08s ease-out;
}
.lightbox img.is-zoomed { cursor: grab; }
.lightbox img.is-dragging { cursor: grabbing; transition: none; }
.lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: #fff;
  font-size: 1.5rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}
.lightbox .lb-nav:hover { background: rgba(255,255,255,0.25); }
.lightbox .lb-nav.prev { left: 1.5rem; }
.lightbox .lb-nav.next { right: 1.5rem; }
.lightbox .lb-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 0.85rem; line-height: 1; cursor: pointer;
  backdrop-filter: blur(4px);
}
.lightbox .lb-close:hover { background: var(--destructive); }
.lightbox .lb-counter {
  position: absolute; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 0.8rem; padding: 0.25rem 0.625rem;
  background: rgba(0,0,0,0.4); border-radius: var(--radius-sm);
  pointer-events: none;
}
.lightbox .lb-zoom {
  position: absolute; bottom: 1.25rem; right: 1.25rem;
  color: #fff; font-size: 0.75rem; font-variant-numeric: tabular-nums;
  padding: 0.25rem 0.5rem; background: rgba(0,0,0,0.48);
  border-radius: var(--radius-sm); pointer-events: none;
}

@media (max-width: 620px) {
  .upload-grid, .output-grid, .left #modelChips { grid-template-columns: 1fr; }
  .cross-face-actions .copy-pattern-btn { width: 100%; }
}

/* ═══════════════════════════════════════════
   日志面板
   ═══════════════════════════════════════════ */
.logs-panel { max-width: 900px; width: 95%; height: 80vh; max-height: 80vh; }
.logs-panel .modal-body { flex: 1; display: flex; flex-direction: column; gap: 0.625rem; overflow: hidden; }
.logs-toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; font-size: 0.75rem; color: var(--fg-muted); }
.logs-toolbar label { display: inline-flex; flex-direction: column; gap: 0.2rem; }
.logs-toolbar label.inline { flex-direction: row; align-items: center; gap: 0.25rem; }
.logs-toolbar input[type=text] { padding: 0.3rem 0.5rem; min-width: 200px; }
.logs-content {
  flex: 1; overflow: auto; background: #0f172a; color: #e2e8f0;
  border-radius: var(--radius-md); padding: 0.5rem;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.55;
}
.log-line { padding: 0.2rem 0.375rem; border-bottom: 1px solid rgba(255,255,255,0.05); white-space: pre-wrap; word-break: break-all; }
.log-line .ts { color: #94a3b8; margin-right: 0.5rem; }
.log-line .lv { display: inline-block; min-width: 44px; text-align: center; padding: 0 0.375rem; border-radius: 3px; font-size: 0.65rem; margin-right: 0.5rem; font-weight: 700; }
.log-line .lv-info  { background: #0369a1; color: #fff; }
.log-line .lv-warn  { background: #b45309; color: #fff; }
.log-line .lv-error { background: #b91c1c; color: #fff; }
.log-line .lv-raw   { background: #475569; color: #fff; }
.log-line .msg { color: #f1f5f9; font-weight: 600; }
.log-line .meta { color: #94a3b8; margin-left: 0.5rem; }
.log-line .log-ref { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.375rem 0 0.25rem 52px; }
.log-line .log-ref-item {
  display: inline-flex; align-items: center; gap: 0.375rem;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  padding: 0.2rem 0.375rem; border-radius: var(--radius-sm); color: #cbd5e1;
  text-decoration: none; font-size: 0.7rem;
}
.log-line .log-ref-item:hover { background: rgba(255,255,255,0.12); color: #fff; }
.log-line .log-ref-item img { width: 36px; height: 36px; object-fit: cover; border-radius: 3px; }
.log-line .log-ref-item.nolink { opacity: 0.7; cursor: default; }
.log-line .log-prompt { margin: 0.25rem 0 0.25rem 52px; color: #cbd5e1; }
.log-line .log-prompt summary { cursor: pointer; color: #93c5fd; font-size: 0.7rem; }
.log-line .log-prompt pre {
  margin: 0.375rem 0 0; padding: 0.5rem; background: rgba(0,0,0,0.3); border-radius: var(--radius-sm);
  white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto;
  font-size: 0.7rem; line-height: 1.5; color: #e2e8f0;
}
.muted { color: var(--fg-muted); font-weight: 400; font-size: 0.75rem; }

/* ═══════════════════════════════════════════
   生成记录弹窗
   ═══════════════════════════════════════════ */
.records-panel { max-width: 960px; width: 95%; height: 82vh; max-height: 82vh; }
.records-panel .modal-body { flex: 1; overflow: auto; }
.records-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.record-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--surface); font-size: 0.7rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.record-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.record-card img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: var(--accent); cursor: zoom-in;
}
.record-noimg {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--fg-muted);
}
.record-meta { padding: 0.375rem 0.5rem; line-height: 1.5; }
.record-line1 {
  display: flex; justify-content: space-between; align-items: center; gap: 0.375rem;
}
.record-model { font-weight: 600; color: var(--fg); }
.record-line2 {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem;
}
.record-cost {
  display: inline-flex; align-items: center; height: 18px; padding: 0 0.5rem;
  border-radius: 9999px;
  background: color-mix(in oklch, var(--warn), transparent 85%);
  color: var(--warn); font-size: 0.7rem; font-weight: 500;
}
.record-line2 .ghost-btn.small { margin-left: auto; padding: 0 0.5rem; font-size: 0.75rem; }

/* ═══════════════════════════════════════════
   A/B 面选择 + 参考图合并回显
   ═══════════════════════════════════════════ */
.input-echo {
  display: flex; gap: 0.625rem; flex-wrap: wrap; align-items: center;
  padding: 0.625rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  font-size: 0.7rem; color: var(--fg-muted); align-items: center;
}
.input-echo .detail-btn { margin-left: auto; }
.face-input-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  flex: 1 1 100%; gap: 0.5rem; min-width: 0;
}
.face-input-card {
  min-width: 0;
  display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 0.55rem; align-items: center;
  padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); overflow: hidden;
}
.face-input-card.face-a { border-left: 3px solid var(--brand-blue); }
.face-input-card.face-b { border-left: 3px solid var(--main); }
.face-input-card.scene-reference { border-left: 3px solid var(--warn); }
.face-input-preview {
  width: 58px; height: 58px; min-width: 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--accent); color: var(--fg-muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: 600 0.58rem/1.2 var(--font-sans);
}
button.face-input-preview { cursor: zoom-in; }
.face-input-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face-input-preview.is-color {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.22), transparent 48%),
    var(--swatch-color);
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.72);
}
.face-input-preview.is-color b { font-size: 0.55rem; }
.face-input-preview.is-material::before { content: '◈'; font-size: 1.1rem; color: var(--main); }
.face-input-copy { min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; line-height: 1.4; }
.face-input-copy b { color: var(--fg); font-size: 0.75rem; }
.face-input-copy span { overflow-wrap: anywhere; }
.face-input-copy span {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  overflow: hidden;
}
.input-empty { color: var(--fg-muted); }
.scene-input-refs {
  display: flex; align-items: center; gap: 0.375rem;
  padding-left: 0.625rem; border-left: 1px solid var(--border);
}
.scene-input-refs > span { white-space: nowrap; font-weight: 600; }
.input-echo .ref-thumb {
  width: 44px; height: 44px; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); cursor: zoom-in; position: relative;
  background: var(--accent);
}
.input-echo .ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.input-echo .ref-thumb .tag {
  position: absolute; left: 0; bottom: 0; right: 0;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 0.55rem;
  text-align: center; padding: 1px 0; line-height: 1.2;
}

.edit-echo {
  display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.625rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface); font-size: 0.72rem;
}
.edit-echo .label {
  flex: 0 0 auto; padding-top: 0.3rem;
  color: var(--fg-muted); font-weight: 600;
}
.scene-supplement-echo {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem;
  padding: 0.625rem 1rem; border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--brand-green), var(--surface) 94%);
  font-size: 0.72rem; line-height: 1.55;
}
.scene-supplement-echo .label { color: var(--fg-muted); font-weight: 600; }
.scene-supplement-text { color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; }
.face-edit-chip {
  min-width: 0; max-width: 100%;
  display: inline-flex; align-items: flex-start; gap: 0.4rem;
  padding: 0.3rem 0.5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-alt);
  color: var(--fg-muted); line-height: 1.35;
}
.face-edit-chip b { flex: 0 0 auto; color: var(--fg); }
.face-edit-chip span { min-width: 0; overflow-wrap: anywhere; }
.face-edit-chip.face-a { border-left: 3px solid var(--brand-blue); }
.face-edit-chip.face-b { border-left: 3px solid var(--main); }

@media (max-width: 640px) {
  .topbar {
    position: static;
    flex-wrap: wrap;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
  }
  .brand { flex: 1 1 100%; min-width: 0; gap: 0.5rem; }
  .brand .brand-logo { width: 30px; height: 30px; flex: 0 0 auto; }
  .brand h1 { font-size: 0.85rem; white-space: normal; overflow-wrap: anywhere; }
  .topbar-right { width: 100%; justify-content: flex-end; gap: 0.375rem; }
  .topbar-right .ghost-btn { height: 30px; padding: 0 0.55rem; font-size: 0.75rem; }
  .settings-dropdown { position: fixed; left: 12px; right: 12px; top: 100px; min-width: 0; }
  .layout { width: 100%; padding: 0.75rem; gap: 1rem; }
  .card { padding: 0.75rem; }
  .upload-grid { grid-template-columns: minmax(0, 1fr); gap: 0.875rem; }
  .pattern-scale-head { align-items: flex-start; flex-direction: column; gap: 2px; }
  .pattern-scale-labels { font-size: 0.56rem; }
  .task-group-head { align-items: flex-start; padding: 0.625rem 0.75rem; }
  .task-group-head > div:last-child { width: 100%; }
  .input-echo { padding: 0.5rem 0.75rem; align-items: stretch; }
  .face-input-cards { flex-basis: 100%; grid-template-columns: minmax(0, 1fr); }
  .face-input-card { min-width: 0; flex-basis: 100%; }
  .scene-input-refs { flex-basis: 100%; padding: 0.5rem 0 0; border-left: 0; border-top: 1px solid var(--border); }
  .input-echo .detail-btn { margin-left: 0; align-self: flex-start; }
  .scene-supplement-echo { grid-template-columns: 1fr; padding: 0.5rem 0.75rem; }
  .pattern-stage-timers { grid-template-columns: 1fr; }
  .compare-row { grid-template-columns: minmax(0, 1fr); }
}

/* ═══════════════════════════════════════════
   预设图库 — 对齐规范 ImageButton
   ═══════════════════════════════════════════ */
.preset-block { margin-top: 0.625rem; }
.preset-head { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 0.375rem; }
.preset-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
}
.preset-card {
  position: relative; cursor: pointer;
  border-radius: var(--radius-md);
  border: 2px solid transparent; overflow: hidden;
  background: var(--bg); transition: border-color 0.15s, transform 0.1s;
}
.preset-card:hover {
  border-color: color-mix(in oklch, var(--main), transparent 50%);
  transform: translateY(-1px);
}
.preset-card.selected { border-color: var(--main); }
.preset-card img {
  width: 100%; height: 86px; object-fit: cover; display: block;
}
.preset-card .preset-name {
  font-size: 0.7rem; line-height: 1.3; padding: 0.25rem 0.375rem; color: var(--fg);
  text-align: center;
  background: color-mix(in oklch, var(--surface), transparent 15%);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preset-card .preset-check {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--main); color: #fff; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.preset-card.selected .preset-check { opacity: 1; }

.dropbox.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.preset-card.disabled { opacity: 0.35; cursor: not-allowed; }
.preset-card.disabled:hover { border-color: transparent; transform: none; }

/* ═══════════════════════════════════════════
   主题切换浮动按钮
   ═══════════════════════════════════════════ */
.theme-toggle {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  cursor: pointer; font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); transition: all 0.2s;
}
.theme-toggle:hover { transform: scale(1.1); }

/* ═══════════════════════════════════════════
   滚动条 — 对齐规范 ScrollArea
   ═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in oklch, var(--fg-muted), transparent 80%);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklch, var(--fg-muted), transparent 60%);
}

/* 积分预览 & 已消耗积分 */
.credits-preview {
  display: inline-block;
  margin-right: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(29, 155, 240, 0.08);
  color: var(--primary, #1d9bf0);
  font-size: 0.88rem;
  align-self: center;
}
.credits-preview.hidden { display: none; }
.credits-preview b { font-weight: 700; }
.consumed-credits {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 0.78rem;
  border-radius: 999px;
  background: rgba(76, 175, 80, 0.12);
  color: #2e7d32;
}
