:root {
  --ink: #172033;
  --muted: #718096;
  --soft: #f3f5f8;
  --line: #e5e9ef;
  --paper: #ffffff;
  --navy: #243a61;
  --teal: #2b9d92;
  --teal-dark: #18766e;
  --peach: #f9eee8;
  --danger: #b84e5e;
  --shadow: 0 18px 45px rgba(37, 55, 89, .08);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #f8fafc;
  min-width: 1100px;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 272px;
  flex: 0 0 272px;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  color: #eef5ff;
  background: linear-gradient(165deg, #1c2d4d 0%, #15223b 100%);
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: #f7d2b8; color: #32486d; font-weight: 900; font-size: 21px;
  box-shadow: 0 6px 16px rgba(247, 210, 184, .2);
}
.brand strong { display: block; font-size: 17px; letter-spacing: .04em; }
.brand span:not(.brand-mark) { display: block; margin-top: 4px; color: #aab9d1; font-size: 11px; letter-spacing: .08em; }

.mode-nav { display: grid; gap: 8px; }
.mode-button {
  width: 100%; border: 0; color: #c1cce0; background: transparent; text-align: left;
  display: flex; gap: 11px; align-items: center; padding: 13px 12px; border-radius: 12px;
  transition: background .2s, color .2s, transform .2s;
}
.mode-button:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.mode-button.is-active { background: rgba(118, 178, 177, .22); color: #fff; box-shadow: inset 3px 0 0 #80d4ca; }
.mode-icon { width: 25px; height: 25px; display: grid; place-items: center; color: #a8e1d9; font-weight: 700; font-size: 18px; }
.mode-button b { display: block; font-size: 13px; font-weight: 600; }
.mode-button small { display: block; margin-top: 4px; color: #91a2bc; font-size: 11px; }
.mode-button.is-active small { color: #b8dcd8; }

.sidebar-divider { height: 1px; background: rgba(255, 255, 255, .11); margin: 26px 10px 18px; }
.episode-sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 9px; color: #9dacbf; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.icon-button { border: 1px solid rgba(255,255,255,.18); color: #d3e5e3; background: rgba(255,255,255,.05); border-radius: 7px; width: 26px; height: 25px; line-height: 1; }
.icon-button:hover { background: rgba(255,255,255,.14); }
.episode-list { flex: 1; min-height: 0; overflow: auto; padding-right: 2px; scrollbar-width: none; }
.episode-list::-webkit-scrollbar { display: none; }
.project-group { margin-bottom: 14px; }
.project-group-head { display: flex; align-items: center; gap: 4px; padding: 3px 0; border-radius: 9px; }
.project-group.is-active .project-group-head { background: rgba(255,255,255,.045); }
.project-title-button { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; padding: 8px 7px; border: 0; background: transparent; color: #f2f6ff; text-align: left; }
.project-title-button:hover { color: #fff; }
.project-collapse-icon { width: 10px; flex: 0 0 10px; color: #9fc9c4; font-size: 11px; }
.project-title-icon { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px; background: #f1c9ae; color: #283f64; font-size: 11px; font-weight: 800; }
.project-title-copy { min-width: 0; }
.project-title-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.project-title-copy small { display: block; margin-top: 3px; color: #8fa3be; font-size: 10px; white-space: nowrap; }
.project-order-actions { display: flex; gap: 1px; padding-right: 5px; }
.project-order-actions button { width: 19px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #8fa3be; font-size: 11px; }
.project-order-actions button:hover:not(:disabled) { background: rgba(255,255,255,.1); color: #fff; }
.project-order-actions button:disabled { opacity: .25; cursor: not-allowed; }
.project-episode-list { margin: 2px 0 0 30px; padding-left: 9px; border-left: 1px solid rgba(255,255,255,.12); }
.project-episode-list.is-collapsed { display: none; }
.episode-item { display: flex; align-items: center; gap: 7px; width: 100%; border: 0; background: transparent; color: #abb8cb; text-align: left; padding: 6px 8px; border-radius: 7px; }
.episode-item:hover { background: rgba(255,255,255,.06); color: #f4f7fb; }
.episode-item.is-active { background: rgba(255, 255, 255, .11); color: #fff; }
.episode-item .episode-number { width: 27px; color: #7fbfb8; font-size: 11px; font-weight: 700; }
.episode-item .episode-copy { min-width: 0; overflow: hidden; }
.episode-item .episode-name { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.episode-item .episode-stats-mini { display: block; margin-top: 2px; color: #8091aa; font-size: 9px; white-space: nowrap; }
.episode-item.is-active .episode-stats-mini { color: #9fc9c4; }
.sidebar-footnote { margin-top: auto; padding: 16px 10px 0; display: flex; align-items: center; gap: 8px; color: #91a2bc; font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7bd1c5; box-shadow: 0 0 0 4px rgba(123,209,197,.12); }

.main-content { flex: 1; min-width: 0; padding: 34px 50px 70px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; max-width: 1450px; margin: 0 auto 36px; }
.eyebrow { margin: 0 0 8px; color: #91a1b6; font-size: 10px; letter-spacing: .18em; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 29px; letter-spacing: -.03em; font-weight: 700; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.025em; }
h3 { font-size: 16px; margin-bottom: 9px; }
.topbar-actions { display: flex; gap: 10px; padding-top: 7px; }
.primary-button, .secondary-button, .ghost-button, .text-button, .add-scene-button {
  border-radius: 8px; border: 1px solid transparent; transition: all .2s;
}
.primary-button { background: var(--navy); color: #fff; padding: 10px 17px; box-shadow: 0 7px 18px rgba(36,58,97,.13); }
.primary-button:hover { background: #1a2c4d; transform: translateY(-1px); }
.secondary-button { background: #fff; color: var(--navy); border-color: #d9e0e9; padding: 10px 17px; }
.secondary-button:hover { border-color: #aab9cb; background: #fbfcfe; }
.ghost-button { color: #778599; background: transparent; padding: 7px 9px; font-size: 11px; }
.ghost-button:hover { background: #f0f3f7; color: var(--navy); }
.danger-text { color: var(--danger); }
.text-button { border: 0; padding: 0; background: transparent; color: var(--teal-dark); font-size: 12px; }
.text-button:hover { text-decoration: underline; }
.wide-button { width: 100%; margin-top: 16px; }
.hidden { display: none !important; }

.mode-panel { display: none; max-width: 1450px; margin: 0 auto; }
.mode-panel.is-visible { display: block; }
.script-title-row { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 25px; }
label { display: block; color: #718096; font-size: 11px; font-weight: 600; margin-bottom: 7px; }
.title-input { border: 0; border-bottom: 2px solid #d7dee8; background: transparent; color: var(--ink); padding: 5px 0 8px; width: 365px; font-size: 22px; outline: none; }
.title-input:focus { border-color: var(--teal); }
.preamble-panel { margin: -8px 0 24px; border: 1px solid #eadfcb; border-radius: 10px; background: #fffaf2; color: #795b45; }
.preamble-panel summary { cursor: pointer; padding: 11px 13px; font-size: 12px; font-weight: 700; }
.preamble-panel summary:hover { background: #fff5e7; }
.preamble-panel > div { border-top: 1px solid #f0e4d4; padding: 13px; color: #806f62; font-size: 12px; line-height: 1.8; white-space: pre-wrap; max-height: 260px; overflow: auto; }
.numbering-note { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #edf8f6; border-radius: 10px; color: var(--teal-dark); }
.numbering-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: white; background: var(--teal); font-size: 13px; }
.numbering-note b { display: block; font-size: 12px; }
.numbering-note small { display: block; margin-top: 2px; color: #5d8f8a; font-size: 10px; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 25px; align-items: start; }
.scene-column { min-width: 0; }
.write-episode { scroll-margin-top: 24px; }
.write-episode + .write-episode { margin-top: 34px; padding-top: 30px; border-top: 2px solid #dfe7ee; }
#mode-write .editor-grid { display: block; }
#mode-write .writing-guide { display: none; }
#mode-write .editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 228px; gap: 18px; }
#mode-write .writing-toolbox { display: grid; }
#mode-write .scene-list { gap: 24px; margin-top: 18px; }
#mode-write .write-scene-list { margin-top: 18px; }
#mode-write .write-scene-list.is-lazy {
  display: block;
  overflow: hidden;
  border: 1px dashed #dce8ed;
  border-radius: 10px;
  background: #fbfcfd;
}
#mode-write .scene-list-placeholder {
  padding: 18px;
  color: #9aa6b5;
  font-size: 11px;
  text-align: center;
}
#mode-write .episode-summary-wrap { padding: 20px 0 8px; }
#mode-write .episode-summary-wrap textarea { width: 100%; min-height: 94px; padding: 12px; border: 1px solid #dce5ec; border-radius: 8px; background: #fbfcfd; line-height: 1.8; font-size: 13px; outline: none; resize: vertical; }
#mode-write .episode-summary-wrap textarea:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); background: #fff; }
#mode-write .scene-card {
  padding: 22px 23px 24px;
  /* 长剧本会同时有几十个大文本框。保留全部编辑内容，但让浏览器只布局视口附近的卡片。 */
  content-visibility: auto;
  contain-intrinsic-size: 0 640px;
}
#mode-write .scene-card textarea.write-scene-content { min-height: 390px; padding: 14px; line-height: 1.9; font-size: 14px; }
#mode-write .scene-card input { min-height: 42px; padding: 10px 12px; font-size: 13px; }
#mode-write .add-scene-button { margin-top: 18px; padding: 16px; font-size: 13px; }
.add-episode-button { width: 100%; margin-top: 28px; padding: 14px; border: 1px dashed #bddbd6; border-radius: 9px; background: #f5fbfa; color: var(--teal-dark); font-size: 12px; }
.add-episode-button:hover { border-color: #83c5bc; background: #eaf7f4; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; border-bottom: 1px solid var(--line); padding-bottom: 13px; }
.section-heading h2 { font-size: 24px; }
.section-heading > div:first-child { min-width: 150px; }
.episode-stats { display: flex; align-items: center; gap: 7px; margin-right: auto; }
.stat-pill { display: inline-flex; align-items: baseline; gap: 4px; padding: 7px 9px; border: 1px solid #e5eaf0; border-radius: 8px; background: #fbfcfd; color: #52647b; white-space: nowrap; }
.stat-pill b { color: var(--navy); font-size: 13px; font-weight: 750; }
.stat-pill small { color: #8a98aa; font-size: 10px; }
.stat-pill.dialogue-stat { border-color: #d6ece8; background: #f2faf8; }
.stat-pill.dialogue-stat b { color: var(--teal-dark); }
.heading-actions { display: flex; gap: 1px; }
.episode-summary-wrap { padding: 18px 0 6px; }
textarea, input { color: var(--ink); }
textarea { resize: vertical; }
#episode-synopsis { width: 100%; border: 1px solid transparent; border-bottom-color: var(--line); background: transparent; padding: 5px 0 10px; min-height: 50px; outline: none; font-size: 13px; line-height: 1.65; }
#episode-synopsis:focus { border-bottom-color: var(--teal); }
.scene-list { display: grid; gap: 12px; margin-top: 12px; }
.scene-card { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 16px 17px 17px; box-shadow: 0 4px 15px rgba(30,46,72,.025); }
.scene-card:hover { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.1), 0 4px 15px rgba(30,46,72,.025); }
.scene-card-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 14px; }
.scene-code { color: var(--teal-dark); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.scene-actions { display: flex; gap: 3px; }
.scene-actions button { border: 0; background: transparent; color: #9ba8b8; padding: 3px 5px; font-size: 11px; }
.scene-actions button:hover { color: var(--navy); }
.scene-actions .delete-scene:hover { color: var(--danger); }
.scene-fields { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.field-group { min-width: 0; }
.scene-fields .full-field { grid-column: 1 / -1; }
.scene-card input, .scene-card textarea, .input-card input, .input-card textarea { width: 100%; border: 1px solid #e2e7ee; border-radius: 7px; background: #fbfcfd; padding: 9px 10px; outline: none; font-size: 12px; }
.scene-card input:focus, .scene-card textarea:focus, .input-card input:focus, .input-card textarea:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); background: #fff; }
.scene-card textarea { min-height: 80px; line-height: 1.7; }
.add-scene-button { width: 100%; margin-top: 13px; padding: 13px; color: var(--teal-dark); background: #eef8f6; border-color: #cde9e4; font-size: 12px; }
.add-scene-button:hover { background: #e2f3f0; }
.empty-scene { border: 1px dashed #cdd7e3; padding: 28px; border-radius: 11px; color: var(--muted); font-size: 12px; text-align: center; }

.writing-guide { display: grid; gap: 13px; }
.new-writing-setup { margin-bottom: 25px; padding: 25px 27px; border: 1px solid #d8e9e6; border-radius: 13px; background: linear-gradient(135deg, #f5fbfa 0%, #ffffff 78%); box-shadow: var(--shadow); }
.new-writing-setup h2 { margin-bottom: 8px; color: var(--navy); }
.new-writing-setup > p:not(.eyebrow) { margin-bottom: 18px; color: #6f7f91; font-size: 12px; line-height: 1.7; }
.new-writing-form { max-width: 680px; }
.new-writing-form-row { display: flex; gap: 10px; align-items: center; }
.new-writing-form-row input { flex: 1; min-width: 0; border: 1px solid #d8e3e8; border-radius: 8px; background: #fff; padding: 11px 12px; outline: none; font-size: 14px; }
.new-writing-form-row input:focus { border-color: #79beb5; box-shadow: 0 0 0 3px rgba(43,157,146,.1); }
.new-writing-empty { padding: 42px 28px; background: #fbfcfd; }
.writing-toolbox { position: sticky; top: 22px; gap: 15px; padding: 16px; border: 1px solid #dfe8ed; border-radius: 12px; background: #fff; box-shadow: 0 10px 28px rgba(37,55,89,.06); }
.toolbox-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; border-bottom: 1px solid #edf0f3; padding-bottom: 11px; }
.toolbox-heading h3 { margin: 0; font-size: 15px; color: var(--navy); }
.toolbox-heading .card-kicker { margin-bottom: 6px; color: var(--teal-dark); font-size: 9px; }
.toolbox-hint { color: #9aa6b5; font-size: 10px; white-space: nowrap; }
.toolbox-groups { display: grid; gap: 14px; }
.toolbox-group h4 { margin: 0 0 7px; color: #728095; font-size: 11px; font-weight: 700; }
.toolbox-items { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbox-item { display: inline-flex; align-items: stretch; max-width: 100%; border: 1px solid #dbe9e6; border-radius: 6px; background: #f6fbfa; overflow: hidden; }
.toolbox-item > button:first-child { border: 0; background: transparent; color: #286f69; padding: 6px 7px; max-width: 175px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.toolbox-item > button:first-child:hover { background: #e8f6f3; color: #145c56; }
.toolbox-item .toolbox-delete { border: 0; border-left: 1px solid #dbe9e6; background: transparent; color: var(--danger); padding: 0 5px; font-size: 13px; line-height: 1; }
.toolbox-item .toolbox-delete:hover { background: #fff0ef; color: var(--danger); }
.toolbox-empty { color: #a5afba; font-size: 11px; }
.toolbox-add { border-top: 1px solid #edf0f3; padding-top: 13px; }
.toolbox-add label { margin-bottom: 6px; }
.toolbox-add > input { width: 100%; border: 1px solid #e2e7ee; border-radius: 7px; background: #fbfcfd; padding: 8px 9px; outline: none; font-size: 11px; }
.toolbox-add > input:focus, .toolbox-add select:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); background: #fff; }
.toolbox-add-row { display: flex; gap: 6px; margin-top: 7px; }
.toolbox-add-row select { min-width: 0; flex: 1; border: 1px solid #e2e7ee; border-radius: 7px; background: #fbfcfd; color: var(--ink); padding: 7px 6px; outline: none; font-size: 10px; }
.toolbox-add-row .secondary-button { padding: 7px 9px; font-size: 10px; }
.toolbox-manager { border-top: 1px solid #edf0f3; padding-top: 13px; }
.toolbox-manager-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.toolbox-manager-head strong { color: var(--navy); font-size: 11px; }
.toolbox-manager-head span { color: #9aa6b5; font-size: 9px; }
.toolbox-category-list { display: grid; gap: 6px; }
.toolbox-category-row { display: flex; gap: 4px; align-items: center; }
.toolbox-category-row input, .toolbox-category-add-row input { min-width: 0; flex: 1; border: 1px solid #e2e7ee; border-radius: 6px; background: #fbfcfd; padding: 6px 7px; outline: none; font-size: 10px; }
.toolbox-category-row input:focus, .toolbox-category-add-row input:focus { border-color: #8fc9c2; background: #fff; }
.toolbox-category-row .secondary-button, .toolbox-category-add-row .secondary-button { padding: 6px 7px; font-size: 9px; white-space: nowrap; }
.toolbox-category-delete { width: 24px; height: 25px; border: 1px solid #efd3d9; border-radius: 6px; background: #fff7f8; color: var(--danger); font-size: 14px; line-height: 1; }
.toolbox-category-delete:hover:not(:disabled) { background: #ffecef; }
.toolbox-category-delete:disabled { opacity: .35; cursor: not-allowed; }
.toolbox-category-add-row { display: flex; gap: 4px; margin-top: 8px; }
.toolbox-item-add-button { width: 100%; margin-top: 9px; padding: 7px 8px; font-size: 10px; }
.guide-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.guide-card p { margin-bottom: 0; color: #728095; line-height: 1.7; font-size: 12px; }
.accent-card { background: #fff9f4; border-color: #f0ddd1; }
.card-kicker { display: block; color: #c77e62; font-size: 10px; font-weight: 800; letter-spacing: .16em; margin-bottom: 12px; }
.accent-card h3 { color: #70483a; }
.code-example { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px solid #f0dfd2; border-radius: 7px; padding: 9px 10px; margin-top: 16px; color: #a86b56; font-size: 11px; }
.code-example b { color: #355e5a; }

.feature-intro { max-width: 700px; margin-bottom: 27px; }
.feature-intro h2 { font-size: 26px; margin-bottom: 11px; }
.feature-intro > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.renumber-feature-intro { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .72fr); gap: 28px; align-items: start; }
.renumber-intro-copy { min-width: 0; }
.renumber-intro-copy > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.adapt-layout, .renumber-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, .8fr); gap: 20px; align-items: start; }
.renumber-layout { grid-template-columns: minmax(0, 1fr); }
.input-card, .preview-card { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 22px; box-shadow: var(--shadow); }
.large-input { min-height: 330px; line-height: 1.8; }
.script-source-tools { margin: 12px 0 10px; padding: 11px 12px; border: 1px solid #e6edf1; border-radius: 9px; background: #fbfcfd; }
.renumber-source-tools { margin: 0; min-width: 0; padding: 13px 14px; transition: border-color .15s, background .15s, box-shadow .15s; }
.renumber-source-tools.is-drag-over { border-color: #65bdb1; background: #f1fbf9; box-shadow: 0 0 0 3px rgba(43,157,146,.12); }
.script-source-tools > label { margin-bottom: 7px; }
.script-source-row { display: flex; align-items: center; gap: 7px; }
.script-source-row select { min-width: 180px; flex: 1; border: 1px solid #dce5ec; border-radius: 7px; background: #fff; color: var(--ink); padding: 8px 9px; font-size: 11px; outline: none; }
.script-source-row select:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); }
.script-source-row .secondary-button { padding: 8px 10px; font-size: 11px; white-space: nowrap; }
.file-button { display: inline-flex; align-items: center; border: 1px solid #d9e0e9; border-radius: 7px; background: #fff; color: var(--navy); padding: 8px 10px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.file-button:hover { border-color: #aab9cb; background: #fbfcfe; }
#script-file-input { display: none; }
#novel-file-input { display: none; }
.novel-source-zone { border-radius: 8px; transition: background .15s, box-shadow .15s; }
.novel-source-zone.is-drag-over { background: #f1fbf9; box-shadow: 0 0 0 3px rgba(43,157,146,.22); }
.novel-source-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.novel-source-heading label { margin: 0; }
.novel-source-zone textarea[hidden] { display: none; }
.novel-source-editor { height: 360px; min-height: 330px; resize: vertical; overflow: hidden; border: 1px solid #e2e7ee; border-radius: 7px; background: #fbfcfd; }
.novel-source-editor:focus-within { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); background: #fff; }
.novel-source-editor .cm-editor { height: 100%; font: inherit; font-size: 13px; }
.novel-source-editor .cm-editor.cm-focused { outline: none; }
.novel-source-editor .cm-scroller { overflow: auto; font: inherit; line-height: 1.8; }
.novel-source-editor .cm-content { padding: 9px 0; caret-color: var(--ink); }
.novel-source-editor .cm-line { padding: 0 10px; }
.novel-source-editor .cm-placeholder { color: #8c97a5; }
.novel-source-editor .cm-focused .cm-selectionBackground { background: #bcded9; }
.novel-source-editor.is-disabled { opacity: .65; }
#novel-file-button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.script-file-name { display: block; margin-top: 7px; color: #9aa6b5; font-size: 10px; }
.adapt-title-input { width: 100%; margin-bottom: 16px; border: 1px solid #e2e7ee; border-radius: 7px; background: #fbfcfd; padding: 10px 11px; outline: none; font-size: 13px; }
.adapt-title-input:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); background: #fff; }
.form-row { display: flex; gap: 12px; margin-top: 17px; }
.small-field { width: 120px; }
.grow-field { flex: 1; }
.input-card .helper-text { margin: 11px 0 0; color: #9aa6b5; font-size: 11px; line-height: 1.5; }
.preview-card { min-height: 425px; }
.editor-helper { margin: -4px 0 14px; color: #8a98aa; font-size: 11px; line-height: 1.6; }
.renumber-import-title-panel { margin-top: 13px; padding: 14px; border: 1px solid #d8e9e6; border-radius: 9px; background: #f5fbfa; }
.renumber-import-title-row { display: flex; gap: 9px; align-items: center; }
.renumber-import-title-row input { flex: 1; min-width: 0; border: 1px solid #dce5ec; border-radius: 7px; background: #fff; padding: 9px 10px; outline: none; font-size: 12px; }
.renumber-import-title-row input:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); }
.renumber-import-title-row .primary-button { margin: 0; padding: 9px 13px; white-space: nowrap; font-size: 11px; }
.renumber-controls { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 0 0 15px; padding: 12px; border: 1px solid #e6ebf0; border-radius: 9px; background: #fbfcfd; }
.renumber-start-fields, .editor-view-actions { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.renumber-start-fields label { width: 100%; margin-bottom: 0; }
.renumber-controls select { min-width: 150px; border: 1px solid #dce5ec; border-radius: 7px; background: #fff; color: var(--ink); padding: 8px 9px; font-size: 11px; outline: none; }
.renumber-controls select:focus { border-color: #8fc9c2; }
.renumber-controls button:disabled { opacity: .45; cursor: not-allowed; }
.batch-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 13px; padding: 9px 11px; border: 1px solid #dcece8; border-radius: 8px; background: #f4fbf9; color: var(--teal-dark); }
.batch-toolbar small { flex: 1; min-width: 230px; color: #789d98; font-size: 10px; }
.batch-toolbar button:disabled { opacity: .45; cursor: not-allowed; }
.renumber-selection-box { position: fixed; z-index: 20; pointer-events: none; border: 1px solid var(--teal); background: rgba(43,157,146,.12); }
body.scene-selecting { cursor: crosshair; user-select: none; }
.renumber-context-menu { position: fixed; z-index: 30; min-width: 180px; padding: 5px; border: 1px solid #dce5ec; border-radius: 8px; background: #fff; box-shadow: 0 12px 30px rgba(25,39,66,.18); }
.context-selection-label { max-width: 240px; padding: 6px 10px 7px; border-bottom: 1px solid #edf0f4; color: #8a98aa; font-size: 10px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.renumber-context-menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; color: #53647b; text-align: left; font-size: 11px; cursor: pointer; }
.renumber-context-menu button:hover { background: #f1f8f7; color: var(--teal-dark); }
.renumber-context-menu button:disabled { color: #aab5c1; cursor: not-allowed; background: transparent; }
.renumber-context-menu .context-divider { height: 1px; margin: 4px 0; background: #edf0f4; }
.novel-context-menu { min-width: 230px; max-height: calc(100vh - 16px); overflow-y: auto; }
.novel-context-menu button { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.novel-context-menu button small { font-size: 10px; color: #91a1b6; }
.novel-context-menu button:focus-visible { outline: 2px solid #8fc9c2; outline-offset: -2px; background: #f1f8f7; }
.novel-context-menu [data-novel-context-action^="delete"]:not(:disabled) { color: var(--danger); }
#project-context-menu { max-width: min(320px, calc(100vw - 16px)); }
#project-context-menu .context-selection-label { overflow-wrap: anywhere; }
.project-rename-input { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 5px; }
.adapt-model-settings { margin: 18px 0; padding: 12px; background: #f8fafd; border: 1px solid var(--line); border-radius: 8px; }
.adapt-model-settings summary { cursor: pointer; color: var(--navy); font-size: 12px; }
.adapt-model-settings input { width: 100%; padding: 9px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 6px; }
.adapt-model-settings label { display: block; margin: 12px 0 6px; }
.adapt-run-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.adapt-run-actions #adapt-generate { flex: 1; }
.adapt-progress { margin: 14px 0; padding: 12px; border: 1px solid #d6ece8; border-radius: 8px; background: #f2faf8; }
.adapt-progress p { margin: 0 0 8px; color: var(--teal-dark); font-size: 12px; }
.adapt-progress pre { max-height: 340px; overflow-y: auto; margin: 0; white-space: pre-wrap; font: inherit; font-size: 12px; line-height: 1.8; color: #53647b; }
#adapt-preview .preview-scene-body { white-space: pre-wrap; }
#project-context-menu [data-project-context-action="delete"] { color: var(--danger); }
.card-heading { display: flex; justify-content: space-between; align-items: center; color: #39475d; font-size: 13px; font-weight: 700; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.muted { color: #9aa6b5; font-size: 11px; font-weight: 400; }
.empty-state { color: #9aa6b5; padding: 45px 12px; text-align: center; font-size: 12px; line-height: 1.7; }
.adapt-preview, .renumber-preview { max-height: 485px; overflow: auto; }
.preview-preamble { margin: 13px 0 2px; padding: 11px 12px; border: 1px solid #eadfcb; border-radius: 8px; background: #fffaf2; color: #795b45; font-size: 11px; line-height: 1.6; }
.preview-preamble summary { cursor: pointer; list-style: none; font-weight: 700; }
.preview-preamble summary::-webkit-details-marker { display: none; }
.preview-preamble summary::before { content: '🔒'; margin-right: 7px; font-size: 10px; }
.preview-preamble[open] summary::before { content: '🔓'; }
.preview-preamble summary span { float: right; color: #a38b73; font-weight: 400; }
.preview-preamble pre { max-height: 170px; overflow: auto; margin: 7px 0 0; padding-top: 7px; border-top: 1px solid #f0e4d4; color: #806f62; white-space: pre-wrap; font: inherit; }
.renumber-layout .preview-preamble pre { max-height: none; }
.preview-episode { position: relative; border-bottom: 1px solid #edf0f4; padding: 15px 0 12px; }
.preview-episode:last-child { border-bottom: 0; }
.preview-episode.is-drag-over { border-radius: 9px; outline: 2px dashed #8fc9c2; outline-offset: -3px; background: #f2faf8; }
.preview-episode.is-drag-over::after { content: '松开后移动到本集开头'; position: absolute; top: 15px; right: 12px; color: var(--teal-dark); font-size: 11px; font-weight: 700; pointer-events: none; }
.preview-episode h4 { margin: 0 0 8px; font-size: 13px; color: var(--navy); }
.preview-episode-stats { margin-left: 9px; color: #8a98aa; font-size: 10px; font-weight: 400; }
.renumber-overview { margin: 16px 0 12px; }
.renumber-overview-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.renumber-overview-stats > div { padding: 12px 15px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafd; }
.renumber-overview-stats dt { color: #748196; font-size: 12px; }
.renumber-overview-stats dd { margin: 5px 0 0; color: var(--navy); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.renumber-overview-stats .dialogue-total { border-color: #d6ece8; background: #f2faf8; }
.renumber-overview-stats .dialogue-total dd { color: var(--teal-dark); }
.renumber-overview > p { margin: 8px 0 0; color: #8a98aa; font-size: 11px; }
.autosave-note { margin-left: 8px; color: var(--teal-dark); font-size: 11px; }
.preview-scene { margin-top: 6px; color: #748196; font-size: 11px; line-height: 1.6; }
.renumber-preview details.preview-scene-editor { position: relative; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px 3px 0; transition: border-color .15s, background .15s, box-shadow .15s; }
.renumber-preview details.preview-scene-editor:hover { border-color: #8fc9c2; background: #fbfefd; box-shadow: 0 0 0 3px rgba(43,157,146,.1); }
.renumber-preview details.preview-scene-editor:hover > summary { color: var(--teal-dark); }
.preview-scene summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
.preview-scene summary::-webkit-details-marker { display: none; }
.preview-scene summary::before { content: '＋'; color: #9aa6b5; width: 10px; }
.preview-scene[open] summary::before { content: '－'; color: var(--teal-dark); }
.preview-scene strong { color: var(--teal-dark); min-width: 43px; }
.preview-scene summary span { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-scene summary em { color: #86a19e; font-style: normal; font-size: 10px; white-space: nowrap; }
.preview-scene summary[draggable="true"] { cursor: grab; }
.preview-scene summary[draggable="true"]:active { cursor: grabbing; }
.preview-scene.is-selected > summary { border-radius: 6px; background: #e8f7f4; box-shadow: inset 3px 0 0 var(--teal); color: var(--teal-dark); }
.preview-scene.is-selected > summary::before { color: var(--teal-dark); }
.preview-scene-body { margin: 7px 0 4px 53px; padding: 10px 12px; border-left: 2px solid #b9dfd8; border-radius: 0 6px 6px 0; background: #f8fbfc; color: #53647b; white-space: pre-wrap; line-height: 1.75; }
.episode-insert-scene { padding: 3px 0 7px 53px; }
.episode-insert-scene button, .insert-scene-button { border: 1px solid #cfe9e4; border-radius: 7px; background: #f4fbf9; color: var(--teal-dark); padding: 7px 10px; font-size: 11px; }
.episode-insert-scene button:hover, .insert-scene-button:hover, .episode-insert-scene button:focus, .insert-scene-button:focus { border-color: #8fc9c2; background: #e9f7f4; }
.insert-scene-button { width: 100%; margin-top: 7px; text-align: left; }
.scene-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.scene-edit-actions button { border: 1px solid #dce5ec; border-radius: 7px; background: #fff; color: #53647b; padding: 7px 10px; font-size: 11px; cursor: pointer; }
.scene-edit-actions button:hover, .scene-edit-actions button:focus { border-color: #8fc9c2; background: #f2faf8; color: var(--teal-dark); }
.scene-edit-actions .danger-scene-button { color: var(--danger); border-color: #efd3d9; }
.scene-edit-actions .danger-scene-button:hover, .scene-edit-actions .danger-scene-button:focus { background: #fff3f5; border-color: #e4a9b4; color: var(--danger); }
.preview-scene-editor .preview-scene-body { display: grid; gap: 6px; }
.preview-scene-editor .preview-scene-body label { margin: 3px 0 0; color: #718096; }
.renumber-editor-input { width: 100%; border: 1px solid #dce5ec; border-radius: 7px; background: #fff; color: var(--ink); padding: 9px 10px; outline: none; font-size: 12px; line-height: 1.7; }
.renumber-editor-input:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); }
.preview-scene-editor textarea.renumber-editor-input { min-height: 150px; resize: vertical; overflow: hidden; }
.renumber-layout .large-input { min-height: 380px; }
.renumber-layout .renumber-preview { max-height: none; overflow: visible; }
.renumber-layout .preview-card { min-height: calc(100vh - 190px); }
.script-import-input { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px !important; }
.input-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.renumber-input-actions { display: flex; align-items: center; gap: 14px; }
.renumber-input-actions #renumber-clear-content { color: var(--danger); padding: 6px 10px; border: 1px solid #efd3d8; border-radius: 6px; }
.renumber-preview .preview-scene { align-items: flex-start; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: #1e2c44; color: #fff; border-radius: 8px; padding: 10px 17px; font-size: 12px; box-shadow: 0 8px 22px rgba(25,39,66,.2); transition: opacity .2s, transform .2s; z-index: 10; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(18,31,52,.35); }
.modal-card { width: min(480px, calc(100vw - 40px)); border: 1px solid #dce5ec; border-radius: 13px; background: #fff; padding: 22px; box-shadow: 0 22px 60px rgba(25,39,66,.24); }
.modal-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-card-head h3 { margin: 0; color: var(--navy); font-size: 19px; }
.modal-close { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: #8290a2; font-size: 22px; line-height: 1; }
.modal-close:hover { background: #f0f3f7; color: var(--navy); }
.modal-target-label { margin: 18px 0 8px; padding: 9px 10px; border-radius: 7px; background: #f2faf8; color: var(--teal-dark); font-size: 11px; line-height: 1.6; }
.modal-helper { margin: 8px 0 15px; color: #7b899b; font-size: 11px; line-height: 1.7; }
.modal-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-form-grid label { margin: 0; }
.modal-form-grid select, .modal-form-grid input { width: 100%; margin-top: 7px; border: 1px solid #dce5ec; border-radius: 7px; background: #fff; color: var(--ink); padding: 9px 10px; outline: none; font-size: 12px; }
.modal-form-grid select:focus, .modal-form-grid input:focus { border-color: #8fc9c2; box-shadow: 0 0 0 3px rgba(43,157,146,.09); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 19px; }

body.writing-focus { background: #f8fafc; }
body.writing-focus .sidebar, body.writing-focus .topbar { display: none; }
body.writing-focus .main-content { width: 100%; min-height: 100vh; padding: 24px 34px 60px; }
body.writing-focus .mode-panel.is-visible { max-width: none; }
body.writing-focus #mode-renumber .feature-intro { display: none; }
body.writing-focus .renumber-layout > .input-card { display: none; }
body.writing-focus .renumber-layout { display: block; }
body.writing-focus .renumber-layout .preview-card { min-height: calc(100vh - 70px); }

@media (max-width: 1180px) {
  body { min-width: 960px; }
  .main-content { padding-left: 30px; padding-right: 30px; }
  .editor-grid { grid-template-columns: minmax(0, 1fr) 240px; }
}

