:root {
  --bg: #fdf7ef;
  --paper: #fff8f1;
  --panel: #ffffff;
  --border: #f0d9c2;
  --ink: #2c1b12;
  --muted: #7c6a60;
  --primary: #f07b62;
  --primary-2: #f6a26c;
  --accent: #6a8caf;
  --mint: #8bc3a3;
  --shadow: 0 12px 30px rgba(45, 27, 18, 0.12);
  --shadow-soft: 0 10px 24px rgba(106, 140, 175, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Smiley Sans", "Poppins", "PingFang SC", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 20% 18%, rgba(240,123,98,0.16), transparent 32%),
    radial-gradient(circle at 82% 8%, rgba(138,192,255,0.18), transparent 28%),
    radial-gradient(circle at 12% 86%, rgba(139,195,163,0.12), transparent 30%),
    linear-gradient(135deg, #fffaf5 0%, #fdf1e6 100%);
  background-attachment: fixed;
  color: var(--ink);
}
a { color: inherit; text-decoration: none; }

.page { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(14px);
  background:
    linear-gradient(95deg, rgba(240,123,98,0.16), rgba(106,140,175,0.14)),
    rgba(255, 255, 255, 0.72);
  border-bottom: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px;
  box-shadow: 0 8px 24px rgba(45, 27, 18, 0.08);
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-img {
  width: 52px; height: 52px;
  border-radius: 30px 30px 30px 30px;
  object-fit: cover;
  background: #c10f0f;
  box-shadow: var(--shadow);
  border: 2px solid rgba(255, 255, 255, 0.6);
}
.title { margin: 0; font-weight: 900; letter-spacing: 0.4px; font-size: 20px; }
.subtitle { margin: 0; font-size: 12px; color: var(--muted); }

.nav-links { display: flex; align-items: center; gap: 12px; }
.nav-links a {
  padding: 9px 14px; border-radius: 14px; color: var(--muted); font-weight: 800;
  transition: all 0.18s ease; border: 1px dashed transparent; background: rgba(255,255,255,0.7);
}
.nav-links a.active { color: var(--ink); border-color: rgba(240,123,98,0.32); background: #fff1e6; box-shadow: var(--shadow-soft); }
.nav-links a:hover { color: var(--ink); background: #fff8f1; transform: translateY(-1px); }

.main { padding: 32px; flex: 1; max-width: 1260px; width: 100%; margin: 0 auto; }
.panel {
  background: linear-gradient(135deg, rgba(255,248,241,0.92), #fff);
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.outputs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 4px 8px 4px;
}
.filter-stack {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.filter-field { display: flex; flex-direction: column; }
.filter-select {
  min-width: 220px;
  background: linear-gradient(135deg, #fffaf5, #fff);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--shadow-soft);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow { margin: 0; font-size: 12px; color: var(--muted); letter-spacing: 0.6px; text-transform: uppercase; }
h2 { margin: 8px 0 0 0; font-size: 22px; letter-spacing: 0.2px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: #c0362c; font-weight: 800; }

.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 18px; }
.stat-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: 18px;
  border: 1px dashed var(--border);
  background: linear-gradient(160deg, #fff6ed, #ffffff 45%);
  box-shadow: var(--shadow-soft);
}
.stat-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 18px; font-weight: 900; letter-spacing: 1px; border: 2px solid rgba(255,255,255,0.3); }
.stat-icon.blue { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.stat-icon.cyan { background: linear-gradient(135deg, #f68b9a, #f4aece); }
.stat-icon.purple { background: linear-gradient(135deg, #6a8caf, #8fa7c5); }
.stat-icon.teal { background: linear-gradient(135deg, #8bc3a3, #9fd0b3); }
.stat-title { margin: 0; color: var(--muted); font-size: 13px; }
.stat-value { margin: 4px 0 0 0; font-size: 24px; font-weight: 900; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 15px; border-radius: 14px; border: 1px dashed transparent;
  font-weight: 900; cursor: pointer; transition: all 0.15s ease; letter-spacing: 0.1px;
}
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: var(--shadow); border-color: rgba(255,255,255,0.6); }
.btn.success { background: linear-gradient(135deg, #2f9e44, #3bcf7e); color: #fff; box-shadow: var(--shadow); border-color: rgba(255,255,255,0.6); }
.btn.ghost { background: #fff1e6; color: var(--ink); border-color: var(--border); box-shadow: var(--shadow-soft); }
.btn.link { background: transparent; color: var(--accent); padding: 8px 12px; font-weight: 800; }
.btn:hover { transform: translateY(-1px) scale(1.01); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 8px 12px; border-radius: 999px; border: 1px dashed var(--border);
  font-weight: 800; color: var(--muted); background: #fffaf3;
}
.pill:hover { color: var(--ink); border-color: var(--primary); }
.pill.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); border-color: transparent; box-shadow: var(--shadow-soft); }

.series-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 14px; }
.series-card { border: 1px dashed var(--border); border-radius: 18px; padding: 16px; background: linear-gradient(150deg, #fff6ed, #ffffff 35%); box-shadow: var(--shadow-soft); }
.series-head { display: flex; align-items: center; justify-content: space-between; }
.series-title { margin: 0; font-weight: 900; letter-spacing: 0.2px; }
.book-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.tag {
  padding: 9px 12px; border-radius: 13px; background: #ffe1d5;
  color: #8f442d; border: 1px dashed #ffc6b4; font-weight: 800; font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
}
.tag i { margin-right: 6px; }
.tag.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-color: transparent; }

.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.sub-panel {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}
.label { margin: 6px 0 6px 0; font-size: 13px; color: var(--muted); letter-spacing: 0.1px; }
.input {
  width: 100%; border: 1px dashed var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; background: #fffdf7;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(240,123,98,0.15); }
.input.tall { min-height: 150px; resize: vertical; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.hint.error { color: #c0362c; }
.input option[disabled] { color: var(--muted); }

.series-head .muted { margin: 0; }

.book-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-top: 12px; }
.nav-pane {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 12px;
  background: #fffdfa;
  box-shadow: var(--shadow-soft);
}
.nav-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.nav-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px dashed var(--border); border-radius: 13px;
  cursor: pointer; transition: all 0.12s ease;
  background: linear-gradient(90deg, #fff6ed, #ffffff 60%);
}
.nav-row:hover { border-color: var(--primary); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.nav-row.active { border-color: var(--primary); background: linear-gradient(90deg, rgba(240,123,98,0.18), #ffffff); box-shadow: var(--shadow-soft); }
.nav-title { margin: 0; font-weight: 800; }
.nav-sub { margin: 2px 0 0 0; font-size: 12px; color: var(--muted); }
.nav-sub.ok { color: var(--mint); }
.nav-arrow { color: var(--muted); font-weight: 900; }

.content-pane {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(160deg, #fff8f1, #ffffff 55%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-soft);
}
.controls .button-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.preview {
  border: 2px dashed var(--border); border-radius: 16px; min-height: 320px;
  display: grid; place-items: center; background: repeating-linear-gradient(135deg, #fff6ed, #fff6ed 16px, #fffdf8 16px, #fffdf8 32px);
}
.preview img { max-width: 100%; max-height: 520px; border-radius: 12px; box-shadow: var(--shadow); }

.preview-frame {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 20%, rgba(240,123,98,0.12), transparent 40%),
    radial-gradient(circle at 80% 78%, rgba(106,140,175,0.12), transparent 42%),
    repeating-linear-gradient(0deg, #fff1e6 0, #fff1e6 18px, #fff9f3 18px, #fff9f3 36px);
  border: 1px dashed var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.button-row .btn { padding-inline: 12px; }
.pill-group .pill.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); border-color: transparent; }

.cover-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 10px; }
.cover-card {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(150deg, #fff6ed, #ffffff 45%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-soft);
}
.cover-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  object-fit: cover;
  background: #ffe8d8;
  border: 1px dashed var(--border);
}
.cover-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.cover-title { margin: 0; font-weight: 900; font-size: 15px; color: var(--ink); }
.cover-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.small-btn {
  padding: 7px 11px;
  border-radius: 11px;
  border: 1px dashed #ffc6b4;
  font-weight: 800;
  font-size: 13px;
  color: #8f442d;
  background: #ffe1d5;
}

.btn.sm { padding: 8px 12px; font-size: 13px; }
.checked-mark { margin-left: 6px; }

.queue-panel {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(135deg, #fff6ff, #f7f0ff);
  box-shadow: var(--shadow);
}
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.queue-actions { display: flex; align-items: center; gap: 10px; }
.task-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.task-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(45, 27, 18, 0.08);
}
.task-row.queued { border-color: rgba(240,123,98,0.35); background: linear-gradient(135deg, #fff0e6, #fffaf3); }
.task-row.running { border-color: rgba(139,195,163,0.32); background: linear-gradient(135deg, #ecfdf3, #f6fffb); }
.task-row.failed { border-color: rgba(220,38,38,0.22); background: linear-gradient(135deg, #fff2f2, #fff8f8); }
.task-row.success { border-color: rgba(47,158,68,0.28); background: linear-gradient(135deg, #eef9f1, #f8fffa); }
.task-row.canceled { border-color: rgba(106,140,175,0.24); background: linear-gradient(135deg, #f3f4f6, #f8fbff); }
.task-title { margin: 0; font-weight: 900; }
.task-sub { margin: 4px 0 0 0; color: var(--muted); font-size: 13px; }
.chip {
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  border: 1px dashed var(--border);
  color: var(--muted);
  background: #fff8ef;
}
.chip.neutral { background: #f0e6ff; color: var(--accent); border-color: rgba(106,140,175,0.28); }
.chip.queued { background: rgba(240,123,98,0.12); color: #a3492e; border-color: rgba(240,123,98,0.28); }
.chip.running { background: rgba(139,195,163,0.14); color: #0f766e; border-color: rgba(139,195,163,0.32); }
.chip.failed { background: rgba(220,38,38,0.14); color: #c0362c; border-color: rgba(220,38,38,0.32); }
.chip.success { background: rgba(47,158,68,0.14); color: #2f9e44; border-color: rgba(47,158,68,0.28); }
.chip.canceled { background: rgba(148,163,184,0.18); color: #334155; border-color: rgba(148,163,184,0.32); }
.chip.sm { font-size: 11px; padding: 4px 8px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.28); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal-card {
  width: min(1100px, 96vw); max-height: 92vh; overflow: auto;
  background: #fffdfa; border-radius: 20px; border: 1px dashed var(--border);
  box-shadow: 0 18px 44px rgba(0,0,0,0.18); padding: 16px 18px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.docstring { line-height: 1.6; color: var(--ink); }
.docstring h1, .docstring h2, .docstring h3, .docstring h4 { margin: 12px 0 8px; }
.docstring p { margin: 8px 0; }
.docstring ul, .docstring ol { padding-left: 20px; margin: 8px 0; }
.docstring blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--border); background: #fff6ed; }
.edit-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; margin-top: 10px; align-items: flex-start; }
.edit-preview { position: relative; border: 1px dashed var(--border); border-radius: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow-soft); display: inline-block; align-self: flex-start; }
.edit-preview img { display: block; width: 100%; height: auto; }
.marker {
  position: absolute; transform: translate(-50%, -50%);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; padding: 8px 10px; border-radius: 12px;
  font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: var(--shadow);
}
.edit-form { display: flex; flex-direction: column; gap: 10px; }
.edit-form .pill { cursor: pointer; }

/* 垫图标签更高对比度 */
.attachment-pill { background: #fff; border: 1px solid #f0d9c2; color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--shadow-soft); }
.attachment-pill.active { background: linear-gradient(135deg, #ffe8d9, #fff6ed); border-color: #f6b98a; color: #8a3d14; }
.attachment-pill .chip.attach-on { background: #ffcfa3; color: #7a2e00; border-color: #f2a76c; }
.attachment-pill .chip.neutral { background: #e8eef7; color: #305a9b; border-color: rgba(106,140,175,0.42); }

/* Viewer 只读布局 */
.viewer-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-top: 12px; }
.viewer-only .nav-pane { max-height: 75vh; overflow: auto; }
.nav-thumb { width: 48px; height: 48px; border-radius: 12px; overflow: hidden; margin-right: 10px; border: 1px dashed var(--border); background: #fff; flex-shrink: 0; }
.nav-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-list { border: 1px dashed var(--border); border-radius: 14px; padding: 10px; background: #fffdf7; box-shadow: var(--shadow-soft); }
.viewer-pane { border: 1px dashed var(--border); border-radius: 14px; padding: 12px; background: linear-gradient(150deg, #fff8f1, #ffffff 40%); box-shadow: var(--shadow-soft); }
.nav-list.horizontal { flex-direction: row; flex-wrap: wrap; gap: 10px; }
.nav-list.horizontal .nav-row { width: 180px; }
.nav-list.horizontal .nav-row .nav-arrow { display: none; }

@media (max-width: 960px) {
  .content-pane { grid-template-columns: 1fr; }
  .book-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .main { padding: 22px; }
  .viewer-layout { grid-template-columns: 1fr; }
  .viewer-only .nav-pane { max-height: none; }
  .nav-list.horizontal { justify-content: flex-start; }
  .nav-list.horizontal .nav-row { width: calc(50% - 6px); }
  .preview-frame { aspect-ratio: 4 / 3; max-width: 100%; }
}

@media (max-width: 640px) {
  .main { padding: 16px; }
  .nav-links { flex-wrap: wrap; }
  .nav-list.horizontal .nav-row { width: 100%; }
  .viewer-pane { padding: 10px; }
  .pill-group { justify-content: flex-start; }
}

/* 脚本审阅 */
.script-review { align-items: flex-start; }
.scrollable { max-height: 720px; overflow-y: auto; }
.script-list { display: flex; flex-direction: column; gap: 12px; }
.script-group { border: 1px dashed var(--border); border-radius: 16px; padding: 12px 14px; background: #fff9f1; box-shadow: inset 0 1px 0 rgba(255,255,255,0.7); }
.script-group .series-title { margin: 0 0 8px; font-weight: 900; }
.script-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.script-tags .tag { cursor: pointer; }
.script-tags .tag.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-color: transparent; }
.script-detail { display: flex; flex-direction: column; gap: 12px; }
.script-meta textarea { min-height: 120px; }
.scene-card { border: 1px dashed var(--border); border-radius: 14px; padding: 12px; background: #fffdf8; box-shadow: 0 4px 14px rgba(45,27,18,0.08); }
.lint-flag { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-right: 6px; border-radius: 50%; font-weight: 900; font-size: 12px; border: 1px solid #f2aa78; color: #a5492e; background: #fff5eb; box-shadow: inset 0 1px 0 rgba(255,255,255,0.85); }
.lint-flag.warning { background: #fff1d6; border-color: #f3b34c; color: #8a4b00; }
.lint-flag.error { background: #ffe4df; border-color: #e17763; color: #a83221; }
.scene-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.scene-title { margin: 0; font-weight: 900; }
.scene-preview { margin: 4px 0 0 0; font-size: 13px; max-width: 540px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap { gap: 12px; }
.script-detail { height: 100%; min-height: 520px; }
.scene-scroll { flex: 1; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 12px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(255,253,248,0.85), #fffdf8); padding: 10px 0 6px; }
.docstring-card { border: 1px dashed var(--border); border-radius: 12px; padding: 10px 12px; background: #fffaf1; box-shadow: inset 0 1px 0 rgba(255,255,255,0.7); }
.docstring { margin: 6px 0 0 0; font-size: 13px; line-height: 1.55; color: var(--ink); }
.docstring h1, .docstring h2, .docstring h3, .docstring h4, .docstring h5, .docstring h6 { margin: 8px 0 4px 0; }
.docstring p { margin: 6px 0; }
.docstring ul { margin: 6px 0 6px 18px; padding: 0 0 0 8px; }
.docstring li { margin: 4px 0; }
.docstring blockquote { margin: 6px 0; padding: 8px 10px; border-left: 3px solid var(--border); background: #fff5eb; border-radius: 8px; }
.detail-tabs { display: flex; gap: 8px; margin-bottom: 8px; }

.tab-bar { display: flex; gap: 10px; margin-bottom: 14px; }
.tab { padding: 10px 16px; border-radius: 14px; border: 1px dashed var(--border); background: #fff4ea; font-weight: 900; color: var(--muted); cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,0.7); }
.tab.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-color: transparent; box-shadow: var(--shadow-soft); }
.tab.sm { padding: 8px 12px; font-size: 13px; }

/* 横向滚动的风格列 & 列内纵向滚动 */
.style-scroll { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.style-column { min-width: 320px; max-width: 360px; flex: 0 0 auto; border: 1px dashed var(--border); border-radius: 16px; padding: 14px; background: linear-gradient(150deg, #fff6ed, #ffffff 45%); box-shadow: var(--shadow-soft); }
.cover-scroll { display: flex; flex-direction: column; gap: 12px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.style-column .cover-card { width: 100%; }

/* 空状态 */
.empty-state {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fff8f1;
  color: var(--muted);
  display: grid;
  gap: 6px;
  place-items: center;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
.empty-state .emoji { font-size: 24px; }
