/* 爆款短剧改编台 —— 界面样式
   设计取向：夜间剪辑台（暗色机架）包裹一张被照亮的剧本纸。
   正文用宋体，贴合中文剧本的排版惯例；界面用系统无衬线；
   场次编号与时间码用等宽，模拟剧本的缩排对齐。
   强调色取自编剧修订色阶中的金菊黄，只用于主操作与当前状态。 */

:root {
  /* 层次：底 < 机架 < 面板 < 控件。每层只差一点点亮度，靠边框与阴影分隔。 */
  --ink:        #0c1015;
  --rack:       #141a20;
  --rack-hi:    #1b222a;
  --panel-top:  #171e25;
  --panel-bot:  #141a20;
  --field:      #0f151b;
  --line:       #262f39;
  --line-soft:  #1e262e;
  --line-strong:#33404d;
  --paper:      #f7f5f0;
  --paper-edge: #e2ddd2;
  --text:       #e7ebef;
  --muted:      #9aa5b1;
  --dim:        #68737f;
  --accent:     #e3b341;
  --accent-soft: rgba(227, 179, 65, .12);
  --accent-ink: #201703;
  --ok:         #56a875;
  --warn:       #cc8a3a;
  --err:        #cc5f55;
  --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Hiragino Sans GB", system-ui, sans-serif;
  --font-script: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Consolas", monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-1: 0 1px 0 rgba(255,255,255,.03) inset, 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 通用件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  background: linear-gradient(180deg, #1e262f, #192028);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background .14s ease, border-color .14s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: linear-gradient(180deg, #252f39, #1e262f); border-color: #3d4a58; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #efc65a, var(--accent));
  border-color: #c99a2b;
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 2px 10px rgba(227,179,65,.18);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #f6d26e, #e9bd48);
  border-color: #d8a832;
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--rack-hi); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-danger { border-color: #4a2a28; color: #e0908a; }
.btn-danger:hover:not(:disabled) { background: #2a1817; border-color: #6b3a36; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .02em;
}

.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
.input::placeholder, .textarea::placeholder { color: #4d5762; }
.input:hover:not(:disabled), .select:hover:not(:disabled), .textarea:hover {
  border-color: var(--line-strong);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, #7d8794 50%),
                    linear-gradient(135deg, #7d8794 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.7; }
.select { cursor: pointer; }

.hint { font-size: 12px; color: var(--dim); line-height: 1.55; }
.mono { font-family: var(--font-mono); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--rack);
}
.chip-ok { color: #86c79b; border-color: #2c4a37; background: #14201a; }
.chip-run { color: var(--accent); border-color: #4a3c12; background: #211a06; }
.chip-err { color: #e0908a; border-color: #4a2a28; background: #211312; }

.divider { height: 1px; background: var(--line-soft); margin: 18px 0; }

/* ---------- 登录 ---------- */

.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, #1b222a 0%, transparent 70%),
    var(--ink);
}

.gate-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 28px 26px;
  background: var(--rack);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gate-mark {
  font-family: var(--font-script);
  font-size: 26px;
  letter-spacing: .04em;
  margin: 0 0 4px;
}
.gate-sub { color: var(--dim); font-size: 12.5px; margin: 0 0 26px; }

.gate-form { display: flex; flex-direction: column; gap: 14px; }

.gate-error {
  padding: 8px 10px;
  border-left: 2px solid var(--err);
  background: #211312;
  color: #e0908a;
  font-size: 12.5px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.gate-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--dim);
}

/* ---------- 应用外壳 ---------- */

.shell {
  display: grid;
  grid-template-rows: 52px 1fr;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, #161d24, #12181e);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--font-script);
  font-size: 17.5px;
  letter-spacing: .04em;
}
.brand span { font-family: var(--font-ui); font-size: 11.5px; color: var(--dim); letter-spacing: 0; }

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.body {
  display: grid;
  grid-template-columns: 262px 1fr;
  min-height: 0;
}

/* 左栏：项目架 */
.rack {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #10161c;
}

.rack-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}
.rack-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .08em;
}

.rack-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }

.rack-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px 9px 11px;
  margin-bottom: 3px;
  background: transparent;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.rack-item:hover { background: #182028; }
.rack-item.is-active {
  background: linear-gradient(90deg, rgba(227,179,65,.09), rgba(227,179,65,.03));
  border-color: transparent;
  border-left-color: var(--accent);
}
.rack-item .t { font-weight: 500; }
.rack-item .t {
  display: block;
  font-size: 13.5px;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rack-item .m {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  color: var(--dim);
}

.rack-empty { padding: 22px 14px; font-size: 12.5px; color: var(--dim); line-height: 1.7; }

/* 主区 */
.main { min-height: 0; overflow-y: auto; }

.pane { max-width: 1180px; padding: 28px 34px 90px; }
.pane-wide { max-width: none; }

.page-head { margin-bottom: 24px; max-width: 900px; }
.page-head h1 {
  margin: 0 0 8px;
  font-family: var(--font-script);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.35;
}
.page-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }

/* 新建：原文输入 / 分析 */
.compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 400px);
  gap: 20px;
  align-items: start;
}
/* 设定栏走正常流；只有提交条吸在视口底部，滚到哪儿都能点 */
.compose-settings { position: relative; }
.compose-settings > .panel { padding-bottom: 0; }
/* 左栏比右栏长时，右栏不要被拉成等高的空壳 */
.compose-grid > .compose-settings { align-self: start; }

.panel {
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bot));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-2);
}
.panel + .panel { margin-top: 16px; }
/* 两个面板并排，避免左栏被拉成一长条 */
.panel-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}
.panel-pair > .panel { margin-top: 0; }
@media (max-width: 900px) { .panel-pair { grid-template-columns: 1fr; } }

/* 右上角的任务摘要：一眼看到这次会怎么跑 */
.panel-brief {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-color: var(--line-soft);
  background: linear-gradient(180deg, rgba(227,179,65,.05), rgba(0,0,0,0));
}
.brief-row { display: flex; align-items: baseline; gap: 10px; }
.brief-label {
  font-size: 11.5px;
  letter-spacing: .09em;
  color: var(--dim);
  flex: none;
}
.brief-value {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.panel h3 .hint { margin-left: auto; font-weight: 400; }
.panel h3 {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h3 { padding-left: 0; }
.panel-note { margin: -6px 0 14px; font-size: 12px; color: var(--dim); line-height: 1.6; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.row > .select, .row > .input { min-width: 0; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.check input { margin-top: 3px; accent-color: var(--accent); }

.source-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--dim);
  font-family: var(--font-mono);
}

.thead-list {
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink);
}
.thead-row {
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
}
.thead-row:last-child { border-bottom: none; }
.thead-row .n { color: var(--dim); width: 34px; flex: none; }
.thead-row .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ---------- 运行进度 ---------- */

.run-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.run-bar {
  flex: 1;
  height: 6px;
  background: var(--line-soft);
  border-radius: 99px;
  overflow: hidden;
}
.run-bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .35s ease;
}

.col-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: .07em;
  margin: 0 0 9px;
}

.log-section { margin-top: 26px; }

.timeline {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--rack);
  max-height: 340px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
}
.tl-row {
  display: grid;
  grid-template-columns: 44px 96px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  align-items: baseline;
}
.tl-row:last-child { border-bottom: none; }
.tl-seq { color: var(--dim); }
.tl-kind { color: var(--muted); }
.tl-text {
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.tl-row.is-stage .tl-text { color: var(--accent); }
.tl-row.is-error .tl-text { color: #e0908a; }
.tl-row.is-done .tl-text { color: #86c79b; }

/* ---------- 结果：剧本纸 ---------- */

.result-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.result-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.ep-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 3px;
}
.ep-item {
  text-align: left;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 9px;
  transition: background .12s ease, color .12s ease;
}
.ep-item:hover { background: #182028; color: var(--text); }
.ep-item.is-active {
  background: linear-gradient(90deg, rgba(227,179,65,.1), rgba(227,179,65,.02));
  border-left-color: var(--accent);
  color: var(--text);
}
.ep-item .n {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--dim);
}
.ep-item .n b {
  font-weight: 600;
  color: #8a95a2;
  min-width: 14px;
  text-align: right;
}
.ep-item.is-active .n b { color: var(--accent); }
.ep-item .ep-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

/* 剧本纸 */
.paper {
  background: var(--paper);
  color: #1a1a1a;
  border-radius: 2px;
  padding: 40px 52px 56px;
  box-shadow: 0 18px 46px rgba(0,0,0,.45), 0 0 0 1px var(--paper-edge);
  font-family: var(--font-script);
  font-size: 15px;
  line-height: 2.05;
  min-height: 380px;
}

.paper-head {
  border-bottom: 1px solid var(--paper-edge);
  padding-bottom: 14px;
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.paper-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .02em;
}
.paper-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #6b6659;
}

.script { white-space: pre-wrap; word-break: break-word; }
.script .scene {
  display: block;
  font-weight: 600;
  letter-spacing: .04em;
  margin-top: 20px;
  color: #3a2f1c;
}
.script .scene:first-child { margin-top: 0; }
.script .cue { color: #4a3a18; }

.doc-section { margin-bottom: 26px; }
.doc-section > h3 {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: #6b6659;
  letter-spacing: .06em;
  margin: 0 0 8px;
}
.doc-body { white-space: pre-wrap; }

.empty-paper {
  color: #8a8475;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.8;
}

/* ---------- 设置 ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 22px;
  align-items: start;
}
.settings-grid > * { min-width: 0; }

.provider-cards { display: flex; flex-direction: column; gap: 8px; }
.provider-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.provider-card:hover { border-color: #38424e; }
.provider-card.is-active { border-color: var(--accent); background: #1d1a0e; }
.provider-card input { margin-top: 4px; accent-color: var(--accent); }
.provider-card .pc-t { font-size: 13.5px; }
.provider-card .pc-d { font-size: 11.5px; color: var(--dim); margin-top: 3px; line-height: 1.5; }

.key-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.callout {
  padding: 10px 12px;
  border-left: 2px solid var(--line);
  background: #141a21;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.callout.is-warn { border-left-color: var(--warn); color: #d8ad78; background: #1e1709; }
.callout.is-ok { border-left-color: var(--ok); color: #9ad3ae; background: #0f1a14; }
.callout.is-err { border-left-color: var(--err); color: #e0908a; background: #1d1210; }

/* ---------- 表格（后台） ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: .05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:hover td { background: #151b22; }
.table .num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* ---------- 遮罩 / 提示条 ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(12px);
  padding: 10px 18px;
  background: #222a33;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
  max-width: min(420px, calc(100vw - 48px));
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
}
.toast.is-on { opacity: 1; transform: translateY(0); }
.toast.is-err { border-color: #4a2a28; color: #e0908a; }
.toast.is-ok { border-color: #2c4a37; color: #9ad3ae; }

.skeleton { color: var(--dim); font-size: 13px; padding: 8px 0; }

.hidden { display: none !important; }

/* ---------- 滚动条 ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c343d; border-radius: 99px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: #3a444f; }

/* ---------- 窄屏 ---------- */

@media (max-width: 1180px) {
  .compose-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .compose-settings { position: static; }

  .result-grid { grid-template-columns: minmax(0, 1fr); }
  .ep-list { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .ep-item { flex: none; }
}

@media (max-width: 760px) {
  .body { grid-template-columns: 1fr; }
  .rack { display: none; }
  .pane { padding: 20px 18px 60px; }
  .paper { padding: 26px 22px 34px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .run-bar > i { transition: none; }
}

/* ---------- 项目工作台：页签 + 右侧实时互动 ---------- */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}
.studio-main { min-width: 0; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-pane { min-width: 0; }

.studio-side {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 40px);
}
.side-panel { flex: 1; min-height: 0; }
.side-panel { display: flex; flex-direction: column; gap: 10px; }
.side-panel h3 { margin: 0; }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: clamp(240px, 44vh, 520px);
  overflow-y: auto;
  padding-right: 4px;
}
.chat-empty { font-size: 12.5px; color: var(--dim); line-height: 1.7; }
.chat-msg {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-msg.is-user { background: var(--rack-hi); border-color: #333d49; }
.chat-msg.is-assistant { background: #10151a; }
.chat-msg .who {
  display: block;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.chat-msg .ctx { display: block; margin-top: 6px; font-size: 11px; color: var(--dim); }

.steer-list { display: flex; flex-direction: column; gap: 6px; }
.steer-item {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 8px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.steer-item .rev { font-family: var(--font-mono); color: var(--dim); flex: none; }

.ref-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 216px;
  overflow-y: auto;
  padding-right: 2px;
}
.ref-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.ref-item input { margin-top: 3px; accent-color: var(--accent); }
.ref-item .rt { color: var(--text); }

@media (max-width: 1100px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .studio-side { position: static; }
}

/* 大纲页的规划表落在「纸」上，用浅色系 */
.table-wrap { overflow-x: auto; }
.paper .table { font-size: 13px; }
.paper .table th {
  color: #6b6659;
  border-bottom: 1px solid var(--paper-edge);
  background: transparent;
}
.paper .table .num { color: #6b6659; }
.paper .table td { border-bottom: 1px solid #eae5da; vertical-align: top; }
.paper .table tr:hover td { background: transparent; }

/* 纸面上的 Markdown 渲染（大纲 / 连续性 / 分析） */
.md { white-space: normal; }
.md p { margin: 0 0 14px; line-height: 1.95; }
.md h3, .md h4, .md h5, .md h6 {
  margin: 22px 0 10px;
  font-weight: 600;
  line-height: 1.5;
}
.md h3 { font-size: 18px; }
.md h4 { font-size: 16px; }
.md h5, .md h6 { font-size: 14.5px; color: #4a4438; }
.md ul { margin: 0 0 14px; padding-left: 20px; }
.md li { line-height: 1.9; margin-bottom: 4px; }
.md blockquote {
  margin: 0 0 14px;
  padding: 4px 0 4px 14px;
  border-left: 2px solid var(--paper-edge);
  color: #5a5446;
}
.md code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: #ece7db;
  padding: 1px 5px;
  border-radius: 3px;
}
.md strong { font-weight: 700; }

/* ---------------------------------------------------------------- 新增 */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* 估时汇总：正文估算 + 上下限 + 计划 + 差额 + 待估时集数 */
.timing-block {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 4px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--rack-hi);
}
.timing-block.is-on { display: grid; }
.timing-cell { font-size: 12px; color: var(--dim); }
.timing-cell b {
  display: block;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-top: 3px;
}
.timing-cell.is-warn b { color: var(--warn, #d9a441); }

/* 流式正文：正在写入的草稿区 */
.chat-msg.is-live { border-style: dashed; }
.chat-msg.is-live .who::after { content: ' · 生成中'; }
.paper.is-live::after {
  content: '▍';
  animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* 技能库条目 */
.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  font-size: 12.5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}
.skill-row .rt {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.skill-row .hint { grid-column: 1; font-size: 11.5px; }
.skill-row > .btn, .skill-row > .chip { grid-column: 2; grid-row: 1 / span 2; }
.skill-row.is-builtin { border-style: dashed; }
.skill-row .grow { flex: 1; }

/* 自动规划集数时：集数输入框置灰但仍可见（单集时长始终可填） */
.input.is-locked,
.input:disabled {
  opacity: .55;
  cursor: not-allowed;
  background: var(--rack-hi);
}

/* ==========================================================================
   新建页：编辑器 + 分组设定
   ========================================================================== */

.input-lg { padding: 11px 13px; font-size: 14.5px; }
.btn-block { width: 100%; padding: 11px 16px; font-size: 14px; }

/* 原文编辑器：工具条 + 纸面正文 + 状态条。
   纸只包正文，工具条留在深色壳里，暗色界面不会被一张大白块劈开。 */
.editor {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--field);
  overflow: hidden;
  transition: border-color .16s ease;
}
.editor:focus-within { border-color: #46525f; }
.editor.is-drop { border-color: var(--accent); }

.editor-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px 7px 14px;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.editor-bar-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .09em;
  color: var(--dim);
}

.editor .editor-text {
  border: none;
  border-radius: 0;
  background: var(--paper);
  box-shadow: none;
  color: #241f18;
  font-family: var(--font-script);
  font-size: 14.5px;
  min-height: clamp(230px, 32vh, 420px);
  max-height: 70vh;
  padding: 22px 26px;
  line-height: 2;
  caret-color: #a8761b;
  display: block;
  resize: vertical;
  overflow-y: auto;
}
.editor .editor-text::placeholder { color: #a49b88; }
.editor .editor-text:focus { box-shadow: none; border: none; }
.editor .editor-text::-webkit-scrollbar-thumb { background: #d8d1c2; border: 2px solid var(--paper); }

.editor-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 14px;
  background: #efeade;
  border-top: 1px solid var(--paper-edge);
  flex-wrap: wrap;
}
.editor-foot .source-meta { color: #857c68; }
.editor-foot .source-meta .dot { background: #cfc6b2; }
.source-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--dim);
  font-family: var(--font-mono);
}
.source-meta .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--line-strong); flex: none;
}

/* 设定分组：一条细标题 + 内容 */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.field-group:first-child { padding-top: 0; border-top: none; }
.panel > .stack > .field-group:first-child { padding-top: 0; border-top: none; }
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.group-head > span:first-child {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .09em;
  color: #8a95a2;
}

/* 开关：替代裸复选框，勾选状态一眼可见 */
.switch {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease;
}
.switch:hover { border-color: var(--line-strong); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  flex: none;
  width: 34px;
  height: 19px;
  margin-top: 1px;
  border-radius: 99px;
  background: #232b34;
  border: 1px solid var(--line-strong);
  transition: background .16s ease, border-color .16s ease;
}
.switch-track > i {
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #7d8794;
  transition: transform .16s ease, background .16s ease;
}
.switch input:checked + .switch-track {
  background: rgba(227,179,65,.22);
  border-color: var(--accent);
}
.switch input:checked + .switch-track > i {
  transform: translateX(15px);
  background: var(--accent);
}
.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text b { font-size: 13px; font-weight: 500; color: var(--text); }
.switch-text em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* 模型摘要：默认只显示一行，点「更换」才展开选择器 */
.model-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  font-size: 13px;
  min-height: 38px;
}
.model-summary .ms-provider { color: var(--muted); font-size: 12px; }
.model-summary .ms-model {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-summary .ms-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); flex: none;
}
.model-summary.is-empty .ms-dot { background: var(--warn); }
.model-edit { display: flex; flex-direction: column; gap: 10px; }

.link-btn {
  padding: 0;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent); }

/* 行内开关：用于分组标题右侧，省一行高度 */
.switch-inline {
  padding: 4px 9px;
  gap: 8px;
  border-radius: 99px;
  align-items: center;
}
.switch-inline .switch-text b { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.switch-inline .switch-track { width: 30px; height: 17px; margin-top: 0; }
.switch-inline .switch-track > i { width: 11px; height: 11px; }
.switch-inline input:checked + .switch-track > i { transform: translateX(13px); }

/* 提交区：与上方分组拉开距离，按钮占满 */
.submit-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px -18px 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24,31,39,.55), rgba(16,22,28,.9));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.submit-block .hint { text-align: center; }
