:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #e3e6ea;
  --line-strong: #d2d7dd;
  --text: #1f2328;
  --text-2: #5b6470;
  --text-3: #8b949e;
  --brand: #2f6bff;
  --brand-weak: #eaf0ff;
  --ok: #1a9c6c;
  --ok-weak: #e6f6ef;
  --warn: #b7791f;
  --warn-weak: #fdf5e6;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
  letter-spacing: .5px;
}
.brand-text h1 { font-size: 16px; }
.brand-text p { margin: 0; font-size: 12px; color: var(--text-3); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.engine-badge {
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ---------- 页面 ---------- */
.page { max-width: 980px; margin: 0 auto; padding: 20px 20px 60px; }

/* ---------- 分步导航 ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
}
.step-item:hover:not(.locked) { background: var(--surface-2); }
.step-item.active { color: var(--text); }
.step-item.active .step-dot { background: var(--brand); color: #fff; border-color: var(--brand); }
.step-item.done { color: var(--text-2); }
.step-item.done .step-dot { background: var(--ok-weak); color: var(--ok); border-color: #bfe6d6; }
.step-item.locked { cursor: not-allowed; opacity: .55; }
.step-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex: 0 0 auto;
}
.step-line { flex: 1; height: 1px; background: var(--line); min-width: 12px; }

/* ---------- 视图（一页一件事） ---------- */
.view { display: none; }
.view.active { display: block; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px;
  margin-bottom: 16px;
}
.card-plain { background: #fbfbfc; }
.card-head { margin-bottom: 16px; }
.card-head-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; }
.card-desc { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); }
.card-desc strong { color: var(--text); }
.mode-chip {
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.mode-chip strong { color: var(--text); font-weight: 600; }
.view-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.progress-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: none;
  padding: 0;
  margin-bottom: 12px;
  text-align: left;
}

/* ---------- 模式卡 ---------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.mode-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.mode-card:hover:not(.disabled) { border-color: var(--brand); background: #fbfcff; }
.mode-card.active { border-color: var(--brand); background: var(--brand-weak); }
.mode-card.disabled { cursor: not-allowed; opacity: .55; }
.mode-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mode-name { font-weight: 600; font-size: 13.5px; }
.mode-desc { margin: 4px 0 0; font-size: 12px; color: var(--text-2); }
.mode-count { margin-top: 6px; font-size: 11.5px; color: var(--text-3); }
.chip {
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  color: var(--text-3);
  white-space: nowrap;
}
.chip-ready { background: var(--ok-weak); border-color: #bfe6d6; color: var(--ok); }

/* ---------- 输入 ---------- */
.raw-input {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  background: #fcfcfd;
}
.raw-input-big { min-height: 52vh; font-size: 14px; }
.raw-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 8px;
}
.raw-count { font-size: 12px; color: var(--text-3); }
.raw-tip { font-size: 12px; color: var(--warn, #b45309); }
.modal-big { max-width: 900px; width: 92vw; }
.condensed-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fcfcfd;
  padding: 8px 12px;
  font-size: 12.5px;
}
.condensed-box summary { cursor: pointer; color: var(--text-2); }
.condensed-box pre {
  margin: 8px 0 2px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
  color: var(--text);
  font-family: inherit;
  line-height: 1.7;
}
.raw-input:focus, .field-input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}

/* ---------- 参考图 / 素材图（两个区） ---------- */
.img-zones { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.img-zone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fcfcfd;
  transition: border-color .15s, background .15s, box-shadow .15s;
  cursor: pointer;
}
.img-zone:hover { border-color: var(--line-strong); background: #f8f9fb; }
.img-zone.dragover { border-color: var(--brand); background: var(--brand-weak); }
/* 当前 Ctrl+V 的粘贴目标 */
.img-zone.active {
  border-style: solid;
  border-color: var(--brand);
  background: #fbfcff;
  box-shadow: 0 0 0 2px rgba(47,107,255,.12);
}
.img-zone-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.img-zone-title { font-weight: 600; font-size: 13px; }
.img-zone-tip { font-size: 11.5px; color: var(--text-3); }
.paste-flag {
  display: none;
  font-size: 11px;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
}
.img-zone.active .paste-flag { display: inline-block; }
.img-list { display: flex; flex-wrap: wrap; gap: 10px; min-height: 26px; }
.img-empty { font-size: 12px; color: var(--text-3); }
.img-item {
  position: relative;
  width: 86px; height: 86px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #fff;
}
.img-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(24,28,36,.62);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.img-del:hover { background: rgba(24,28,36,.85); }
.img-cell { display: flex; flex-direction: column; gap: 4px; }
.img-meta { display: flex; flex-direction: column; gap: 3px; width: 86px; }
.img-role {
  width: 100%;
  font-family: inherit;
  font-size: 11px;
  padding: 1px 2px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text-2);
  background: #fff;
  cursor: pointer;
}
.img-name {
  width: 100%;
  font-family: inherit;
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text);
  background: #fff;
}
.img-name::placeholder { color: var(--text-3); }
.img-count { font-size: 12px; color: var(--text-3); align-self: center; }

/* ---------- 图片预览（点缩略图放大看） ---------- */
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed; inset: 0;
  background: rgba(16,18,24,.86);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  padding: 40px 60px;
}
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  border-radius: 8px;
  background: #fff;
  display: block;
}
.lb-close {
  position: absolute; top: 14px; right: 18px;
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 50%;
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.lb-close:hover { background: rgba(255,255,255,.24); }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 56px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 8px;
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.lb-nav:hover { background: rgba(255,255,255,.24); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-info {
  position: absolute;
  bottom: 16px; left: 0; right: 0;
  text-align: center;
  color: rgba(255,255,255,.86);
  font-size: 12.5px;
}
.img-item img { cursor: zoom-in; }

/* ---------- 按钮 ---------- */
.btn {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #2559dd; }
.btn-ghost { color: var(--text-2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.hint { font-size: 12px; color: var(--text-3); margin: 8px 0 0; }

/* ---------- 需求表 ---------- */
.progress-box { display: inline-flex; align-items: baseline; gap: 6px; }
.progress-num { font-size: 15px; font-weight: 600; color: var(--brand); }
.progress-label { font-size: 11.5px; color: var(--text-3); }

.field-list { display: flex; flex-direction: column; gap: 12px; }
.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}
.field-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fcfcfd;
}
.field-item.filled { background: #fff; }
.field-item.missing { border-color: #eddcbb; background: #fffdf8; }
.field-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.field-label { font-weight: 600; font-size: 13px; }
.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-flag {
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: auto;
  white-space: nowrap;
}
.flag-ai { background: var(--brand-weak); color: var(--brand); }
.flag-missing { background: var(--warn-weak); color: var(--warn); }
.flag-manual { background: var(--surface-2); color: var(--text-2); }

.field-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  background: #fff;
}
textarea.field-input { min-height: 62px; }
select.field-input { cursor: pointer; }
.field-source { margin: 6px 0 0; font-size: 11.5px; color: var(--text-3); }

.missing-box {
  margin-top: 14px;
  border: 1px solid #eddcbb;
  background: var(--warn-weak);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.missing-box h3 { font-size: 13px; color: var(--warn); }
.missing-box ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); }
.missing-box .hint { color: var(--text-3); }

/* ---------- 生图区 ---------- */
.gen-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
  padding: 14px 16px;
}
.gen-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.gen-head h3 { font-size: 14px; }
.gen-model { font-size: 12px; color: var(--text-2); }
.gen-model strong { color: var(--text); font-weight: 600; }
.gen-label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
#genPrompt { min-height: 76px; }
.gen-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 10px;
}
.size-label { font-size: 12px; color: var(--text-3); align-self: center; }
.size-info {
  margin: 8px 0 10px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-3);
  white-space: pre-line;
}
.size-select {
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
/* ---------- 需求表提醒 ---------- */
.warn-box {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border: 1px solid #f0d9a8;
  background: #fffaf0;
  border-radius: 10px;
}
.warn-box h3 { margin: 0 0 8px; font-size: 13px; color: #a5761b; font-weight: 600; }
.warn-box ul { margin: 0; padding-left: 18px; }
.warn-box li { font-size: 12.5px; line-height: 1.75; color: var(--text-2, #4a4a4a); margin-bottom: 6px; }
.warn-box li:last-child { margin-bottom: 0; }

/* ---------- 指定成品尺寸 ---------- */
.fixsize-box {
  margin: 12px 0 4px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: #fcfcfd;
}
.fixsize-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.fixsize-head input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.fixsize-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; flex-wrap: wrap;
}
.mini-input {
  width: 74px; padding: 6px 8px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
  text-align: center;
}
.fixsize-x { color: var(--text-3); font-size: 13px; }
.fixsize-unit { color: var(--text-3); font-size: 13px; margin-right: 6px; }

.gen-result { margin-top: 14px; }
.gen-img-wrap { position: relative; display: block; width: 100%; }
.gen-busy {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  backdrop-filter: blur(1px);
}
.gen-busy-inner {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line-strong);
  font-size: 13px; color: var(--text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.spin {
  width: 14px; height: 14px; flex: 0 0 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: wbspin 0.8s linear infinite;
}
@keyframes wbspin { to { transform: rotate(360deg); } }
.dl-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-3); }
.btn[disabled], .btn.is-busy { opacity: 0.6; cursor: not-allowed; }
.gen-result img {
  max-width: 100%;
  max-height: 520px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
  cursor: zoom-in;
  background: #fff;
}
.gen-result-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 10px;
}
.policy-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f5f6f8;
  border: 1px solid var(--line);
}
.policy-label { font-size: 12.5px; color: var(--text-2); }
.policy-btn {
  font-family: inherit;
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
}
.policy-btn:hover { border-color: var(--brand); color: var(--brand); }
.policy-btn.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 500;
}
.policy-hint { font-size: 12px; color: var(--text-3); }

.deliver-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfc;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.deliver-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wm-text { flex: 1; min-width: 180px; max-width: 320px; }
.gen-result-bar { margin-top: 8px; }
.refine-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
}
.refine-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.refine-row .field-input { flex: 1; min-width: 220px; }
.gen-cost { font-size: 12px; color: var(--text-3); }
.settings-group {
  margin: 16px 0 10px;
  font-size: 12.5px;
  color: var(--text-3);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* ---------- 页脚 ---------- */
.footer { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 24px; }

/* ---------- 弹窗 ---------- */
/* 注意：hidden 属性必须显式覆盖 display，否则 display:flex 会让元素一直显示 */
.modal-mask[hidden],
.missing-box[hidden] { display: none; }

/* ⚠️ 通用兜底：「hidden 属性」必须真的隐藏。
   类规则里写了 display:flex / block 的，会盖掉浏览器对 [hidden] 的默认 display:none
   —— 生成中的遮罩"生成了也藏不起来"就是这个原因。 */
[hidden] { display: none !important; }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(24,28,36,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%;
  max-width: 460px;
}
.modal h3 { font-size: 15px; margin-bottom: 14px; }
.form-item { margin-bottom: 12px; }
.form-item label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.form-item input, .form-item select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
.modal-actions { justify-content: flex-end; margin-top: 16px; }

@media (max-width: 640px) {
  .progress-box { text-align: left; }
  .stepper { flex-wrap: wrap; }
  .step-line { display: none; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
}
