:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #7a8293;
  --line: #e6e8ef;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 1cm;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 32px; }
.topbar h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 0; color: var(--muted); font-size: 13px; }

.badge {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #eef2ff;
  color: var(--accent);
}
.badge.real { background: #ecfdf5; color: var(--ok); }

.hint {
  margin: 12px 1cm 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fff7ed;
  color: var(--warn);
  border: 1px solid #fed7aa;
  font-size: 13px;
}
.hint.real { background: #ecfdf5; color: var(--ok); border-color: #bbf7d0; }

.layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
  padding: 20px 28px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  margin: 0 28px 20px;
}
.layout .panel { margin: 0; }
.panel h2 { margin: 0 0 14px; font-size: 16px; }

textarea {
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
}
textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.muted { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.primary { font-size: 16px; padding: 12px 26px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--err); margin-top: 8px; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.grid label.full { grid-column: 1 / -1; }
.grid .check { flex-direction: row; align-items: center; gap: 8px; }
.grid input[type="text"], .grid input[type="number"], .grid select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}
.grid input[type="range"] { width: 100%; }

.progressbar {
  height: 12px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  transition: width 0.4s ease;
}

.seglist { list-style: none; padding: 0; margin: 14px 0 0; }
.seglist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.seg-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.seg-dot.running { background: var(--accent); animation: pulse 1s infinite; }
.seg-dot.done { background: var(--ok); }
.seg-dot.failed { background: var(--err); }
.seg-text { flex: 1; }
.seg-ai {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: #7c3aed;
  background: #f3e8ff;
  padding: 2px 8px;
  border-radius: 999px;
}
.seg-note { color: var(--muted); font-size: 12px; }
@keyframes pulse { 50% { opacity: 0.3; } }

video { width: 100%; min-height: 340px; border-radius: 12px; background: #000; display: block; }
.actions { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

.foot { text-align: center; padding: 0 28px 30px; }
.hidden { display: none; }

/* 设置弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
}

/* ===== 向导式界面 ===== */
.stepper {
  display: flex;
  gap: 6px;
  padding: 16px 28px 0;
  flex-wrap: wrap;
}
.stepper .step {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.stepper .step .num {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--line);
  font-weight: 700;
  flex: none;
}
.stepper .step.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.stepper .step.active .num { background: var(--accent); color: #fff; }

.info-card {
  padding: 12px 14px;
  border-radius: 10px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  line-height: 1.7;
}
.warn { color: var(--warn); font-weight: 600; }

/* 八要素分镜展示 */
.seg-body { flex: 1; min-width: 0; }
.seg-elements { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.seg-elements .elm {
  font-size: 11px;
  background: #f0f4ff;
  color: #334;
  padding: 2px 8px;
  border-radius: 999px;
}
.seg-elements .elm b { color: var(--accent); margin-right: 3px; }
.seg-prompt { font-size: 11px; margin-top: 4px; word-break: break-all; }
.seglist li { align-items: flex-start; }

/* 质检清单 */
.quality { margin-bottom: 16px; }
.quality h3 { font-size: 13px; }
.q-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.q-item.ok { border-color: #bbf7d0; background: #f0fdf4; }
.q-item.warn { border-color: #fed7aa; background: #fff7ed; }
.q-ico { flex: none; }

/* ===== 对话式界面 ===== */
.chat-layout { padding: 20px 28px; max-width: 860px; margin: 0 auto; }
.chat-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.chat-thread {
  height: 440px;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfd;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.ai { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.typing .bubble { color: var(--muted); font-style: italic; }

.chat-input {
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #fff;
}
.chat-input textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}
.chat-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; }
.btn.small { padding: 8px 16px; font-size: 14px; }
.btn.full { width: 100%; margin: 14px 0; }

.summary {
  border-top: 1px solid var(--line);
  padding: 16px 20px;
  background: #f0f7ff;
}
.summary h3 { margin: 0 0 10px; font-size: 15px; }
.sum-row { display: flex; gap: 12px; padding: 5px 0; font-size: 14px; }
.sum-row b { flex: none; width: 76px; color: var(--accent); }

.advanced { border-top: 1px solid var(--line); padding: 14px 20px; background: #fff; }
.advanced summary { cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }
.advanced .grid { margin-top: 12px; }

/* 上传区域 */
.upload-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  cursor: pointer;
  background: #f0f7ff;
  transition: background 0.2s;
}
.upload-zone:hover { background: #e6f1ff; }
.upload-ico { font-size: 28px; }
.upload-text { font-size: 14px; color: var(--text); }
.upload-text b { color: var(--accent); }

/* 生成按钮醒目 */
#generateBtn.full {
  padding: 16px 26px;
  font-size: 17px;
  background: linear-gradient(90deg, #2563eb, #6366f1);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
#generateBtn.full:hover { transform: translateY(-1px); }

/* 选项卡片 */
.opt-box {
  max-width: 88%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.opt-title { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.opt-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-card {
  padding: 9px 14px;
  border: 1px solid var(--accent);
  background: #f0f7ff;
  color: var(--accent);
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.opt-card:hover { background: var(--accent); color: #fff; }
.opt-custom {
  flex: 1;
  min-width: 140px;
  padding: 9px 12px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  font-size: 13px;
}

/* 结合图缩略图 */
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.thumb {
  width: 110px;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  transition: transform 0.15s;
}
.thumb:hover { transform: scale(1.03); }

/* 剧本可编辑文本框 */
.script-editor {
  width: 100%;
  min-height: 360px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  margin: 10px 0;
}

/* 人物卡片 */
.char-card { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.char-name { font-size: 12px; color: var(--text); font-weight: 600; }

/* 混剪素材包片段卡片 */
.clip-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 12px 0; background: #fafbfd; }
.clip-meta { font-size: 13px; color: var(--muted, #888); margin: 8px 0 6px; }

/* 任务中台看板 */
.hub-board { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 10px 0; background: #fafbfd; }
.hub-task { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.hub-task:last-child { border-bottom: none; }
.hub-task b { font-size: 14px; }
.hub-status { margin-left: auto; font-size: 13px; color: #666; }
.hub-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.hub-dot.pending { background: #ccc; }
.hub-dot.running { background: #f0a020; animation: pulse 1s infinite; }
.hub-dot.done { background: #22a06b; }
.hub-dot.failed { background: #e04040; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* 剧本确认面板 */
.script-view {
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0;
  max-height: 320px;
  overflow-y: auto;
}
.script-view h4 { margin: 0 0 8px; font-size: 15px; }
.script-view p { margin: 4px 0; font-size: 13px; }
.scene-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.scene-item {
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* ===== 运行动画 ===== */
/* 思考中跳动点 */
.typing .bubble::after {
  content: '…';
  display: inline-block;
  animation: blink 1.2s infinite;
}
@keyframes blink {
  0%, 20% { content: '…'; }
  40% { content: '….'; }
  60% { content: '…..'; }
  80%, 100% { content: '……'; }
}

/* 进度条流动光效 */
.progressbar { position: relative; overflow: hidden; }
#progressFill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 旋转加载图标 */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 分镜卡片呼吸 */
.seglist li.running .seg-dot { animation: pulse 1s infinite; }
.seglist li.running { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(59,130,246,0.2); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* 图片骨架屏 */
/* 阶段提示 */
.stage-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* 图片骨架屏 */
.img-skeleton {
  width: 120px; height: 180px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eef1f6 25%, #dfe4ec 50%, #eef1f6 75%);
  background-size: 200% 100%;
  animation: skeleton 1.2s infinite;
  display: inline-block;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== 单主工作区（Claude 式）===== */
.chat-main {
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.chat-input {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}

/* 浮动进度条 */
.float-progress {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* 单主工作区：输入行 + 加号上传 */
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chat-input-row textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
}
.plus-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 22px;
  color: var(--accent);
  cursor: pointer;
  background: #fff;
}
.plus-btn:hover { background: #f0f7ff; }

/* 内嵌产物卡片 */
.artifact { justify-content: center; }
.artifact-card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  font-size: 14px;
}
.artifact-card h3, .artifact-card h4 { margin: 0 0 10px; }

/* ===== 左侧功能栏 ===== */
.workspace { display: flex; gap: 10px; padding: 10px 1cm 0; height: calc(100vh - 120px); }
.workspace.collapsed .sidebar { display: none; }
.sidebar {
  flex: none;
  width: 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  overflow-y: auto;
}
.side-title { font-size: 11px; color: var(--muted); margin: 8px 4px 4px; font-weight: 600; }
.side-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 9px;
  margin-bottom: 2px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.side-btn:hover { background: #f0f4ff; }
.side-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.side-settings { padding: 0 4px; }
.side-settings summary { cursor: pointer; font-size: 14px; color: var(--text); padding: 6px 8px; }
.side-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.side-grid label { font-size: 12px; color: var(--muted); }
.side-grid input, .side-grid select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.side-grid .check { flex-direction: row; align-items: center; gap: 6px; }
.chat-main { flex: 1; min-width: 0; }

/* 右上角下载栏 */
.download-bar { display: flex; gap: 6px; }
.download-bar .btn { padding: 5px 10px; font-size: 12px; }
