:root {
  color-scheme: light;
  --color-primary: #e8593c;
  --color-primary-hover: #d44d33;
  --color-primary-light: rgba(232, 89, 60, 0.08);
  --color-primary-muted: rgba(232, 89, 60, 0.15);
  --state-success: #34a853;
  --state-warning: #f5a623;
  --state-error: #ea4335;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-tertiary: #f0f0f2;
  --bg-sidebar: #fafafa;
  --bg-inset: #f4f4f6;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --border-primary: #d2d2d7;
  --border-secondary: #e5e5ea;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.04);
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 44px;
  --content-max-width: 1200px;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-primary-muted);
  outline-offset: 2px;
}

.app-frame {
  width: 100%;
  height: 100vh;
  min-width: 1120px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--bg-primary);
  transition: grid-template-columns 180ms ease;
}

.app-frame.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.app-sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-secondary);
  background: var(--bg-sidebar);
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  color: var(--text-primary);
}

.sidebar-brand svg {
  flex: 0 0 auto;
  color: var(--color-primary);
}

.sidebar-brand strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
}

.sidebar-collapsed .sidebar-brand strong,
.sidebar-collapsed .tab-button span,
.sidebar-collapsed .sidebar-user span:last-child {
  display: none;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
}

.tab-button {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-collapsed .tab-button {
  justify-content: center;
  padding: 0;
}

.tab-button svg {
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-button:hover {
  background: var(--bg-tertiary);
}

.tab-button.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.sidebar-user {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-top: 1px solid var(--border-secondary);
  color: var(--text-secondary);
  font-size: 12px;
}

.sidebar-collapsed .sidebar-user {
  justify-content: center;
  padding: 0;
}

.user-avatar {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-size: 12px;
}

.app-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
}

.topbar {
  min-width: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(255, 255, 255, 0.92);
}

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-secondary);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.icon-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.sidebar-collapsed .sidebar-toggle svg path {
  transform-origin: 10px 10px;
  transform: rotate(180deg);
}

.project-switch {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.topbar-summary {
  max-width: 520px;
  position: relative;
  flex: 0 1 520px;
  padding: 0 18px 0 0;
  background: transparent;
  text-align: left;
}

.topbar-summary::after {
  content: "⌄";
  position: absolute;
  right: 0;
  top: 50%;
  margin-left: 0;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 12px;
}

.topbar.is-expanded .topbar-summary::after {
  content: "⌃";
}

.project-switch span,
.project-switch em {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 11px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-switch strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer {
  min-width: 0;
  flex: 1;
}

.topbar-details {
  min-width: 280px;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-details select {
  min-width: 260px;
}

.topbar-details .secondary-pill {
  flex: 0 0 auto;
}

.topbar.is-collapsed .topbar-details {
  display: none;
}

.status-pill {
  min-width: 88px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.busy {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.status-pill.error {
  background: rgba(234, 67, 53, 0.1);
  color: var(--state-error);
}

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px 32px 32px;
  background: var(--bg-primary);
}

.tab-view {
  width: min(100%, var(--content-max-width));
  min-width: 0;
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-view.active {
  display: flex;
}

#tab-image.active {
  height: calc(100vh - var(--topbar-height) - 56px);
  max-height: calc(100vh - var(--topbar-height) - 56px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

#tab-image.active.image-prompt-collapsed {
  grid-template-rows: auto minmax(0, 1fr);
}

#tab-image .page-head {
  position: sticky;
  top: 0;
  z-index: 4;
  margin-bottom: 0;
  padding-bottom: 14px;
  background: var(--bg-primary);
}

.page-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.page-head h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.2;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.page-actions,
.panel-actions,
.settings-test-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.primary-pill,
.secondary-pill,
.text-action,
.pearl-button {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-weight: 600;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.primary-pill {
  min-height: 36px;
  padding: 0 16px;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
}

.primary-pill:hover {
  background: var(--color-primary-hover);
}

.primary-pill.ghost {
  border: 1px solid var(--color-primary-muted);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.secondary-pill,
.pearl-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-primary);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
}

.secondary-pill.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.secondary-pill:hover,
.pearl-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.secondary-pill.danger {
  border-color: rgba(234, 67, 53, 0.28);
  color: var(--state-error);
}

.secondary-pill.danger:hover {
  border-color: var(--state-error);
  background: rgba(234, 67, 53, 0.08);
  color: var(--state-error);
}

.text-action {
  min-height: 28px;
  padding: 0;
  background: transparent;
  color: var(--color-primary);
  font-size: 12px;
}

input,
select {
  width: 100%;
  height: 36px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 450;
}

select {
  appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 15px,
    calc(100% - 12px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.compact-select {
  width: auto;
  min-width: 116px;
}

textarea {
  width: 100%;
  min-height: 0;
  resize: vertical;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.65;
}

.prompt-textarea {
  min-height: 96px;
  padding: 14px;
}

.storyboard-prompt-textarea {
  min-height: 180px;
  resize: vertical;
}

.settings-prompt-textarea {
  min-height: 220px;
  font-size: 12px;
}

.project-create-panel,
.flow-section,
.image-prompt-panel,
.gallery-panel,
.settings-panel,
.render-settings-panel,
.video-output-panel,
.advanced-story,
.output-card,
.project-tile {
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.project-create-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  align-items: end;
  gap: 14px;
  padding: 20px;
}

.copy-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.theme-editor-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
}

.auto-pipeline-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(420px, 1.12fr);
  gap: 16px;
  align-items: start;
}

.auto-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.theme-style-grid {
  grid-template-columns: minmax(260px, 420px);
  margin: 0 0 14px;
}

.auto-option-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 13px;
}

.auto-option-list label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-option-list input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.auto-progress-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.auto-progress-summary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-progress-summary span {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

.auto-step-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.auto-step-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.auto-step-item span {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
}

.auto-step-item strong {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.auto-step-item em {
  grid-column: 1 / -1;
  color: var(--text-tertiary);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.auto-step-item.done,
.auto-step-item.skipped {
  border-color: rgba(52, 168, 83, 0.24);
  background: rgba(52, 168, 83, 0.04);
}

.auto-step-item.running,
.auto-step-item.waiting {
  border-color: var(--color-primary-muted);
  background: var(--color-primary-light);
}

.auto-step-item.failed {
  border-color: rgba(234, 67, 53, 0.28);
  background: rgba(234, 67, 53, 0.06);
}

.auto-step-item .error {
  color: var(--state-error);
}

.auto-result {
  max-height: 240px;
  margin-top: 14px;
  overflow: auto;
}

.theme-brief-textarea {
  min-height: 132px;
}

.theme-idea-candidates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.theme-idea-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.theme-idea-card.selected {
  border-color: var(--color-primary-muted);
  background: var(--color-primary-light);
}

.theme-idea-card h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.theme-idea-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.theme-idea-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.theme-idea-tags span {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.theme-idea-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-intro-textarea {
  min-height: 132px;
  resize: vertical;
}

.theme-revision-textarea {
  min-height: 112px;
  resize: vertical;
}

.copy-editor-grid > div:first-child {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(260px, 1fr) auto;
}

.copy-editor-grid .prompt-textarea {
  min-height: 260px;
  resize: vertical;
}

.topic-field,
.field {
  min-width: 0;
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.field-action-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.audio-upload-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.audio-upload-row input[type="file"] {
  width: 100%;
  min-width: 0;
  font-size: 12px;
}

#ttsPreviewAudio {
  width: 100%;
  max-width: 520px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.project-tile {
  min-height: 158px;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.project-tile.active {
  border-color: var(--color-primary-muted);
  background: linear-gradient(0deg, var(--color-primary-light), transparent 38%), #fff;
}

.project-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.project-tile h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.35;
}

.project-tile p {
  display: -webkit-box;
  min-height: 42px;
  margin: 10px 0 20px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-tile-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.project-tile-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 40px;
  border: 1px dashed var(--border-secondary);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  text-align: center;
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 26px;
  margin: 8px 0 18px;
  padding: 0;
  list-style: none;
}

.workflow-steps li {
  position: relative;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.workflow-steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  left: calc(50% + 40px);
  right: calc(-50% + 40px);
  height: 2px;
  background: var(--border-secondary);
}

.workflow-steps li.done:not(:last-child)::after {
  background: var(--state-success);
}

.workflow-steps span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-weight: 700;
}

.workflow-steps li.done span {
  background: var(--state-success);
  color: #fff;
}

.workflow-steps li.active span {
  background: var(--color-primary);
  color: #fff;
}

.workflow-steps li.done,
.workflow-steps li.active {
  color: var(--color-primary);
}

.workflow-steps li.done {
  color: var(--state-success);
}

.flow-section {
  padding: 20px;
}

.flow-section.compact {
  padding: 20px;
}

.flow-section.active {
  border-color: rgba(232, 89, 60, 0.32);
}

.flow-section-head,
.settings-title-row,
.image-toolbar,
.output-head,
.panel-foot,
.field-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flow-section-head {
  margin-bottom: 14px;
}

.flow-section-head strong,
.settings-title-row h2,
.image-toolbar strong {
  margin: 0;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 650;
}

.readonly-topic {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
}

.readonly-topic-multiline {
  min-height: 72px;
  align-items: flex-start;
  padding-top: 12px;
  padding-bottom: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.field-title-row {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

.panel-foot {
  margin-top: 10px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.output-card {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr);
  background: var(--bg-secondary);
}

.output-head {
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-secondary);
  color: var(--text-secondary);
  font-size: 12px;
}

.output-card textarea {
  min-height: 260px;
  padding: 14px 16px;
  border: 0;
  background: transparent;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.state-badge.done {
  background: rgba(52, 168, 83, 0.1);
  color: var(--state-success);
}

.state-badge.editing {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.state-badge.generating {
  background: rgba(245, 166, 35, 0.14);
  color: #b76a00;
}

.state-badge.pending {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.state-badge.error {
  background: rgba(234, 67, 53, 0.1);
  color: var(--state-error);
}

.state-badge.policy-error {
  background: rgba(245, 166, 35, 0.14);
  color: #9a5b00;
}

.advanced-story {
  overflow: hidden;
  box-shadow: none;
}

.advanced-story summary {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 26px;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  cursor: pointer;
  list-style: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 650;
}

.advanced-story summary::-webkit-details-marker {
  display: none;
}

.advanced-story summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.advanced-story[open] summary::after {
  content: "-";
}

#jsonMeta {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
}

#jsonEditor {
  min-height: 360px;
  padding: 14px 16px;
  border: 0;
  border-top: 1px solid var(--border-secondary);
  border-radius: 0;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}

.image-prompt-panel {
  padding: 16px;
  min-height: 0;
}

.image-prompt-panel .prompt-textarea {
  min-height: 84px;
  max-height: 112px;
  resize: none;
}

.image-prompt-collapsed .image-prompt-panel {
  display: none;
}

.gallery-panel {
  overflow: hidden;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
}

.image-toolbar {
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-secondary);
}

.toolbar-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.toolbar-title span {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
  justify-content: start;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 16px;
  padding: 16px;
  overflow: auto;
}

.shot-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  background: #fff;
}

.shot-card.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.shot-card.cover-selected {
  border-color: rgba(52, 168, 83, 0.6);
}

.shot-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: var(--shot-ratio, 9 / 16);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg-tertiary);
  cursor: pointer;
}

.shot-thumb .state-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
}

.cover-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(52, 168, 83, 0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.shot-thumb:focus-visible {
  outline: 3px solid var(--color-primary-muted);
  outline-offset: -3px;
}

.shot-card.selected .shot-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--color-primary);
}

.shot-redraw-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.72);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 150ms ease, background 150ms ease;
}

.shot-redraw-button:hover {
  background: var(--color-primary);
  transform: translateY(-1px);
}

.shot-redraw-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.shot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-tertiary);
}

.shot-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

.shot-placeholder.generating {
  color: #b76a00;
}

.shot-placeholder.error {
  color: var(--state-error);
}

.shot-placeholder.policy-error {
  color: #9a5b00;
}

.shot-info {
  padding: 14px;
}

.shot-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.shot-cover-button {
  margin: -2px 0 10px;
}

.shot-title-row strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-title-row span {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 650;
}

.shot-info p {
  display: -webkit-box;
  min-height: 40px;
  margin: 0 0 12px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.shot-prompt {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: text;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.shot-prompt:hover {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.shot-prompt-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.shot-prompt-head strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-prompt-head span {
  flex: 0 0 auto;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 650;
}

.shot-prompt-ai {
  flex: 0 0 auto;
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--color-primary-muted);
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.shot-prompt-ai:hover {
  border-color: var(--color-primary);
  background: #fff;
}

.shot-prompt-ai:disabled {
  border-color: var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}

.shot-prompt p {
  display: -webkit-box;
  min-height: 34px;
  margin: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.shot-prompt-status {
  margin-top: 8px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shot-prompt-status.optimizing {
  color: #b76a00;
}

.shot-prompt-status.optimized {
  color: var(--state-success);
}

.shot-prompt-status.error {
  color: var(--state-error);
}

.shot-prompt:has(.shot-prompt-status.optimizing) {
  border-color: rgba(245, 166, 35, 0.5);
  background: rgba(245, 166, 35, 0.08);
}

.shot-prompt:has(.shot-prompt-status.optimized) {
  border-color: rgba(52, 168, 83, 0.32);
  background: rgba(52, 168, 83, 0.07);
}

.shot-prompt:has(.shot-prompt-status.error) {
  border-color: rgba(234, 67, 53, 0.38);
  background: rgba(234, 67, 53, 0.07);
}

.shot-prompt-editor {
  width: 100%;
  min-height: 104px;
  max-height: 180px;
  padding: 8px;
  resize: vertical;
  border: 1px solid var(--color-primary);
  border-radius: calc(var(--radius-md) - 2px);
  background: #fff;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.55;
}

.pearl-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.render-settings-panel {
  overflow: hidden;
}

.render-settings-panel summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  cursor: pointer;
  list-style: none;
}

.render-settings-panel summary::-webkit-details-marker {
  display: none;
}

.render-settings-panel summary strong,
.render-settings-panel summary small {
  display: block;
}

.render-settings-panel summary strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.render-settings-panel summary small {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
}

.settings-chevron {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 650;
}

.render-settings-panel[open] summary {
  border-bottom: 1px solid var(--border-secondary);
}

.video-output-panel {
  display: grid;
  grid-template-columns: minmax(320px, min(44vw, 720px)) minmax(360px, 1fr);
  align-items: start;
  gap: 16px;
  padding: 16px;
}

.video-control-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 16px;
}

.video-control-panel .field {
  gap: 8px;
}

.intro-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
}

.intro-preview-modal[hidden] {
  display: none;
}

.intro-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.intro-preview-sheet {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  width: min(860px, calc(100vw - 48px));
  max-height: min(760px, calc(100vh - 48px));
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.intro-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.intro-preview-head h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
}

.intro-preview-head p {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.intro-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px;
  min-height: 240px;
  min-width: 0;
  align-content: start;
  overflow: auto;
  padding: 2px;
}

.intro-preview-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.intro-preview-card.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, #fff);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 16%, transparent);
}

.intro-preview-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: calc(var(--radius-md) - 2px);
  object-fit: contain;
  background: #000;
}

.intro-preview-card span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intro-preview-empty {
  display: grid;
  align-items: center;
  justify-items: center;
  min-height: 220px;
  border: 1px dashed var(--border-secondary);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: 13px;
}

.intro-preview-empty.error {
  color: var(--state-error);
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.image-preview-sheet {
  position: relative;
  z-index: 1;
  width: min(96vw, 1440px);
  height: min(92vh, 980px);
  display: grid;
  place-items: center;
}

.image-preview-sheet img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #111;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}

.image-preview-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.render-progress {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.render-progress[hidden] {
  display: none;
}

.render-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.render-progress-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.render-progress-head span {
  flex: 0 0 auto;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
}

.render-progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-tertiary);
}

.render-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--color-primary);
  transition: width 240ms ease;
}

.render-progress.error .render-progress-head span {
  color: var(--state-error);
}

.render-progress.error .render-progress-bar {
  background: var(--state-error);
}

.preview-panel {
  min-height: 300px;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: var(--radius-md);
  background: #151515;
}

video {
  display: block;
  background: #050507;
}

#preview {
  width: 100%;
  max-width: 420px;
  max-height: min(68vh, 760px);
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border-radius: calc(var(--radius-md) - 2px);
}

#preview:not([src]) {
  max-width: 100%;
  min-height: 260px;
  aspect-ratio: 16 / 9;
}

.preview-panel.landscape #preview {
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.preview-panel.square #preview {
  max-width: min(100%, 560px);
  aspect-ratio: 1 / 1;
}

.preview-panel.portrait #preview {
  max-width: min(100%, 420px);
  aspect-ratio: 9 / 16;
}

.result-panel {
  min-height: 360px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: #fff;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-secondary);
}

.result-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

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

.text-link {
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.button-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

pre {
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.62;
}

.settings-panel {
  padding: 20px;
}

.settings-title-row {
  margin-bottom: 18px;
}

.settings-form {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px 20px;
  align-items: center;
}

.settings-form .field {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
}

.settings-form .field span {
  color: var(--text-secondary);
}

.prompt-settings-form {
  grid-template-columns: 120px minmax(0, 1fr);
}

.settings-form .full-field {
  align-items: start;
}

.settings-form .full-field span {
  padding-top: 10px;
}

.test-result {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.test-result.testing {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.test-result.ok {
  background: rgba(52, 168, 83, 0.1);
  color: var(--state-success);
}

.test-result.error {
  background: rgba(234, 67, 53, 0.1);
  color: var(--state-error);
}

#ttsPreviewResult {
  max-width: min(560px, 52vw);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-bind-grid,
.reference-create-grid,
.reference-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.reference-upload-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.reference-upload-grid .full-field {
  grid-column: 1 / 4;
}

.toggle-field {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.asset-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
}

.asset-thumb {
  aspect-ratio: 16 / 10;
  background: var(--bg-secondary);
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.asset-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.asset-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.asset-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-title-row span {
  flex: none;
  color: var(--text-secondary);
  font-size: 12px;
}

.asset-body p {
  min-height: 36px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.asset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

.asset-tags em {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  font-style: normal;
}

.text-action.danger {
  color: var(--state-error);
}

.shot-reference {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 1180px) {
  .app-frame {
    min-width: 0;
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .video-output-panel,
  .video-control-panel,
  .project-create-panel,
  .theme-editor-grid,
  .reference-bind-grid,
  .reference-create-grid,
  .reference-upload-grid,
  .copy-editor-grid {
    grid-template-columns: 1fr;
  }

  .reference-upload-grid .full-field {
    grid-column: auto;
  }

  .intro-preview-head {
    align-items: stretch;
    flex-direction: column;
  }

  .intro-preview-sheet {
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
  }

  .intro-preview-grid {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    min-height: 220px;
  }

  .shot-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
