/* ============================================================
   ChatGPT 极简风格 —— 设计令牌
   背景 #ffffff / 次级 #f7f7f8 / 边框 #e5e5e5
   正文 #0d0d0d / 次要 #5d5d5d / 主按钮黑底白字
   ============================================================ */
:root {
  --bg: #ffffff;
  --bg-secondary: #f7f7f8;
  --border: #e5e5e5;
  --border-strong: #d0d0d0;
  --text: #0d0d0d;
  --muted: #5d5d5d;
  --muted-2: #8f8f8f;
  --accent: #0d0d0d;          /* 主按钮 = 黑 */
  --accent-hover: #2b2b2b;
  --danger: #dc2626;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ 顶栏 ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  transition: all 0.15s;
}
.nav a:hover { color: var(--text); background: var(--bg-secondary); }
.nav a.active { color: var(--text); background: var(--bg-secondary); font-weight: 500; }
.user { font-size: 12px; color: var(--muted-2); display: flex; align-items: center; gap: 10px; }
.user .token { font-family: ui-monospace, monospace; color: var(--muted); }
.user .user-name { color: var(--text); font-size: 13px; font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .logout-btn {
  font: inherit; font-size: 12px; color: var(--muted-2);
  background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 12px; cursor: pointer; transition: all 0.15s;
}
.user .logout-btn:hover { color: #dc2626; border-color: #dc2626; background: rgba(220, 38, 38, 0.06); }

/* ============ 主体布局 ============ */
#app {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.footer {
  text-align: center;
  padding: 16px;
  color: var(--muted-2);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* ============ 首页 Hero ============ */
.hero {
  position: relative;
  text-align: center;
  padding: 48px 8px 36px;
  margin-bottom: 28px;
}
.hero-bg {
  position: absolute;
  inset: -30px -20px -16px;
  pointer-events: none;
  overflow: hidden;
  border-radius: 40px;
}
.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: orbFloat 16s ease-in-out infinite alternate;
}
.orb-a {
  width: 320px; height: 320px;
  left: -70px; top: -120px;
  background: radial-gradient(circle at 35% 35%, rgba(122, 140, 255, 0.5), transparent 70%);
}
.orb-b {
  width: 300px; height: 300px;
  right: -80px; top: -70px;
  background: radial-gradient(circle at 60% 40%, rgba(214, 152, 255, 0.42), transparent 70%);
  animation-delay: -8s;
}
.hero-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(13, 13, 13, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-mask-image: radial-gradient(58% 80% at 50% 42%, #000 30%, transparent 100%);
  mask-image: radial-gradient(58% 80% at 50% 42%, #000 30%, transparent 100%);
}
.hero-badge,
.hero-title,
.hero-sub { position: relative; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  margin-bottom: 20px;
  animation: heroFadeUp 0.6s ease both;
}
.hero-title {
  margin: 0 0 14px;
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.18;
  color: var(--text);
  animation: heroFadeUp 0.6s ease 0.08s both;
}
.hero-title .grad {
  background: linear-gradient(115deg, #2f2f6e 10%, #6a5bd8 55%, #a878e8 95%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero-sub {
  margin: 0;
  font-size: 14.5px;
  color: var(--muted);
  animation: heroFadeUp 0.6s ease 0.16s both;
}
@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes orbFloat {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(26px, 18px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-badge, .hero-title, .hero-sub, .hero-orb { animation: none; }
}
h2.page-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 20px; }
h3.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }

/* ============ Segmented Tab ============ */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.segmented button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow);
}

/* ============ 卡片（风格模板区等） ============ */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  background: var(--bg);
}
.panel .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel .panel-head .label { font-size: 13px; font-weight: 600; color: var(--muted); }

/* 子 Tab（文字风格 / 参考图） */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.subtabs button {
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.subtabs button.active { color: var(--text); font-weight: 500; border-bottom-color: var(--text); }

/* ============ 风格提示词 textarea ============ */
.style-textarea {
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg-secondary);
  color: var(--text);
  transition: all 0.15s;
}
.style-textarea:focus { outline: none; border-color: var(--border-strong); background: var(--bg); }

/* chip 行 */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip-row .chip-group-label {
  width: 100%;
  font-size: 12px;
  color: var(--muted-2);
  margin-bottom: 2px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  background: var(--bg);
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { border-color: var(--text); color: var(--text); background: var(--bg-secondary); font-weight: 500; }
.chip .chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 11px;
  color: var(--muted-2);
}
.chip .chip-x:hover { background: var(--bg-secondary); color: var(--danger); }

/* ============ ChatGPT 式主输入框 ============ */
.composer {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg);
  transition: border-color 0.15s;
  overflow: hidden;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea.main-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 18px 20px 8px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.6;
  min-height: 96px;
  background: transparent;
  color: var(--text);
}
.composer textarea.main-input::placeholder { color: var(--muted-2); }

/* 附件 chips */
.attachments { padding: 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments:empty { display: none; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  animation: fadeIn 0.15s;
}
.attach-chip.extracting { color: var(--muted-2); font-style: italic; }
.attach-chip .x { cursor: pointer; color: var(--muted-2); font-size: 13px; }
.attach-chip .x:hover { color: var(--danger); }

/* 底部工具栏 */
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 14px;
  gap: 12px;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.ratio-select {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}
.ratio-select:hover { border-color: var(--border-strong); }

.page-count-box {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.page-count-box input {
  width: 52px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  text-align: center;
  font-family: inherit;
  color: var(--text);
}
.page-count-box input:focus { outline: none; border-color: var(--border-strong); }

/* 黑色圆形下一步按钮 */
.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }

/* ============ 按钮 ============ */
.btn {
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { background: var(--border); color: var(--muted-2); cursor: not-allowed; }
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-secondary); }
.btn-ghost { background: transparent; color: var(--muted); border: none; padding: 8px 12px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-secondary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c02626; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ============ 进度条（四步） ============ */
.progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  padding: 0 4px;
}
.progress-step {
  font-size: 12px;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.progress-step .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted-2);
}
.progress-step.active { color: var(--text); font-weight: 500; }
.progress-step.active .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress-step.done .dot { background: var(--bg-secondary); border-color: var(--border); color: var(--text); }
.progress-step.clickable { cursor: pointer; border-radius: var(--radius-sm); padding: 4px 6px; margin: -4px -6px; transition: background 0.15s; }
.progress-step.clickable:hover { background: var(--bg-secondary); color: var(--text); }
.progress-line { flex: 1; height: 1px; background: var(--border); min-width: 16px; }
/* 退出按钮：进度条右端，警示语义 */


/* ============ 流式状态条 ============ */
.stream-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}
.stream-status .stop-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
}
.stream-status .stop-btn:hover { background: rgba(220, 38, 38, 0.08); }

/* ============ 大纲卡片（第二步） ============ */
.outline-list { display: flex; flex-direction: column; gap: 12px; }
.outline-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg);
  animation: fadeIn 0.15s;
  transition: transform 180ms ease;
}
/* 拖拽排序：把手 + 拖拽中状态 */
.outline-card .head-left { display: flex; align-items: center; gap: 8px; }
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  cursor: grab;
  color: var(--muted-2);
  border-radius: 5px;
  flex: none;
}
.drag-handle:hover { color: var(--text); background: var(--bg-secondary); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 14px; height: 14px; }
.outline-card.dragging {
  opacity: 0.45;
  border-style: dashed;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.outline-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.outline-card .idx { font-size: 12px; color: var(--muted-2); font-weight: 500; }
/* 「封面」徽标：第 1 页在全链路的类型标签 */
.cover-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  flex-shrink: 0;
  margin-right: 8px;
  vertical-align: middle;
}
.outline-card .idx.cover-tag { color: #fff; }
.outline-card .card-actions { display: flex; gap: 4px; }
.outline-card input.title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  padding: 0 0 8px;
  background: transparent;
  border-bottom: 1px solid transparent;
}
.outline-card input.title-input:focus { border-bottom-color: var(--border); }
.outline-card textarea.bullets-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--muted);
  resize: vertical;
  min-height: 56px;
  background: transparent;
  line-height: 1.7;
}

/* 光标闪烁（流式生成中） */
.caret::after {
  content: "▍";
  color: var(--muted-2);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============ 骨架卡片（第三步流式占位） ============ */
.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg);
  min-height: 88px;
}
.skeleton-card .sk-line {
  height: 12px;
  border-radius: 6px;
  background: var(--bg-secondary);
  margin-bottom: 8px;
  animation: breathe 1.4s ease-in-out infinite;
}
.skeleton-card .sk-line.short { width: 45%; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ============ 页面内容卡片（第三步） ============ */
.page-cards { display: flex; flex-direction: column; gap: 12px; }
.page-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg);
  animation: fadeIn 0.15s;
}
.page-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.page-card .pc-title { font-size: 15px; font-weight: 600; }
.page-card .pc-excerpt {
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 66px;
  overflow: hidden;
  position: relative;
}
.page-card .pc-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.page-card .pc-tag {
  font-size: 11px;
  color: var(--muted-2);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 6px;
}
.page-card .card-actions { display: flex; gap: 4px; }

/* ============ 弹窗（编辑页面） ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s;
  padding: 24px;
}
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.modal .modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.modal .modal-body { padding: 20px; overflow-y: auto; }
.modal .modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.modal .field textarea, .modal .field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg-secondary);
  color: var(--text);
}
.modal .field textarea:focus, .modal .field input:focus { outline: none; border-color: var(--border-strong); background: var(--bg); }
.modal .field textarea { min-height: 72px; }
.modal .field textarea.tall { min-height: 120px; }
.modal .field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text);
}
.modal .field select:focus { outline: none; border-color: var(--border-strong); background: var(--bg); }
.modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}
.modal-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 0;
  font-size: 13px;
  font-family: inherit;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
}
.modal-tabs button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow);
}
.modal .ai-hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: -4px 0 0; }

/* ============ 素材库：方式选择 + 选择弹窗 ============ */
.source-options { display: flex; flex-direction: column; gap: 10px; }
.source-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.source-option:hover { border-color: var(--text); background: var(--bg); }
.source-option-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  flex-shrink: 0;
}
.source-option-icon svg { width: 18px; height: 18px; }
.source-option-text { display: flex; flex-direction: column; min-width: 0; }
.so-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.so-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

.asset-filter { margin-bottom: 12px; display: flex; gap: 8px; }
.asset-filter button {
  padding: 5px 14px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.asset-filter button:hover { color: var(--text); border-color: var(--border-strong); }
.asset-filter button.active {
  color: var(--text);
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  font-weight: 500;
}

/* ============ 素材库管理页（顶部菜单入口） ============ */
.lib-page { max-width: 960px; margin: 0 auto; padding: 28px 24px; }
.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.lib-head-left { display: flex; align-items: baseline; gap: 12px; }
.lib-count { font-size: 12.5px; color: var(--muted-2); }
.lib-grid { max-height: none; }
.lib-del {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(13, 13, 13, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.asset-card:hover .lib-del { opacity: 1; }
.lib-del:hover { background: var(--danger); }

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 2px;
}
.asset-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--bg-secondary);
  transition: border-color 0.12s, transform 0.12s;
}
.asset-card:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.asset-card.selected { border-color: var(--text); }
.asset-thumb { width: 100%; height: 100%; }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-source-tag {
  position: absolute;
  right: 4px;
  bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  pointer-events: none;
}
.asset-source-tag.ai { background: rgba(13, 13, 13, 0.82); color: #fff; }
/* 素材库文档卡片：PDF 无缩略图，用图标 + 文件名 */
.asset-doc-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  box-sizing: border-box;
  font-size: 30px;
  background: var(--bg-secondary);
}
.asset-doc-thumb .asset-doc-name {
  max-width: 100%;
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-check {
  position: absolute;
  left: 6px;
  top: 6px;
  width: 20px;
  height: 20px;
  background: var(--text);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.asset-check svg { width: 11px; height: 11px; }
.asset-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 40px 0;
}

/* ============ 卡片内素材行（大纲/内容步） ============ */
.asset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.asset-mini {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.asset-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.asset-mini img:hover { opacity: 0.85; }
.asset-mini-del {
  position: absolute;
  right: 0;
  top: 0;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 0 0 0 6px;
  background: rgba(13, 13, 13, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.asset-mini-del:hover { background: var(--danger); }
.asset-add-btn {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.asset-add-btn:hover { border-color: var(--text); color: var(--text); background: var(--bg-secondary); }
.asset-ai-btn { border-style: solid; }

/* 图片预览浮层 */
.img-preview-mask {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.15s;
}
.img-preview-mask img {
  max-width: 86vw;
  max-height: 86vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

/* ============ 第四步：缩略图 + 大图 ============ */
.image-workspace {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.thumb-nav {
  width: 168px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 640px;
  overflow-y: auto;
}
.thumb {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  background: var(--bg-secondary);
  aspect-ratio: 16 / 9;
}
.thumb.active { border-color: var(--text); border-width: 2px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-label {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
}
.thumb .thumb-status {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}
.thumb .thumb-status.done { background: #16a34a; }
.thumb .thumb-status.failed { background: var(--danger); }
.thumb .thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted-2);
}

.main-preview { flex: 1; min-width: 0; }
.main-preview img.big-img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: var(--bg-secondary);
}
.main-preview .preview-empty {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 13px;
  background: var(--bg-secondary);
}
.main-preview .preview-title {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 4px;
}
.main-preview .preview-actions { display: flex; gap: 8px; margin-top: 12px; }

@media (max-width: 640px) {
  .image-workspace { flex-direction: column; }
  .thumb-nav { width: 100%; flex-direction: row; overflow-x: auto; max-height: none; }
  .thumb { min-width: 120px; }
}

/* ============ 历史 ============ */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.history-item:hover { border-color: var(--border-strong); background: var(--bg-secondary); }
.history-item .cover {
  width: 72px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-item .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.history-item .cover .cover-placeholder svg { width: 18px; height: 18px; color: var(--muted-2); opacity: 0.6; }
.history-item .info { min-width: 0; flex: 1; }
.history-item .title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .meta { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.history-item .ops { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.history-item .status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--muted);
  flex-shrink: 0;
}
.history-item .status.completed { background: #f0fdf4; color: #16a34a; }
.history-item .status.failed { background: #fef2f2; color: var(--danger); }
@media (max-width: 640px) {
  .history-item { flex-wrap: wrap; }
  .history-item .ops { width: 100%; justify-content: flex-end; }
}

/* ============ 加载 ============ */
.loading { text-align: center; padding: 56px 0; color: var(--muted); font-size: 14px; }
.loading .spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 22px;
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 1000;
  animation: toastIn 0.15s;
  max-width: 86vw;
}
.toast.error { background: var(--danger); }
.toast.success { background: #16a34a; }
@keyframes toastIn { from { transform: translate(-50%, 8px); opacity: 0; } }

/* ============ 通用动画 ============ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============ 帮助页 ============ */
.help-content h3 { font-size: 14px; margin: 18px 0 8px; }
.help-content ol, .help-content ul { padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.9; }

/* ============ 隐藏的 file input ============ */
.hidden-input { display: none; }

/* ============ 大纲步「生成输入」面板 ============ */
.orig-panel { margin-bottom: 20px; animation: fadeIn 0.15s; }
.orig-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.orig-title { font-size: 14px; font-weight: 600; }
.orig-head .ai-hint { flex: 1; margin: 0; }
.orig-toggle {
  border: none; background: transparent; color: var(--muted);
  font-size: 12.5px; cursor: pointer; padding: 4px 10px;
  border-radius: 999px;
}
.orig-toggle:hover { background: var(--bg-secondary); color: var(--text); }
.orig-panel.collapsed .orig-body,
.orig-panel.collapsed .orig-foot { display: none; }
.orig-panel .field { margin-bottom: 14px; }
.orig-panel .field label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500;
}
.orig-panel .field textarea,
.orig-panel .field input,
.orig-panel .field select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text);
  resize: vertical;
}
.orig-panel .field textarea:focus,
.orig-panel .field input:focus,
.orig-panel .field select:focus { outline: none; border-color: var(--border-strong); background: var(--bg); }
.orig-panel .field textarea { min-height: 72px; }
.orig-panel .field textarea.tall { min-height: 120px; }
.orig-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.orig-mode {
  font-size: 11px; color: var(--muted-2); font-weight: 400;
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}
.orig-inline { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.orig-inline label { margin-bottom: 0 !important; }
.orig-inline input, .orig-inline select { width: auto !important; flex: 1; min-width: 0; }
.orig-panel .field label .ai-hint { font-size: 11px; color: var(--muted-2); font-weight: 400; }
.orig-chips { margin-top: 8px; }
.orig-chips .chip { font-size: 11.5px; padding: 3px 10px; }
.orig-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.orig-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.orig-attach { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.orig-foot { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ============ 素材库头部按钮组 + AI 生图弹窗 ============ */
.lib-head-actions { display: flex; gap: 10px; }
.t2i-refs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.t2i-ref-add {
  width: 48px; height: 48px;
  border: 1px dashed var(--border-strong); border-radius: 10px;
  background: var(--bg-secondary); color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.t2i-ref-add:hover { border-color: var(--text); color: var(--text); }
