/* ─── Design Tokens ─────────────────────────────────── */
:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --green: #10b981;
  --green-dark: #059669;
  --lime: #86efac;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --danger: #ef4444;
  --shadow-xs: 0 1px 3px rgba(15,23,42,0.05);
  --shadow: 0 4px 20px rgba(15,23,42,0.07);
  --shadow-md: 0 8px 32px rgba(15,23,42,0.10);
  --shadow-lg: 0 24px 64px rgba(15,23,42,0.14);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }

/* ─── 侧栏 ────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  padding: 20px 16px;
  color: #f8fafc;
  background: #0f172a;
  border-right: 1px solid rgba(255,255,255,0.05);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 4px 4px;
  min-height: 48px;
}
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(135deg, #a7f3d0, #10b981);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.brand strong { display: block; font-size: 14px; font-weight: 700; color: #f1f5f9; }
.brand span   { display: block; margin-top: 1px; color: #64748b; font-size: 11px; }

.nav {
  display: grid;
  gap: 2px;
  margin: 24px 0 auto;
}
.nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.01em;
}
.nav a:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.06);
}
.nav a.active {
  color: #ffffff;
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.25);
}

.nav-settings-btn {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  margin-top: 8px;
  color: #64748b;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: color 0.15s, background 0.15s;
}
.nav-settings-btn:hover {
  color: #94a3b8;
  background: rgba(255,255,255,0.05);
}

.side-card {
  padding: 14px;
  margin-top: 24px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius);
}
.side-card strong { display: block; font-size: 13px; font-weight: 600; color: #e2e8f0; }

.label {
  margin: 0 0 6px;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-card .label { color: #475569; }

.mini-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  color: #64748b;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 12px;
}
.mini-grid b { color: #a7f3d0; font-weight: 600; }

/* ─── 主区域 ──────────────────────────────────────── */
.app {
  width: calc(100% - 240px);
  margin-left: 240px;
  padding: 16px 18px 100px;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 18px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(6px);
}
.app-topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.app-topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* ─── 面板 ────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px;
}
.compact-panel + .compact-panel,
.compact-section + .compact-panel,
.compact-panel + .compact-section { margin-top: 12px; }

.section-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 12px;
  margin-top: 12px;
}
.compact-section { margin-top: 12px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.compact-head { margin-bottom: 10px; }
.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.step-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 7px;
  flex-shrink: 0;
  letter-spacing: 0;
}
.panel h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ─── 底部固定操作栏 ─────────────────────────────── */
.action-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 240px;
  z-index: 90;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.92);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(15,23,42,0.06);
  backdrop-filter: blur(12px);
}
.action-dock-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}
.action-dock-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.action-dock-btns {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

/* ─── 折叠说明 ────────────────────────────────────── */
.hint-details {
  margin: 0 0 12px;
  padding: 8px 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
}
.hint-details summary {
  cursor: pointer;
  color: #334155;
  font-weight: 700;
  user-select: none;
}
.hint-details p { margin: 6px 0 0; }

/* ─── 表单基础 ────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px 10px;
}
.form-grid-dense { grid-template-columns: repeat(3, minmax(0,1fr)); }

.field-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
#useCaseHint { background: #f1f5f9; color: var(--ink); cursor: default; }

label {
  display: grid;
  gap: 5px;
  color: #475569;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

input, select, textarea {
  width: 100%;
  min-height: 36px;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  outline: none;
  padding: 0 10px;
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea {
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}
.compact-textarea textarea { min-height: 56px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.wide { grid-column: 1 / -1; }

/* ─── 12 列紧凑表单 ───────────────────────────────── */
.form-sheet { display: grid; gap: 0; }
.form-block {
  display: grid;
  gap: 6px;
  padding: 14px 0;
}
.form-block:first-child { padding-top: 4px; }
.form-block + .form-block { border-top: 1px solid var(--line); }
.form-block-title {
  margin: 0;
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0,1fr));
  gap: 8px 10px;
  align-items: start;
}
.form-row > label { min-width: 0; }
.form-row > label[hidden] { display: none !important; }
.c-1  { grid-column: span 1; }
.c-2  { grid-column: span 2; }
.c-3  { grid-column: span 3; }
.c-4  { grid-column: span 4; }
.c-5  { grid-column: span 5; }
.c-6  { grid-column: span 6; }
.c-7  { grid-column: span 7; }
.c-8  { grid-column: span 8; }
.c-9  { grid-column: span 9; }
.c-10 { grid-column: span 10; }
.c-11 { grid-column: span 11; }
.c-12 { grid-column: span 12; }

/* ─── 按钮 ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  color: #334155;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-xs);
}
.btn:active { transform: translateY(1px); }

.btn.primary {
  color: #ffffff;
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(16,185,129,0.30);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 4px 16px rgba(16,185,129,0.40);
  transform: translateY(-1px);
}
.btn.secondary {
  color: #475569;
  background: #f8fafc;
  border-color: #e2e8f0;
}
.btn.secondary:hover { background: #f1f5f9; }
.btn.compact { min-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; }

/* ─── 角标 / 计数 ─────────────────────────────────── */
.badge, .counter {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.muted { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.counter { color: #1e40af; background: #eff6ff; border-color: #bfdbfe; }

/* ─── 规则卡 ───────────────────────────────────────── */
.rules { display: grid; gap: 8px; }
.rule {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.rule span { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; flex-shrink: 0; }
.rule.ok   span { background: var(--green); }
.rule.warn span { background: var(--yellow); }
.rule p { margin: 0; color: #475569; font-size: 13px; line-height: 1.6; }

/* ─── 上传区 ──────────────────────────────────────── */
.upload {
  display: grid;
  min-height: 96px;
  place-items: center;
  gap: 4px;
  padding: 14px;
  text-align: center;
  background: #fafcff;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload:hover {
  border-color: var(--green);
  background: rgba(16,185,129,0.04);
}
.upload-slim { min-height: 84px; padding: 12px; }
.upload input { display: none; }
.upload strong, .upload span { pointer-events: none; }
.upload strong { font-size: 13.5px; font-weight: 600; color: #334155; }
.upload span   { max-width: 420px; color: var(--muted); font-size: 12px; line-height: 1.4; }

/* ─── 缩略图 ──────────────────────────────────────── */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px,1fr));
  gap: 6px;
  margin-top: 8px;
}
.thumbs.small { grid-template-columns: repeat(auto-fill, minmax(60px,1fr)); }

.thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  background: #e2e8f0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  background: rgba(15,23,42,0.6);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}
.thumb:hover .thumb-del { opacity: 1; }
.thumb-del:hover { background: var(--danger); }

/* ─── 素材上传工作区 ─────────────────────────────── */
.upload-workspace {
  display: grid;
  grid-template-columns: minmax(0,1.15fr) minmax(300px,0.85fr);
  gap: 12px;
  align-items: stretch;
}
.upload-workspace-main .category-grid-2x2 { min-height: 440px; }
.upload-workspace-main, .upload-workspace-side { min-width: 0; }

.upload-zone-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}
.zone-hint { color: var(--muted); font-size: 11px; font-weight: 500; }

.upload-workspace-side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  align-content: stretch;
  min-height: 440px;
}

.side-card-block { display: flex; flex-direction: column; min-height: 0; }

.upload-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mini-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 20px;
  padding: 0 6px;
  color: #1e40af;
  font-size: 10px;
  font-weight: 700;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  flex-shrink: 0;
}

.upload-card-desc {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.required-tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  color: #991b1b;
  font-size: 10px;
  font-weight: 700;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 999px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}
.category-grid-2x2 { grid-template-columns: repeat(2, minmax(0,1fr)); }

.upload-card {
  min-width: 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.upload-card:hover { border-color: #cbd5e1; box-shadow: var(--shadow-xs); }

.upload-card-tall { display: flex; flex-direction: column; min-height: 210px; }
.upload-workspace-side .upload-card-tall { min-height: 0; height: 100%; }

.upload-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.upload-card-head strong { font-size: 13px; font-weight: 700; color: var(--ink); }
.upload-card-head > span:last-child,
.upload-card-head .counter { margin-left: auto; }
.upload-card-head span:not(.required-tag):not(.counter):not(.mini-step) {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.tile-upload {
  flex: 1;
  min-height: 118px;
  padding: 16px 12px;
  place-content: center;
}
.tile-upload-side { flex: 1; min-height: 132px; }
.tile-upload strong { font-size: 13px; font-weight: 600; }
.tile-upload span   { font-size: 11.5px; max-width: none; }

.compact-upload { min-height: 76px; padding: 10px; }
.compact-upload strong { font-size: 13px; }
.compact-upload span   { font-size: 11.5px; }

/* ─── 任务卡网格 ──────────────────────────────────── */
.task-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.task-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.task-card:hover { box-shadow: var(--shadow); border-color: #cbd5e1; }

.task-card-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  flex-shrink: 0;
  align-items: start;
}
.task-card-head-text { min-width: 0; }
.task-number {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 6px;
  flex-shrink: 0;
}
.task-title { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.task-description {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
  min-height: calc(11.5px * 1.4 * 2);
}

.ai-preview {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 2 / 3;
  margin-top: 10px;
  overflow: hidden;
  background: #0a0c10;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}
.ai-preview.is-empty { background: #f8fafc; }
.ai-empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  gap: 5px;
  place-items: center;
  padding: 16px;
  text-align: center;
}
.ai-empty strong { color: #334155; font-size: 13px; font-weight: 600; }
.ai-empty span   { color: var(--muted); font-size: 11px; }

.result-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center;
}
.result-image.visible { display: block; }

.task-card-foot {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-top: 8px;
}

.review-warn-slot {
  min-height: 0;
  margin-bottom: 0;
}
.review-warn-slot:not(:empty) {
  margin-bottom: 6px;
}

.task-status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.task-status.pending { color: #64748b; background: #f1f5f9; }
.task-status.running { color: #1e40af; background: #eff6ff; }
.task-status.done    { color: #065f46; background: #d1fae5; }
.task-status.warn    { color: #92400e; background: #fef3c7; }
.task-status.error   { color: #991b1b; background: #fef2f2; }

/* P7: review 告警标签 */
.review-warn-slot .review-warn-tag {
  margin: 0;
  padding: 5px 8px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  cursor: help;
}

.image-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.image-actions .btn { flex: 1; font-size: 12px; min-height: 30px; }
.image-actions .btn:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }

.task-custom-prompt {
  width: 100%;
  min-height: 50px;
  max-height: 120px;
  margin-top: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}
.task-custom-prompt:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
  outline: none;
}
.task-custom-prompt::placeholder { color: #94a3b8; }

.prompt {
  display: none;
  max-height: 320px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 8px 10px;
  color: #475569;
  white-space: pre-wrap;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
}
.prompt.visible { display: block; }

/* P4: 生成进度条 */
.gen-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.gen-progress-bar {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.gen-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 999px;
  transition: width 0.5s ease;
}
.gen-progress-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}

/* P1: 草稿提示徽章 */
.draft-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 3px 9px;
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

/* ─── 文案区 ──────────────────────────────────────── */
.copy-usage-hint {
  margin: 0 0 10px;
  padding: 8px 12px;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.45;
}
.compact-hint { margin-top: -2px; }
.copy-usage-hint strong { color: #1e3a8a; }

.copy-list, .detail-copy { display: grid; gap: 8px; }
.copy-item, .detail-copy p {
  margin: 0;
  padding: 10px 12px;
  color: #1e293b;
  background: #f8fafc;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  line-height: 1.6;
  font-size: 13.5px;
  transition: border-color 0.15s, background 0.15s;
}
/* P2: 文案可编辑 */
.editable-copy {
  cursor: text;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.editable-copy:hover { border-color: #94a3b8; background: #ffffff; }
.editable-copy:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.10);
}
.copy-item { cursor: pointer; }
.copy-item:hover { border-color: #94a3b8; background: #ffffff; }

/* ─── 导出区 ──────────────────────────────────────── */
.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.compact-export div {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.compact-export strong { color: var(--ink); font-weight: 700; font-size: 14px; }
.compact-export p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

/* ─── 设置抽屉 ────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10,18,32,0.45);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-end;
}
.settings-overlay[hidden] { display: none; }
.settings-drawer {
  width: min(520px, 90vw);
  height: 100%;
  padding: 28px;
  background: #ffffff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 40px rgba(15,23,42,0.12);
  overflow-y: auto;
}
.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.settings-header h3 { margin: 0; font-size: 19px; font-weight: 700; }

.settings-backend-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.settings-hint {
  margin: -8px 0 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* ─── 中文详情页上传区 ────────────────────────────── */
.zh-detail-upload-wrap {
  margin-top: 10px;
  padding: 12px;
  background: #f0fdf4;
  border: 1.5px dashed #86efac;
  border-radius: var(--radius-sm);
}
.zh-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.zh-detail-head > div > strong { display: block; font-size: 13px; font-weight: 700; color: #134e4a; }
.zh-detail-head > div > span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  max-width: 560px;
  line-height: 1.4;
}

/* ─── 响应式 ──────────────────────────────────────── */
@media (max-width: 1200px) {
  .form-row { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .form-row > label { grid-column: span 3; }
  .form-row > label.c-6 { grid-column: span 6; }
  .form-row > label.c-7 { grid-column: span 6; }
  .upload-workspace { grid-template-columns: 1fr; }
}
@media (max-width: 1400px) {
  .task-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 1100px) {
  .task-grid, .category-grid-2x2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1020px) {
  .sidebar { position: static; width: 100%; }
  .app { width: 100%; margin-left: 0; padding: 12px 12px 100px; }
  .action-dock { left: 0; }
  .section-grid, .export-grid { grid-template-columns: 1fr; }
  .action-dock-inner { flex-direction: column; align-items: stretch; }
  .action-dock-btns { justify-content: stretch; }
  .action-dock-btns .btn { flex: 1; }
}
@media (max-width: 720px) {
  .form-row,
  .form-grid, .form-grid-dense,
  .task-grid, .category-grid, .category-grid-2x2 { grid-template-columns: 1fr; }
  .form-row > label,
  .form-row > label[class*="c-"] { grid-column: span 1; }
  .panel { padding: 12px 14px; }
  .panel-head { display: grid; }
  .action-dock-hint { display: none; }
  .upload-card-tall { min-height: 180px; }
  .profit-layout,
  .profit-page-layout { grid-template-columns: 1fr; }
  .profit-results { position: static; }
}

/* ─── 利润计算器（独立页 profit.html）──────────────────────── */
.profit-page-panel { margin-bottom: 40px; }

.profit-page-layout {
  grid-template-columns: 1fr 360px;
}

.profit-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.profit-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px 12px;
  margin-bottom: 14px;
  background: var(--panel-soft);
}
.profit-fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.profit-results {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: sticky;
  top: 16px;
}

.profit-placeholder {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.profit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 14px;
}
.profit-table td {
  padding: 5px 2px;
  border-bottom: 1px solid var(--line);
}
.profit-table tfoot td {
  border-top: 2px solid var(--ink);
  border-bottom: none;
  font-weight: 700;
  font-size: 15px;
  padding-top: 10px;
}
.profit-table .profit-num { text-align: right; font-variant-numeric: tabular-nums; }
.profit-deduct { color: var(--muted); }

.profit-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.profit-metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 8px 8px;
  text-align: center;
}
.profit-metric-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.profit-metric-value {
  display: block;
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.profit-positive { color: #059669; }
.profit-negative { color: var(--danger); }

.profit-note {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  margin: 0;
}
.profit-note-warn {
  background: #fffbeb !important;
  border-color: #fde68a !important;
  color: #92400e !important;
}
.profit-note-muted {
  background: #f8fafc !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
  margin-top: 8px;
}
.profit-field-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── 登录页 ──────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #f1f5f9 45%);
}

.login-shell { width: min(420px, 92vw); padding: 24px; }
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
.login-brand { margin-bottom: 18px; }
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-hint { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-form { display: grid; gap: 12px; }
.login-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.login-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 12px;
}
.login-register { margin-top: 18px; font-size: 13px; color: var(--muted); }
.login-register summary { cursor: pointer; font-weight: 600; color: var(--ink); }

/* ─── 侧栏：平台切换 & 账号 ──────────────────────────────── */
.platform-switcher {
  margin: 4px 0 10px;
}
.platform-switcher-card {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
}
.platform-switcher-kicker {
  display: block;
  margin-bottom: 10px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.platform-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.05);
}
.platform-seg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  min-width: 0;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.platform-seg-btn:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.04);
}
.platform-seg-btn.is-active {
  color: #f8fafc;
  background: rgba(16,185,129,0.16);
  border-color: rgba(16,185,129,0.28);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
html[data-platform="pdd"] .platform-seg-btn.is-active {
  background: rgba(225,29,72,0.18);
  border-color: rgba(225,29,72,0.32);
}
.platform-seg-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #0f172a;
  background: linear-gradient(135deg, #a7f3d0, #10b981);
}
.platform-seg-btn[data-platform="pdd"] .platform-seg-mark {
  background: linear-gradient(135deg, #fda4af, #e11d48);
  color: #fff;
}
.platform-seg-label {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
}

.sidebar-user-card {
  display: grid;
  gap: 10px;
  margin: 0 0 4px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sidebar-user-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #ecfdf5;
  background: linear-gradient(145deg, rgba(16,185,129,0.55), rgba(15,23,42,0.9));
  border: 1px solid rgba(167,243,208,0.25);
}
.sidebar-user-meta {
  min-width: 0;
  flex: 1;
}
.sidebar-user-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.sidebar-user-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
  color: #f1f5f9;
  line-height: 1.2;
}
.sidebar-role-pill {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #a7f3d0;
  background: rgba(16,185,129,0.14);
  border: 1px solid rgba(16,185,129,0.28);
}
.sidebar-user-handle {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: #64748b;
}
.sidebar-quota {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}
.sidebar-logout-btn {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.sidebar-logout-btn:hover {
  color: #fecaca;
  background: rgba(239,68,68,0.1);
  border-color: rgba(248,113,113,0.28);
}

html[data-platform="pdd"] .brand-mark {
  background: linear-gradient(135deg, #fda4af, #e11d48);
  color: #fff;
}
html[data-platform="pdd"] .sidebar-user-avatar {
  background: linear-gradient(145deg, rgba(225,29,72,0.55), rgba(15,23,42,0.9));
  border-color: rgba(253,164,175,0.28);
}

.platform-banner {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 13px;
}

/* ─── 产品库 ──────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.products-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.product-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-soft);
  display: grid;
  gap: 8px;
}
.product-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.product-card-head strong { font-size: 15px; line-height: 1.35; }
.product-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  white-space: nowrap;
}
.product-status.generated { background: #d1fae5; color: #065f46; }
.product-status.archived { background: #fef3c7; color: #92400e; }
.product-card-meta,
.product-card-price {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.product-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.product-editor-drawer { width: min(640px, 94vw); }
.danger-text { color: var(--danger) !important; }

/* ─── 账号管理 ─────────────────────────────────────────────── */
.user-list { display: grid; gap: 10px; }
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.user-row.is-self { border-color: rgba(16,185,129,0.35); background: #f0fdf4; }
.user-row-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.inline-checks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 38px;
  color: var(--muted);
  font-size: 12.5px;
}
.inline-checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-weight: 600;
}
.inline-checks input { width: 14px; height: 14px; margin: 0; }
.user-platform-controls { margin-top: 8px; }
.user-usage-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.user-create-form .user-create-action {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* ─── 列表工具栏 / 生成历史 ─────────────────────────────────── */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.list-toolbar input[type="search"],
.list-toolbar select {
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  font-size: 13px;
}
.list-toolbar input[type="search"] { flex: 1 1 240px; }

.product-card-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
}
.product-editor-wide { width: min(760px, 96vw); }
.save-library-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.history-list { display: grid; gap: 12px; }
.history-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.history-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-soft);
  display: grid;
  gap: 10px;
}
.history-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.history-card-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.history-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: #e2e8f0;
  color: #475569;
}
.history-status.gen-success { background: #d1fae5; color: #065f46; }
.history-status.gen-partial { background: #fef3c7; color: #92400e; }
.history-status.gen-failed { background: #fee2e2; color: #991b1b; }
.history-card-summary,
.history-card-stats {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.history-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.history-error { color: var(--danger); }
.history-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
}
.history-detail-body {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.history-detail-block ul {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.5;
}
.history-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
