/* ============================================================================
 * 启未AI场景平台 V2 · 样式（沿用旧版主题体系：深浅双主题 / 响应式）
 * 字号统一使用 rem：顶部 A+/A− 按钮改 html 字号，所有文字跟随缩放
 * 布局紧凑：三步设置一屏可见（1440×1000 无需滚动即可浏览全景）
 * ==========================================================================*/

/* 三套主题配色（右上角「主题」按钮循环切换，选择自动记忆）：
   纯白（默认，干净清爽的电商白）→ 浅绿（浅绿底+豆绿，护眼绿植系）→ 深色（暗蓝灰+靛蓝紫冷色科技感）。
   全部元素走主题变量，切换整体换肤、无残留旧色。 */
:root {
  --bg: #ffffff;             /* 纯白页面背景 */
  --surface: #ffffff;        /* 纯白卡片 */
  --surface-2: #f4f5f6;      /* 浅灰次级面 */
  --line: #e5e7eb;           /* 浅灰边框 */
  --text: #1f2937;           /* 深灰文字 */
  --muted: #6b7280;          /* 灰次要文字 */
  --brand: #2563eb;          /* 明亮蓝 主品牌色 */
  --brand-strong: #1d4ed8;   /* 深蓝（文字用，对比更足） */
  --brand-soft: rgba(37, 99, 235, .12);
  --brand-gradient: linear-gradient(135deg, #1d4ed8, #2563eb);  /* 深蓝→亮蓝（白字可读） */
  --accent-amber: #b45309;
  --accent-emerald: #2f8f5b;
  --accent-rose: #d64545;
  --accent-amber-soft: rgba(230, 164, 60, .15);
  --accent-emerald-soft: rgba(47, 143, 91, .13);
  --accent-rose-soft: rgba(214, 69, 69, .12);
  --radius: 8px;
  --radius-card: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05), 0 4px 14px rgba(17, 24, 39, .05);
  --shadow-card: 0 20px 40px rgba(17, 24, 39, .08), 0 1px 0 rgba(255, 255, 255, .8) inset;
  --danger: #dc2626;
}
:root[data-theme="cream"] {
  --bg: #eef5ec;             /* 浅绿页面背景（比豆绿更浅的护眼绿） */
  --surface: #f7faf4;        /* 浅绿白卡片 */
  --surface-2: #e3efe0;      /* 豆绿浅次级面 */
  --line: #cfdfca;           /* 浅豆绿边框 */
  --text: #2f4035;           /* 深灰绿文字 */
  --muted: #6d8873;          /* 灰绿次要文字 */
  --brand: #55a86b;          /* 豆绿 主品牌色 */
  --brand-strong: #3f8c57;   /* 深豆绿（文字用，对比更足） */
  --brand-soft: rgba(85, 168, 107, .18);
  --brand-gradient: linear-gradient(135deg, #46925e, #55a86b);  /* 深豆绿→豆绿（白字可读） */
  --accent-amber: #b45309;
  --accent-emerald: #3d8b63;
  --accent-rose: #c2463e;
  --accent-amber-soft: rgba(230, 164, 60, .16);
  --accent-emerald-soft: rgba(61, 139, 99, .14);
  --accent-rose-soft: rgba(194, 70, 62, .13);
  --shadow-sm: 0 1px 2px rgba(45, 95, 60, .08), 0 4px 14px rgba(45, 95, 60, .08);
  --shadow-card: 0 20px 40px rgba(45, 95, 60, .12), 0 1px 0 rgba(255, 255, 255, .9) inset;
  --danger: #b33a2b;
}

:root[data-theme="dark"] {
  --bg: #111827;
  --surface: #1e293b;
  --surface-2: #263349;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --brand: #818cf8;
  --brand-strong: #6366f1;
  --brand-soft: rgba(129, 140, 248, .26);
  --accent-amber: #fbbf24;
  --accent-emerald: #34d399;
  --accent-rose: #fb7185;
  --accent-amber-soft: rgba(251, 191, 36, .15);
  --accent-emerald-soft: rgba(52, 211, 153, .15);
  --accent-rose-soft: rgba(251, 113, 133, .15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --shadow-card: 0 20px 40px rgba(0, 0, 0, .42), 0 1px 0 rgba(255, 255, 255, .08) inset;
  --danger: #f87171;
}

* { box-sizing: border-box; }
/* 字号基准 15px：顶栏 A+/A− 会改这里的值，页面所有 rem 文字跟随 */
html { font-size: 15px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  line-height: 1.5;
}

/* ============================ 整体骨架 ============================ */

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 210px minmax(0, 1fr); }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand-mark { font-size: 1.13rem; font-weight: 800; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 2px 6px; }
.nav-list { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-radius: var(--radius);
  color: var(--muted); text-decoration: none; font-size: 0.9rem;
}
.nav-item:hover { background: var(--brand-soft); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.nav-item.locked { opacity: .55; cursor: not-allowed; }
.lock-badge { font-size: 0.67rem; padding: 1px 6px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted); }

.main-area { min-width: 0; display: flex; flex-direction: column; }

/* ============================ 顶栏 ============================ */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.product-name { font-weight: 700; }
.version-tag { font-size: 0.73rem; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 1px 9px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.api-state { font-size: 0.8rem; color: var(--accent-rose); padding: 3px 10px; border-radius: var(--radius-pill); background: var(--accent-rose-soft); }
.api-state.ok { color: var(--accent-emerald); background: var(--accent-emerald-soft); }
.theme-toggle, .font-btn, .reset-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 3px 9px; cursor: pointer; font-size: 0.87rem;
}
.theme-toggle:hover, .font-btn:hover, .reset-btn:hover { background: var(--brand-soft); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ============================ 三步导航 ============================ */

.step-pills {
  display: flex; gap: 10px; padding: 10px 18px 0;
  flex-wrap: wrap;
}
.step {
  font-size: 0.83rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 3px 14px; background: var(--surface); cursor: pointer;
  transition: all .15s;
}
.step:hover { border-color: var(--brand); color: var(--text); }
/* 点击高亮：外框亮起（描边 + 柔和光晕），不做其他功能 */
.step.active {
  color: var(--brand-strong); font-weight: 700;
}

/* ============================ 主工作区 ============================ */

.workspace-grid {
  display: grid; grid-template-columns: minmax(430px, 1fr) minmax(340px, .82fr);
  gap: 12px; padding: 12px 16px 18px; align-items: start;
}
.editor-column, .result-column { display: grid; align-content: start; gap: 12px; }
/* 结果列允许收缩：图片多了靠卡片区自己的滚动条，而不是把页面撑出横向滚动 */
.result-column { min-width: 0; }
.result-grid { min-width: 0; max-width: 100%; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.panel-title { margin: 0 0 8px; font-size: 0.97rem; }
.panel-title--with-action { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-reset-workspace { flex: 0 0 auto; min-height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-2); font: inherit; font-size: .76rem; font-weight: 700; cursor: pointer; }
.panel-reset-workspace:hover { color: var(--brand-strong); border-color: var(--brand); background: var(--brand-soft); }

.field-block { margin-bottom: 7px; }
.field-block:last-child { margin-bottom: 0; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.field-label { font-size: 0.9rem; font-weight: 700; }
.field-hint { font-size: 0.75rem; color: var(--muted); }

/* 可折叠块：点标题展开/收起（场景主题、产品尺寸、02 场景细节整面板） */
.collapsible > .collapse-head { cursor: pointer; user-select: none; transition: color .15s; }
.collapsible > .collapse-head:hover { color: var(--brand); }
.collapsible > .collapse-head::after {
  content: '▾'; margin-left: 2px; font-size: .8em; color: var(--muted);
  transition: transform .18s;
}
.collapsible.collapsed > .collapse-head::after { transform: rotate(-90deg); }
.collapsible.collapsed > .collapse-head .field-hint::after { content: ' · 点击展开'; }
.collapsible.collapsed > .collapse-body { display: none; }
.collapsible > .collapse-body { margin-bottom: 3px; }
/* 整面板折叠（02 场景细节）：收起时隐藏全部子块 */
.collapsible.collapsed > .field-block { display: none; }
.collapsible.collapsed > .panel-title { margin-bottom: 0; }

/* 必选项醒目标记 */
  animation: reqPulse 2s infinite;
.required-field .field-label { color: var(--brand-strong); }
.req-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-rose); margin-right: 6px; vertical-align: 2px;
}
@keyframes reqPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.select {
  width: 100%; padding: 5px 8px; font-size: 0.87rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.select.missing, .chip-group.missing, .upload-card.missing {
  border-color: var(--accent-rose) !important;
  box-shadow: 0 0 0 3px var(--accent-rose-soft) !important;
}
.upload-card.missing {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px var(--brand-soft) !important;
}
.upload-card { border: 1px dashed var(--line); border-radius: var(--radius-card); background: var(--surface-2); transition: border-color .2s; }
.upload-card.dragging { border-color: var(--brand); background: var(--brand-soft); }

.drop-zone {
  padding: 11px 16px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.drop-icon { color: var(--brand); opacity: .85; }
.drop-text strong { display: block; font-size: 0.87rem; }
.drop-text small { color: var(--muted); font-size: 0.73rem; }
.upload-card.has-images { display: flex; align-items: stretch; gap: 8px; padding: 8px; min-height: 112px; }
.upload-card.has-images .drop-zone { order: 2; flex: 1; min-width: 132px; padding: 8px 10px; flex-direction: column; gap: 2px; text-align: center; border-left: 1px dashed var(--line); }
.upload-card.has-images .drop-icon { display: none; }
.upload-plus { display: none; }
.upload-card.has-images .upload-plus { display: block; color: var(--brand); font-size: 2rem; line-height: 1; font-weight: 300; }
.upload-card.has-images .drop-text strong { font-size: 0.8rem; }
.upload-card.has-images .drop-text small { display: block; font-size: .72rem; }
.upload-card.upload-full .drop-zone { display: none; }

.reference-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 10px 10px; }
.upload-card:not(.has-images) .reference-list { display: none; }
.upload-card.has-images .reference-list { order: 1; display: flex; flex: 0 1 auto; gap: 8px; padding: 0; }
.reference-item { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface); border: 1px solid var(--line); }
.upload-card.has-images .reference-item { flex: 0 1 130px; width: min(130px, 22vw); }
.reference-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.main-badge {
  position: absolute; top: 6px; left: 6px; font-size: 0.67rem;
  background: rgba(217, 119, 6, .92); color: #fff; padding: 1px 8px; border-radius: var(--radius-pill);
}
.ref-remove {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border: none;
  border-radius: 50%; background: rgba(15, 23, 42, .55); color: #fff; cursor: pointer; font-size: 0.8rem; line-height: 1;
}
.ref-remove:hover { background: var(--accent-rose); }
.upload-note { font-size: 0.73rem; color: var(--muted); margin: 6px 0 0; }
@media (max-width: 620px) {
  .upload-card.has-images { flex-wrap: wrap; }
  .upload-card.has-images .reference-list { flex: 1 1 100%; }
  .upload-card.has-images .drop-zone { border-left: 0; border-top: 1px dashed var(--line); min-height: 74px; }
}

/* 产品尺寸：一行两段——左侧长/宽/高输入框紧凑靠左，右侧 5 档体型标签靠右 */
.size-block { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.size-row { display: flex; align-items: flex-end; gap: 6px; }
.size-item { display: flex; flex-direction: column; gap: 3px; font-size: 0.77rem; color: var(--muted); width: 76px; }
.size-item input {
  padding: 4px 6px; font-size: 0.87rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%;
}
.size-unit { font-size: 0.77rem; color: var(--muted); padding-bottom: 6px; white-space: nowrap; }
.size-tier-block { display: flex; align-items: center; gap: 8px; padding-bottom: 1px; }
.size-tier-label { font-size: 0.77rem; color: var(--muted); white-space: nowrap; }

/* 属性风格 / 视角 / 镜头 / 复杂度 chips（标签点选，不用下拉） */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius-pill); padding: 3px 10px; font-size: 0.83rem; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--brand); }
.chip.selected { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

/* 风格池有“跟随 + 9 个显式项”；仅压缩该行，不影响其余控制芯片的点击尺寸。 */
#attrStyleGroup { gap: 4px; }
#attrStyleGroup .chip { padding-inline: 7px; font-size: 0.79rem; white-space: nowrap; }

/* V3 场景主题：模式单选 + 节日二级菜单 + 装饰强度（规则卡 1.3/3.1） */
.theme-bar { position: relative; display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.holiday-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  min-width: 210px; max-width: 290px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 6px;
}
.holiday-item {
  width: 100%; border: none; background: transparent; color: var(--text);
  text-align: left; padding: 6px 10px; border-radius: 8px;
  font-size: 0.84rem; cursor: pointer; transition: background .15s;
}
.holiday-item-more {
  width: 100%; border: none; background: transparent; color: var(--muted);
  text-align: left; padding: 6px 10px; font-size: 0.8rem; cursor: pointer;
  border-top: 1px dashed var(--line); margin-top: 4px; transition: background .15s;
}
.holiday-item-more:hover { background: var(--brand-soft); color: var(--brand); }
.holiday-more {
  border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px;
}
.theme-intensity-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding: 6px 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--line);
}
.intensity-label { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.chip.chip-small { padding: 2px 8px; font-size: 0.78rem; }

/* 产品分类两级下拉菜单：点触发按钮展开第一级大类，鼠标移到大类上出第二级产品 */
.product-pick-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: baseline; gap: 8px; }
.custom-product-title { font-size: .8rem; font-weight: 600; color: var(--text); }
.product-pick-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 8px; }
.product-pick-row:has(.custom-product-field.hidden) { grid-template-columns: minmax(0, 1fr); }
.cat-menu-wrap { position: relative; }
.cat-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 8px 12px; font-size: 0.9rem; cursor: pointer;
  transition: border-color .15s;
}
.cat-trigger:hover { border-color: var(--brand); }
.cat-trigger.picked { border-color: var(--brand); background: var(--brand-soft); }
.cat-caret { color: var(--muted); font-size: 0.8rem; }
.cat-dropdown {
  /* 两列菜单按条目自然展开，分类和产品均不使用内部滚动。 */
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 9999;
  display: flex; min-height: 120px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: visible;
}
.cat-level { padding: 6px; min-width: 170px; max-width: 220px; height: auto; max-height: none; overflow: visible; }
.cat-level + .cat-level { border-left: 1px solid var(--line); min-width: 190px; }
.cat-level-title { padding: 5px 10px 7px; color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .04em; }
.cat-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  border: none; background: transparent; color: var(--text);
  text-align: left; padding: 7px 10px; border-radius: 8px;
  font-size: 0.87rem; cursor: pointer; transition: background .15s;
}
.cat-item:hover { background: var(--brand-soft); color: var(--brand); }
.cat-item.selected { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.cat-item.open { color: var(--brand); font-weight: 700; }
.cat-arrow { color: var(--muted); font-size: 0.75rem; }
.flyout-item {
  width: 100%; border: none; background: transparent; color: var(--text);
  text-align: left; padding: 7px 10px; border-radius: 8px;
  font-size: 0.87rem; cursor: pointer; transition: background .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flyout-item:hover { background: var(--brand-soft); color: var(--brand); }
.flyout-item.selected { background: var(--brand); color: #fff; font-weight: 700; }
.flyout-item--custom { margin-top: 5px; padding-top: 9px; border-top: 1px dashed var(--line); color: var(--brand-strong); font-weight: 700; }
.custom-product-field { min-width: 0; }
.custom-product-field input { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.custom-product-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.custom-product-field.missing input { border-color: var(--accent-rose); box-shadow: 0 0 0 3px var(--accent-rose-soft); }
.current-pick {
  margin: 6px 0 0; font-size: 0.8rem; color: var(--muted);
}
.current-pick.picked { color: var(--brand); font-weight: 600; }

/* 景深 / 多选开关 */
.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row input { display: none; }
.switch-track {
  width: 36px; height: 20px; border-radius: var(--radius-pill); background: var(--line);
  position: relative; transition: background .2s; flex: none;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .2s;
}
.switch-row input:checked + .switch-track { background: var(--brand); }
.switch-row input:checked + .switch-track .switch-thumb { left: 19px; }
.switch-text { font-size: 0.85rem; }
.switch-row.compact .switch-track { width: 30px; height: 17px; }
.switch-row.compact .switch-thumb { width: 12px; height: 12px; top: 2.5px; left: 2.5px; }
.switch-row.compact input:checked + .switch-track .switch-thumb { left: 15.5px; }
.switch-row.compact .switch-text { font-size: 0.8rem; font-weight: 700; color: var(--brand-strong); }

/* ============================ 右侧出图区 ============================ */

.result-column { position: sticky; top: 12px; }
.prompt-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prompt-title { margin: 0; font-size: 0.97rem; }
.prompt-head-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.plan-generate-btn { border: 1px solid var(--brand); border-radius: var(--radius); background: var(--brand); color: #fff; font: inherit; font-size: .76rem; font-weight: 700; padding: 6px 9px; white-space: nowrap; cursor: pointer; }
.plan-generate-btn:hover { filter: brightness(1.05); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan-generate-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
/* 刷新按钮：圆形图标，悬停描边发光 + 图标旋转 */
.reroll-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; flex: none;
  border: 1px solid var(--brand); background: transparent; color: var(--brand-strong);
  border-radius: 50%; cursor: pointer; transition: all .18s;
}
.reroll-btn svg { transition: transform .35s ease; }
.reroll-btn:hover {
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.reroll-btn:hover svg { transform: rotate(180deg); }
.reroll-btn:disabled { opacity: .4; cursor: not-allowed; }
.reroll-btn:disabled:hover svg { transform: none; }
.prompt-desc { margin: 2px 0 8px; font-size: 0.75rem; color: var(--muted); }

/* 方案 pills：多选 + 标签化说明 */
.plan-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-bottom: 6px; }
.plan-pill {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 6px 4px; cursor: pointer; transition: all .15s;
}
/* 未选中：鼠标移过去边框亮起 + 外圈光晕，移走自然暗淡（transition 过渡） */
.plan-pill:hover { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.plan-pill.active { background: var(--brand-soft); border-color: var(--brand); }
/* 选中 = 被锁定的明显标识：加粗品牌色边框 + 品牌色底 + 外发光 + 右上角 ✓ 勾标。
   不改文字颜色（保持原色显示），浅色/深色主题下都清晰可读 */
.plan-pill.selected {
  border-color: var(--brand); border-width: 3px;
  background: var(--brand-soft);
  box-shadow: 0 0 0 2px var(--brand-soft), 0 0 16px 1px var(--brand-soft), 0 4px 14px rgba(0, 0, 0, .16);
  transform: translateY(-1px);
}
.plan-pill.selected .plan-pill-name { color: var(--brand-strong); }
.plan-pill.selected .plan-pill-label { color: var(--text); }
/* 收藏方案模式：原 8 方案停用（灰显、无悬停光晕、无框选效果），与收藏方案二选一 */
.plan-pill--inert { opacity: .42; filter: grayscale(.7); cursor: not-allowed; }
.plan-pill--inert:hover { border-color: var(--line); box-shadow: none; }
.plan-pill--inert .fav-heart { opacity: .5; pointer-events: none; }
.plan-pill-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 24px; padding: 3px 6px; border-radius: 7px; background: var(--accent-amber-soft); color: var(--accent-amber); }
.plan-pill-name { font-weight: 800; font-size: .92rem; color: currentColor; line-height: 1.2; text-align: left; }
.plan-pill-label {
  font-size: .75rem; color: var(--muted); line-height: 1.4; text-align: left;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.plan-pill.active .plan-pill-label { color: var(--brand-strong); }
.plan-pill-tags { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px; margin-top: 2px; }
.plan-pill-tag { max-width: 100%; padding: 2px 6px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted); font-size: .66rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-pill.active .plan-pill-tag, .plan-pill.selected .plan-pill-tag { background: rgba(255,255,255,.6); color: var(--brand-strong); }
.plan-pill--pending { border-style: dashed; background: var(--surface-2); color: var(--muted); cursor: default; }
.plan-pill--pending:hover { border-color: var(--line); box-shadow: none; }
.plan-pill--pending .plan-pill-head { background: var(--surface); color: var(--muted); }

.multi-hint { margin: 0 0 8px; font-size: 0.75rem; color: var(--muted); }
.multi-hint.warn {
  color: var(--accent-rose); background: var(--accent-rose-soft);
  padding: 5px 9px; border-radius: var(--radius);
}

.prompt-editor {
  width: 100%; min-height: 108px; resize: vertical; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.83rem;
  background: var(--surface-2); color: var(--text); font-family: inherit; line-height: 1.6;
}

.generate-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.ctrl-item { display: flex; flex-direction: column; gap: 3px; font-size: 0.77rem; color: var(--muted); }

.generate-btn {
  width: 100%; margin-top: 10px; padding: 9px; border: none; border-radius: var(--radius);
  background: var(--brand-gradient); color: #fff; font-size: 0.97rem; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.generate-btn:disabled { opacity: .4; cursor: not-allowed; }

.progress-wrap { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.progress-bar-wrap {
  height: 12px; border-radius: var(--radius-pill); background: var(--surface-2);
  border: 1px solid var(--line); overflow: hidden; position: relative;
}
.progress-bar-fill {
  height: 100%; width: 0%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand), var(--brand-strong), #ec4899, #f59e0b, var(--brand));
  background-size: 300% 100%;
  animation: progressFlow 2.2s linear infinite;
  transition: width .35s ease;
  box-shadow: 0 0 10px var(--brand-soft);
}
.progress-bar-wrap.done .progress-bar-fill {
  background: linear-gradient(90deg, #059669, #34d399, #059669);
  background-size: 300% 100%;
  animation: none;
}
.progress-bar-wrap.error .progress-bar-fill { background: var(--accent-rose); animation: none; box-shadow: none; }
@keyframes progressFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
.progress-bar-text { font-size: 0.8rem; color: var(--muted); padding: 0 2px; }
.progress-bar-text.done { color: var(--accent-emerald); font-weight: 700; }
.progress-bar-text.error { color: var(--accent-rose); font-weight: 600; }

.result-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 12px; box-shadow: var(--shadow-sm); min-width: 0; }
.result-tabs { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 10px; }
.result-tabs-left { display: flex; gap: 6px; }
.tab-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: var(--radius-pill); padding: 3px 12px; font-size: 0.8rem; cursor: pointer;
}
.tab-btn.active { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand); font-weight: 700; }
.tab-btn.download-all { color: var(--accent-emerald); border-color: var(--accent-emerald); }
.tab-btn.download-all:hover { background: var(--accent-emerald-soft); }
/* 结果区：单行横向滚动。不超过 2 张时内容不满、自动不出现滚动条；多张时横向滑动查看 */
.result-grid {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 6px; scroll-behavior: smooth;
  scrollbar-width: thin; scrollbar-color: var(--brand-strong) var(--surface-2);
}
/* 滚动条加粗常显：图片多了（历史记录满）时一眼可见、方便横拉 */
.result-grid::-webkit-scrollbar { height: 10px; }
.result-grid::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 5px; }
.result-grid::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 5px; }
.result-grid::-webkit-scrollbar-thumb:hover { background: var(--brand-strong); }
/* 结果区空状态引导（当前结果 vs 历史记录） */
.grid-empty {
  flex: none; width: 100%; min-height: 96px; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 0.75rem; color: var(--muted); line-height: 1.7;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-2);
  white-space: pre-line; padding: 12px;
}
.result-card {
  position: relative; flex: none; height: 200px;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); cursor: zoom-in; background: var(--surface-2);
  aspect-ratio: 4 / 3; /* 渲染时按生成画幅覆盖（宽度=高度×比例，忠实还原不裁切） */
}
/* 历史记录：与当前结果同款卡片与逻辑，仅画幅更小（预览形式，方便一眼找到想要的图） */
.result-grid.small .result-card { height: 96px; }
.result-grid.small .card-download { width: 20px; height: 20px; font-size: 0.67rem; }
.result-card img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--surface-2); }
.result-grid.small .result-card { height: 96px; }
.result-grid.small .card-download { width: 20px; height: 20px; font-size: 0.67rem; }
.card-download {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  border: none; border-radius: 50%; background: rgba(15, 23, 42, .55); color: #fff;
  font-size: 0.8rem; cursor: pointer; line-height: 1; opacity: 0; transition: opacity .15s;
}
.result-card:hover .card-download { opacity: 1; }
.card-download:hover { background: var(--accent-emerald); }
.hidden { display: none !important; }

.principle-panel {
  padding: 10px 12px; border-left: 3px solid var(--accent-amber);
  background: var(--accent-amber-soft); border-radius: var(--radius);
}
.principle-panel strong { font-size: 0.8rem; }
.principle-panel p { margin: 4px 0 0; color: var(--muted); font-size: 0.73rem; }

/* ============================ 大图预览 ============================ */

.lightbox {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .78); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
.lightbox img { max-width: 88%; max-height: 88%; border-radius: var(--radius-card); box-shadow: var(--shadow-card); object-fit: contain; transition: transform .16s ease, opacity .14s ease; will-change: transform; cursor: grab; touch-action: none; contain: layout paint; }
.lightbox img.is-dragging { cursor: grabbing; transition: none; }
.lightbox img.is-loading { opacity: .48; }
.lightbox-close {
  position: absolute; top: 18px; right: 22px; width: 36px; height: 36px; border: none;
  border-radius: 50%; background: rgba(255, 255, 255, .18); color: #fff; font-size: 1.07rem; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .32); }
.lightbox-nav {
  position: fixed; top: 50vh; transform: translateY(-50%);
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .18); color: #fff; font-size: 1.33rem; cursor: pointer; z-index: 101;
}
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .32); transform: translateY(-50%); }
.lightbox-nav:active { transform: translateY(-50%); }
.lightbox .lightbox-nav,
.lightbox .lightbox-nav:hover:not(:disabled),
.lightbox .lightbox-nav:active { transform: translateY(-50%); transition: background-color .18s ease, color .18s ease, box-shadow .18s ease; }
.lightbox-tools {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(15, 23, 42, .55); padding: 6px 12px; border-radius: var(--radius-pill);
}
.lightbox-counter { color: rgba(255, 255, 255, .85); font-size: 0.8rem; padding-right: 4px; }
.lightbox-tool {
  border: none; border-radius: 50%; background: rgba(255, 255, 255, .2); color: #fff;
  width: 32px; height: 32px; font-size: 0.93rem; cursor: pointer;
}
.lightbox-tool:hover { background: rgba(255, 255, 255, .38); }
/* 缩放百分比（夹在 🔍− 与 🔍+ 之间，位于中间工具条、下载按钮左边） */
.lightbox-scale-label {
  color: rgba(255, 255, 255, .85); font-size: .78rem; min-width: 44px; text-align: center;
}

.result-card--generating { display: grid; place-items: center; align-content: center; gap: 6px; overflow: hidden; color: #47637f; text-align: center; background: linear-gradient(125deg, #eef6ff, #fafcff 46%, #e5f1ff); isolation: isolate; }
.result-card--generating::before { content: ''; position: absolute; inset: -50%; z-index: -1; background: linear-gradient(110deg, transparent 38%, rgba(255,255,255,.9) 50%, transparent 62%); animation: result-generating-sheen 1.7s ease-in-out infinite; }
.result-card--generating .qiwei-brand-loader { width: 76px; height: 64px; margin: 0 auto 2px; }
.result-card--generating .qiwei-brand-loader .loader-ambient-glow { display: none !important; }
.result-card--generating .qiwei-brand-loader .loader-halo-ring { width: 48px; height: 48px; border-color: rgba(0, 190, 255, 0.45); }
.result-card--generating .qiwei-brand-loader .loader-symbol-wrap { width: 44px; height: 36px; background: transparent !important; }
.result-card--generating strong { display: block; font-size: .84rem; }
.result-card--generating small { display: block; margin-top: 4px; color: #7189a0; font-size: .72rem; }
.result-card--delivery-delayed { color: #8a5a12; background: linear-gradient(125deg, #fff9ea, #fffdf8 46%, #fff2d3); }
.result-card--delivery-delayed::before { animation: none; background: none; }
.result-card--delivery-delayed small { color: #9a6a20; }
.result-card--delivery-delayed .result-generation-orb { animation: none; border-color: #dba341; border-top-color: transparent; }
.result-generation-orb { width: 30px; height: 30px; border: 3px solid rgba(0,113,227,.18); border-top-color: #0071e3; border-radius: 50%; animation: result-generating-spin .85s linear infinite; }
.result-card--delivery-pending { background: linear-gradient(125deg, #eefbf7, #fbfffd 46%, #e6f6ee); color: #27674f; }
.result-card--delivery-pending::before { animation: none; opacity: .34; }
.result-card--delivery-pending small { color: #5c8b76; }
.result-card--delivery-pending .result-generation-orb { animation: none; border-color: rgba(39, 103, 79, .18); border-top-color: #2f9b70; }
@keyframes result-generating-sheen { to { transform: translateX(55%); } }
@keyframes result-generating-spin { to { transform: rotate(360deg); } }

/* ============================ 响应式 ============================ */

@media (max-width: 1120px) {
  .workspace-grid { grid-template-columns: minmax(400px, 1fr) minmax(300px, .8fr); }
}
@media (max-width: 920px) {
  .app-shell { display: block; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .nav-list { flex-direction: row; }
  .nav-item { white-space: nowrap; }
  .workspace-grid { grid-template-columns: 1fr; }
  .result-column { position: static; }
}
@media (max-width: 560px) {
  .workspace-grid { padding: 12px 10px 24px; }
  .panel { padding: 12px; }
  .reference-list { grid-template-columns: repeat(2, 1fr); }
  .generate-controls { grid-template-columns: 1fr 1fr; }
}

/* Running jobs retain this lock even if a board updates its validation state. */
.qiwei-generation-busy,
:is(#il_generate, #homeSend, #generateButton, #generatePlansButton, #peProductGenerate, #btnProceedToImages, #btnGeneratePlans, #generateDeck, #seriesGenerate, #toolGenerateBtn):disabled {
  background: #606976 !important;
  background-image: none !important;
  color: #d8dde5 !important;
  box-shadow: none !important;
  opacity: .65 !important;
  cursor: not-allowed !important;
  transform: none !important;
}
