:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-soft: #5b6472;
  --line: #e4e7ec;
  --accent: #e6533c;       /* 电影红 */
  --accent-2: #2b6cb0;     /* 镜头蓝 */
  --good: #2f9e6f;
  --warn: #d99a18;
  --bad: #d6453d;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,30,50,.08), 0 6px 24px rgba(20,30,50,.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; background: linear-gradient(120deg, #1c2230, #2a2230);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .3px; }
.topbar .sub { margin: 2px 0 0; font-size: 12px; color: #b9c0cc; }
.badge { background: rgba(230,83,60,.18); color: #ffb4a3; border: 1px solid rgba(230,83,60,.4);
  padding: 4px 12px; border-radius: 999px; font-size: 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 10px 22px 0; background: #1c2230; flex-wrap: wrap; }
.tab {
  background: transparent; border: none; color: #aeb6c2; padding: 10px 16px; cursor: pointer;
  font-size: 14px; border-bottom: 2px solid transparent; transition: .15s;
}
.tab:hover { color: #fff; }
.tab.active { color: #fff; border-bottom-color: var(--accent); }

/* ---------- Layout ---------- */
.container { padding: 22px; max-width: 1200px; margin: 0 auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 880px){ .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.hint { color: var(--ink-soft); font-size: 12.5px; margin: 8px 0; }

/* ---------- Form ---------- */
.row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.lbl { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.input, .textarea, .select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; background: #fff; color: var(--ink); outline: none; transition: border .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-2); }
.textarea { min-height: 84px; resize: vertical; }
.textarea.tall { min-height: 220px; }

.btn { border: none; border-radius: 9px; padding: 9px 16px; cursor: pointer; font: inherit;
  font-weight: 600; transition: .15s; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #cf4631; }
.btn.ghost { background: #eef1f5; color: var(--ink); }
.btn.ghost:hover { background: #e3e8ef; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Prompt Studio ---------- */
.fw-select { display: flex; flex-wrap: wrap; gap: 8px; }
.fw-chip { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: 13px; background: #fff; color: var(--ink); }
.fw-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.fw-fields { display: flex; flex-direction: column; gap: 11px; margin-top: 6px; }

.output { background: #0f1320; color: #e8ecf3; padding: 16px; border-radius: 10px; white-space: pre-wrap;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 13px; line-height: 1.7;
  min-height: 160px; margin: 0; overflow: auto; max-height: 460px; }

/* ---------- Lexicon ---------- */
.filter-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 14px; }
.cat-chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: 12.5px; background: #fff; }
.cat-chip.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.lex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lex-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; background: #fff;
  cursor: pointer; transition: .15s; position: relative; }
.lex-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.lex-card .en { font-weight: 700; font-size: 13.5px; }
.lex-card .zh { color: var(--accent); font-weight: 600; margin-left: 6px; }
.lex-card .cat { display: inline-block; font-size: 11px; color: var(--accent-2);
  background: #eaf1fa; padding: 1px 8px; border-radius: 6px; margin: 6px 0; }
.lex-card .effect { font-size: 12.5px; color: var(--ink); }
.lex-card .best { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.lex-card .copy-hint { position: absolute; top: 10px; right: 12px; font-size: 11px; color: #b6bdc8; }

/* ---------- Recommender ---------- */
.rec-out, .sl-out, .qc-out { font-size: 13.5px; }
.rec-block { border: 1px solid var(--line); border-left: 4px solid var(--accent-2); border-radius: 8px;
  padding: 11px 13px; margin-bottom: 11px; background: #fbfcfe; }
.rec-block h3 { margin: 0 0 5px; font-size: 14px; }
.rec-block .meta { color: var(--ink-soft); font-size: 12.5px; }
.rec-block .prompt { margin-top: 7px; background: #0f1320; color: #d7e3f4; padding: 9px 11px;
  border-radius: 7px; font-family: monospace; font-size: 12.5px; white-space: pre-wrap; }

/* ---------- Shotlist ---------- */
.sl-out table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sl-out th, .sl-out td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.sl-out th { background: #f0f3f7; font-weight: 700; }
.sl-out .shot-no { font-weight: 700; color: var(--accent); }
.sl-out .prow { background: #fafbfc; }
.sl-out .pcode { font-family: monospace; font-size: 11.5px; color: #334; white-space: pre-wrap; }

/* ---------- QC ---------- */
.score { font-weight: 800; font-size: 18px; padding: 2px 12px; border-radius: 8px; background: #eee; }
.score.good { background: #e3f5ec; color: var(--good); }
.score.warn { background: #fbf2dc; color: var(--warn); }
.score.bad { background: #fbe4e2; color: var(--bad); }
.qc-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 9px; }
.qc-item.red { border-left: 4px solid var(--bad); }
.qc-item.yellow { border-left: 4px solid var(--warn); }
.qc-item.green { border-left: 4px solid var(--good); }
.qc-item .tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 6px; margin-right: 8px; }
.qc-item.red .tag { background: #fbe4e2; color: var(--bad); }
.qc-item.yellow .tag { background: #fbf2dc; color: var(--warn); }
.qc-item.green .tag { background: #e3f5ec; color: var(--good); }
.qc-item .reason { font-weight: 600; }
.qc-item .fix { color: var(--ink-soft); font-size: 12.5px; margin-top: 3px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c2230; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0;
  pointer-events: none; transition: .25s; font-size: 13px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Reverse Engineering (视频→分镜反推) ---------- */
.rv-out { font-size: 13.5px; }
.dim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 4px 0 6px; }
.dim { font-size: 11.5px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink-soft); }
.dim.ok { background: #e3f5ec; border-color: #bfe6d2; color: var(--good); }
.dim.todo { background: #fbfcfe; }
.rv-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.rv-table th, .rv-table td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.rv-table th { background: #f0f3f7; font-weight: 700; }
.rv-table .prow { background: #fafbfc; }
.rv-table .pcode { font-family: monospace; font-size: 11px; color: #334; white-space: pre-wrap; line-height: 1.55; }

/* ---------- 广告级模板 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 9px; margin-bottom: 4px; }
.cat-card { text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px 12px; cursor: pointer; transition: .15s; font: inherit; display: flex; flex-direction: column; gap: 4px; }
.cat-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.cat-card.active { border-color: var(--accent); background: #fdf1ef; }
.cat-card b { font-size: 13px; color: var(--ink); }
.cat-card.active b { color: var(--accent); }
.cat-card .meta { font-size: 11.5px; color: var(--ink-soft); line-height: 1.5; }

/* ---------- 分段切换控件 ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg-btn { border: none; background: transparent; padding: 7px 14px; cursor: pointer; font: inherit;
  font-size: 12.5px; color: var(--ink-soft); transition: .15s; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { background: #f2f5f9; }
.seg-btn.active { background: var(--accent); color: #fff; }

/* ---------- 面部微表情选择器 ---------- */
.expr-sel { width: 100%; min-width: 84px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px;
  font: inherit; font-size: 12px; background: #fff; color: var(--ink); cursor: pointer; }
.expr-sel:focus { outline: none; border-color: var(--accent-2); }
.expr-picker { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.expr-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px;
  font-size: 11.5px; cursor: pointer; color: var(--ink-soft); transition: .15s; }
.expr-chip:hover { border-color: var(--accent); color: var(--accent); background: #fdf1ef; }
.expr-group-title { width: 100%; font-size: 11px; color: var(--ink-soft); font-weight: 700;
  margin: 7px 0 2px; padding-left: 2px; }
.expr-chip.grp-负面 { border-color: #f2c4c0; color: #c2453c; background: #fdf3f2; }
.expr-chip.grp-负面:hover { border-color: var(--bad); background: #fbe4e2; }
.expr-chip.grp-正面 { border-color: #bfe6d2; color: #227d56; background: #effaf4; }
.expr-chip.grp-正面:hover { border-color: var(--good); background: #e3f5ec; }
.expr-chip.grp-复杂 { border-color: #cfdff3; color: #2b6cb0; background: #f2f7fc; }
.expr-chip.grp-复杂:hover { border-color: var(--accent-2); background: #eaf1fa; }

/* 中文镜头库卡片补充样式 */
.lex-card .zh.big { font-size: 14px; font-weight: 700; color: var(--ink); margin-left: 0; }
.lex-card .prompt-mini { margin-top: 7px; padding: 7px 9px; background: #f7f9fc; border-radius: 7px;
  font-size: 11.5px; color: var(--ink-soft); line-height: 1.6; border-left: 2px solid var(--line); }

/* ---------- 首帧图提示词 ---------- */
.frame-item { display: flex; gap: 9px; align-items: flex-start; padding: 8px 10px; margin-top: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; transition: .15s; }
.frame-item:hover { border-color: var(--accent-2); box-shadow: var(--shadow); }
.frame-item .shot-no { flex: 0 0 auto; margin-top: 1px; }
.frame-txt { font-size: 12px; color: var(--ink); line-height: 1.65; }

/* ---------- diff 对比 ---------- */
.diff-box { background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  font-size: 13px; line-height: 2; max-height: 320px; overflow: auto; word-break: break-word; }
.d-same { color: var(--ink-soft); }
.d-del { background: #fbe4e2; color: #b3372f; text-decoration: line-through; border-radius: 4px; padding: 1px 3px; }
.d-add { background: #e3f5ec; color: #1f7a52; border-radius: 4px; padding: 1px 3px; font-weight: 600; }
.d-chip { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 6px; margin-right: 4px; }
.d-chip.del { background: #fbe4e2; color: var(--bad); }
.d-chip.add { background: #e3f5ec; color: var(--good); }
.d-chip.same { background: #eef1f5; color: var(--ink-soft); }

/* ---------- 文生图模块 ---------- */
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.param-cell { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "cb nm" "cb sy" ". ds";
  gap: 1px 7px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  background: #fff; cursor: pointer; transition: .15s; }
.param-cell:hover { border-color: var(--accent-2); box-shadow: var(--shadow); }
.param-cell input { grid-area: cb; cursor: pointer; }
.param-cell b { grid-area: nm; font-size: 12.5px; }
.param-cell code { grid-area: sy; font-size: 11px; color: var(--accent); font-family: monospace; }
.param-cell .meta { grid-area: ds; font-size: 11px; color: var(--ink-soft); line-height: 1.5; }
.expr-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.expr-chip.active:hover { background: #cf4631; color: #fff; }

details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--accent); }
details[open] summary::before { content: "▾ "; }

/* ---------- 创作工作流（阶段导航） ---------- */
.phase-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.phase-btn { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 7px 15px; cursor: pointer; font: inherit; font-size: 12.5px;
  color: var(--ink-soft); transition: .15s; }
.phase-btn:hover { border-color: var(--accent-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.phase-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ph-ico { font-size: 14px; }
.phase-detail { border: 1px solid var(--line); border-radius: 11px; padding: 16px 18px; background: #fbfcfe; }
.phase-head h2 { margin: 0 0 5px; font-size: 15px; }
.phase-head .meta { margin: 2px 0; }
.step-list { margin: 12px 0 4px; padding-left: 22px; font-size: 13px; line-height: 1.9; color: var(--ink); }
.step-list li::marker { color: var(--accent); font-weight: 700; }
.rule-list { margin: 8px 0 2px; padding-left: 20px; font-size: 12.5px; line-height: 1.85; color: var(--ink-soft); }
.rule-list li { margin-bottom: 3px; }
.rule-list code { background: #eef1f5; padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--accent); }

/* ---------- 导演模式 ---------- */
.dir-out { font-size: 13.5px; }
.char-out, .cont-out { font-size: 13px; }

/* ---------- AI 导演助手 ---------- */
.ai-status { font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.ai-status.on { background: #e3f5ec; color: var(--good); }
.ai-status.off { background: #f0f2f5; color: var(--ink-soft); }
.ai-layout { display: grid; grid-template-columns: 1fr 1.15fr; gap: 18px; }
@media (max-width: 980px) { .ai-layout { grid-template-columns: 1fr; } }
.ai-left, .ai-right { min-width: 0; }
.ai-right .output { max-height: 620px; }
.modal { position: fixed; inset: 0; background: rgba(18,24,36,.55); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-card code { background: #eef1f5; padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--accent); }

/* ---------- 项目库 ---------- */
.lib-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.lib-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; transition: .15s; }
.lib-item:hover { border-color: var(--accent-2); box-shadow: var(--shadow); }
.lib-main { display: flex; flex-direction: column; min-width: 0; }
.lib-main b { font-size: 13.5px; }
.lib-main .meta { font-size: 11.5px; color: var(--ink-soft); }
.lib-acts { display: flex; gap: 6px; flex: 0 0 auto; }

.footer { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 22px; line-height: 1.9; }
.footer p { margin: 0 0 6px; }
.footer code { background: #e9edf2; padding: 2px 7px; border-radius: 5px; font-size: 11.5px; color: var(--accent); }

.panel { display: none; }
.panel.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- OpenPose 姿势编辑器 ---------- */
#poseCanvas {
  width: 100%; max-width: 512px; display: block; margin: 12px auto;
  border: 1px solid var(--line); border-radius: 10px;
  background: #faf8f2; touch-action: none; cursor: crosshair;
}
#posePresets { margin-bottom: 4px; }
#posePresets .expr-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 姿势参考库（ai-pose-gallery-zh） ---------- */
.pl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 10px; }
.pl-card { position: relative; cursor: pointer; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: #fff; transition: .15s; }
.pl-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.pl-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: #f0ede6; }
.pl-card span { display: block; font-size: 11px; padding: 4px 6px 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.pl-card i { position: absolute; top: 4px; right: 4px; font-style: normal; font-size: 10px;
  background: rgba(28,34,48,.75); color: #fff; padding: 1px 6px; border-radius: 999px; }
.pl-big { width: 100%; max-width: 420px; display: block; margin: 0 auto 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #f0ede6; }
#plDetail h3 { margin: 4px 0 2px; font-size: 15px; }
#plDetail .meta { margin: 0 0 10px; }
.pl-recipe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.pl-recipe-cell { cursor: pointer; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; transition: .15s; }
.pl-recipe-cell:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pl-recipe-cell img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: #f0ede6; }
.pl-recipe-cell span { display: block; font-size: 11px; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 角色配方槽（自选 + 随机） ---------- */
.pl-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 2px; }
.pl-slot { border: 1px dashed var(--line); border-radius: 10px; padding: 6px; text-align: center;
  font-size: 12px; color: var(--muted); background: #faf8f2; min-height: 86px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.pl-slot.filled { border-style: solid; border-color: var(--accent); color: var(--ink);
  background: #fff; cursor: pointer; }
.pl-slot.filled:hover { box-shadow: var(--shadow); transform: translateY(-1px); transition: .15s; }
.pl-slot img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px;
  display: block; margin-bottom: 2px; background: #f0ede6; }
.pl-slot > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-slot .ops { display: flex; gap: 4px; justify-content: center; margin-top: 2px; }
.pl-slot .ops .btn { padding: 1px 8px; font-size: 11px; }
