:root {
  color-scheme: light;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --ink: #111827;
  --muted: #667085;
  --soft: #98a2b3;
  --line: #d9dee7;
  --line-strong: #c9d1dd;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #e8efff;
  --teal: #0f766e;
  --teal-soft: #e7f5f3;
  --amber: #b7791f;
  --amber-soft: #fff4db;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.07), transparent 330px),
    var(--canvas);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

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

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-block {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.3vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

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

.app-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.05);
  overflow-x: auto;
}

.tab-panel {
  min-width: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  min-width: 176px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill.ready {
  border-color: rgba(15, 118, 110, 0.28);
  background: var(--teal-soft);
  color: #0b5d57;
}

.status-pill.warning {
  border-color: rgba(183, 121, 31, 0.32);
  background: var(--amber-soft);
  color: #87520a;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 16px;
  align-items: start;
}

.script-workspace,
.controls-panel,
.section-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.script-workspace {
  display: grid;
  gap: 14px;
  min-height: 680px;
  padding: 16px;
}

.controls-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  position: sticky;
  top: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.compact-heading {
  align-items: end;
}

.meter-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

label {
  color: #475467;
  font-size: 0.82rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  padding: 13px 14px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#scriptText {
  min-height: 500px;
  max-height: 68vh;
  background: #fff;
  color: #101828;
  font-size: clamp(1.05rem, 1.1vw, 1.22rem);
  line-height: 1.7;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.wide-field {
  grid-column: 1 / -1;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.direction-box {
  min-height: 86px;
  max-height: 180px;
  font-size: 0.92rem;
}

.speaker-panel,
.rewrite-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.speaker-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.speaker-row select {
  grid-column: 2;
}

.speaker-panel.voice-pool-mode input {
  display: none;
}

.speaker-panel.voice-pool-mode select {
  grid-column: 2;
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mood-button {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.mood-button:hover {
  border-color: var(--line-strong);
  background: #fbfcff;
}

.mood-button span {
  display: block;
  margin-bottom: 4px;
  font-weight: 850;
  line-height: 1.2;
}

.mood-button small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.mood-button[aria-checked="true"] {
  border-color: rgba(37, 99, 235, 0.65);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.28);
}

.primary-button,
.secondary-button,
.ghost-action-button,
.ghost-button,
.settings-button,
.tab-button,
.copy-button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.small-primary {
  min-width: 112px;
}

.secondary-button {
  background: #172033;
  color: #fff;
}

.secondary-button:hover {
  background: #26344f;
}

.ghost-action-button,
.ghost-button,
.settings-button,
.tab-button {
  border-color: var(--line);
  background: #fff;
  color: #1f2937;
}

.ghost-action-button:hover,
.ghost-button:hover,
.settings-button:hover,
.tab-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.tab-button {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 18px;
  box-shadow: none;
}

.tab-button.is-active {
  border-color: rgba(37, 99, 235, 0.42);
  background: var(--primary);
  color: #fff;
}

.ghost-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--primary-strong);
}

.danger-button {
  color: var(--danger);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-action-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.button-row,
.download-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.output-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.voice-variant-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.voice-variant-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.voice-variant-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  white-space: nowrap;
}

.voice-variant-list {
  display: grid;
  gap: 8px;
}

.voice-variant-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-muted);
}

.voice-variant-card.is-selected {
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--teal-soft);
}

.voice-variant-card div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.voice-variant-card strong,
.memory-variant-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-variant-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.voice-variant-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.voice-variant-actions .ghost-action-button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 0.8rem;
}

.output-copy {
  min-width: 0;
}

audio {
  width: 100%;
  min-width: 0;
}

.download-link {
  display: none;
  min-height: 38px;
  background: var(--teal);
  color: #fff;
}

.download-link.visible {
  display: inline-flex;
}

.message {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.message.error {
  color: var(--danger);
  font-weight: 760;
}

.error-detail {
  display: none;
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  border: 1px solid rgba(180, 35, 24, 0.26);
  border-radius: 8px;
  padding: 12px;
  background: var(--danger-soft);
  color: #8a1f16;
  white-space: pre-wrap;
  font-size: 0.84rem;
  line-height: 1.45;
}

.error-detail.visible {
  display: block;
}

.section-band {
  margin-top: 16px;
  padding: 16px;
}

.storyboard-panel {
  display: grid;
  gap: 14px;
}

.script-studio-panel {
  display: grid;
  gap: 14px;
}

.script-studio-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.82fr) minmax(0, 1.18fr);
  gap: 16px;
  align-items: start;
}

.script-controls,
.script-result-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.script-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.script-topic-box {
  min-height: 118px;
}

.script-result {
  display: grid;
  gap: 12px;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.script-result-card {
  display: grid;
  gap: 12px;
}

.script-result-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--teal-soft);
  color: #0b5d57;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.script-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.script-meta-grid span,
.source-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
}

.generated-script-box {
  min-height: 250px;
  font-size: 1rem;
  line-height: 1.65;
  background: #fff;
}

.script-angle-list,
.script-quality-list,
.script-sources {
  display: grid;
  gap: 8px;
}

.script-clean-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.script-clean-details summary {
  cursor: pointer;
  font-weight: 850;
}

.script-clean-details textarea {
  margin-top: 10px;
}

.script-angle-list article,
.script-quality-list article,
.script-error-card,
.script-warning-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.script-error-card {
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--danger-soft);
  color: var(--danger);
}

.script-warning-card {
  border-color: rgba(183, 121, 31, 0.32);
  background: var(--amber-soft);
  color: #87520a;
}

.script-error-card pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-size: 0.82rem;
  line-height: 1.45;
}

.script-angle-list p,
.script-quality-list p,
.script-warning-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.script-sources:empty {
  display: none;
}

.source-chip {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  color: var(--primary-strong);
  text-decoration: none;
}

.storyboard-toolbar {
  display: grid;
  grid-template-columns: minmax(250px, 1.35fr) repeat(3, minmax(170px, 0.85fr));
  gap: 12px;
  align-items: start;
}

.storyboard-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.86fr) minmax(0, 1.14fr);
  gap: 16px;
  align-items: start;
}

.storyboard-settings {
  display: grid;
  gap: 14px;
}

.image-style-box {
  min-height: 76px;
}

.timeline-export-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.timeline-export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline-export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.timeline-export-box {
  min-height: 150px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.srt-export-box {
  min-height: 180px;
}

.visual-bible-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.visual-bible-details summary {
  cursor: pointer;
  font-weight: 850;
}

.visual-bible-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.visual-bible-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-muted);
}

.visual-bible-grid strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.visual-bible-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.storyboard-result {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.storyboard-result-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.stock-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 760;
  font-size: 0.88rem;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.stock-video-result {
  display: grid;
  gap: 12px;
}

.stock-summary,
.stock-segment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.stock-summary {
  display: grid;
  gap: 8px;
}

.stock-summary p,
.stock-segment-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
}

.stock-segment-grid {
  display: grid;
  gap: 10px;
}

.stock-segment-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.stock-preview {
  width: 116px;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  object-fit: cover;
}

.stock-preview-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stock-card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.stock-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.stock-card-head strong {
  font-size: 0.98rem;
}

.stock-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stock-chip-row span,
.stock-chip-row a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  text-decoration: none;
}

.stock-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stock-candidate-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 8px;
  display: grid;
  gap: 2px;
  text-align: left;
  cursor: pointer;
}

.stock-candidate-button span {
  font-size: 0.78rem;
  font-weight: 860;
}

.stock-candidate-button small {
  color: var(--muted);
  font-size: 0.7rem;
}

.stock-candidate-button.is-active {
  border-color: var(--primary);
  background: #e8f7f4;
}

.stock-warning {
  border-color: #f0c36a;
  background: #fff7df;
}

.storyboard-summary {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.storyboard-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
}

.character-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.character-strip span,
.memory-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.timeline-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.timeline-details summary {
  cursor: pointer;
  font-weight: 850;
}

.timeline-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.timeline-item {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.timeline-item p,
.timeline-item span,
.timeline-item small {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.timeline-item p {
  color: var(--ink);
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.prompt-card,
.voice-demo-card,
.memory-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.prompt-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 850;
}

.prompt-card h3 {
  font-size: 0.98rem;
}

.duration {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.prompt-card textarea {
  min-height: 150px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.prompt-card details {
  color: var(--muted);
  font-size: 0.86rem;
}

.prompt-card details p {
  margin: 8px 0 0;
}

.copy-button {
  min-height: 34px;
  padding: 0 10px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 16px;
  align-items: start;
}

.secondary-grid .section-band {
  margin-top: 0;
}

.voice-demo-panel,
.memory-panel {
  display: grid;
  gap: 12px;
}

.voice-demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.voice-demo-card div,
.memory-card-head,
.key-item div:first-child {
  min-width: 0;
}

.voice-demo-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-demo-card span,
.voice-demo-card p,
.memory-card-head span,
.memory-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.voice-demo-card strong,
.memory-card-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empty-memory {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: var(--surface-muted);
}

.memory-card-head {
  display: grid;
  gap: 4px;
}

.memory-tags,
.memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.memory-variant-list {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-muted);
}

.memory-variant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-radius: 6px;
  padding: 7px;
  background: #fff;
}

.memory-variant-row.is-selected {
  background: var(--teal-soft);
}

.memory-variant-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.memory-variant-row div {
  display: flex;
  gap: 5px;
}

.memory-variant-row .ghost-action-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.76rem;
}

.memory-tags span {
  color: #0b5d57;
  background: var(--teal-soft);
}

.memory-actions .ghost-action-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.settings-modal {
  width: min(720px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.settings-modal::backdrop {
  background: rgba(17, 24, 39, 0.55);
}

.settings-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 24px 72px rgba(17, 24, 39, 0.25);
}

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

.compact-settings-head {
  margin-top: 2px;
}

.settings-divider {
  height: 1px;
  background: var(--line);
  margin: 2px 0;
}

.stock-key-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stock-key-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.compact-key-list {
  max-height: 190px;
  overflow: auto;
}

.key-list {
  display: grid;
  gap: 10px;
}

.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.key-item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.key-actions,
.key-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key-form input {
  flex: 1 1 190px;
}

@media (max-width: 1180px) {
  .workbench,
  .storyboard-layout,
  .script-studio-layout,
  .stock-key-grid,
  .secondary-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

  .storyboard-result:empty {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 10px;
  }

  .app-header,
  .section-heading,
  .output-panel,
  .storyboard-summary,
  .settings-head,
  .key-item {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .button-row,
  .download-group {
    width: 100%;
    justify-content: stretch;
  }

  .status-pill,
  .settings-button,
  .header-actions > .ghost-action-button,
  .button-row > *,
  .download-group > * {
    width: 100%;
  }

  .app-tabs {
    margin-bottom: 12px;
  }

  .workbench {
    gap: 12px;
  }

  .script-workspace,
  .controls-panel,
  .section-band {
    padding: 12px;
  }

  .script-workspace {
    min-height: auto;
  }

  #scriptText {
    min-height: 360px;
    max-height: none;
  }

  .output-panel,
  .voice-variant-card,
  .memory-variant-row,
  .stock-control-grid,
  .stock-segment-card,
  .storyboard-toolbar,
  .script-control-grid,
  .script-meta-grid,
  .visual-bible-grid,
  .control-grid,
  .mood-grid,
  .prompt-grid,
  .voice-demo-grid,
  .memory-grid {
    grid-template-columns: 1fr;
  }

  .output-panel {
    display: grid;
  }

  .meter-row {
    justify-content: space-between;
  }

  .compact-heading {
    align-items: stretch;
  }

  .small-primary {
    width: 100%;
  }

  .stock-preview {
    width: min(160px, 100%);
  }

  .speaker-row {
    grid-template-columns: 1fr;
  }

  .speaker-row select {
    grid-column: auto;
  }
}

/* Clean creator-studio UI refresh */
:root {
  --canvas: #eef3f8;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --ink: #101828;
  --muted: #596579;
  --soft: #8a95a8;
  --line: #d6deea;
  --line-strong: #b9c4d4;
  --primary: #2457e6;
  --primary-strong: #173fba;
  --primary-soft: #eaf0ff;
  --teal: #0d7a73;
  --teal-soft: #e6f6f3;
  --amber: #aa6a12;
  --amber-soft: #fff4dd;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 10px 28px rgba(16, 24, 40, 0.06);
}

html {
  background: var(--canvas);
}

body {
  background:
    linear-gradient(180deg, rgba(36, 87, 230, 0.08), rgba(13, 122, 115, 0.04) 360px, transparent 740px),
    var(--canvas);
}

.app-shell {
  width: min(1540px, calc(100% - 36px));
  padding: 20px 0 42px;
}

.app-header {
  min-height: 82px;
  margin-bottom: 12px;
  border-color: rgba(214, 222, 234, 0.92);
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.brand-block {
  gap: 4px;
}

.brand-subtitle {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.7rem;
}

h1 {
  font-size: clamp(1.55rem, 2.4vw, 2.35rem);
}

h2 {
  font-size: 1.13rem;
}

h3 {
  font-size: 1rem;
}

.header-actions {
  gap: 8px;
}

.status-pill {
  min-height: 36px;
  min-width: 160px;
  border-color: rgba(214, 222, 234, 0.95);
  background: #f9fbff;
  font-size: 0.82rem;
}

.app-tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-bottom: 10px;
  border-color: rgba(214, 222, 234, 0.95);
  padding: 5px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.tab-button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 16px;
  color: #344054;
  font-size: 0.88rem;
}

.tab-button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(36, 87, 230, 0.2);
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}

.workflow-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  min-height: 58px;
  border: 1px solid rgba(214, 222, 234, 0.9);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.68);
}

.workflow-step span {
  grid-row: 1 / 3;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #eef2f7;
  color: #516076;
  font-size: 0.74rem;
  font-weight: 900;
}

.workflow-step strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step.is-live {
  border-color: rgba(36, 87, 230, 0.45);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.workflow-step.is-live span {
  background: var(--primary);
  color: #fff;
}

.section-band,
.script-studio-panel,
.storyboard-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.section-band {
  margin-top: 0;
  padding: 0;
}

.script-studio-panel,
.storyboard-panel {
  gap: 14px;
}

.script-studio-panel > .section-heading,
.storyboard-panel > .section-heading,
.voice-demo-panel > .section-heading,
.memory-panel > .section-heading {
  min-height: 64px;
  border: 1px solid rgba(214, 222, 234, 0.92);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.workbench {
  grid-template-columns: minmax(0, 1fr) minmax(350px, 408px);
  gap: 14px;
}

.script-workspace,
.controls-panel,
.script-controls,
.script-result-panel,
.storyboard-settings,
.storyboard-result-column,
.voice-demo-panel,
.memory-panel {
  border: 1px solid rgba(214, 222, 234, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.script-workspace,
.controls-panel {
  padding: 16px;
}

.script-controls,
.script-result-panel,
.storyboard-settings,
.storyboard-result-column,
.voice-demo-panel,
.memory-panel {
  min-width: 0;
  padding: 14px;
}

.controls-panel {
  top: 74px;
}

.script-studio-layout {
  grid-template-columns: minmax(350px, 0.76fr) minmax(0, 1.24fr);
  gap: 14px;
}

.storyboard-layout {
  grid-template-columns: minmax(340px, 0.78fr) minmax(0, 1.22fr);
  gap: 14px;
}

.script-controls,
.storyboard-settings {
  align-content: start;
}

.script-result-panel,
.storyboard-result-column {
  min-height: 520px;
}

.storyboard-result-column:has(.storyboard-result:empty):has(.stock-video-result:empty) {
  min-height: 420px;
}

.storyboard-toolbar {
  grid-template-columns: minmax(260px, 1.35fr) repeat(3, minmax(160px, 0.85fr));
  border: 1px solid rgba(214, 222, 234, 0.92);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.secondary-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
  align-items: start;
}

label {
  color: #415064;
  font-size: 0.8rem;
}

input,
select,
textarea {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 40px;
}

textarea {
  line-height: 1.56;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(36, 87, 230, 0.72);
  box-shadow: 0 0 0 3px rgba(36, 87, 230, 0.14);
}

#scriptText {
  min-height: 480px;
  max-height: 66vh;
  border-color: rgba(185, 196, 212, 0.9);
  background: #fff;
  font-size: clamp(1.02rem, 1vw, 1.16rem);
}

.script-topic-box {
  min-height: 126px;
}

.direction-box {
  min-height: 82px;
}

.hint {
  color: var(--muted);
  font-size: 0.79rem;
}

.primary-button,
.secondary-button,
.ghost-action-button,
.ghost-button,
.settings-button,
.tab-button,
.copy-button,
.download-link {
  min-height: 40px;
  border-radius: 7px;
  padding: 0 13px;
  font-size: 0.88rem;
}

.primary-button,
.secondary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(36, 87, 230, 0.2);
}

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

.ghost-action-button,
.ghost-button,
.settings-button {
  border-color: var(--line);
  background: #fff;
  color: #293548;
}

.ghost-action-button:hover,
.ghost-button:hover,
.settings-button:hover {
  border-color: var(--line-strong);
  background: #f8fafd;
}

.danger-button {
  border-color: rgba(180, 35, 24, 0.24);
  color: var(--danger);
}

.button-row,
.download-group,
.timeline-export-actions {
  gap: 7px;
}

.mood-grid {
  gap: 8px;
}

.mood-button {
  min-height: 76px;
  border-color: var(--line);
  background: #fff;
}

.mood-button:hover {
  border-color: rgba(36, 87, 230, 0.28);
  transform: translateY(-1px);
}

.mood-button span {
  color: #182230;
}

.mood-button[aria-checked="true"] {
  border-color: rgba(13, 122, 115, 0.56);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 1px rgba(13, 122, 115, 0.22);
}

.speaker-panel,
.rewrite-panel,
.output-panel,
.voice-variant-panel,
.timeline-export-panel,
.stock-summary,
.stock-segment-card,
.script-result,
.script-clean-details,
.script-angle-list article,
.script-quality-list article,
.script-error-card,
.script-warning-card,
.stock-key-panel,
.key-item {
  border-color: rgba(214, 222, 234, 0.95);
  border-radius: 8px;
}

.output-panel {
  grid-template-columns: minmax(150px, 0.55fr) minmax(260px, 1fr) auto;
  background: var(--surface-muted);
}

.voice-variant-panel,
.timeline-export-panel,
.script-result {
  background: var(--surface-muted);
}

.generated-script-box,
.timeline-export-box,
.srt-export-box {
  border-color: rgba(185, 196, 212, 0.86);
  background: #fff;
}

.timeline-export-box {
  min-height: 138px;
}

.srt-export-box {
  min-height: 170px;
}

.stock-video-panel {
  background: #fbfcff;
}

.stock-control-grid {
  gap: 9px;
}

.checkbox-row {
  min-height: 32px;
}

.stock-segment-card {
  grid-template-columns: 108px minmax(0, 1fr);
}

.stock-preview {
  width: 108px;
}

.stock-chip-row span,
.stock-chip-row a,
.script-meta-grid span,
.source-chip,
.score-pill,
.memory-tags span {
  border-radius: 999px;
}

.memory-grid,
.voice-demo-grid {
  gap: 10px;
}

.settings-card {
  border-color: rgba(214, 222, 234, 0.95);
  box-shadow: 0 28px 80px rgba(16, 24, 40, 0.25);
}

@media (max-width: 1180px) {
  .workflow-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .script-result-panel,
  .storyboard-result-column {
    min-height: 0;
  }

  .controls-panel {
    top: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 10px;
  }

  .app-header {
    gap: 12px;
  }

  .brand-subtitle {
    font-size: 0.86rem;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }

  .workflow-step {
    min-height: 52px;
  }

  .app-tabs {
    top: 0;
    margin-bottom: 10px;
    max-width: 100%;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .tab-button {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 0;
    padding: 0 8px;
  }

  .script-studio-panel > .section-heading,
  .storyboard-panel > .section-heading,
  .voice-demo-panel > .section-heading,
  .memory-panel > .section-heading,
  .storyboard-toolbar,
  .script-controls,
  .script-result-panel,
  .storyboard-settings,
  .storyboard-result-column,
  .voice-demo-panel,
  .memory-panel {
    padding: 12px;
  }

  .workbench,
  .script-studio-layout,
  .storyboard-layout,
  .secondary-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .script-controls,
  .script-result-panel,
  .storyboard-settings,
  .storyboard-result-column,
  .voice-demo-panel,
  .memory-panel {
    width: 100%;
    max-width: 100%;
  }

  .storyboard-toolbar,
  .script-control-grid,
  .script-meta-grid,
  .visual-bible-grid,
  .control-grid,
  .mood-grid,
  .stock-control-grid,
  .stock-segment-card,
  .stock-key-grid,
  .prompt-grid,
  .voice-demo-grid,
  .memory-grid {
    grid-template-columns: 1fr;
  }

  #scriptText {
    min-height: 360px;
  }

  .output-panel {
    grid-template-columns: 1fr;
  }
}
