:root {
  color-scheme: light;
  --background: #f4f5f3;
  --surface: #ffffff;
  --surface-soft: #f8f9f7;
  --surface-strong: #ecefec;
  --text: #19211e;
  --text-muted: #56625c;
  --text-subtle: #77817c;
  --border: #dce1dd;
  --border-strong: #c4ccc6;
  --primary: #c74730;
  --primary-hover: #ad3824;
  --primary-soft: #fff0eb;
  --success: #087568;
  --success-soft: #e8f5f2;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --focus: #176b5f;
  --shadow: 0 18px 46px rgb(25 33 30 / 8%), 0 2px 8px rgb(25 33 30 / 5%);
  --radius: 8px;
  --transition: 180ms ease-out;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button,
label,
summary,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

img {
  display: block;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 4px;
  background: var(--text);
  color: #fff;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.failure-guidance {
  display: grid;
  min-width: 0;
  gap: 12px;
  color: var(--text);
}

.failure-guidance-summary {
  margin: 0;
  color: var(--text);
  font-weight: 650;
  line-height: 1.55;
}

.failure-guidance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid color-mix(in srgb, var(--danger) 18%, var(--border));
}

.failure-guidance-item {
  min-width: 0;
  padding: 12px 16px 12px 0;
}

.failure-guidance-item + .failure-guidance-item {
  padding-left: 16px;
  border-left: 1px solid color-mix(in srgb, var(--danger) 18%, var(--border));
}

.failure-guidance-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-subtle);
  font-size: 0.75rem;
  font-weight: 700;
}

.failure-guidance-item p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.failure-guidance-item.is-caution p {
  color: var(--danger);
  font-weight: 650;
}

.failure-guidance-technical {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.failure-guidance-technical summary {
  width: fit-content;
  min-height: 44px;
  padding-block: 11px;
  cursor: pointer;
  font-weight: 650;
}

.failure-guidance-technical pre {
  max-width: 100%;
  margin: 4px 0 0;
  padding: 12px;
  overflow: auto;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger-soft) 55%, var(--surface));
  color: var(--text-muted);
  font: 0.76rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.failure-guidance.is-compact {
  gap: 10px;
}

.failure-guidance.is-compact .failure-guidance-grid {
  grid-template-columns: minmax(0, 1fr);
}

.failure-guidance.is-compact .failure-guidance-item {
  padding: 9px 0;
}

.failure-guidance.is-compact .failure-guidance-item + .failure-guidance-item {
  padding-left: 0;
  border-top: 1px solid color-mix(in srgb, var(--danger) 14%, var(--border));
  border-left: 0;
}

.task-history-recovery {
  display: block;
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .failure-guidance-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .failure-guidance-item {
    padding: 10px 0;
  }

  .failure-guidance-item + .failure-guidance-item {
    padding-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--danger) 14%, var(--border));
    border-left: 0;
  }

  .generation-dialog.is-error {
    padding: 20px 16px;
  }

  .generation-dialog.is-error .generation-orbit {
    width: 40px;
    height: 40px;
    margin-bottom: 6px;
  }

  .generation-dialog.is-error .generation-orbit span {
    left: 14px;
    transform-origin: 5px 24px;
  }

  .generation-dialog.is-error .generation-pipeline {
    margin: 12px 0 14px;
  }

  .generation-dialog.is-error .generation-progress-heading,
  .generation-dialog.is-error > progress {
    display: none;
  }

  .generation-dialog.is-error .generation-dialog-error,
  .generation-dialog.is-error .generation-dialog-actions {
    margin-top: 12px;
  }

  .generation-dialog.is-error .generation-dialog-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  min-height: 68px;
  max-width: 1504px;
  margin: 0 auto;
  padding: 0 32px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark,
.section-icon,
.preview-play {
  display: inline-grid;
  place-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--text);
}

.brand-mark img {
  width: 19px;
  filter: invert(1);
}

.header-actions,
.restart-button {
  display: inline-flex;
  align-items: center;
}

.header-actions {
  gap: 10px;
}

.restart-button {
  min-height: 44px;
  padding: 8px 13px;
  gap: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}

.restart-button:hover {
  border-color: var(--text-muted);
  background: var(--surface-soft);
}

.restart-button img {
  width: 16px;
}

.restart-button[hidden] {
  display: none;
}

.mode-badge,
.status-label,
.format-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
}

.mode-badge {
  min-height: 32px;
  padding: 5px 11px;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
}

.mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa39e;
}

.mode-badge.live .mode-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.mode-badge.unconfigured .mode-dot {
  background: #c26b18;
  box-shadow: 0 0 0 3px #fff3df;
}

.workspace {
  display: grid;
  max-width: 1504px;
  margin: 0 auto;
  padding: 32px 32px 80px;
  grid-template-columns: minmax(0, 1fr) minmax(460px, 520px);
  gap: 32px;
  align-items: start;
}

.editor {
  min-width: 0;
}

.page-heading {
  max-width: 760px;
  margin-bottom: 28px;
}

.eyebrow,
.section-step {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 7px 0 8px;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-heading > p:last-child {
  margin: 0;
  color: var(--text-muted);
  font-size: 16px;
}

.workflow-steps {
  display: grid;
  margin: 0 0 28px;
  padding: 5px;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.workflow-steps li {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 60px;
  padding: 9px 7px;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  color: var(--text-subtle);
}

.workflow-steps li + li::before {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 1px;
  background: var(--border);
  content: "";
}

.workflow-steps span {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.workflow-steps strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-steps li.current {
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
}

.workflow-steps li.complete {
  color: var(--success);
}

.workflow-steps li.skipped {
  color: var(--text-subtle);
  opacity: 0.58;
}

.form-section {
  padding: 26px 0 30px;
  border-top: 1px solid var(--border);
}

.section-heading {
  display: flex;
  margin-bottom: 18px;
  align-items: center;
  gap: 12px;
}

.section-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.section-icon img {
  width: 19px;
  opacity: 0.75;
}

.section-heading h2,
.preview-heading h2 {
  margin: 1px 0 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

.material-subsection {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.material-subheading {
  display: flex;
  margin-bottom: 14px;
  align-items: center;
  gap: 12px;
}

.material-subheading .section-icon {
  flex-basis: 36px;
  width: 36px;
  height: 36px;
  background: var(--surface-soft);
}

.material-subheading h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
}

.material-subheading h3 span {
  margin-left: 5px;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 600;
}

.material-subheading p {
  margin: 2px 0 0;
  color: var(--text-subtle);
  font-size: 13px;
}

.scene-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.compact-dropzone {
  min-height: 112px;
  padding: 16px;
}

.compact-dropzone.disabled {
  cursor: not-allowed;
  border-style: solid;
  background: var(--surface-soft);
  opacity: 0.54;
}

.compact-dropzone.disabled:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.compact-dropzone.has-selection {
  border-color: #8dbcb4;
  background: var(--success-soft);
}

.scene-requirements-field {
  margin-top: 14px;
}

.dropzone {
  display: flex;
  min-height: 132px;
  padding: 24px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone.has-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.dropzone[hidden] {
  display: none;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.dropzone:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.dropzone-icon {
  width: 27px;
  margin-bottom: 3px;
  opacity: 0.67;
}

.dropzone-title {
  font-weight: 700;
}

.dropzone-meta {
  color: var(--text-subtle);
  font-size: 13px;
  text-align: center;
}

.image-list {
  display: grid;
  margin-top: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.image-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.image-preview-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  cursor: zoom-in;
  border: 0;
  background: transparent;
}

.image-preview-button > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 160ms ease;
}

.image-preview-button:hover > img {
  transform: scale(1.02);
}

.image-preview-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.image-kind-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  min-height: 24px;
  padding: 3px 7px;
  align-items: center;
  border: 1px solid rgb(255 255 255 / 42%);
  border-radius: 4px;
  background: rgb(23 32 28 / 82%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  z-index: 1;
}

.remove-image {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(29 36 33 / 82%);
  z-index: 2;
}

.remove-image img {
  width: 17px;
  filter: invert(1);
}

.image-lightbox {
  width: min(1080px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 6px;
  background: #111513;
  color: #fff;
  box-shadow: 0 24px 80px rgb(0 0 0 / 38%);
}

.image-lightbox::backdrop {
  background: rgb(10 13 12 / 82%);
  backdrop-filter: blur(3px);
}

.image-lightbox-header {
  display: flex;
  min-height: 56px;
  padding: 6px 8px 6px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgb(255 255 255 / 12%);
}

.image-lightbox-header strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-lightbox-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.image-lightbox-close,
.image-lightbox-download {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 10%);
}

.image-lightbox-close:hover,
.image-lightbox-download:hover {
  background: rgb(255 255 255 / 18%);
}

.image-lightbox-close img,
.image-lightbox-download img {
  width: 18px;
  filter: invert(1);
}

.image-lightbox-close:focus-visible,
.image-lightbox-download:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.image-lightbox-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 90px);
  object-fit: contain;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.field label span {
  color: var(--danger);
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field input:hover,
.field textarea:hover {
  border-color: #909c94;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--focus);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(23 107 95 / 15%);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  min-height: 0;
  margin-top: 5px;
  color: var(--danger);
  font-size: 13px;
}

.field-error:not(:empty) {
  min-height: 20px;
}

.story-options {
  display: grid;
  margin: 0;
  padding: 4px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.story-option {
  position: relative;
  display: flex;
  min-height: 76px;
  padding: 12px 28px 12px 10px;
  cursor: pointer;
  justify-content: center;
  flex-direction: column;
  border: 1px solid transparent;
  border-radius: 5px;
  text-align: center;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.story-option:hover {
  background: rgb(255 255 255 / 62%);
}

.story-option:has(input:checked) {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgb(189 70 46 / 12%), 0 1px 4px rgb(26 39 32 / 7%);
}

.story-option::before,
.story-option::after {
  box-sizing: border-box;
  position: absolute;
  top: 10px;
  right: 9px;
  border-radius: 50%;
  content: "";
}

.story-option::before {
  width: 15px;
  height: 15px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.story-option::after {
  width: 7px;
  height: 7px;
  margin: 4px;
  transform: scale(0);
  background: var(--primary);
  transition: transform var(--transition);
}

.story-option:has(input:checked)::before {
  border-color: var(--primary);
}

.story-option:has(input:checked)::after {
  transform: scale(1);
}

.story-option input {
  position: absolute;
  opacity: 0;
}

.story-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.story-option span {
  font-size: 14px;
  font-weight: 700;
}

.story-option small {
  margin-top: 3px;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.35;
}

.story-options.locked .story-option {
  cursor: default;
}

.story-options.locked .story-option:not(:has(input:checked)) {
  opacity: 0.48;
}

.story-lock-note {
  display: flex;
  margin: 9px 0 0;
  align-items: center;
  gap: 6px;
  color: var(--text-subtle);
  font-size: 13px;
}

.story-lock-note[hidden] {
  display: none;
}

.story-lock-note img {
  width: 14px;
}

.custom-plot-field {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.custom-plot-field[hidden] {
  display: none;
}

.creative-video-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.creative-video-tabs button {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-subtle);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.creative-video-tabs button[aria-selected="true"] {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.creative-video-tabs button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -3px;
}

.creative-video-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.creative-video-actions .secondary-button {
  width: auto;
  min-height: 44px;
  max-width: 100%;
}

.creative-video-actions input[hidden],
#creativeManualPanel[hidden],
#creativeVideoPanel[hidden],
.creative-video-result[hidden],
.creative-video-progress[hidden],
.creative-video-preview[hidden],
.creative-video-status[hidden],
.creative-video-notes[hidden] {
  display: none;
}

.creative-video-status {
  margin: 14px 0 8px;
  color: var(--text-subtle);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.creative-video-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--text-subtle);
}

.creative-video-progress li {
  padding-top: 8px;
  border-top: 3px solid var(--border);
}

.creative-video-progress .is-current,
.creative-video-progress .is-complete {
  border-top-color: var(--primary);
  color: var(--primary);
}

.creative-video-result {
  min-width: 0;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.creative-video-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

.creative-video-heading span {
  color: var(--text-subtle);
  font-size: 12px;
}

.creative-video-preview {
  display: block;
  width: 100%;
  max-height: 340px;
  aspect-ratio: 16 / 9;
  margin-bottom: 14px;
  background: #171c19;
  object-fit: contain;
}

.creative-video-story {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.7;
}

.creative-video-notes {
  margin-top: 14px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.creative-video-notes ul {
  margin: 6px 0 0;
  padding-left: 20px;
  color: var(--text-subtle);
  line-height: 1.65;
}

.creative-video-adopted {
  color: var(--primary);
  font-size: 13px;
}

@media (max-width: 480px) {
  .creative-video-tabs button {
    padding-right: 10px;
    padding-left: 10px;
    font-size: 13px;
  }

  .creative-video-actions {
    gap: 8px;
  }

  .creative-video-actions .secondary-button {
    padding-right: 10px;
    padding-left: 10px;
    font-size: 12px;
  }
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-label-row > span,
.custom-plot-field > small,
.custom-story-review .compact-field > small {
  color: var(--text-subtle);
  font-size: 12px;
}

.custom-plot-field > small,
.custom-story-review .compact-field > small {
  display: block;
  margin-top: 6px;
  line-height: 1.45;
}

.advanced-settings,
.prompt-details {
  margin-top: 14px;
  border-top: 1px solid var(--border);
}

.advanced-settings summary,
.prompt-details summary {
  display: flex;
  min-height: 48px;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 650;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary img,
.prompt-details summary img {
  width: 18px;
  transition: transform var(--transition);
}

details[open] > summary img {
  transform: rotate(180deg);
}

.advanced-content {
  padding: 6px 0 4px;
}

.duration-setting {
  display: flex;
  margin: 16px 0 0;
  padding: 16px 0 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  border-top: 1px solid var(--border);
}

.duration-setting legend {
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
}

.duration-options {
  display: grid;
  width: 168px;
  padding: 3px;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.duration-options label {
  position: relative;
  cursor: pointer;
}

.duration-options input {
  position: absolute;
  opacity: 0;
}

.duration-options span {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.duration-options input:checked + span {
  border-color: var(--border);
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgb(26 39 32 / 7%);
}

.duration-options input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.spec-list {
  display: flex;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.spec-list span {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
}

.toggle-row {
  display: flex;
  min-height: 64px;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--border);
}

.toggle-row > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.toggle-row strong {
  font-size: 14px;
}

.toggle-row small {
  color: var(--text-subtle);
  font-size: 12px;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
}

.toggle {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #aeb7b1;
  transition: background var(--transition);
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 20%);
  content: "";
  transition: transform var(--transition);
}

.toggle-row input:checked + .toggle {
  background: var(--success);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(20px);
}

.toggle-row input:focus-visible + .toggle {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.form-message {
  display: none;
  margin-bottom: 12px;
  padding: 11px 13px;
  border: 1px solid #efc4bd;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.locked-material-note {
  display: flex;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 13px;
}

.locked-material-note[hidden] {
  display: none;
}

.form-message:not(:empty) {
  display: block;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 50px;
  padding: 0 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 6px;
  font-weight: 750;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.primary-button {
  width: 100%;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgb(189 70 46 / 18%);
}

.primary-button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.primary-button:not(:disabled):hover {
  box-shadow: 0 10px 24px rgb(189 70 46 / 22%);
}

.primary-button:active,
.secondary-button:active {
  opacity: 0.82;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.48;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button img,
.secondary-button img {
  width: 19px;
}

.primary-button img {
  filter: invert(1);
}

.preview-panel {
  position: static;
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overview-layout,
.overview-details {
  min-width: 0;
}

.review-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.review-section[hidden],
.three-view-block[hidden],
.review-section button[hidden] {
  display: none;
}

.review-heading,
.asset-label {
  display: flex;
  margin-bottom: 12px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-heading > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.review-heading strong {
  font-size: 16px;
}

.review-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
}

.compact-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.analysis-summary {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.story-profile-meta {
  display: grid;
  margin: 0;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.story-profile-meta > div {
  padding: 9px 0;
}

.story-profile-meta > div + div {
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.story-profile-meta dt {
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 700;
}

.story-profile-meta dd {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.story-structure-summary {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.story-review-warning {
  display: grid;
  margin-bottom: 14px;
  padding: 12px;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  border-left: 3px solid var(--danger);
  background: #fff4f2;
  color: #7f2d22;
}

.story-review-warning[hidden] {
  display: none;
}

.story-review-warning > img {
  width: 18px;
  margin-top: 1px;
}

.story-review-warning strong {
  font-size: 13px;
}

.story-review-warning ul {
  margin: 5px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.55;
}

.custom-story-review .story-review-warning {
  border-color: #f0d79a;
  border-left-color: #d99016;
  background: #fff9e8;
  color: #6f4d12;
}

.scene-review {
  position: relative;
}

.scene-review::before {
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: -24px;
  width: 3px;
  background: var(--success);
  content: "";
}

.scene-board-block > img {
  aspect-ratio: 1;
}

.placement-analysis {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.placement-analysis[hidden] {
  display: none;
}

.placement-meta {
  margin-top: 12px;
}

.scene-asset-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.scene-asset-comparison > :only-child {
  grid-column: 1 / -1;
}

.scene-asset-comparison:not(:has(.placement-source-block:not([hidden]))) .scene-board-block {
  grid-column: 1 / -1;
}

.placement-source-block > img,
.placement-source-block .review-image-preview > img {
  aspect-ratio: 1;
}

.replace-scene-details {
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.replace-scene-details summary {
  display: flex;
  min-height: 48px;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}

.replace-scene-details summary img {
  width: 16px;
}

.replace-scene-fields {
  display: grid;
  padding: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.replace-scene-fields label {
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.replace-scene-fields input {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.replace-scene-fields .secondary-button {
  grid-column: 1 / -1;
  min-height: 44px;
}

.single-upload-field {
  grid-template-columns: 1fr;
}

.video-confirmation-layout {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(0, 1.7fr);
  align-items: start;
  gap: 16px;
}

.video-confirmation-layout > div {
  min-width: 0;
}

.final-placement-reference img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  object-fit: contain;
}

.text-action {
  display: inline-flex;
  min-height: 44px;
  margin-top: 8px;
  padding: 8px 0;
  cursor: pointer;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.text-action:hover {
  text-decoration: underline;
}

.danger-action {
  color: var(--danger);
}

.custom-story-review .compact-field textarea {
  min-height: 168px;
  resize: vertical;
}

.custom-story-meta {
  display: grid;
  margin: 14px 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.custom-story-meta > div {
  min-width: 0;
  padding: 9px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.custom-story-meta dt {
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 700;
}

.custom-story-meta dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.story-plan-block {
  margin-top: 12px;
}

.story-plan-block > strong {
  font-size: 12px;
}

.story-plan-block ul {
  display: grid;
  margin: 7px 0 0;
  padding: 0;
  gap: 7px;
  list-style: none;
}

.story-plan-block li,
.story-plan-block p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.story-plan-block li strong {
  color: var(--text);
  font-size: 13px;
}

.custom-story-review > .primary-button {
  margin-top: 16px;
}

.analysis-features {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 7px;
  list-style: none;
}

.analysis-features li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.analysis-features span {
  padding: 2px 4px;
  border-radius: 3px;
  background: var(--surface-soft);
  color: var(--text-subtle);
  font-size: 11px;
  text-align: center;
}

.analysis-features p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.three-view-block {
  margin-top: 16px;
}

.asset-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}

.asset-label small {
  color: var(--text-subtle);
  font-weight: 500;
}

.three-view-block > img,
.review-image-preview > img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8f9f7;
  object-fit: contain;
}

.review-image-preview {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.generated-image-shell,
.keyframe-focus {
  position: relative;
}

.generated-image-download-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 50%;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 5px 18px rgb(0 0 0 / 18%);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.generated-image-download-button:hover {
  background: #fff;
  box-shadow: 0 7px 22px rgb(0 0 0 / 24%);
  transform: translateY(-1px);
}

.generated-image-download-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.generated-image-download-button img {
  width: 19px;
  height: 19px;
}

.review-image-preview:focus-visible,
.product-preview-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.hook-fieldset {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.hook-fieldset legend {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.hook-options {
  display: grid;
  gap: 8px;
}

.hook-option {
  display: grid;
  min-height: 54px;
  padding: 9px 10px;
  cursor: pointer;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.hook-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.hook-option input {
  margin: 3px 0 0;
  accent-color: var(--primary);
}

.hook-option span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.hook-option strong {
  font-size: 13px;
}

.hook-option small {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.compact-field {
  margin-bottom: 12px;
}

.compact-field label {
  font-size: 12px;
}

.script-beats-editor {
  display: grid;
  margin: 14px 0;
  gap: 10px;
}

.script-beat-editor {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.script-beat-editor > div {
  display: flex;
  margin-bottom: 10px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.script-beat-editor > div span {
  color: var(--primary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.script-beat-editor > div strong {
  font-size: 13px;
}

.script-beat-editor label {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.script-beat-editor input,
.script-beat-editor textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
  padding: 8px 9px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.script-beat-editor input:disabled,
.script-beat-editor textarea:disabled,
.compact-field input:disabled {
  color: var(--text-muted);
  opacity: 0.8;
}

.keyframe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.keyframe-item {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.keyframe-item.current {
  border-color: var(--primary);
}

.keyframe-item.confirmed {
  border-color: #8dbcb4;
}

.keyframe-item.scene-warning {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px rgb(180 35 24 / 12%);
}

.keyframe-item.scene-warning figcaption small {
  color: var(--danger);
  font-weight: 700;
}

.keyframe-item.scene-accepted {
  border-color: #c88a35;
}

.keyframe-item.scene-accepted figcaption small {
  color: #8a5617;
  font-weight: 700;
}

.keyframe-preview-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  border: 0;
  background: #eef0ed;
}

.keyframe-preview-button > img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #eef0ed;
  object-fit: cover;
  transition: transform 160ms ease;
}

.keyframe-preview-button:hover > img {
  transform: scale(1.02);
}

.keyframe-preview-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.keyframe-item figcaption {
  display: grid;
  min-height: 48px;
  padding: 7px 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 6px;
  align-items: center;
}

.keyframe-item figcaption span {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.keyframe-item figcaption small {
  color: var(--text-subtle);
  font-size: 11px;
}

.keyframe-redo {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  grid-row: 1 / 3;
  grid-column: 2;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
}

.keyframe-redo:hover {
  background: var(--surface-strong);
}

.keyframe-redo img {
  width: 16px;
}

.review-actions {
  display: grid;
  margin-top: 12px;
  grid-template-columns: 1fr 1.45fr;
  gap: 8px;
}

.review-actions .primary-button,
.review-actions .secondary-button {
  min-height: 46px;
  padding: 0 12px;
  font-size: 12px;
}

.review-actions > :only-child {
  grid-column: 1 / -1;
}

.review-actions:has(#confirmSceneButton:not([hidden])):not(:has(#regenerateSceneButton:not([hidden]))) #confirmSceneButton {
  grid-column: 1 / -1;
}

.preview-heading {
  display: flex;
  margin-bottom: 18px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-label {
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
}

.task-notice {
  display: grid;
  margin: 0 0 18px;
  padding: 14px;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 11px;
  border: 1px solid #efc4bd;
  border-radius: 7px;
  background: var(--danger-soft);
  color: var(--danger);
}

.task-notice[hidden] {
  display: none;
}

.task-notice > img {
  width: 21px;
  margin-top: 1px;
  filter: invert(22%) sepia(70%) saturate(2827%) hue-rotate(350deg) brightness(82%) contrast(91%);
}

.task-notice strong {
  font-size: 14px;
}

.task-notice p {
  margin: 3px 0 0;
  color: #7f261f;
  font-size: 13px;
  line-height: 1.55;
}

.task-notice details {
  margin-top: 8px;
  border-top: 1px solid #efc4bd;
}

.task-notice summary {
  display: flex;
  min-height: 42px;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  color: #7f261f;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}

.task-notice summary img {
  width: 16px;
  transition: transform var(--transition);
}

.task-notice pre {
  max-height: 132px;
  margin: 0 0 4px;
  padding: 10px;
  overflow: auto;
  border-radius: 5px;
  background: rgb(255 255 255 / 65%);
  color: #69231e;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-notice-action {
  display: inline-flex;
  min-height: 44px;
  margin-top: 10px;
  padding: 8px 12px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #d69b91;
  border-radius: 6px;
  background: var(--surface);
  color: #7f261f;
  font-size: 13px;
  font-weight: 750;
}

.task-notice-action:hover {
  border-color: var(--danger);
  background: #fff9f8;
}

.task-notice-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

.task-notice-action[hidden] {
  display: none;
}

.task-notice-action img {
  width: 16px;
}

.status-label.success {
  background: var(--success-soft);
  color: var(--success);
}

.status-label.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.video-stage {
  position: relative;
  overflow: hidden;
  width: min(100%, 300px);
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  border: 1px solid #cbd2cd;
  border-radius: 8px;
  background: #eef0ed;
}

.empty-preview,
.progress-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
}

.empty-preview strong {
  margin-top: 7px;
  color: var(--text);
}

.empty-preview > span:last-child {
  font-size: 13px;
}

.preview-play {
  width: 52px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
}

.preview-play img {
  width: 21px;
  margin-left: 3px;
  opacity: 0.62;
}

.product-preview-button,
.product-preview,
.video-stage video {
  width: 100%;
  height: 100%;
  background: #f8f9f7;
  object-fit: contain;
}

.product-preview-button {
  display: block;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  border: 0;
}

.product-preview-button:focus-visible {
  outline-offset: -3px;
}

.video-stage video {
  object-fit: cover;
}

.progress-overlay {
  z-index: 4;
  background: rgb(245 247 244 / 94%);
}

.progress-overlay[hidden],
.empty-preview[hidden],
.product-preview-button[hidden],
.video-stage video[hidden],
.result-actions[hidden],
.prompt-details[hidden],
.toast[hidden] {
  display: none;
}

.spinner {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

.progress-overlay > span:last-child {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.format-badge {
  position: absolute;
  z-index: 5;
  top: 10px;
  right: 10px;
  min-height: 25px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgb(29 36 33 / 76%);
  color: #fff;
}

.three-view-review {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.three-view-review[hidden],
#confirmViewsButton[hidden] {
  display: none;
}

.three-view-heading {
  display: flex;
  margin-bottom: 10px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.three-view-heading span {
  color: var(--text-subtle);
  font-size: 12px;
}

.three-view-review > img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8f9f7;
  object-fit: contain;
}

.three-view-review .primary-button {
  min-height: 46px;
  margin-top: 12px;
}

.result-summary {
  display: flex;
  margin: 16px 0 4px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.result-summary > span {
  color: var(--text-muted);
  text-align: right;
  line-height: 1.45;
}

.story-beats {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.story-beats li {
  display: grid;
  min-height: 54px;
  padding: 9px 0;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border-top: 1px solid var(--border);
}

.story-beats li > span {
  color: var(--primary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.story-beats li div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.story-beats strong {
  font-size: 13px;
}

.story-beats small {
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.45;
}

.result-actions {
  margin-top: 14px;
}

.secondary-button {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--text-muted);
  background: var(--surface-soft);
}

.viewing-task .editor input:disabled,
.viewing-task .editor textarea:disabled {
  cursor: default;
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text);
  opacity: 1;
}

.viewing-task .workspace {
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
}

.viewing-task .page-heading {
  margin-bottom: 18px;
}

.viewing-task .page-heading h1 {
  font-size: 30px;
}

.viewing-task .workflow-steps {
  margin-bottom: 16px;
}

.viewing-task .workflow-steps li {
  min-height: 52px;
  padding-block: 7px;
}

.viewing-task .form-section {
  padding: 18px 0 20px;
}

.viewing-task .section-heading {
  margin-bottom: 12px;
}

.viewing-task .section-icon {
  flex-basis: 36px;
  width: 36px;
  height: 36px;
}

.viewing-task #generateButton {
  display: none;
}

.viewing-task .workflow-steps {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.viewing-task .story-options {
  padding: 0;
  grid-template-columns: 1fr;
  border: 0;
  background: transparent;
}

.viewing-task.task-assets-cleaned .story-option:not(:has(input:checked)) {
  display: none;
}

.viewing-task .story-option {
  min-height: 56px;
  padding: 9px 36px 9px 12px;
  justify-content: center;
  border-color: var(--border);
  background: var(--surface);
  text-align: left;
}

.viewing-task .story-option::before,
.viewing-task .story-option::after {
  top: 19px;
  right: 12px;
}

.viewing-task .workflow-steps li:nth-child(n + 5) {
  border-top: 1px solid var(--border);
}

.viewing-task .workflow-steps li:nth-child(5)::before {
  display: none;
}

.viewing-task .script-beats-editor {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.viewing-task .keyframe-grid {
  grid-template-columns: repeat(var(--keyframe-columns, 4), minmax(0, 1fr));
}

.viewing-task.task-assets-cleaned .editor .story-option,
.viewing-task.task-assets-cleaned .editor .duration-options label,
.viewing-task.task-assets-cleaned .editor .toggle-row {
  cursor: default;
}

.viewing-task.task-assets-cleaned .editor .toggle-row input:not(:checked) + .toggle {
  opacity: 0.6;
}

.task-source-image {
  background: var(--surface-soft);
}

.prompt-details pre {
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

@media (min-width: 921px) {
  body:not(.viewing-task) .preview-panel {
    position: sticky;
    top: 92px;
    max-height: calc(100dvh - 112px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
  }
}

@media (min-width: 1181px) {
  .viewing-task .overview-layout {
    display: grid;
    padding-bottom: 22px;
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    border-bottom: 1px solid var(--border);
  }

  .viewing-task .overview-layout > .video-stage {
    width: 100%;
    margin: 0;
  }

  .viewing-task .overview-details .review-section {
    padding: 18px 0;
  }

  .viewing-task .overview-details .review-section:first-child {
    padding-top: 0;
  }

  .viewing-task .overview-details .review-section:last-child {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .viewing-task .three-view-block {
    margin-top: 12px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 24px;
  }

  .story-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viewing-task .script-beats-editor {
    grid-template-columns: 1fr;
  }

  .viewing-task .keyframe-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .header-inner {
    padding: 0 20px;
  }

  .workspace {
    padding: 32px 20px 64px;
    grid-template-columns: 1fr;
  }

  .viewing-task .workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
    grid-row: 2;
  }

  .overview-details .review-section:first-child {
    margin-top: 4px;
  }

  .viewing-task .preview-panel {
    grid-row: 1;
  }

  .viewing-task .editor {
    grid-row: 2;
  }

  .workflow-steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workflow-steps li:nth-child(5) {
    border-top: 1px solid var(--border);
  }

  .workflow-steps li:nth-child(n + 6) {
    border-top: 1px solid var(--border);
  }

  .workflow-steps li:nth-child(5)::before {
    display: none;
  }

  .scene-review::before {
    left: -20px;
  }
}

@media (max-width: 700px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding: 0 16px;
  }

  .mode-badge {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .viewing-task .mode-badge {
    display: none;
  }

  .workspace {
    padding: 24px 16px 48px;
    gap: 24px;
  }

  .page-heading {
    margin-bottom: 24px;
  }

  .page-heading h1 {
    font-size: 28px;
  }

  .page-heading > p:last-child {
    font-size: 16px;
  }

  .form-section {
    padding: 24px 0 28px;
  }

  .image-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-upload-grid,
  .replace-scene-fields,
  .scene-asset-comparison,
  .video-confirmation-layout {
    grid-template-columns: 1fr;
  }

  .replace-scene-fields .secondary-button {
    grid-column: auto;
  }

  .material-subheading {
    align-items: flex-start;
  }

  .story-options {
    grid-template-columns: 1fr 1fr;
  }

  .story-option {
    min-height: 82px;
  }

  .viewing-task .story-option {
    min-height: 56px;
  }

  .preview-panel {
    padding: 16px;
  }

  .workflow-steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workflow-steps li:nth-child(n + 5) {
    border-top: 1px solid var(--border);
  }

  .workflow-steps li:nth-child(5)::before {
    display: none;
  }

  .workflow-steps li {
    min-height: 54px;
    padding-inline: 4px;
  }

  .workflow-steps strong {
    font-size: 11px;
  }

  .review-actions {
    grid-template-columns: 1fr;
  }

  .scene-review::before {
    left: -16px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* 2026 visual refinement: quiet production workspace */
.app-header {
  border-bottom-color: rgb(25 33 30 / 9%);
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 1px 0 rgb(255 255 255 / 70%);
}

.header-inner {
  min-height: 64px;
  width: min(100%, 1320px);
  padding-inline: 36px;
}

.brand {
  gap: 11px;
  font-size: 17px;
  letter-spacing: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--text);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%);
}

.brand-mark img {
  width: 17px;
}

.restart-button {
  min-height: 40px;
  padding-inline: 12px;
  border-color: var(--border);
  background: rgb(255 255 255 / 72%);
}

.mode-badge {
  min-height: 30px;
  border-color: transparent;
  background: var(--surface-soft);
  font-size: 12px;
}

.workspace,
.viewing-task .workspace {
  width: min(100%, 1248px);
  max-width: 1248px;
  padding: 38px 36px 112px;
}

.wizard-heading-row {
  min-height: 80px;
  margin-bottom: 22px;
  align-items: flex-start;
}

.wizard-heading-row .page-heading,
.viewing-task .wizard-heading-row .page-heading {
  max-width: 760px;
}

.wizard-heading-row .page-heading h1,
.viewing-task .wizard-heading-row .page-heading h1 {
  margin: 5px 0 7px;
  font-size: clamp(30px, 3vw, 36px);
  line-height: 1.16;
  font-weight: 780;
}

.page-heading > p:last-child {
  max-width: 660px;
  color: var(--text-muted);
  font-size: 15px;
}

.eyebrow,
.section-step,
.review-kicker {
  letter-spacing: .02em;
}

.wizard-heading-row > .status-label {
  margin-top: 6px;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid transparent;
  font-size: 12px;
}

/* A connected stepper gives progress hierarchy without reading as a table. */
.workflow-steps,
.viewing-task .workflow-steps {
  overflow: visible;
  margin: 0 0 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.workflow-steps li,
.viewing-task .workflow-steps li {
  min-height: 62px;
}

.workflow-steps li + li::before,
.workflow-steps li:nth-child(5)::before,
.viewing-task .workflow-steps li:nth-child(5)::before {
  z-index: 0;
  top: 16px;
  bottom: auto;
  left: -50%;
  width: 100%;
  height: 1px;
  background: var(--border-strong);
}

.workflow-steps button {
  position: relative;
  z-index: 1;
  min-height: 62px;
  padding: 0 8px;
  flex-direction: column;
  gap: 7px;
}

.workflow-steps button:hover:not(:disabled),
.workflow-steps li.current button {
  background: transparent;
}

.workflow-steps span,
.viewing-task .workflow-steps span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--background);
  color: var(--text-subtle);
  font-size: 11px;
  box-shadow: 0 0 0 6px var(--background);
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
}

.workflow-steps strong,
.viewing-task .workflow-steps strong {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.workflow-steps button:hover:not(:disabled) span {
  transform: translateY(-1px);
  border-color: var(--text-muted);
}

.workflow-steps li.current span {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.workflow-steps li.current strong {
  color: var(--primary-hover);
}

.workflow-steps li.complete span {
  border-color: #83b6ac;
  background: var(--success-soft);
  color: var(--success);
}

.workflow-steps li.complete strong {
  color: var(--success);
}

.workflow-steps li.locked button {
  opacity: 1;
}

.workflow-steps li.locked span,
.workflow-steps li.locked strong {
  color: #a3aaa6;
}

.workflow-steps li.locked span {
  border-color: #d8ddda;
}

.step-view-product {
  width: min(100%, 840px);
}

.step-view-creative {
  width: min(100%, 960px);
}

.step-view-script {
  width: min(100%, 1000px);
}

.step-view-scene {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
  gap: 64px;
}

.form-section,
.viewing-task .form-section,
.review-section,
.viewing-task .review-section,
.material-subsection {
  padding-bottom: 38px;
}

.form-section + .form-section,
.review-section + .review-section {
  padding-top: 38px;
}

.section-heading,
.viewing-task .section-heading {
  margin-bottom: 20px;
  gap: 13px;
}

.section-icon,
.viewing-task .section-icon {
  flex-basis: 38px;
  width: 38px;
  height: 38px;
  border-color: #ead5ce;
  background: var(--primary-soft);
}

.section-icon img {
  width: 18px;
  opacity: .82;
  filter: invert(31%) sepia(57%) saturate(1485%) hue-rotate(339deg) brightness(90%) contrast(93%);
}

.section-heading h2,
.review-heading strong {
  margin-top: 2px;
  font-size: 19px;
  line-height: 1.3;
}

.section-step {
  font-size: 11px;
}

.material-subsection {
  margin-top: 2px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.material-subheading {
  margin-bottom: 16px;
}

.material-subheading .section-icon {
  background: var(--surface-strong);
  border-color: var(--border);
}

.material-subheading .section-icon img {
  filter: none;
}

.dropzone {
  position: relative;
  min-height: 164px;
  padding: 28px 22px;
  gap: 8px;
  border-color: var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(25 33 30 / 3%);
}

.dropzone::after {
  position: absolute;
  inset: 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  content: "";
  pointer-events: none;
  transition: border-color var(--transition);
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--primary);
  background: #fffaf8;
}

.dropzone:hover::after,
.dropzone.dragging::after {
  border-color: #f2d4ca;
}

.compact-dropzone {
  min-height: 138px;
  padding: 22px 16px;
}

.dropzone-icon {
  width: 25px;
  margin-bottom: 4px;
  opacity: .72;
}

.dropzone-title {
  font-size: 14px;
}

.dropzone-meta {
  font-size: 12px;
}

.dropzone.disabled {
  border-color: var(--border);
  background: #f1f3f1;
  box-shadow: none;
}

.dropzone.has-selection {
  border-color: #79afa5;
  background: #f4fbf9;
}

.image-list {
  margin-top: 14px;
  gap: 10px;
}

.image-item {
  border-radius: 8px;
  box-shadow: 0 2px 10px rgb(25 33 30 / 5%);
}

.remove-image {
  top: 5px;
  right: 5px;
  width: 38px;
  height: 38px;
}

.field-grid {
  gap: 18px 16px;
}

.field label {
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.script-beat-editor input,
.script-beat-editor textarea {
  min-height: 50px;
  border-color: var(--border-strong);
  background: rgb(255 255 255 / 92%);
  box-shadow: inset 0 1px 0 rgb(25 33 30 / 2%);
}

.field textarea {
  min-height: 108px;
}

.field input:focus,
.field textarea:focus,
.script-beat-editor input:focus,
.script-beat-editor textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(8 117 104 / 12%);
}

.story-options {
  padding: 5px;
  gap: 5px;
  border-color: var(--border);
  background: var(--surface-strong);
}

.story-option {
  min-height: 82px;
  background: rgb(255 255 255 / 45%);
}

.story-option:has(input:checked) {
  border-color: #e6c5bb;
  background: #fff;
  box-shadow: 0 3px 12px rgb(25 33 30 / 6%);
}

.duration-setting {
  min-height: 70px;
}

.duration-options {
  background: var(--surface-strong);
}

.advanced-settings,
.prompt-details {
  margin-top: 18px;
}

.advanced-settings summary,
.prompt-details summary {
  min-height: 52px;
}

.hook-review {
  padding-top: 38px;
}

.review-heading {
  margin-bottom: 18px;
}

.review-heading strong {
  font-size: 19px;
}

.compact-badge {
  padding: 4px 8px;
  border-color: var(--border);
  background: var(--surface);
  font-size: 11px;
}

.script-timeline {
  margin-bottom: 18px;
  padding: 6px;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.script-timeline button {
  min-height: 66px;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.script-timeline button:hover {
  background: rgb(255 255 255 / 64%);
}

.script-timeline button.current {
  border-color: #e8c9c0;
  border-bottom-color: #e8c9c0;
  background: var(--surface);
  color: var(--primary-hover);
  box-shadow: 0 3px 12px rgb(25 33 30 / 6%);
}

.script-timeline span {
  color: var(--text-subtle);
}

.script-beat-editor {
  padding: 26px;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(25 33 30 / 4%);
}

.script-node-pager {
  margin-top: 14px;
}

.script-node-pager .secondary-button {
  min-width: 116px;
}

.step-view-keyframes #keyframeReview {
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px 36px;
}

.keyframe-focus {
  min-height: 520px;
  border-color: #202824;
  border-radius: 8px;
  background: #111714;
  box-shadow: 0 16px 40px rgb(17 23 20 / 13%);
}

.keyframe-focus > .image-preview-button {
  background: #111714;
}

.keyframe-focus-meta {
  padding: 13px 16px;
  border-top: 1px solid rgb(255 255 255 / 8%);
  background: #19211e;
  color: #fff;
}

.keyframe-filmstrip {
  margin-top: 14px;
  padding: 2px 2px 10px;
  grid-auto-columns: 108px;
  gap: 10px;
}

.keyframe-filmstrip .keyframe-item {
  width: 108px;
  border-width: 1px;
  border-color: var(--border);
  border-radius: 7px;
  box-shadow: 0 2px 8px rgb(25 33 30 / 4%);
}

.keyframe-filmstrip .keyframe-item.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.step-view-keyframes #keyframeReview > .compact-field {
  margin: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(25 33 30 / 4%);
}

.step-view-keyframes #keyframeReview > .review-actions {
  margin-top: -10px;
  gap: 10px;
}

.story-review-warning {
  border: 1px solid #f0c7be;
  border-left: 3px solid var(--danger);
  border-radius: 6px;
}

.step-review-layout {
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 64px;
}

.video-main-visual .video-stage,
.viewing-task .video-main-visual .video-stage {
  width: min(100%, 410px);
  border-color: #242c28;
  border-radius: 8px;
  background: #111714;
  box-shadow: 0 18px 46px rgb(17 23 20 / 16%);
}

.step-review-aside {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 10px 28px rgb(25 33 30 / 5%);
}

.step-review-aside .video-review,
.step-review-aside .video-confirmation-layout {
  padding: 0;
}

.step-review-aside .result-summary {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 7px;
  font-size: 14px;
}

.primary-button {
  box-shadow: 0 6px 16px rgb(199 71 48 / 16%);
}

.primary-button:not(:disabled):hover {
  box-shadow: 0 8px 20px rgb(199 71 48 / 20%);
}

.secondary-button {
  border-color: var(--border-strong);
  box-shadow: 0 1px 1px rgb(25 33 30 / 2%);
}

.wizard-action-bar {
  border-top-color: rgb(25 33 30 / 10%);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 -10px 30px rgb(25 33 30 / 5%);
}

.wizard-action-inner {
  min-height: 76px;
  width: min(100%, 1248px);
  padding: 12px 36px;
}

.wizard-action-inner .primary-button,
.wizard-action-inner .secondary-button {
  min-width: 174px;
}

.wizard-action-inner #wizardBackButton {
  min-width: 120px;
}

.task-summary-drawer {
  right: 28px;
  bottom: 88px;
  border-color: rgb(25 33 30 / 12%);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 18px 50px rgb(25 33 30 / 13%);
  backdrop-filter: blur(16px);
}

.task-summary-drawer:not([open]) {
  width: 250px;
}

.task-summary-drawer > summary {
  min-height: 46px;
  font-size: 13px;
  font-weight: 700;
}

.task-summary-drawer > summary:hover {
  background: var(--surface-soft);
}

.toast {
  right: auto;
  bottom: 90px;
  left: 50%;
  padding: 11px 14px;
  transform: translateX(-50%);
  border-color: rgb(255 255 255 / 10%);
  border-radius: 6px;
  background: #18211d;
  box-shadow: 0 12px 30px rgb(17 23 20 / 18%);
  font-size: 13px;
}

.generation-dialog {
  max-height: calc(100dvh - 48px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 38px 40px 36px;
  border-color: rgb(25 33 30 / 10%);
  box-shadow: 0 30px 90px rgb(16 23 19 / 28%);
}

.generation-dialog::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  content: "";
}

.generation-dialog:focus {
  outline: 0;
}

.generation-dialog::backdrop {
  background: rgb(15 21 18 / 48%);
  backdrop-filter: blur(5px);
}

.generation-dialog h2 {
  margin-top: 10px;
  font-size: 23px;
}

.generation-orbit {
  width: 50px;
  height: 50px;
  margin-bottom: 18px;
  border-color: #f5d9d1;
}

.generation-orbit span {
  left: 20px;
  transform-origin: 5px 28px;
}

.generation-dialog progress,
.mobile-progress progress {
  overflow: hidden;
  border-radius: 99px;
}

.generation-dialog progress::-webkit-progress-bar,
.mobile-progress progress::-webkit-progress-bar {
  background: var(--surface-strong);
}

.generation-dialog progress::-webkit-progress-value,
.mobile-progress progress::-webkit-progress-value {
  background: var(--primary);
}

.generation-dialog progress::-moz-progress-bar,
.mobile-progress progress::-moz-progress-bar {
  background: var(--primary);
}

.image-lightbox {
  border-radius: 8px;
  background: #101512;
  box-shadow: 0 30px 100px rgb(0 0 0 / 45%);
}

@media (max-width: 920px) {
  .header-inner {
    padding-inline: 22px;
  }

  .workspace,
  .viewing-task .workspace {
    padding: 30px 22px 104px;
  }

  .wizard-heading-row {
    min-height: 0;
    margin-bottom: 22px;
  }

  .mobile-progress {
    margin: 0 0 34px;
    padding: 14px 0 0;
    border-top: 1px solid var(--border);
  }

  .mobile-progress > div {
    margin-bottom: 10px;
    font-size: 13px;
  }

  .mobile-progress > div span {
    color: var(--text-muted);
    font-weight: 650;
  }

  .mobile-progress progress {
    height: 5px;
  }

  .step-view-scene,
  .step-view-keyframes #keyframeReview,
  .step-review-layout {
    display: block;
  }

  .scene-review,
  .step-view-keyframes #keyframeReview > .story-review-warning,
  .step-view-keyframes #keyframeReview > .compact-field,
  .step-view-keyframes #keyframeReview > .review-actions,
  .step-review-aside {
    margin-top: 34px;
    padding-top: 34px;
    border-top: 1px solid var(--border);
  }

  .step-view-keyframes #keyframeReview > .compact-field,
  .step-review-aside {
    padding: 22px;
    border: 1px solid var(--border);
  }

  .step-view-keyframes #keyframeReview > .review-actions {
    padding-top: 0;
    border-top: 0;
  }

  .video-main-visual .video-stage,
  .viewing-task .video-main-visual .video-stage {
    width: min(100%, 380px);
  }

  .wizard-action-inner {
    padding-inline: 22px;
  }
}

@media (max-width: 600px) {
  body {
    padding-bottom: 84px;
  }

  .header-inner {
    min-height: 58px;
    padding-inline: 16px;
  }

  .brand {
    font-size: 16px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .restart-button {
    min-height: 38px;
    padding-inline: 10px;
  }

  .workspace,
  .viewing-task .workspace {
    padding: 24px 16px 88px;
  }

  .wizard-heading-row {
    margin-bottom: 20px;
  }

  .wizard-heading-row .page-heading h1,
  .viewing-task .wizard-heading-row .page-heading h1 {
    margin-top: 5px;
    font-size: 28px;
    line-height: 1.18;
  }

  .page-heading > p:last-child {
    font-size: 14px;
    line-height: 1.55;
  }

  .wizard-heading-row .status-label {
    margin-top: 11px;
  }

  .mobile-progress {
    margin-bottom: 30px;
    padding-top: 13px;
  }

  .form-section,
  .viewing-task .form-section,
  .review-section,
  .viewing-task .review-section,
  .material-subsection {
    padding-bottom: 32px;
  }

  .form-section + .form-section,
  .review-section + .review-section {
    padding-top: 32px;
  }

  .section-heading,
  .viewing-task .section-heading {
    margin-bottom: 18px;
  }

  .section-icon,
  .viewing-task .section-icon {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .section-heading h2,
  .review-heading strong {
    font-size: 18px;
  }

  .dropzone {
    min-height: 150px;
    padding: 24px 16px;
  }

  .compact-dropzone {
    min-height: 130px;
  }

  .script-timeline {
    margin-inline: -2px;
    padding: 5px;
  }

  .script-timeline button {
    min-width: 126px;
  }

  .script-beat-editor {
    padding: 20px 16px;
  }

  .keyframe-focus,
  .keyframe-focus.is-empty {
    min-height: 390px;
  }

  .keyframe-focus > .image-preview-button {
    height: min(56dvh, 500px);
  }

  .step-view-keyframes #keyframeReview > .compact-field,
  .step-review-aside {
    padding: 18px 16px;
  }

  .wizard-action-inner {
    min-height: 70px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }

  .wizard-action-inner #wizardBackButton {
    min-width: 48px;
    width: 48px;
  }

  .task-summary-drawer {
    right: 16px;
    bottom: 82px;
  }

  .task-summary-drawer:not([open]) {
    width: 156px;
  }

  .task-summary-drawer > summary {
    padding-inline: 13px;
  }

  .toast {
    bottom: 142px;
    width: max-content;
    max-width: calc(100vw - 32px);
    text-align: center;
  }

  .generation-dialog {
    padding: 32px 20px 28px;
  }
}

.character-role-section {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fcfa;
}

.character-role-heading,
.character-role-row-actions,
.character-library-row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.character-role-heading p,
.character-library-body > p,
.character-role-empty,
.character-library-empty,
.character-library-status {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.character-role-list,
.character-library-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.character-role-row,
.character-library-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.75fr) minmax(150px, 1fr) minmax(0, 2.2fr) max-content;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid #d8e3dd;
  border-radius: 8px;
  background: #fff;
}

.character-role-row label,
.character-library-row label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.character-role-row input,
.character-role-row select,
.character-role-row textarea,
.character-library-row input,
.character-library-row textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #bccbc4;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
}

.character-role-row textarea,
.character-library-row textarea {
  min-height: 70px;
  resize: vertical;
  line-height: 1.5;
}

.character-source-control {
  display: grid;
  gap: 8px;
}

.character-asset-preview {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 60px;
  padding: 4px;
  border: 1px solid #d8e3dd;
  border-radius: 6px;
  background: #f7faf8;
}

.character-asset-preview[hidden] {
  display: none;
}

.character-asset-preview-button {
  position: relative;
  display: block;
  width: 52px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  border: 0;
  border-radius: 5px;
  background: #e8efeb;
}

.character-asset-preview-button > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 160ms ease;
}

.character-asset-preview-button:hover > img {
  transform: scale(1.04);
}

.character-asset-preview-button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.character-asset-preview-zoom {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 4px;
  background: rgb(20 35 30 / 78%);
  pointer-events: none;
}

.character-asset-preview-zoom img {
  width: 12px;
  height: 12px;
  filter: invert(1);
}

.character-asset-preview span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.character-asset-preview strong,
.character-asset-preview small {
  overflow-wrap: anywhere;
}

.character-asset-preview strong {
  color: var(--text);
  font-size: 13px;
}

.character-asset-preview small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.character-role-row :is(input, select, textarea):focus,
.character-library-row :is(input, textarea):focus {
  border-color: var(--primary);
  outline: 3px solid rgb(12 148 104 / 14%);
}

.character-role-row-actions,
.character-library-row-actions {
  gap: 8px;
  justify-content: flex-start;
  align-self: stretch;
}

.character-role-row-actions .secondary-button,
.character-library-row-actions .secondary-button {
  flex: 0 0 auto;
  width: auto;
  min-width: 44px;
  padding-inline: 12px;
  white-space: nowrap;
}

.character-library-details {
  margin-top: 16px;
  border-top: 1px solid #d8e3dd;
  padding-top: 12px;
}

.character-library-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
}

.character-library-details summary img {
  width: 18px;
}

.character-library-body {
  padding-top: 4px;
}

.character-library-row {
  grid-template-columns: minmax(140px, 0.8fr) minmax(0, 2fr) max-content;
}

.character-library-status[data-tone="error"] {
  color: var(--danger);
}

.character-role-section[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .character-role-row,
  .character-library-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.script-plan-note {
  margin: 8px 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.65;
}

.script-locked-story {
  margin-top: 20px;
}

.script-locked-story textarea[readonly] {
  min-height: 280px;
  resize: vertical;
  cursor: text;
  color: var(--text);
  background: var(--surface-soft);
  line-height: 1.8;
}

.script-shooting-mode select {
  min-height: 44px;
  max-width: 280px;
}

#scriptBeatsEditor > .script-shooting-mode {
  grid-column: 1 / -1;
  grid-row: 1;
}

#scriptBeatsEditor > .script-plan-note {
  grid-column: 1 / -1;
  grid-row: 2;
}

#scriptBeatsEditor > .script-timeline {
  grid-column: 1;
  grid-row: 3;
}

#scriptBeatsEditor > .script-beat-editor {
  grid-column: 2;
  grid-row: 3;
}

#scriptBeatsEditor > .script-node-pager {
  grid-column: 2;
  grid-row: 4;
}

/* Six-step wizard */
body {
  padding-bottom: 96px;
}

.workspace,
.viewing-task .workspace {
  display: block;
  width: min(100%, 1280px);
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.editor,
.viewing-task .editor {
  display: block;
  min-width: 0;
}

.wizard-heading-row {
  display: flex;
  margin-bottom: 28px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.wizard-heading-row .page-heading,
.viewing-task .wizard-heading-row .page-heading {
  max-width: 720px;
  margin: 0;
}

.wizard-heading-row .page-heading h1,
.viewing-task .wizard-heading-row .page-heading h1 {
  margin-top: 4px;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: 0;
}

.workflow-steps,
.viewing-task .workflow-steps {
  display: grid;
  overflow: hidden;
  margin: 0 0 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.workflow-steps li,
.viewing-task .workflow-steps li {
  position: relative;
  display: block;
  min-height: 72px;
  padding: 0;
  border: 0;
}

.workflow-steps li + li::before,
.workflow-steps li:nth-child(5)::before,
.viewing-task .workflow-steps li:nth-child(5)::before {
  position: absolute;
  z-index: 1;
  top: 16px;
  bottom: 16px;
  left: 0;
  display: block;
  width: 1px;
  height: auto;
  background: var(--border);
  content: "";
}

.workflow-steps button {
  display: flex;
  width: 100%;
  min-height: 72px;
  padding: 12px 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.workflow-steps button:hover:not(:disabled) {
  background: var(--surface-soft);
}

.workflow-steps li.current button {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.workflow-steps li.complete button {
  color: var(--success);
}

.workflow-steps li.locked button {
  color: var(--text-subtle);
  cursor: not-allowed;
  opacity: 0.52;
}

.workflow-steps span,
.viewing-task .workflow-steps span {
  color: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.workflow-steps strong,
.viewing-task .workflow-steps strong {
  color: inherit;
  font-size: 14px;
}

.mobile-progress {
  display: none;
}

.step-host,
.step-view {
  min-width: 0;
}

.step-view-product,
.step-view-creative,
.step-view-script {
  width: min(100%, 800px);
  margin: 0 auto;
}

.step-view-scene,
.step-view-keyframes,
.step-view-video,
.step-view-result {
  width: 100%;
}

.step-view-scene {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 48px;
  align-items: start;
}

.step-view[hidden],
.step-view-scene[hidden] {
  display: none;
}

.form-section,
.viewing-task .form-section,
.review-section,
.viewing-task .review-section,
.material-subsection {
  margin: 0;
  padding: 0 0 32px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.form-section + .form-section,
.review-section + .review-section {
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.section-heading,
.viewing-task .section-heading {
  margin-bottom: 24px;
}

.section-heading h2,
.review-heading strong {
  font-size: 20px;
  letter-spacing: 0;
}

.scene-upload-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.scene-upload-grid #placementDropzone {
  grid-column: 1 / -1;
}

.dropzone,
.field input,
.field textarea,
.script-beat-editor input,
.script-beat-editor textarea {
  border-radius: 6px;
}

.dropzone {
  min-height: 150px;
  background: var(--surface);
}

.image-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.image-item,
.image-preview-button {
  min-width: 0;
}

.image-preview-button {
  cursor: zoom-in;
}

.hook-review {
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

#confirmHookButton,
#confirmStoryButton,
#confirmScriptButton,
#confirmKeyframeButton,
#confirmSceneButton,
#confirmVideoButton {
  display: none !important;
}

.script-beats-editor,
.viewing-task .script-beats-editor {
  display: block;
}

.script-timeline {
  display: grid;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  grid-template-columns: repeat(var(--script-columns, 7), minmax(0, 1fr));
}

.script-timeline button {
  min-height: 64px;
  padding: 8px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.script-timeline button.current {
  border-bottom-color: var(--primary);
  color: var(--text);
}

.script-timeline span,
.script-timeline strong {
  display: block;
  font-size: 12px;
}

.script-timeline strong {
  margin-top: 2px;
  font-size: 13px;
}

.script-beat-editor {
  display: grid;
  padding: 24px 0 8px;
  border: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.script-beat-editor[hidden] {
  display: none;
}

.script-beat-editor > div {
  grid-column: 1 / -1;
}

.script-node-pager {
  display: flex;
  margin-top: 16px;
  justify-content: space-between;
  gap: 16px;
}

.script-node-pager .secondary-button {
  width: auto;
  min-width: 128px;
}

.step-view-keyframes #keyframeReview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px 40px;
  align-items: start;
}

.step-view-keyframes #keyframeReview > .review-heading {
  grid-column: 1 / -1;
}

.keyframe-grid,
.viewing-task .keyframe-grid {
  display: block;
  min-width: 0;
}

.keyframe-focus {
  display: grid;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #101512;
  place-items: center;
}

.keyframe-focus > .image-preview-button {
  width: 100%;
  height: min(68dvh, 700px);
  border: 0;
  background: #101512;
}

.keyframe-focus img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.keyframe-focus-meta {
  display: flex;
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  justify-content: space-between;
}

.keyframe-focus.is-empty {
  min-height: 560px;
  color: #fff;
}

.keyframe-filmstrip {
  display: grid;
  overflow-x: auto;
  margin-top: 12px;
  padding: 2px 2px 8px;
  grid-auto-columns: 104px;
  grid-auto-flow: column;
  gap: 8px;
}

.keyframe-filmstrip .keyframe-item {
  display: grid;
  width: 104px;
  min-height: 132px;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  grid-template-rows: 96px auto;
}

.keyframe-filmstrip .keyframe-item.current {
  border-color: var(--primary);
}

.keyframe-filmstrip .keyframe-item.scene-warning {
  border-color: var(--danger);
}

.keyframe-filmstrip img {
  width: 100%;
  height: 96px;
  object-fit: cover;
}

.keyframe-filmstrip span {
  overflow: hidden;
  padding: 6px;
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyframe-filmstrip .keyframe-item-placeholder {
  display: grid;
  width: 100%;
  height: 96px;
  place-items: center;
  padding: 8px;
  background: var(--surface-soft);
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
  white-space: normal;
}

.step-view-keyframes #keyframeReview > .story-review-warning,
.step-view-keyframes #keyframeReview > .compact-field,
.step-view-keyframes #keyframeReview > .review-actions {
  grid-column: 2;
}

.step-view-keyframes #keyframeReview > .review-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.step-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: start;
}

.video-main-visual {
  display: grid;
  min-width: 0;
  place-items: start center;
}

.video-main-visual .video-stage,
.viewing-task .video-main-visual .video-stage {
  width: min(100%, 430px);
  margin: 0;
  aspect-ratio: 9 / 16;
}

.step-review-aside .video-review,
.step-review-aside .video-confirmation-layout {
  display: block;
}

.final-placement-reference img {
  cursor: zoom-in;
}

.wizard-action-bar {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  border-top: 1px solid var(--border);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 -8px 24px rgb(27 41 34 / 7%);
  backdrop-filter: blur(14px);
}

.wizard-action-inner {
  display: flex;
  min-height: 80px;
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 12px 32px;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.wizard-action-inner .primary-button,
.wizard-action-inner .secondary-button {
  width: auto;
  min-width: 180px;
}

.wizard-action-inner #wizardBackButton {
  min-width: 128px;
  margin-right: auto;
}

.task-summary-drawer {
  position: fixed;
  z-index: 45;
  right: 24px;
  bottom: 92px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(620px, calc(100dvh - 180px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.task-summary-drawer > summary {
  display: flex;
  min-height: 48px;
  padding: 12px 16px;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
}

.task-summary-drawer > summary img {
  width: 18px;
  transition: transform var(--transition);
}

.task-summary-drawer:not([open]) > summary img {
  transform: rotate(180deg);
}

.task-summary-content {
  padding: 0 16px 8px;
}

.task-summary-content section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.task-summary-content h3,
.task-summary-content p {
  margin: 0;
}

.task-summary-content h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.task-summary-content p {
  color: var(--text-muted);
  font-size: 13px;
}

.task-summary-content .image-preview-button {
  width: 100%;
  height: 140px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 5px;
}

.task-summary-content img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-summary-drawer > .text-action {
  margin: 8px 16px 16px;
}

.toast {
  right: 420px;
  bottom: 96px;
}

.generation-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 24px 80px rgb(16 25 20 / 24%);
}

.generation-dialog::backdrop {
  background: rgb(14 21 17 / 55%);
  backdrop-filter: blur(3px);
}

.generation-dialog h2 {
  margin: 8px 0;
  font-size: 24px;
  letter-spacing: 0;
}

.generation-dialog progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  accent-color: var(--primary);
}

.generation-dialog > span {
  display: block;
  margin-top: 8px;
  color: var(--text-subtle);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.generation-orbit {
  position: relative;
  width: 54px;
  height: 54px;
  margin: 0 auto 20px;
  border: 2px solid var(--primary-soft);
  border-radius: 50%;
}

.generation-orbit span {
  position: absolute;
  top: -3px;
  left: 22px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  transform-origin: 5px 30px;
  animation: wizard-orbit 1.2s linear infinite;
}

.generation-dialog-error {
  margin-top: 20px;
  padding: 12px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  text-align: left;
}

.generation-dialog-actions {
  display: grid;
  margin-top: 20px;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@keyframes wizard-orbit {
  to { transform: rotate(360deg); }
}

@media (max-width: 920px) {
  .workspace,
  .viewing-task .workspace {
    padding: 28px 20px 72px;
  }

  .workflow-steps,
  .viewing-task .workflow-steps {
    display: none;
  }

  .mobile-progress {
    display: block;
    margin-bottom: 32px;
  }

  .mobile-progress > div {
    display: flex;
    margin-bottom: 8px;
    justify-content: space-between;
    gap: 16px;
  }

  .mobile-progress progress {
    display: block;
    width: 100%;
    height: 6px;
    accent-color: var(--primary);
  }

  .step-view-scene,
  .step-view-keyframes #keyframeReview,
  .step-review-layout {
    display: block;
  }

  .scene-review,
  .step-view-keyframes #keyframeReview > .story-review-warning,
  .step-view-keyframes #keyframeReview > .compact-field,
  .step-view-keyframes #keyframeReview > .review-actions,
  .step-review-aside {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
  }

  .keyframe-focus > .image-preview-button {
    height: min(64dvh, 620px);
  }

  .video-main-visual .video-stage,
  .viewing-task .video-main-visual .video-stage {
    width: min(100%, 390px);
  }
}

@media (max-width: 600px) {
  body {
    padding-bottom: 88px;
  }

  .header-inner {
    min-height: 60px;
    padding: 0 16px;
  }

  .mode-badge {
    display: none;
  }

  .workspace,
  .viewing-task .workspace {
    padding: 24px 16px 64px;
  }

  .wizard-heading-row {
    display: block;
    margin-bottom: 24px;
  }

  .wizard-heading-row .status-label {
    margin-top: 12px;
  }

  .wizard-heading-row .page-heading h1,
  .viewing-task .wizard-heading-row .page-heading h1 {
    font-size: 28px;
  }

  .scene-upload-grid,
  .script-beat-editor,
  .generation-dialog-actions {
    grid-template-columns: 1fr;
  }

  .image-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .script-timeline {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .script-timeline button {
    min-width: 132px;
    scroll-snap-align: start;
  }

  .script-node-pager .secondary-button {
    min-width: 0;
    flex: 1;
  }

  .keyframe-focus,
  .keyframe-focus.is-empty {
    min-height: 420px;
  }

  .keyframe-focus > .image-preview-button {
    height: min(58dvh, 520px);
  }

  .wizard-action-inner {
    min-height: 72px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }

  .wizard-action-inner .primary-button,
  .wizard-action-inner .secondary-button {
    min-width: 0;
  }

  .wizard-action-inner #wizardBackButton {
    width: 52px;
    min-width: 52px;
    padding-inline: 0;
  }

  .wizard-action-inner #wizardBackButton span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .wizard-action-inner #wizardPrimaryButton {
    flex: 1;
  }

  .task-summary-drawer {
    right: 16px;
    bottom: 84px;
  }

  .toast {
    right: 16px;
    bottom: 92px;
  }

  .generation-dialog {
    padding: 32px 20px;
  }
}

/* Final cascade layer for the six-step workspace. */
.workspace,
.viewing-task .workspace {
  width: min(100%, 1248px);
  max-width: 1248px;
  padding: 38px 36px 112px;
}

.wizard-heading-row {
  min-height: 80px;
  margin-bottom: 22px;
}

.wizard-heading-row .page-heading h1,
.viewing-task .wizard-heading-row .page-heading h1 {
  margin: 5px 0 7px;
  font-size: clamp(30px, 3vw, 36px);
  line-height: 1.16;
  font-weight: 780;
}

.workflow-steps,
.viewing-task .workflow-steps {
  overflow: visible;
  margin: 0 0 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.workflow-steps li,
.viewing-task .workflow-steps li,
.workflow-steps li.current,
.workflow-steps li.complete,
.workflow-steps li.locked {
  min-height: 62px;
  padding: 0;
  border: 0;
  background: transparent;
}

.workflow-steps li + li::before,
.workflow-steps li:nth-child(5)::before,
.viewing-task .workflow-steps li:nth-child(5)::before {
  z-index: 0;
  top: 16px;
  bottom: auto;
  left: -50%;
  display: block;
  width: 100%;
  height: 1px;
  background: var(--border-strong);
}

.workflow-steps li.complete + li::before {
  background: #9dc6be;
}

.workflow-steps button {
  position: relative;
  z-index: 1;
  min-height: 62px;
  padding: 0 8px;
  flex-direction: column;
  gap: 7px;
  opacity: 1;
}

.workflow-steps button:hover:not(:disabled),
.workflow-steps li.current button,
.workflow-steps li.complete button,
.workflow-steps li.locked button {
  background: transparent;
}

.workflow-steps span,
.viewing-task .workflow-steps span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--background);
  color: var(--text-subtle);
  font-size: 11px;
  box-shadow: 0 0 0 6px var(--background);
}

.workflow-steps strong,
.viewing-task .workflow-steps strong {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.workflow-steps li.complete span {
  border-color: #83b6ac;
  background: var(--success-soft);
  color: var(--success);
}

.workflow-steps li.complete strong {
  color: var(--success);
}

.workflow-steps li.locked span {
  border-color: #d8ddda;
  background: var(--background);
  color: #a3aaa6;
}

.workflow-steps li.locked strong {
  color: #a3aaa6;
}

.workflow-steps li.current button {
  opacity: 1;
}

.workflow-steps li.current span {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.workflow-steps li.current strong {
  color: var(--primary-hover);
}

.step-view-product {
  width: min(100%, 840px);
}

.step-view-creative {
  width: min(100%, 960px);
}

.step-view-script {
  width: min(100%, 1000px);
}

.step-view-scene {
  grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
  gap: 64px;
}

.step-view-scene:not(:has(.scene-review:not([hidden]))) {
  display: block;
  width: min(100%, 840px);
  margin-inline: auto;
}

.form-section,
.viewing-task .form-section,
.review-section,
.viewing-task .review-section,
.material-subsection {
  padding: 0 0 38px;
}

.form-section + .form-section,
.review-section + .review-section {
  padding-top: 38px;
}

.section-heading,
.viewing-task .section-heading {
  margin-bottom: 20px;
}

.dropzone {
  min-height: 164px;
  padding: 28px 22px;
  border-radius: 8px;
}

.compact-dropzone {
  min-height: 138px;
  padding: 22px 16px;
}

.script-timeline {
  margin-bottom: 18px;
  padding: 6px;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.script-timeline button {
  min-height: 66px;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.script-timeline button.current {
  border: 1px solid #e8c9c0;
  background: var(--surface);
  color: var(--primary-hover);
  box-shadow: 0 3px 12px rgb(25 33 30 / 6%);
}

.script-beat-editor {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.step-view-keyframes #keyframeReview {
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px 36px;
}

.keyframe-focus {
  min-height: 520px;
  border-color: #202824;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgb(17 23 20 / 13%);
}

.keyframe-filmstrip {
  margin-top: 14px;
  grid-auto-columns: 108px;
  gap: 10px;
}

.keyframe-filmstrip .keyframe-item {
  width: 108px;
  border-width: 1px;
  border-color: var(--border);
  border-radius: 7px;
}

.keyframe-filmstrip .keyframe-item.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.step-review-layout {
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 64px;
}

.video-main-visual .video-stage,
.viewing-task .video-main-visual .video-stage {
  width: min(100%, 410px);
}

.wizard-action-inner {
  min-height: 76px;
  width: min(100%, 1248px);
  padding: 12px 36px;
}

.task-summary-drawer {
  right: 28px;
  bottom: 88px;
}

.task-summary-drawer:not([open]) {
  width: 250px;
}

.toast {
  right: auto;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
}

.generation-dialog {
  padding: 38px 40px 36px;
}

.generation-dialog:focus,
.generation-dialog:focus-visible {
  outline: 0;
}

@media (max-width: 920px) {
  .workspace,
  .viewing-task .workspace {
    padding: 30px 22px 104px;
  }

  .wizard-heading-row {
    min-height: 0;
    margin-bottom: 22px;
  }

  .mobile-progress {
    margin: 0 0 34px;
    padding: 14px 0 0;
    border-top: 1px solid var(--border);
  }

  .step-view-scene,
  .step-view-scene:not(:has(.scene-review:not([hidden]))),
  .step-view-keyframes #keyframeReview,
  .step-review-layout {
    display: block;
    width: 100%;
  }

  .wizard-action-inner {
    padding-inline: 22px;
  }
}

@media (max-width: 600px) {
  .workspace,
  .viewing-task .workspace {
    padding: 24px 16px 88px;
  }

  .wizard-heading-row {
    margin-bottom: 20px;
  }

  .wizard-heading-row .page-heading h1,
  .viewing-task .wizard-heading-row .page-heading h1 {
    font-size: 28px;
  }

  .mobile-progress {
    margin-bottom: 30px;
    padding-top: 13px;
  }

  .dropzone {
    min-height: 150px;
    padding: 24px 16px;
  }

  .compact-dropzone {
    min-height: 130px;
  }

  .script-timeline {
    display: flex;
    overflow-x: auto;
  }

  .script-timeline button {
    min-width: 126px;
  }

  .script-beat-editor {
    padding: 20px 16px;
  }

  .wizard-action-inner {
    min-height: 70px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }

  .task-summary-drawer {
    right: 16px;
    bottom: 82px;
  }

  .task-summary-drawer:not([open]) {
    width: 156px;
  }

  .toast {
    right: auto;
    bottom: 142px;
    left: 50%;
  }

  .generation-dialog {
    padding: 32px 20px 28px;
  }
}
