/* 分镜工坊 - 样式 */
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2329;
  --ink-2: #4e5969;
  --ink-3: #86909c;
  --line: #e5e6eb;
  --brand: #0aa6a0;
  --brand-dark: #07857f;
  --brand-soft: #e6f7f6;
  --accent: #ff7d2e;
  --danger: #f53f3f;
  --ok: #00b96b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(31, 35, 41, .08), 0 4px 16px rgba(31, 35, 41, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { color: var(--brand); }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 13px; color: var(--ink-3); }
.topbar-tag {
  font-size: 12px; color: var(--ink-2);
  background: var(--brand-soft); border: 1px solid #cdeae8;
  padding: 3px 10px; border-radius: 999px;
}

/* ===== 布局 ===== */
.container { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.section-hidden { display: none !important; }

/* ===== Hero ===== */
.hero h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: .3px; }
.hero-desc { color: var(--ink-2); margin: 0 0 20px; font-size: 15px; }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
textarea#idea-input {
  width: 100%; min-height: 84px; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 15px; font-family: inherit;
  color: var(--ink); background: #fbfcfe; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea#idea-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10, 166, 160, .14); }
.idea-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.idea-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 13px; color: var(--ink-2); cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; background: #fff; transition: all .15s;
  max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }

/* ===== 按钮 ===== */
.btn {
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: none; border-radius: 10px; cursor: pointer;
  padding: 9px 18px; transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-lg { padding: 12px 26px; font-size: 15px; }
.btn-ghost {
  background: #fff; color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.btn-label { display: inline-flex; align-items: center; gap: 6px; }
.btn-label::before { content: "✦"; font-size: 12px; }

/* ===== 步骤条 ===== */
.steps { display: flex; align-items: center; margin-top: 22px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); }
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: #eef0f3; color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.step.active { color: var(--brand-dark); font-weight: 600; }
.step.active .step-num { background: var(--brand); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--line); margin: 0 12px; border-radius: 2px; }
.step.done .step-num { background: var(--ok); color: #fff; }
.step.done { color: var(--ok); }

/* ===== 区块头 ===== */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h2 { font-size: 19px; margin: 0; display: flex; align-items: center; gap: 10px; }
.step-badge {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.badge-ai { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #cdeae8; }
.badge-mock { background: #fff3e8; color: #cc7300; border: 1px solid #ffdfbf; }

/* ===== 加载态 ===== */
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 0; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #dce6e5; border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--ink-2); font-size: 14px; margin: 0; }

/* ===== 大纲 ===== */
.logline {
  font-size: 17px; font-weight: 600; color: var(--ink);
  background: var(--brand-soft); border-left: 4px solid var(--brand);
  padding: 12px 16px; border-radius: 8px; margin: 0 0 16px;
}
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.meta-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe; }
.meta-title { font-size: 12px; font-weight: 700; color: var(--ink-3); margin-bottom: 4px; letter-spacing: 1px; }
.meta-text { font-size: 14px; color: var(--ink); }
.acts { display: flex; flex-direction: column; gap: 12px; }
.act-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.act-title { font-size: 15px; font-weight: 700; color: var(--brand-dark); margin-bottom: 8px; }
.act-beats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.act-beats li { font-size: 14px; color: var(--ink-2); padding-left: 20px; position: relative; }
.act-beats li::before {
  content: ""; position: absolute; left: 4px; top: 9px;
  width: 7px; height: 7px; border-radius: 2px; background: var(--brand);
}
.board-cta { margin-top: 20px; text-align: center; }
.hint { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }

/* ===== 分镜表 ===== */
.board-tip { font-size: 13px; color: var(--ink-3); margin-bottom: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.board-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 860px; }
.board-table th, .board-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.board-table thead th {
  background: #f7f8fa; font-size: 12px; color: var(--ink-3);
  font-weight: 600; white-space: nowrap; position: sticky; top: 0;
}
.board-table tbody tr:last-child td { border-bottom: none; }
.board-table tbody tr:hover { background: #fafcfc; }
.col-idx { width: 44px; text-align: center; }
.col-scene { width: 110px; }
.col-scale { width: 76px; }
.col-action { width: 26%; }
.col-dialogue { width: 18%; }
.col-caption { width: 16%; }
.col-duration { width: 80px; }
.col-del { width: 44px; text-align: center; }
td[contenteditable="true"] { outline: none; border-radius: 4px; }
td[contenteditable="true"]:hover { background: #f0fafa; }
td[contenteditable="true"]:focus { background: #eaf7f7; box-shadow: inset 0 0 0 2px var(--brand); }
.del-btn {
  border: none; background: none; cursor: pointer; color: var(--ink-3);
  font-size: 16px; border-radius: 6px; width: 26px; height: 26px; line-height: 1;
}
.del-btn:hover { color: var(--danger); background: #fff0f0; }

/* ===== 边界说明 ===== */
.notes h3 { font-size: 15px; margin: 0 0 10px; }
.notes ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.notes li { font-size: 13px; color: var(--ink-2); }

/* ===== Footer ===== */
.footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  max-width: 980px; margin: 0 auto; padding: 8px 16px 28px;
  font-size: 12px; color: var(--ink-3);
}

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: #2b333d; color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 99; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ===== 记忆面板 ===== */
.memory-box {
  margin-top: 18px; padding: 14px 16px;
  border: 1px dashed #cdeae8; border-radius: 10px; background: #f7fcfc;
}
.memory-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.memory-title { font-size: 14px; font-weight: 700; color: var(--brand-dark); }
.memory-hint { font-size: 12px; color: var(--ink-3); }
.memory-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.memory-tag {
  font-size: 13px; color: var(--ink-2); background: #fff;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  display: inline-flex; align-items: center; gap: 6px;
}
.memory-del { cursor: pointer; color: var(--ink-3); font-size: 12px; }
.memory-del:hover { color: var(--danger); }
.memory-add { display: flex; gap: 8px; }
.memory-add input {
  flex: 1; min-width: 200px; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; font-family: inherit; outline: none;
}
.memory-add input:focus { border-color: var(--brand); }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ===== 任务历史 ===== */
.task-box { margin-top: 14px; }
.task-list { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.task-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.task-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-goal { font-size: 13px; color: var(--ink); }
.task-meta { font-size: 12px; color: var(--ink-3); margin: 5px 0 8px; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-ok { background: #e8f7ee; color: #009a4e; border: 1px solid #bfe8cd; }
.badge-warn { background: #fff7e8; color: #cc7300; border: 1px solid #ffe0b3; }

/* ===== Agent 过程面板 ===== */
.agent-sub-title { font-size: 14px; font-weight: 700; color: var(--ink-2); margin: 6px 0 10px; }
.plan-list, .tool-log-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plan-item, .tool-log-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-size: 14px; background: #fbfcfe;
}
.plan-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex: none; }
.plan-item.running .plan-dot { background: var(--brand); animation: pulse 1s infinite; }
.plan-item.done .plan-dot { background: var(--ok); }
.plan-item.failed .plan-dot { background: var(--danger); }
.plan-item.running { border-color: var(--brand); background: var(--brand-soft); }
.plan-item.done { opacity: .85; }
@keyframes pulse { 50% { opacity: .35; } }
.plan-label { color: var(--ink); }
.tool-log-item { align-items: flex-start; flex-direction: column; gap: 4px; }
.tool-name { font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.tool-mock { font-size: 11px; padding: 1px 7px; }
.tool-summary { font-size: 13px; color: var(--ink-2); }

/* ===== 反思面板 ===== */
.agent-reflect { margin-top: 4px; }
.reflect-score {
  font-size: 15px; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px;
  background: #f0f0f0; color: var(--ink-2);
}
.reflect-score.high { background: #e8f7ee; color: #009a4e; }
.reflect-score.mid { background: #fff7e8; color: #cc7300; }
.reflect-score.low { background: #fff0f0; color: #d43c3c; }
.reflect-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.reflect-col { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.reflect-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.reflect-title.ok { color: var(--ok); }
.reflect-title.warn { color: #cc7300; }
.reflect-title.tip { color: var(--brand-dark); }
.reflect-col ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.reflect-col li { font-size: 13px; color: var(--ink-2); }

/* ===== 结构检查报告 ===== */
.check-report { margin-top: 14px; }
.check-pass, .check-fail {
  border-radius: 8px; padding: 10px 14px; font-size: 13px;
}
.check-pass { background: #e8f7ee; color: #009a4e; border: 1px solid #bfe8cd; }
.check-fail { background: #fff7e8; color: #cc7300; border: 1px solid #ffe0b3; }
.check-fail ul { margin: 6px 0 0; padding-left: 18px; }
.check-fail li { margin-top: 2px; }

/* ===== 响应式 ===== */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .brand-sub { display: none; }
  .container { padding: 16px 10px 36px; }
  .card { padding: 16px; }
  .hero h1 { font-size: 21px; }
  .head-actions { width: 100%; }
}
