:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f9;
  color: #202631;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.topbar {
  /* 两侧列等宽才能让中间步骤条真居中；flex + space-between 会在成片页隐藏上传区后把步骤条挤向右 */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  height: 72px;
  padding: 0 20px;
  background: #ffffff;
  border-bottom: 1px solid #e8ebf0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #ffffff;
  font-weight: 800;
  background: linear-gradient(135deg, #11c5d9, #8d5bff 58%, #ff9d4d);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.course-type {
  height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #ff8a1c;
  background: #fff3e3;
  border: 1px solid #ffd5a1;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.course-name {
  max-width: 290px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #7b8490;
  font-size: 13px;
}

.steps {
  display: flex;
  align-items: center;
  gap: 34px;
  color: #a4abb4;
  font-weight: 700;
}

.step {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.step + .step::before {
  content: "";
  position: absolute;
  left: -24px;
  width: 10px;
  height: 10px;
  border-top: 2px solid #c8ced6;
  border-right: 2px solid #c8ced6;
  transform: rotate(45deg);
}

.step span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #b5bcc5;
  color: #ffffff;
  font-size: 13px;
}

.step.active {
  color: #1b6df2;
}

.step.active span {
  background: #1b6df2;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.save-state {
  color: #5d6672;
  font-size: 14px;
}

.upload-panel {
  display: flex;
  gap: 10px;
  align-items: center;
}

.file-picker {
  width: 150px;
  height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #8d63ff;
  border-radius: 10px;
  background: #ffffff;
  color: #8a4dff;
  font-weight: 700;
  cursor: pointer;
}

.file-picker input {
  display: none;
}

.file-picker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #eef2f8;
  color: #596574;
  cursor: pointer;
}

.primary-button,
.ghost-button {
  height: 42px;
  min-width: 116px;
  color: #ffffff;
  background: linear-gradient(135deg, #5f7df8, #8758f4);
  font-weight: 700;
}

.ghost-button {
  min-width: 92px;
  background: #7b61ff;
  color: #ffffff;
}

button:disabled {
  background: #e9edf2;
  color: #9aa4b0;
  cursor: not-allowed;
}

/* 容器内按钮自带背景，与 button:disabled 同权重且位置更晚会盖掉置灰，必须显式补禁用态 */
.primary-button:disabled,
.ghost-button:disabled,
.rail-actions button:disabled,
.play-controls button:disabled,
.script-tools button:disabled,
.script-footer button:disabled,
.script-actions button:disabled {
  border-color: #dfe4ea;
  background: #e9edf2;
  color: #9aa4b0;
  cursor: not-allowed;
}

.status {
  height: 38px;
  padding: 9px 20px;
  border-bottom: 1px solid #e8ebf0;
  color: #41505f;
  background: #fbfcfd;
  font-size: 14px;
}

.status.error {
  color: #a42323;
  background: #fff4f2;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(16, 24, 40, 0.28);
  backdrop-filter: blur(4px);
}

.busy-overlay.active {
  display: flex;
}

.busy-dialog {
  width: min(460px, 100%);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 22px 24px;
  border: 1px solid #dfe6f2;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.busy-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid #e7ecf5;
  border-top-color: #5f7df8;
  animation: spin 0.9s linear infinite;
}

.busy-title {
  font-size: 18px;
  font-weight: 900;
  color: #202631;
}

.busy-message {
  margin-top: 6px;
  color: #5d6877;
  line-height: 1.5;
}

.busy-progress {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.busy-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2576f6, #8c5cf6);
  transition: width 0.25s ease;
}

.busy-progress-text {
  min-height: 20px;
  margin-top: 8px;
  color: #6a7584;
  font-size: 13px;
  font-weight: 700;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.workspace {
  display: grid;
  grid-template-columns: 194px minmax(520px, 1fr) 430px;
  min-height: 0;
  height: calc(100vh - 110px);
}

.thumb-rail {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid #e1e5eb;
  background: #ffffff;
  padding: 16px 14px;
  min-height: 0;
}

.rail-title {
  margin-bottom: 12px;
  color: #5a6471;
  font-weight: 800;
}

.thumb-list {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
}

.thumb-card {
  position: relative;
  width: 100%;
  height: 86px;
  display: block;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(18, 28, 42, 0.12);
}

.thumb-card.active {
  border-color: #1b6df2;
}

.thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-no,
.duration {
  position: relative;
  z-index: 1;
}

.page-no {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 0 7px 0 0;
  color: #ffffff;
  background: rgba(32, 38, 49, 0.72);
  font-size: 13px;
  font-weight: 800;
}

.duration {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 4px 8px;
  border-radius: 7px 0 0 0;
  color: #ffffff;
  background: rgba(32, 38, 49, 0.68);
  font-size: 12px;
}

.thumb-title {
  display: none;
}

.rail-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 14px;
}

.rail-actions button {
  height: 40px;
  padding: 0;
  background: #ffffff;
  border: 1px solid #d6dce5;
}

.stage-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr 72px;
  padding: 40px 20px 0;
  background: #f5f7fa;
  overflow: hidden;
}

.slide-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
}

.slide-stage img {
  display: none;
  max-width: min(100%, 1180px);
  max-height: calc(100vh - 230px);
  box-shadow: 0 14px 40px rgba(23, 30, 42, 0.18);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  color: #7c8794;
}

.empty-icon {
  width: 86px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px dashed #bcc6d3;
  color: #7b61ff;
  font-weight: 900;
  background: #ffffff;
}

.player-bar {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  align-items: center;
  color: #8b929b;
}

.time-readout {
  font-size: 22px;
  font-weight: 800;
  color: #202631;
}

.play-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.play-controls button {
  width: 42px;
  padding: 0;
  color: #9aa2ad;
  background: transparent;
  font-size: 22px;
}

.continuous-play {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5d6876;
  font-size: 15px;
  cursor: pointer;
}

.continuous-play input {
  width: 18px;
  height: 18px;
  accent-color: #1b6df2;
}

.thumb-card.audio-completed .duration {
  background: rgba(28, 122, 60, 0.86);
}

.thumb-card.audio-stale .duration {
  background: rgba(154, 101, 8, 0.96);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
  font-weight: 800;
}

.thumb-card.audio-generating .duration {
  background: rgba(154, 101, 8, 0.86);
}

.thumb-card.audio-failed .duration {
  background: rgba(164, 35, 35, 0.88);
}

.script-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 14px;
  padding: 22px;
  border-left: 1px solid #e1e5eb;
  background: #ffffff;
  min-height: 0;
}

.script-tools {
  height: 76px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid #e1e5eb;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}

.script-tools button {
  height: 100%;
  padding: 0 6px;
  border-right: 1px solid #e8ebf0;
  border-radius: 0;
  background: #ffffff;
  color: #1b6df2;
  font-weight: 700;
}

.script-tools button:not(:disabled):hover {
  background: #f2f7ff;
}

.script-tools button:last-child {
  border-right: 0;
}

.source-panel {
  max-height: 138px;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid #e1e5eb;
  border-radius: 12px;
  overflow: hidden;
  background: #fbfcfe;
}

.source-title {
  padding: 10px 14px 6px;
  color: #657181;
  font-size: 13px;
  font-weight: 800;
}

.source-text {
  overflow: auto;
  padding: 0 14px 12px;
  color: #3d4652;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.script-body {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  border: 1px solid #e1e5eb;
  border-radius: 16px;
  overflow: hidden;
}

textarea {
  width: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  padding: 20px;
  line-height: 1.7;
  color: #202631;
  background: #ffffff;
  font-size: 17px;
}

textarea:focus {
  outline: none;
}

.script-footer {
  height: 58px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-top: 1px solid #eef1f5;
}

.script-footer button {
  height: 34px;
  border-radius: 999px;
  background: #f4f6f9;
}

.script-footer span {
  justify-self: end;
  color: #4f5966;
}

.script-body.pause-view {
  grid-template-rows: auto 1fr auto auto;
}

.script-body.pause-view > textarea,
.script-body.pause-view > .script-footer {
  display: none;
}

.pause-panel {
  display: none;
  min-height: 0;
}

.script-body.pause-view .pause-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 0;
}

.pause-hint {
  padding: 14px 16px 6px;
  color: #657181;
  font-size: 13px;
  line-height: 1.5;
}

.pause-hint.warning {
  color: #9a6508;
  font-weight: 800;
}

.pause-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 0 16px;
}

.pause-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  padding: 8px 10px;
  border: 1px solid #eef1f5;
  border-radius: 10px;
  background: #fbfcfe;
}

.pause-row .pause-text {
  grid-column: 1 / -1;
  color: #3d4652;
  font-size: 14px;
  line-height: 1.6;
}

.pause-row input {
  width: 100%;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  accent-color: #1b6df2;
  cursor: pointer;
}

.pause-row .pause-value {
  min-width: 44px;
  color: #1b6df2;
  font-size: 14px;
  font-weight: 800;
  text-align: right;
}

.pause-footer {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  margin-top: 10px;
  border-top: 1px solid #eef1f5;
}

.pause-footer button {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f4f6f9;
}

.pause-footer button.primary {
  background: #1b6df2;
  color: #ffffff;
  font-weight: 800;
}

.pause-footer button:disabled {
  background: #e9edf2;
  color: #9aa4b0;
  cursor: not-allowed;
}

.pause-summary {
  padding: 0 16px 12px;
  color: #4f5966;
  font-size: 13px;
}

.script-tools button.pause-on:not(:disabled) {
  background: #eaf1ff;
  color: #0f4fb8;
  box-shadow: inset 0 -3px 0 #1b6df2;
}

.audio-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #dbe6f7;
  border-radius: 14px;
  background: #f7faff;
}

.audio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.audio-title {
  color: #41505f;
  font-size: 14px;
  font-weight: 800;
}

.audio-state {
  padding: 3px 10px;
  border-radius: 999px;
  background: #eaeef4;
  color: #657181;
  font-size: 13px;
  font-weight: 800;
}

.audio-state.completed {
  background: #e5f5ea;
  color: #1c7a3c;
}

.audio-state.generating {
  background: #fff2df;
  color: #9a6508;
}

.audio-state.failed {
  background: #fdeae8;
  color: #a42323;
}

.audio-meta {
  color: #5d6876;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
}

.audio-meta.error {
  color: #a42323;
}

.audio-meta.warning {
  color: #9a6508;
  font-weight: 800;
}

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

.audio-actions button {
  height: 46px;
  border: 1px solid #8fc0ff;
  border-radius: 10px;
  background: #ffffff;
  color: #1b6df2;
  font-size: 16px;
  font-weight: 800;
}

.audio-actions button.primary {
  border-color: #1b6df2;
  background: #1b6df2;
  color: #ffffff;
}

.audio-actions button:disabled {
  border-color: #dfe4ea;
  background: #e9edf2;
  color: #9aa4b0;
  cursor: not-allowed;
}

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

.script-actions button {
  height: 54px;
  border: 1px solid #8fc0ff;
  background: #ffffff;
  color: #1b6df2;
  font-size: 17px;
  font-weight: 800;
}

.steps .step {
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
}

.steps .step:disabled {
  cursor: not-allowed;
  color: #c3c9d1;
  background: none;
}

.steps .step:disabled span {
  background: #d6dbe2;
}

.video-view {
  display: none;
}

body.view-video .video-view {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 340px;
  min-height: 0;
  height: calc(100vh - 110px);
}

body.view-video .workspace,
body.view-video .upload-panel,
body.view-video .save-state {
  display: none;
}

.video-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  align-content: start;
  gap: 12px;
  padding: 20px;
  background: #f5f7fa;
  overflow: auto;
}

.video-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.video-state {
  padding: 3px 10px;
  border-radius: 999px;
  background: #eaeef4;
  color: #657181;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}

.video-state.completed {
  background: #e5f5ea;
  color: #1c7a3c;
}

.video-state.generating {
  background: #fff2df;
  color: #9a6508;
}

.video-state.failed {
  background: #fdeae8;
  color: #a42323;
}

.video-summary {
  color: #41505f;
  font-size: 14px;
  font-weight: 700;
}

.video-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf2;
  visibility: hidden;
}

.video-progress.active {
  visibility: visible;
}

.video-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2576f6, #8c5cf6);
  transition: width 0.25s ease;
}

.video-meta {
  color: #5d6876;
  font-size: 13px;
  line-height: 1.6;
}

.video-meta.error {
  color: #a42323;
}

.video-meta.warn {
  color: #9a6508;
}

/* 舞台会撑满整列剩余空间，它一旦自带深色底，16:9 的画面两侧就会各留一条黑边，看着像播放器比画面大一号。
   深色底只挂在 <video> 本身，画面多大播放器就多大。 */
.video-stage {
  position: relative;
  min-height: 320px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.video-stage video {
  /* 不能用 width:100% + max-height：高度被夹住时 Chrome 不等比回缩宽度，
     画面会在元素盒里再被上下留黑，等于把黑边从舞台挪进播放器。两个 auto + max-* 才按比例出盒。 */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 330px);
  border-radius: 14px;
  background: #000000;
}

.video-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 24px;
  border-radius: 14px;
  background: #0e1116;
  color: #aab3bf;
  font-size: 14px;
  text-align: center;
}

.video-empty.hide {
  display: none;
}

.video-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-actions button,
.video-download {
  height: 46px;
  font-weight: 800;
}

.video-actions button {
  padding: 0 22px;
  border: 1px solid #1b6df2;
  background: #1b6df2;
  color: #ffffff;
}

.video-actions button:disabled {
  border-color: #dfe4ea;
  background: #e9edf2;
  color: #9aa4b0;
  cursor: not-allowed;
}

.video-download {
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  border: 1px solid #1b6df2;
  border-radius: 10px;
  background: #ffffff;
  color: #1b6df2;
  text-decoration: none;
}

.video-download[hidden] {
  display: none;
}

.video-rail {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  padding: 16px 14px;
  border-left: 1px solid #e1e5eb;
  background: #ffffff;
}

.video-thumb-list {
  position: relative;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
}

/* 这一列比左边栏宽近一倍，沿用 86px 会把整页幻灯片裁成一条横带，按 312px 栏宽取 16:9 的 176px。
   不能用 height:auto + aspect-ratio：卡片里唯一的常规流内容是 height:100% 的 <img>，
   比例盒要等行轨定高、行轨又要按内容算高，grid 行轨会压塌成几十像素，卡片整排互相叠在一起。 */
.video-thumb-list .thumb-card {
  height: 176px;
}

/* 缩略图自带白底，权重高过元素级 button:disabled，禁用态必须在这一组里显式补 */
.video-thumb-list .thumb-card:disabled {
  box-shadow: none;
  opacity: 0.62;
  cursor: not-allowed;
}

.video-thumb-list .thumb-card:disabled img {
  filter: grayscale(0.9);
}

.video-thumb-list .thumb-card.missing .duration {
  background: rgba(164, 35, 35, 0.88);
  font-weight: 800;
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    padding: 14px;
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .actions,
  .upload-panel {
    width: 100%;
  }

  .file-picker,
  .primary-button,
  .ghost-button {
    flex: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .thumb-rail {
    border-right: 0;
    border-bottom: 1px solid #dfe5ec;
  }

  .thumb-list,
  .video-thumb-list {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    max-height: 280px;
  }

  .video-thumb-list .thumb-card {
    height: 86px;
  }

  .stage-panel,
  .script-panel {
    min-height: 520px;
  }

  .script-panel {
    border-left: 0;
  }

  body.view-video .video-view {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .video-stage video {
    max-height: 60vh;
  }

  .video-rail {
    border-left: 0;
    border-top: 1px solid #dfe5ec;
  }
}
