:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #fff7ed;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-orange: #fed7aa;
  --text: #0f172a;
  --text-muted: #64748b;
  --orange: #f97316;
  --orange-hover: #ea580c;
  --orange-soft: #ffedd5;
  --orange-text: #c2410c;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (min-width: 1025px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }
  body {
    display: flex;
    flex-direction: column;
  }
}

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

[hidden] {
  display: none !important;
}

/* Top Header */
.sm-topbar {
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.sm-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1840px;
  margin: 0 auto;
}

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

.sm-brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 8px;
  background: #ffffff;
  flex-shrink: 0;
}

.sm-brand-logo {
  display: block;
  height: 64px;
  width: auto;
  object-fit: contain;
}

.sm-dialog-logo {
  display: block;
  height: 34px;
  width: auto;
  object-fit: contain;
  background: #ffffff;
  border-radius: 6px;
  padding: 2px 4px;
}

.sm-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sm-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sm-brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sm-product-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--orange-text);
  border: 1px solid var(--border-orange);
  white-space: nowrap;
}

.sm-tagline {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#newProjectBtn {
  padding: 11px 22px;
  font-size: 1.08rem;
  font-weight: 700;
  border-radius: 12px;
  line-height: 1.15;
}

.sm-header-typewriter {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  overflow: hidden;
  user-select: none;
}

.sm-tw-inner {
  display: inline;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: clamp(1.15rem, 1.55vw, 1.65rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text);
}

.sm-tw-accent {
  color: #EA580C;
}

.sm-tw-cursor {
  display: inline-block;
  color: #EA580C;
  font-weight: 500;
  font-size: clamp(1.15rem, 1.55vw, 1.65rem);
  line-height: 1.25;
  margin-left: 3px;
  flex-shrink: 0;
  animation: smTwBlink 0.9s step-end infinite;
}

@keyframes smTwBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-tw-cursor {
    animation: none;
    opacity: 0.85;
  }
}

.sm-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.status-dot.ready { background: var(--green); }
.status-dot.error { background: var(--red); }

/* Preview Summary Cards */
.sm-preview-pane-head {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 14px;
}

.sm-summary-cards {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sm-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sm-summary-card-cost {
  background: var(--surface-soft);
  border-color: var(--border-orange);
}

.sm-sum-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-sum-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-summary-card-cost .sm-sum-value {
  color: var(--orange-text);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--orange);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(249, 115, 22, 0.24);
}
.btn-primary:hover:not(:disabled) {
  background: var(--orange-hover);
}
.btn-soft {
  background: var(--surface-soft);
  color: var(--orange-text);
  border-color: var(--border-orange);
}
.btn-soft:hover:not(:disabled) {
  background: var(--orange-soft);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-subtle);
}
.btn-xs { padding: 6px 10px; font-size: 0.76rem; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; }
.btn-generate { width: 100%; padding: 12px 18px; font-size: 0.95rem; border-radius: 12px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 3-Column Desktop Workspace */
.sm-workspace {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 1840px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px 16px;
  display: grid;
  grid-template-columns: minmax(340px, 400px) minmax(0, 1fr) minmax(290px, 340px);
  gap: 16px;
}

.sm-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sm-pane-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sm-pane-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
}

.sm-pane-sub {
  margin: 1px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sm-badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--orange-text);
  border: 1px solid var(--border-orange);
  white-space: nowrap;
}

.sm-setup-scroll,
.sm-progress-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Setup Step Cards */
.sm-step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sm-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sm-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--orange-soft);
  color: var(--orange-text);
  font-size: 0.74rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sm-step-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  flex: 1 1 auto;
}

.sm-step-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: transparent;
}
.sm-step-check.done {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

/* Inputs & Mode Switch */
.sm-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  background: var(--surface-subtle);
  border-radius: 10px;
}

.sm-mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.sm-mode-btn.active {
  background: var(--surface);
  color: var(--orange-text);
  box-shadow: var(--shadow-sm);
}

.sm-mode-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sm-topic-row {
  display: flex;
  gap: 6px;
}

.sm-input {
  width: 100%;
  min-width: 0;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
}
.sm-input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.14);
}
.sm-input-compact {
  width: 88px;
  text-align: center;
}
.sm-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
}

.sm-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.sm-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sm-muted,
.sm-help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.sm-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}

.sm-chip-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
}
.chip-btn:hover {
  border-color: var(--orange);
  background: var(--surface-soft);
}

.sm-hint-box {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-soft);
  border: 1px dashed var(--border-orange);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sm-subhead {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sm-titles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title-card {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: inherit;
}
.title-card:hover {
  border-color: var(--orange);
  background: var(--surface-soft);
}
.title-card.selected {
  border-color: var(--orange);
  background: var(--surface-soft);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}
.title-card-index {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--orange-text);
}
.title-card-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.title-card-angle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Duration Presets */
.sm-duration-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.sm-preset-btn {
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.sm-preset-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #ffffff;
}

.sm-field-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Style & Aspect Ratio Cards */
.sm-style-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sm-choice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.sm-choice-card:hover:not(:disabled) {
  border-color: #fdba74;
  background: #fffaf5;
  transform: translateY(-1px);
}

.sm-choice-card.active {
  border-color: var(--orange);
  background: var(--surface-soft);
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.15);
}

.sm-choice-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}
.sm-choice-body strong { font-size: 0.84rem; font-weight: 700; color: var(--text); }
.sm-choice-body small { font-size: 0.72rem; color: var(--text-muted); line-height: 1.35; }

.sm-style-thumb {
  width: 76px;
  height: 76px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: #e0f2fe;
  box-shadow: var(--shadow-sm);
}

.sm-style-thumb canvas,
.sm-style-thumb svg {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.24s ease;
}

.sm-choice-card:hover:not(:disabled) .sm-style-thumb canvas,
.sm-choice-card:hover:not(:disabled) .sm-style-thumb svg,
.sm-choice-card.active .sm-style-thumb canvas,
.sm-choice-card.active .sm-style-thumb svg {
  transform: scale(1.03);
}

@media (max-width: 480px) {
  .sm-style-thumb {
    width: 64px;
    height: 64px;
  }
}

.sm-center-style-preview {
  width: 220px;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-orange);
  border-radius: 14px;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: width 0.2s ease;
}

.sm-center-style-preview[data-aspect-ratio="9:16"] {
  width: 196px;
}

.sm-center-style-preview[data-aspect-ratio="16:9"] {
  width: 310px;
}

.sm-center-style-preview[data-aspect-ratio="1:1"] {
  width: 216px;
}

.sm-center-preview-stage {
  width: 100%;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f172a;
}

.sm-center-style-preview[data-aspect-ratio="9:16"] .sm-center-preview-stage {
  width: 146px;
  max-width: 100%;
  aspect-ratio: 9 / 16;
}

.sm-center-style-preview[data-aspect-ratio="16:9"] .sm-center-preview-stage {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.sm-center-style-preview[data-aspect-ratio="1:1"] .sm-center-preview-stage {
  width: 184px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
}

.sm-center-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.sm-center-canvas[hidden] {
  display: none !important;
}

.sm-center-style-preview[data-active-style="stickman_colourful"] .sm-center-canvas-3d,
.sm-center-style-preview[data-active-style="stickman_3d"] .sm-center-canvas-2d {
  display: none !important;
}

.sm-center-style-preview[data-active-style="stickman_colourful"] .sm-center-canvas-2d,
.sm-center-style-preview[data-active-style="stickman_3d"] .sm-center-canvas-3d {
  display: block !important;
}

.sm-center-style-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.74rem;
}

.sm-center-style-tag {
  color: var(--orange-text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.64rem;
}

.sm-preview-actor-2d,
.sm-preview-actor-3d {
  transform-origin: 110px 105px;
  animation: smStyleFloat 3.2s ease-in-out infinite;
}

@keyframes smStyleFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-2.5px); }
}

@media (prefers-reduced-motion: reduce) {
  .sm-preview-actor-2d,
  .sm-preview-actor-3d { animation: none; }
}

.sm-ratio-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sm-ratio-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
}
.sm-ratio-card.active {
  border-color: var(--orange);
  background: var(--surface-soft);
  color: var(--orange-text);
}
.sm-ratio-card strong { font-size: 0.82rem; }
.sm-ratio-card small { font-size: 0.7rem; color: var(--text-muted); }

.sm-ratio-box {
  border: 2px solid currentColor;
  border-radius: 3px;
  display: inline-block;
}
.sm-ratio-9-16 { width: 12px; height: 20px; }
.sm-ratio-16-9 { width: 22px; height: 13px; }
.sm-ratio-1-1  { width: 16px; height: 16px; }

/* Voice-Over Controls */
.sm-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.sm-toggle-row input { accent-color: var(--orange); width: 16px; height: 16px; }

.sm-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sm-voice-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.sm-voice-play-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--radius-sm);
}

.sm-voice-play-btn[data-state="pause"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.sm-voice-play-btn[data-state="pause"]:hover:not(:disabled) {
  background: var(--orange-hover, #ea580c);
  border-color: var(--orange-hover, #ea580c);
}

.sm-audio-player {
  width: 100%;
  height: 36px;
}

.sm-cloning-row,
.sm-upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.sm-audio-box {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sm-audio-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.sm-audio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sm-compat-warning {
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 500;
}

.sm-script-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.74rem;
  color: var(--text-muted);
}

.sm-script-info-row strong {
  color: var(--text);
  font-weight: 700;
}

.sm-script-info-row.is-over-limit {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.sm-script-info-row.is-over-limit strong {
  color: var(--red);
}

/* FPS & Captions Controls */
.sm-subblock {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sm-subblock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sm-fps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.sm-fps-btn {
  padding: 7px 6px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sm-fps-btn strong { font-size: 0.76rem; font-weight: 700; }
.sm-fps-btn span { font-size: 0.64rem; color: var(--text-muted); }

.sm-fps-btn.active {
  border-color: var(--orange);
  background: var(--surface-soft);
  color: var(--orange-text);
}

.sm-fps-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.sm-caption-templates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.sm-caption-tpl {
  padding: 7px 6px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
}

.sm-caption-tpl.active {
  border-color: var(--orange);
  background: var(--surface-soft);
}

.sm-tpl-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 22px;
  border-radius: 5px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
}

.sm-tpl-karaoke { color: #facc15; }
.sm-tpl-highlight { background: #ea580c; color: #ffffff; }
.sm-tpl-cinematic { letter-spacing: 0.08em; font-weight: 600; }

.sm-final-download-bar {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: center;
}

.sm-download-video-btn {
  min-width: 210px;
  padding: 11px 22px;
  font-size: 0.92rem;
  font-weight: 700;
}

/* Center Video Preview Stage */
.sm-preview-meta-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sm-export-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sm-stage-outer {
  flex: 1 1 auto;
  min-height: 0;
  container-type: size;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-frame {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}
.preview-frame.ratio-9-16 { aspect-ratio: 9 / 16; width: min(100cqw, calc(100cqh * 9 / 16)); height: auto; }
.preview-frame.ratio-16-9 { aspect-ratio: 16 / 9; width: min(100cqw, calc(100cqh * 16 / 9)); height: auto; }
.preview-frame.ratio-1-1  { aspect-ratio: 1 / 1;  width: min(100cqw, 100cqh); height: auto; }

.preview-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0f172a;
}

.sm-welcome-state {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  display: block;
  overflow: hidden;
  background: #0f172a;
}

.sm-welcome-state[hidden] {
  display: none !important;
}

.sm-center-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.sm-center-canvas[hidden] {
  display: none !important;
}

.sm-welcome-state[data-active-style="stickman_colourful"] .sm-center-canvas-3d,
.sm-welcome-state[data-active-style="stickman_3d"] .sm-center-canvas-2d {
  display: none !important;
}

.sm-welcome-state[data-active-style="stickman_colourful"] .sm-center-canvas-2d,
.sm-welcome-state[data-active-style="stickman_3d"] .sm-center-canvas-3d {
  display: block !important;
}

.sm-preloader {
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 340px;
}

.sm-welcome-title {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.sm-welcome-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sm-welcome-brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid var(--border-orange);
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.08);
}

.sm-welcome-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 14px;
}

.sm-welcome-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.sm-loader-ring {
  position: relative;
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sm-loader-svg {
  animation: smSpin 1s linear infinite;
}

.sm-loader-icon {
  position: absolute;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
  padding: 2px;
}

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

.sm-preloader-stage {
  font-size: 0.92rem;
  color: var(--text);
}
.sm-preloader-elapsed {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--orange-text);
}
.sm-preloader-bar {
  width: 200px;
  height: 6px;
  border-radius: 999px;
  background: var(--orange-soft);
  overflow: hidden;
}
.sm-preloader-fill {
  height: 100%;
  width: 0%;
  background: var(--orange);
  transition: width 0.2s ease;
}
.sm-preloader-fill.indeterminate {
  width: 42%;
  animation: smSlide 1.2s ease-in-out infinite;
}
@keyframes smSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(260%); }
}

.sm-video-meta {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Right Panel: Project Progress & Collapsible Logs */
.sm-pipeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sm-pipe-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
}

.sm-pipe-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
}
.sm-pipe-state {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sm-pipe-item.is-active {
  border-color: var(--orange);
  background: var(--surface-soft);
}
.sm-pipe-item.is-active .sm-pipe-dot {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.2);
}
.sm-pipe-item.is-active .sm-pipe-state {
  color: var(--orange-text);
}

.sm-pipe-item.is-done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.sm-pipe-item.is-done .sm-pipe-dot {
  background: var(--green);
}
.sm-pipe-item.is-done .sm-pipe-state {
  color: var(--green);
}

.sm-pipe-item.is-error {
  border-color: #fecaca;
  background: var(--red-soft);
}
.sm-pipe-item.is-error .sm-pipe-dot {
  background: var(--red);
}
.sm-pipe-item.is-error .sm-pipe-state {
  color: var(--red);
}

/* Story & Timeline Summary */
.sm-story-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sm-story-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sm-story-summary-head h3 {
  margin: 0;
  font-size: 0.84rem;
}
.sm-inline-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sm-story-text-box {
  max-height: 110px;
  overflow-y: auto;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--surface-subtle);
  padding: 8px 10px;
  border-radius: 8px;
  white-space: pre-wrap;
}
.sm-timeline-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.76rem;
}

/* Collapsible Logs */
.sm-logs-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.sm-logs-summary {
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-subtle);
}
.sm-logs-inner {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.terminal-window {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  overflow: hidden;
}
.terminal-chrome {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}
.terminal-live {
  display: flex;
  align-items: center;
  gap: 5px;
}
.live-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
}
.terminal-body {
  max-height: 170px;
  overflow-y: auto;
  padding: 8px 10px;
  word-break: break-word;
}
.term-line { margin-bottom: 3px; }
.term-ok { color: #4ade80; }
.term-warn { color: #fbbf24; }
.term-error { color: #f87171; }
.term-cmd { color: #fdba74; }
.terminal-footer {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}
.sm-compat-mini {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.72rem;
}
.sm-compat-mini li {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--surface-subtle);
  border-radius: 7px;
}

/* Alert Banner & Modal */
.alert-float-wrap {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(560px, calc(100% - 24px));
}
.alert-banner {
  background: var(--surface);
  border: 1px solid var(--border-orange);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.alert-content p { margin: 3px 0 0; font-size: 0.8rem; color: var(--text-muted); }
.alert-actions { display: flex; gap: 6px; flex-shrink: 0; }

.setup-dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  max-width: 440px;
  width: calc(100% - 24px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.dialog-header h3 { margin: 0; }

/* Mobile Stepper & Bottom Nav (Hidden on Desktop/Tablet) */
.sm-mobile-stepper,
.sm-mobile-nav {
  display: none;
}

/* Tablet Layout (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  .sm-summary-cards {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sm-brand-logo {
    height: 48px;
  }
  #newProjectBtn {
    padding: 9px 18px;
    font-size: 0.96rem;
    border-radius: 10px;
  }
  .sm-tw-inner,
  .sm-tw-cursor {
    font-size: clamp(0.95rem, 1.8vw, 1.25rem);
  }
  .sm-workspace {
    grid-template-columns: 1fr 1fr;
    padding: 10px 16px 20px;
    overflow: visible;
  }
  .sm-pane-progress {
    grid-column: 1 / -1;
  }
  .sm-stage-outer {
    min-height: 440px;
    height: 480px;
  }
}

/* Mobile Guided Flow (<= 767px) */
@media (max-width: 767px) {
  .sm-topbar {
    padding: 8px 10px;
  }
  .sm-brand-logo {
    height: 36px;
  }
  #newProjectBtn {
    padding: 7px 12px;
    font-size: 0.84rem;
    border-radius: 9px;
  }
  .sm-header-typewriter {
    padding: 0 6px;
  }
  .sm-tw-inner,
  .sm-tw-cursor {
    font-size: clamp(0.76rem, 2.9vw, 0.92rem);
  }
  .sm-header-actions {
    gap: 5px;
  }
  #headerStatusText {
    display: none;
  }
  .sm-status-pill {
    padding: 6px 8px;
  }
  .sm-product-pill,
  .sm-tagline,
  #runFixtureBtn {
    display: none;
  }
  .sm-summary-cards {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .sm-summary-card { padding: 6px 9px; }

  .sm-mobile-stepper {
    display: block;
    padding: 6px 12px 10px;
  }
  .sm-mobile-stepper-top {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--orange-text);
    margin-bottom: 5px;
  }
  .sm-mobile-step-track {
    height: 6px;
    border-radius: 999px;
    background: var(--orange-soft);
    overflow: hidden;
  }
  .sm-mobile-step-fill {
    height: 100%;
    background: var(--orange);
    transition: width 0.2s ease;
  }

  .sm-workspace {
    display: block;
    padding: 4px 12px calc(80px + env(safe-area-inset-bottom));
  }
  .sm-pane {
    overflow: visible;
    box-shadow: var(--shadow-sm);
  }
  .sm-setup-scroll,
  .sm-progress-scroll {
    overflow: visible;
    padding: 10px;
  }

  /* Show only the active step on mobile */
  body[data-mobile-step="1"] .sm-pane-preview,
  body[data-mobile-step="1"] .sm-pane-progress,
  body[data-mobile-step="2"] .sm-pane-preview,
  body[data-mobile-step="2"] .sm-pane-progress,
  body[data-mobile-step="3"] .sm-pane-preview,
  body[data-mobile-step="3"] .sm-pane-progress,
  body[data-mobile-step="4"] .sm-pane-preview,
  body[data-mobile-step="4"] .sm-pane-progress,
  body[data-mobile-step="5"] .sm-pane-preview,
  body[data-mobile-step="5"] .sm-pane-progress,
  body[data-mobile-step="6"] .sm-pane-preview,
  body[data-mobile-step="6"] .sm-pane-progress {
    display: none;
  }

  body[data-mobile-step="7"] .sm-pane-setup,
  body[data-mobile-step="7"] .sm-pane-preview {
    display: none;
  }

  body[data-mobile-step="8"] .sm-pane-setup,
  body[data-mobile-step="8"] .sm-pane-progress {
    display: none;
  }

  body[data-mobile-step="1"] .sm-step-card:not([data-step="1"]),
  body[data-mobile-step="2"] .sm-step-card:not([data-step="2"]),
  body[data-mobile-step="3"] .sm-step-card:not([data-step="3"]),
  body[data-mobile-step="4"] .sm-step-card:not([data-step="4"]),
  body[data-mobile-step="5"] .sm-step-card:not([data-step="5"]),
  body[data-mobile-step="6"] .sm-step-card:not([data-step="6"]) {
    display: none;
  }

  /* >= 44px touch targets on mobile */
  .btn,
  .sm-input,
  .sm-mode-btn,
  .sm-preset-btn,
  .sm-choice-card,
  .sm-ratio-card,
  .title-card,
  .sm-mob-btn {
    min-height: 44px;
  }
  .sm-topic-row {
    flex-direction: column;
  }
  .sm-duration-presets {
    grid-template-columns: repeat(3, 1fr);
  }
  .sm-grid-2 {
    grid-template-columns: 1fr;
  }
  .sm-stage-outer {
    min-height: 300px;
    height: min(60dvh, 460px);
    padding: 10px;
  }

  .sm-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}

/* Studio Header Live Credit Pill & Duration Credit Badges */
.sm-header-credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.sm-header-credit-pill:hover { background: #ffedd5; border-color: #fb923c; }
.sm-header-credit-pill[hidden] { display: none; }
.sm-preset-btn { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding-top: 8px; padding-bottom: 6px; }
.sm-preset-cr {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  color: #ea580c;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  padding: 2px 5px;
}
.sm-preset-btn.active .sm-preset-cr { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.4); color: #ffffff; }
.sm-entitle-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.55); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sm-entitle-modal { background: #ffffff; border-radius: 16px; max-width: 420px; width: 100%; padding: 24px; box-shadow: 0 24px 60px rgba(15,23,42,0.22); }
.sm-entitle-modal h3 { margin: 0 0 8px; font-size: 1.15rem; color: #0f172a; }
.sm-entitle-modal p { margin: 0 0 18px; font-size: 0.9rem; color: #475569; line-height: 1.5; }
.sm-entitle-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sm-entitle-actions .btn { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 18px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.sm-entitle-actions .btn-secondary { background: #ffffff; color: #0f172a; border: 1px solid #cbd5e1; }
.sm-entitle-actions .btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }
