/* 剧本工作台：三栏确认页。依赖 app.css 的变量和基础控件。 */

.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

body.script-page {
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 0% -10%, rgba(255, 77, 109, .12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(124, 92, 255, .13), transparent 55%),
    var(--bg);
}

.work-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  height: 58px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 14, 19, .9);
  backdrop-filter: blur(14px);
}

.work-topbar .brand { margin: 0; }
.work-topbar .brand h1 { font-size: 16px; }
.work-topbar .brand p { display: none; }

.project-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #14141d;
}
.project-pick span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.project-pick select {
  width: 190px;
  margin: 0;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  font-size: 13px;
}

.topbar-meta { display: flex; align-items: center; gap: 8px; margin-left: 2px; }
.topbar-meta .badge { white-space: nowrap; }

.work-topbar .spacer { flex: 1; }
.work-topbar .btn { padding: 7px 12px; font-size: 12px; }

.workbench {
  display: grid;
  grid-template-columns: 330px minmax(420px, 1fr) 400px;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 58px);
}

.wb-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.wb-col.source { background: #171722; }
.wb-col.side { background: transparent; border: 0; gap: 10px; overflow: hidden; padding-right: 2px; }

.wb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.wb-head h2 { margin: 0; font-size: 14px; letter-spacing: .5px; }
.wb-head .hint { color: var(--muted); font-size: 11px; }

.wb-body {
  padding: 12px 14px 16px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

/* ---------------------------------------------------------------- 左栏 */

.source textarea#rawText {
  height: 240px;
  min-height: 180px;
  font-size: 13px;
  line-height: 1.75;
}

.char-count {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  margin: -6px 0 10px;
}
.char-count b { color: var(--text); font-weight: 600; }

.mode-tip {
  margin: 2px 0 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(124, 92, 255, .1);
  border: 1px solid rgba(124, 92, 255, .25);
  color: #c9c2ff;
  font-size: 11px;
  line-height: 1.6;
}

.source .btn-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 4px; }
.source .btn-row .btn.primary { grid-column: 1 / -1; }
.stage-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.stage-row .btn { flex: 1 1 auto; min-width: 110px; }

.test-fill {
  margin-top: 8px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.test-fill:hover { color: var(--text); }

.chapter-list { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.chapter-list h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; font-weight: 500; }
.chapter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.chapter-head h3 { margin: 0; }
.chapter-head .icon-btn { padding: 3px 7px; font-size: 10.5px; }
.chapter-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #14141d;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.chapter-item.active { border-color: var(--accent-2); background: rgba(124, 92, 255, .1); }
.chapter-item small { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------------------------------------------------------------- 中栏 */

.shot-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  flex: 0 0 auto;
}
.shot-toolbar b { color: var(--text); }
.shot-toolbar .spacer { flex: 1; }
.shot-toolbar .btn { padding: 5px 9px; font-size: 11px; }
#queueKeyframesBtn { white-space: nowrap; flex-shrink: 0; }

.shot-list { display: flex; flex-direction: column; gap: 10px; }

.shot-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #14141d;
  padding: 10px 12px;
  transition: border-color .15s;
}
.shot-card:hover { border-color: #3b3b4f; }
.shot-card.excluded { opacity: .55; }
.beat-card {
  border: 1px dashed rgba(255, 193, 7, .32);
  border-radius: 12px;
  background: rgba(255, 193, 7, .04);
  padding: 10px 12px;
}
.beat-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.beat-card-id {
  flex: none; padding: 2px 7px; border-radius: 6px;
  background: rgba(255, 193, 7, .14); color: #ffc107; font-size: 10px;
}
.beat-card-title { font-size: 13px; font-weight: 600; }
.beat-card-meta { color: var(--muted); font-size: 10.5px; margin-left: auto; }
.beat-card p { margin: 4px 0 5px; color: var(--text); font-size: 12.5px; line-height: 1.6; }
.beat-card .beat-source { color: var(--muted); font-size: 11px; line-height: 1.5; }
.review-hint {
  margin: 0 0 10px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid rgba(255, 193, 7, .3); background: rgba(255, 193, 7, .07);
  color: #ffe7b2; font-size: 11.5px; line-height: 1.55;
}
.shot-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.shot-seq {
  flex: 0 0 auto;
  width: 30px; height: 24px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: rgba(255, 77, 109, .14);
  color: var(--accent);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.shot-title-input {
  margin: 0;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  border-color: transparent;
  min-width: 90px;
  flex: 1 1 90px;
}
.shot-title-input:hover { border-color: var(--line); }
.shot-dur {
  flex: 0 0 64px;
  width: 64px;
  margin: 0;
  padding: 5px 6px;
  font-size: 11px;
  text-align: center;
}
.shot-ops {
  display: flex;
  gap: 5px;
  margin-left: 0;
  width: 100%;
  justify-content: flex-end;
}
.icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn:hover { color: var(--text); border-color: #4a4a60; }
.icon-btn:disabled { opacity: .38; cursor: not-allowed; }
.icon-btn.danger:hover { color: var(--bad); border-color: rgba(248, 113, 113, .5); }
.icon-btn.on { color: var(--ok); border-color: rgba(52, 211, 153, .4); }

.shot-content {
  margin: 0 0 8px;
  min-height: 54px;
  font-size: 12.5px;
  line-height: 1.65;
  background: #101018;
}
.shot-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.shot-meta-row label { margin: 0; }
.shot-meta-row select { margin-top: 3px; padding: 6px 8px; font-size: 11px; }
.shot-dialogue { margin: 0; padding: 6px 9px; font-size: 12px; }
.shot-scene { margin: 0 0 8px; }
.shot-scene select { margin-top: 3px; padding: 6px 8px; font-size: 11px; }
.shot-scene-val {
  display: block;
  margin-top: 3px;
  padding: 7px 9px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.shot-people { margin: 0 0 8px; font-size: 11px; color: var(--muted); }
.char-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.char-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.char-chip.on { border-color: var(--accent-2); background: rgba(124, 92, 255, .14); }
.char-chip input { width: 12px; height: 12px; accent-color: var(--accent-2); }
.char-add {
  margin-left: 8px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--accent-2);
  background: transparent;
  border: 1px solid var(--accent-2);
  border-radius: 999px;
  cursor: pointer;
}
.char-add:hover { background: rgba(124, 92, 255, .12); }
.char-empty { font-size: 12px; color: var(--muted); padding: 4px 0; }

.prompt-fold { margin-top: 8px; }
.prompt-fold summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  padding: 3px 0;
  user-select: none;
}
.prompt-fold summary:hover { color: var(--text); }
.prompt-fold textarea {
  margin-top: 6px;
  min-height: 84px;
  font-size: 11.5px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- 右栏 */

.estimate-card { padding: 14px 16px; margin: 0; flex: 0 0 auto; }
.estimate-top { display: flex; align-items: baseline; gap: 6px; }
.estimate-top .amount { font-size: 30px; font-weight: 700; letter-spacing: -.5px; color: #fff; }
.estimate-top .unit { color: var(--muted); font-size: 12px; }
.estimate-top .currency { font-size: 15px; color: var(--muted); margin-right: -2px; }
.est-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.est-cell { background: #14141d; border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; }
.est-cell span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; white-space: nowrap; }
.est-cell b { font-size: 15px; font-variant-numeric: tabular-nums; }
.est-cell b small { color: var(--muted); font-size: 10px; font-weight: 400; }
.est-formula { margin: 10px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.6; }

.warn-box { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.warn-item {
  display: flex;
  gap: 6px;
  font-size: 11px;
  line-height: 1.55;
  color: #ffd89b;
  background: rgba(251, 191, 36, .08);
  border: 1px solid rgba(251, 191, 36, .22);
  border-radius: 8px;
  padding: 7px 9px;
}
.warn-item::before { content: "!"; color: var(--warn); font-weight: 700; flex: 0 0 auto; }

.assets-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0; margin: 0; }
.asset-tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.asset-tab {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}
.asset-tab.active { color: var(--text); border-color: var(--accent-2); background: rgba(124, 92, 255, .13); }

.asset-list { padding: 10px 12px 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.asset-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px dashed var(--line);
  color: var(--muted);
  font-size: 10.5px;
  flex: 0 0 auto;
}
.asset-tools { flex-wrap: wrap; }
.asset-tools .icon-btn { padding: 3px 8px; font-size: 10.5px; }
.model-select {
  background: #111827;
  color: #dbeafe;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 4px 22px 4px 8px;
  font-size: 10.5px;
  max-width: 168px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%), linear-gradient(135deg, #94a3b8 50%, transparent 50%);
  background-position: calc(100% - 11px) 50%, calc(100% - 6px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.model-select option { background: #0f172a; color: #e2e8f0; }

.asset-task {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 10.5px;
}
.task-badge {
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.task-thumb {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.task-badge.off { color: var(--muted); }
.task-badge.run { color: #ffd28a; border-color: rgba(255, 180, 60, .45); background: rgba(255, 180, 60, .08); }
.task-badge.done { color: #7ddca8; border-color: rgba(80, 220, 140, .35); background: rgba(80, 220, 140, .08); }
.task-badge.bad { color: #ff8f8f; border-color: rgba(255, 100, 100, .4); background: rgba(255, 80, 80, .08); }
.task-price { color: var(--muted); }
.task-btn {
  margin-left: auto;
  padding: 3px 9px;
  font-size: 10.5px;
  color: var(--accent-2);
  background: transparent;
  border: 1px solid var(--accent-2);
  border-radius: 999px;
  cursor: pointer;
}
.task-btn:hover { background: rgba(124, 92, 255, .12); }

.asset-card { border: 1px solid var(--line); border-radius: 10px; background: #14141d; padding: 10px; }
.asset-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.asset-type {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.asset-name { margin: 0; padding: 5px 7px; background: transparent; border-color: transparent; font-size: 13px; font-weight: 600; }
.asset-name:hover { border-color: var(--line); }
.asset-summary { margin: 0 0 6px; min-height: 48px; font-size: 11.5px; line-height: 1.55; background: #101018; }
.asset-gen { margin: 0; min-height: 70px; font-size: 11px; line-height: 1.5; background: #101018; }
.asset-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.asset-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 24px 0; }

.confirm-dock { flex: 0 0 auto; display: flex; flex-direction: column; gap: 7px; }
.confirm-btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), #ff7a45);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.confirm-btn:disabled {
  opacity: 1;
  background: linear-gradient(135deg, #5a3540, #4a3a36);
  color: #a9a1b0;
  cursor: not-allowed;
}
.confirm-note { color: var(--muted); font-size: 10.5px; text-align: center; line-height: 1.5; }

/* 内嵌浏览器会拦截原生 confirm，这里用页面内弹层，保证删除/确认都能走通 */
.confirm-mask {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(3px);
}
.confirm-box {
  width: min(430px, 90vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.confirm-msg { margin: 0 0 16px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-box { width: min(500px, 92vw); max-height: 86vh; overflow-y: auto; }
.form-title { margin: 0 0 14px; font-size: 16px; }
.form-field { margin-bottom: 10px; }
.form-field input, .form-field textarea { font-size: 12.5px; }

.status-banner {
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 1.55;
  border: 1px solid rgba(52, 211, 153, .35);
  background: rgba(52, 211, 153, .09);
  color: #d1ffe9;
}
.status-banner.draft { border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); color: #ffe7b2; }

@media (max-width: 1280px) {
  .workbench { grid-template-columns: 290px minmax(320px, 1fr) 360px; }
}
@media (max-width: 1080px) {
  .workbench { grid-template-columns: 250px minmax(260px, 1fr) 318px; gap: 10px; padding: 10px; }
  .est-cell { padding: 7px; }
  .est-cell b { font-size: 13px; }
}
@media (max-width: 900px) {
  body.script-page { overflow: auto; height: auto; }
  .workbench { display: flex; flex-direction: column; height: auto; }
  .wb-col { min-height: 420px; }
  .wb-col.side { overflow: visible; }
  .work-topbar { flex-wrap: wrap; height: auto; }
}

/* ---------------------------------------------------------------- P5.1 导入 / P5.5 导出 */

.import-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.import-row .btn { padding: 7px 10px; font-size: 12px; }
.import-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.import-box {
  width: min(780px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.import-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.import-head h3 { margin: 0 0 4px; font-size: 15px; }
.import-head p { margin: 0; color: var(--muted); font-size: 12px; }
.import-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.import-list {
  overflow: auto;
  min-height: 120px;
  max-height: 58vh;
  padding-right: 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.import-item {
  display: flex;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
}
.import-item:last-child { border-bottom: 0; }
.import-item.too-long { opacity: .5; cursor: not-allowed; }
.import-item input { margin-top: 3px; accent-color: var(--pink, #ff4d6d); }
.import-item-main { min-width: 0; }
.import-item-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.import-item-title b { font-size: 13px; }
.import-item-title span { color: var(--muted); font-size: 11px; }
.import-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shot-origin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  min-width: 0;
}
.origin-badge {
  flex: none;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255,255,255,.07);
  color: var(--muted);
  font-size: 10px;
}
.origin-badge.ai_expanded { background: rgba(255,77,109,.18); color: #ff8aa0; }
.origin-badge.mixed { background: rgba(255,193,7,.16); color: #ffc107; }
.origin-badge.manual, .origin-badge.manual_split { background: rgba(124,92,255,.18); color: #b9a7ff; }
.shot-source {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10.5px;
}
.beat-id { flex: none; color: #666; font-size: 10px; font-family: monospace; }

/* ---------------------------------------------------------------- P6.2 资产锁定 / 首帧确认 */
.asset-lock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 6px;
  padding: 7px 8px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
  flex-wrap: wrap;
}
.asset-lock-thumb {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
  border: 1px solid rgba(255,255,255,.12); flex: none;
}
.asset-status {
  font-size: 10px; padding: 2px 7px; border-radius: 5px;
  background: rgba(255,255,255,.08); color: var(--muted);
}
.asset-status.ready, .asset-status.ready { background: rgba(52,211,153,.14); color: #6ee7b7; }
.asset-status.locked { background: rgba(255,77,109,.16); color: #ff8aa0; }
.asset-status.generating { background: rgba(96,165,250,.14); color: #93c5fd; }
.asset-lock-note { color: var(--muted); font-size: 10.5px; }

/* P7.1 镜头角色 + 配音/视频行 */
.shot-role {
  display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; color: #ffe9b0; background: rgba(255, 196, 0, .12);
  border: 1px solid rgba(255, 196, 0, .28); white-space: nowrap;
}
.shot-audio {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 6px; padding: 6px 8px; border-radius: 7px;
  background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.07);
}
.shot-audio .audio-url {
  flex: 1 1 240px; min-width: 160px; height: 26px; padding: 0 7px;
  border-radius: 5px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18); color: inherit; font-size: 11px;
}
.shot-audio .audio-dur {
  width: 54px; height: 26px; padding: 0 5px; border-radius: 5px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.18); color: inherit;
}
.task-btn.primary { background: rgba(88, 166, 255, .18); border-color: rgba(88,166,255,.5); color: #cfe6ff; }
.task-btn.danger { background: rgba(255, 90, 90, .12); border-color: rgba(255,90,90,.35); color: #ffd0d0; }
