:root {
  color-scheme: light;
  --bg: #fbfcfe;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --line: #e3e8ef;
  --line-strong: #d4dbe5;
  --text: #171b24;
  --muted: #697386;
  --subtle: #98a2b3;
  --blue: #2f6df6;
  --blue-strong: #245de0;
  --blue-soft: #edf4ff;
  --danger: #c53939;
  --shadow: 0 16px 40px rgba(28, 39, 57, 0.08);
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-width: 1040px;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(47, 109, 246, 0.22);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr);
}

.topbar {
  display: grid;
  grid-template-columns: 236px minmax(280px, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  flex: 0 0 auto;
}

.brand-name {
  font-size: 18px;
  line-height: 1;
  font-weight: 750;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.project-switcher {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-list {
  min-width: 0;
  max-width: 520px;
}

.project-item {
  width: 100%;
  height: 42px;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.project-item.active,
.project-item:first-child {
  display: flex;
}

.project-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.project-item span {
  display: none;
}

.text-button,
.quiet-button,
.secondary-button,
.primary-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 600;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.text-button,
.quiet-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.text-button {
  padding: 0 8px;
  white-space: nowrap;
}

.text-button:hover,
.quiet-button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.secondary-button {
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  border-color: #aeb8c7;
  background: var(--surface-soft);
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.18);
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-strong);
  border-color: var(--blue-strong);
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.wide {
  width: 100%;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.project-open .topbar-status {
  display: none;
}

.status-pill {
  padding: 6px 9px;
  border-radius: 6px;
  background: #f4f5f7;
  color: var(--muted);
  font-size: 12px;
}

.status-pill.ready {
  background: #eaf8ef;
  color: #287a45;
}

.save-state {
  font-size: 12px;
  color: var(--subtle);
}

.main {
  min-height: 0;
  overflow: hidden;
}

.welcome-view {
  width: min(1080px, calc(100% - 64px));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) 480px;
  gap: 88px;
  align-items: center;
}

.eyebrow {
  display: block;
  margin-bottom: 16px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.welcome-copy h1 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(42px, 4vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.welcome-copy p {
  max-width: 570px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
}

.import-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.import-tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 0 0 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.tab.active {
  border-bottom-color: var(--blue);
  color: var(--text);
}

.tab-pane {
  display: none;
  padding-top: 24px;
}

.tab-pane.active {
  display: block;
}

.drop-zone {
  min-height: 218px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  border: 1.5px dashed #b9c3d2;
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--muted);
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  color: var(--text);
  font-size: 16px;
}

.drop-zone span {
  font-size: 13px;
}

.tab-pane .primary-button {
  height: 46px;
}

.inline-status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.editor-view {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 168px;
  background: var(--surface);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.top-generate-button {
  min-width: 112px;
  padding: 0 20px;
}

.quiet-button {
  padding: 0 12px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  overflow: hidden;
}

.slides-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 18px 0 26px;
  border-right: 1px solid var(--line);
  background: #fcfdff;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.slide-list {
  min-height: 0;
  overflow-y: auto;
  padding: 2px 5px 24px 2px;
  scrollbar-width: thin;
  scrollbar-color: #c9d1dc transparent;
}

.slide-item {
  width: 100%;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 8px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.slide-item:hover {
  background: var(--surface-soft);
}

.slide-item.active {
  border-color: #bfd1ff;
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue);
}

.slide-thumb {
  width: 78px;
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--subtle);
  font-size: 10px;
}

.slide-item-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 5px;
  align-items: baseline;
}

.slide-number {
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
}

.slide-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #4c5565;
  font-size: 13px;
}

.script-panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 22px clamp(34px, 5vw, 82px) 56px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: #c9d1dc transparent;
}

.script-toolbar {
  max-width: 790px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slide-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.script-stats,
.writing-guide {
  color: var(--subtle);
  font-size: 12px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.preview-button,
.preview-stop-button {
  border: 1px solid #bfd1ff;
  border-radius: 7px;
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 650;
}

.preview-button {
  min-height: 34px;
  padding: 0 13px;
}

.preview-button:hover:not(:disabled) {
  border-color: #91adf5;
  background: #e3edff;
}

.preview-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.slide-preview-wrap {
  width: min(600px, 82%);
  margin: 0 auto 28px;
}

.preview-player {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #c9d8fb;
  border-radius: 8px;
  background: #f5f8ff;
}

.preview-player-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  color: #526079;
  font-size: 12px;
}

.preview-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #dfe7f7;
}

.preview-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.preview-stop-button {
  min-height: 30px;
  margin-top: 9px;
  padding: 0 10px;
  background: transparent;
}

.selected-slide-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: contain;
  border: 1px solid var(--line-strong);
  background: #fff;
  box-shadow: 0 7px 22px rgba(27, 38, 56, 0.08);
}

.narration-heading {
  max-width: 790px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 10px;
}

.narration-heading h3 {
  max-width: 620px;
  margin: 0 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  line-height: 1.3;
}

.narration-heading div > span {
  color: var(--muted);
  font-size: 13px;
}

.script-editor {
  width: min(790px, 100%);
  min-height: 220px;
  display: block;
  margin: 0 auto;
  padding: 20px 22px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  line-height: 1.9;
}

.script-editor:hover {
  border-color: #b6c0ce;
}

.script-editor:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(47, 109, 246, 0.12);
}

.source-details {
  width: min(790px, 100%);
  margin: 16px auto 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.source-details summary {
  padding: 15px 0;
  cursor: pointer;
  font-weight: 600;
}

.source-details pre {
  max-height: 220px;
  overflow: auto;
  margin: 0 0 16px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: #515b6b;
  font-family: inherit;
  line-height: 1.65;
  white-space: pre-wrap;
}

.tip-row {
  width: min(790px, 100%);
  margin: 4px auto 0;
  color: var(--subtle);
  font-size: 12px;
}

@media (min-width: 1380px) {
  .script-toolbar,
  .narration-heading,
  .script-editor,
  .source-details,
  .tip-row {
    margin-right: 0;
    margin-left: 80px;
  }

  .slide-preview-wrap {
    margin-right: 0;
    margin-left: 175px;
  }
}

.export-panel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(190px, 0.8fr) minmax(170px, 0.7fr) minmax(240px, 1.1fr) 190px;
  align-items: end;
  gap: 20px;
  padding: 15px 28px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -12px 30px rgba(28, 39, 57, 0.05);
  z-index: 10;
}

.editor-view:has(.voice-clone-panel[open]) {
  grid-template-rows: minmax(260px, 1fr) minmax(0, 46vh);
}

.editor-view:has(.voice-clone-panel[open]) .export-panel {
  align-items: start;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c9d1dc transparent;
}

.export-field {
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.text-input,
.select-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.text-input:hover,
.select-input:hover {
  border-color: #aeb8c7;
}

.range-input {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--blue);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: var(--subtle);
  font-size: 10px;
}

.generate-button {
  height: 46px;
  padding: 0 20px;
  white-space: nowrap;
}

.job-card {
  position: fixed;
  right: 28px;
  bottom: 112px;
  width: 390px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 30;
}

.job-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  font-size: 13px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9edf3;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 220ms ease;
}

.job-card p {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-top: 12px;
  padding: 0 16px;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.toast {
  position: fixed;
  top: 92px;
  left: 50%;
  z-index: 100;
  max-width: 520px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1e2430;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 1240px) {
  .topbar {
    grid-template-columns: 210px minmax(240px, 1fr) auto auto;
    gap: 14px;
    padding: 0 18px;
  }

  .save-state {
    display: none;
  }

  .editor-actions {
    gap: 6px;
  }

  .editor-actions .quiet-button {
    display: none;
  }

  .top-generate-button {
    min-width: 104px;
    padding: 0 14px;
  }

  .workspace {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .slides-panel {
    padding-left: 16px;
  }

  .slide-item {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .slide-thumb {
    width: 66px;
  }

  .script-panel {
    padding-right: 34px;
    padding-left: 34px;
  }

  .export-panel {
    grid-template-columns: 1.1fr 0.8fr 0.8fr 1fr 170px;
    gap: 12px;
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-height: 830px) {
  .editor-view {
    grid-template-rows: minmax(0, 1fr) 158px;
  }

  .script-panel {
    padding-top: 16px;
  }

  .slide-preview-wrap {
    width: min(540px, 78%);
    margin-bottom: 18px;
  }

  .script-editor {
    min-height: 180px;
  }
}

@media (max-width: 1100px) {
  body {
    min-width: 760px;
  }

  .editor-view {
    grid-template-rows: minmax(260px, 1fr) minmax(0, 42vh);
  }

  .export-panel {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    align-items: start;
    overflow-y: auto;
    gap: 16px 20px;
    padding-bottom: 24px;
    scrollbar-width: thin;
    scrollbar-color: #c9d1dc transparent;
  }

  .generate-button {
    align-self: end;
  }

  .job-card {
    bottom: 24px;
  }
}

@media (max-width: 820px) {
  body,
  .app-shell {
    min-width: 0;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .brand,
  .project-meta,
  .editor-actions {
    display: none;
  }

  .workspace {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .export-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Editor operation rail: keep every export control accessible beside the deck. */
.editor-view,
.editor-view:has(.voice-clone-panel[open]) {
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr);
}

.workspace {
  grid-column: 1;
  grid-row: 1;
}

.export-panel,
.editor-view:has(.voice-clone-panel[open]) .export-panel {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px 20px 28px;
  border-top: 0;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 30px rgba(28, 39, 57, 0.05);
  scrollbar-width: thin;
  scrollbar-color: #c9d1dc transparent;
}

.export-panel .generate-button {
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex: 0 0 auto;
  width: 100%;
  margin-top: 2px;
  box-shadow: 0 -8px 18px rgba(255, 255, 255, 0.92);
}

.export-panel .job-card {
  right: 20px;
  bottom: 20px;
  width: 320px;
}

@media (max-width: 1240px) {
  .editor-view,
  .editor-view:has(.voice-clone-panel[open]) {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: minmax(0, 1fr);
  }

  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .export-panel,
  .editor-view:has(.voice-clone-panel[open]) .export-panel {
    display: flex;
    padding: 18px 16px 24px;
  }
}

@media (max-width: 900px) {
  .editor-view,
  .editor-view:has(.voice-clone-panel[open]) {
    grid-template-columns: minmax(0, 1fr) 290px;
  }

  .workspace {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .slides-panel {
    padding-right: 10px;
    padding-left: 10px;
  }

  .script-panel {
    padding-right: 20px;
    padding-left: 20px;
  }
}
