/* ============================================================
   STORY CANVAS — Standalone Page Styles
   3-Stage Pipeline: Input → Outline → Canvas
   ============================================================ */

/* ── CSS Variables (inherit from parent, define SC-specific) ── */
:root {
    --sc-sidebar-width: 400px;
    --sc-filmstrip-width: 300px;
    --sc-toolbar-height: 52px;
    --sc-bottom-bar-height: 56px;
    --sc-nav-height: 64px;
    --sc-progress-height: 4px;
    --sc-radius: 10px;
    --sc-radius-sm: 6px;
    --sc-radius-lg: 14px;
    --sc-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --sc-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --sc-shadow-lg: 0 8px 30px rgba(0,0,0,0.15);
    --sc-accent: #6366f1;
    --sc-accent-hover: #4f46e5;
    --sc-accent-light: #eef2ff;
    --sc-success: #10b981;
    --sc-warning: #f59e0b;
    --sc-danger: #ef4444;
    --sc-bg: #fafbfc;
    --sc-bg-card: #ffffff;
    --sc-bg-sidebar: #f8f9fb;
    --sc-border: #e5e7eb;
    --sc-text: #1e293b;
    --sc-text-secondary: #64748b;
    --sc-text-muted: #94a3b8;
}

/* ── Page Root (override goatgraphics.css !important) ── */
html, body {
    margin: 0;
    padding: 0;
    height: 100% !important;
    overflow: hidden !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--sc-bg);
    color: var(--sc-text);
}

body {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
}

* { box-sizing: border-box; }

/* (header styles from goatgraphics.css) */

/* ── Stage Progress Bar ── */
.sc-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 48px;
    background: var(--sc-bg-card);
    border-bottom: 1px solid var(--sc-border);
}
.sc-progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
}
.sc-progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sc-text-muted);
    cursor: default;
    position: relative;
    transition: color 0.2s;
}
.sc-progress-step.active {
    color: var(--sc-accent);
    font-weight: 600;
}
.sc-progress-step.completed {
    color: var(--sc-success);
    cursor: pointer;
}
.sc-progress-step.completed:hover { opacity: 0.85; }
.sc-progress-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--sc-border);
    color: var(--sc-text-muted);
    transition: all 0.2s;
}
.sc-progress-step.active .sc-progress-num {
    background: var(--sc-accent);
    color: #fff;
}
.sc-progress-step.completed .sc-progress-num {
    background: var(--sc-success);
    color: #fff;
}
.sc-progress-connector {
    flex: 0 0 40px;
    height: 2px;
    background: var(--sc-border);
    transition: background 0.3s;
}
.sc-progress-connector.done { background: var(--sc-success); }

/* ── Main Content Area — grid: stages left, settings right ── */
.sc-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 340px;
    overflow: hidden;
    position: relative;
}

/* Stages area takes up the left column */
.sc-stages-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ============================================================
   STAGE 1: INPUT
   ============================================================ */
.sc-stage { display: none; flex: 1; overflow: hidden; }
.sc-stage.active { display: flex; }

/* Input stage — single column, source panel fills width */
.sc-stage-input {
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 24px;
}
.sc-stage-input .workspace-grid {
    width: 100%;
    display: block;
}

/* Source panel overrides for story canvas */
.sc-source-panel { min-height: 70vh; }
.sc-source-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sc-source-panel .panel-header h2 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}
.sc-source-panel .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 56px;
    position: relative;
}

/* Editor wrapper inside source panel */
.sc-editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Config panel — right sidebar, persists across stages 1 & 2 */
.sc-config-panel {
    position: static;
    inset: auto;
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    z-index: auto;
    animation: none;
    overflow-y: auto;
    border-left: 1px solid var(--sc-border);
    background: var(--sc-bg-sidebar);
}
.sc-config-panel .sc-select,
.sc-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    font-size: 12px;
    background: var(--sc-bg-card);
    color: var(--sc-text);
}

/* Mode tabs (Create | Record) — compact for panel header */
.sc-input-mode-tabs {
    display: flex;
    gap: 0;
    background: var(--sc-bg, #f1f5f9);
    border-radius: var(--sc-radius);
    padding: 3px;
}
.sc-input-mode-tab {
    padding: 5px 14px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--sc-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.sc-input-mode-tab.active {
    background: var(--sc-bg-card);
    color: var(--sc-text);
    box-shadow: var(--sc-shadow-sm);
}

/* Record mode */
.sc-record-area { display: none; }
.sc-record-area.active { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.sc-record-waveform-wrap {
    width: 100%;
    max-width: 600px;
    height: 120px;
    background: #f1f5f9;
    border-radius: var(--sc-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.sc-record-waveform-wrap canvas {
    width: 100%;
    height: 100%;
}
.sc-record-controls-bar {
    display: flex;
    align-items: center;
    gap: 16px;
}
.sc-record-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid var(--sc-danger);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}
.sc-record-btn::after {
    content: '';
    width: 24px;
    height: 24px;
    background: var(--sc-danger);
    border-radius: 50%;
    transition: all 0.2s;
}
.sc-record-btn.recording::after {
    border-radius: 4px;
    width: 20px;
    height: 20px;
}
.sc-record-btn.recording {
    border-color: var(--sc-danger);
    animation: sc-pulse-ring 1.5s ease-out infinite;
}
@keyframes sc-pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    70% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.sc-record-timer {
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--sc-text);
    min-width: 70px;
    text-align: center;
}
.sc-record-word-count {
    font-size: 13px;
    color: var(--sc-text-muted);
}
.sc-record-transcript-preview {
    width: 100%;
    max-width: 600px;
    max-height: 200px;
    overflow-y: auto;
    padding: 16px;
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    font-size: 14px;
    line-height: 1.6;
    color: var(--sc-text-secondary);
}
.sc-record-transcript-preview:empty::before {
    content: 'Your words will appear here as you speak...';
    color: var(--sc-text-muted);
    font-style: italic;
}

/* Analysis loading overlay */
.sc-analyse-loading {
    display: none;
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--sc-bg) 85%, transparent);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--sc-text-secondary);
    border-radius: var(--sc-radius);
}
.sc-analyse-loading.active {
    display: flex;
}
.sc-analyse-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--sc-border);
    border-top-color: var(--sc-accent);
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}
@keyframes sc-spin {
    to { transform: rotate(360deg); }
}

/* Quick controls (max panels slider) */
.sc-quick-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
}

/* Try sample inline link */
.sc-try-sample-row {
    margin-top: 8px;
}
.sc-try-sample-link {
    background: none;
    border: none;
    color: var(--sc-accent);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.sc-try-sample-link:hover { opacity: 0.8; }

/* Mobile tab bar for prompt/settings panels */
.mobile-tab-bar {
    display: none;
    width: 100%;
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 3px;
    gap: 0;
}
.mobile-tab-bar button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    color: var(--sc-text-secondary);
    transition: all 0.15s;
}
.mobile-tab-bar button.active {
    background: var(--sc-accent);
    color: #fff;
}

/* Character sheet */
.sc-character-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sc-character-entry {
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    padding: 10px;
    position: relative;
}
.sc-character-entry .char-name-display {
    font-size: 13px;
    font-weight: 600;
    color: var(--sc-text);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
    min-height: 24px;
    transition: background 0.15s;
}
.sc-character-entry .char-name-display:hover {
    background: color-mix(in srgb, var(--sc-text) 6%, transparent);
}
.sc-character-entry .char-name-placeholder {
    color: var(--sc-text-muted);
    font-weight: 400;
    font-style: italic;
}
.sc-character-entry .char-name-input {
    display: none;
    width: 100%;
    border: 1px solid var(--sc-accent);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    margin-bottom: 6px;
    color: var(--sc-text);
    background: var(--sc-bg);
}
.sc-character-entry .char-name-input:focus {
    outline: none;
    border-color: var(--sc-accent);
}
.sc-character-entry textarea {
    width: 100%;
    border: 1px solid var(--sc-border);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    font-family: inherit;
    color: var(--sc-text);
    background: var(--sc-bg);
}
.sc-character-entry textarea:focus {
    outline: none;
    border-color: var(--sc-accent);
}
.sc-character-entry textarea { min-height: 90px; resize: vertical; }
.sc-character-remove {
    background: none;
    border: none;
    color: var(--sc-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    position: absolute;
    top: 6px;
    right: 6px;
    line-height: 1;
    z-index: 1;
}
/* Add character card */
.sc-character-add-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    border-style: dashed;
    min-height: 90px;
    color: var(--sc-text-muted);
    font-size: 12px;
    transition: all 0.15s;
}
.sc-character-add-card:hover {
    border-color: var(--sc-accent);
    color: var(--sc-accent);
}
.sc-character-add-icon {
    font-size: 22px;
    line-height: 1;
    font-weight: 300;
}
.sc-character-remove:hover { color: var(--sc-danger); background: #fee2e2; }
.sc-add-character-btn {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--sc-border);
    border-radius: var(--sc-radius-sm);
    background: transparent;
    color: var(--sc-text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.sc-add-character-btn:hover {
    border-color: var(--sc-accent);
    color: var(--sc-accent);
}

/* Custom instructions (collapsible) */
.sc-instr-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--sc-text-secondary);
    padding: 6px 0;
    width: 100%;
    text-align: left;
}
.sc-instr-toggle .chevron {
    font-size: 10px;
    transition: transform 0.2s;
}
.sc-instr-toggle.open .chevron { transform: rotate(90deg); }
.sc-instr-body {
    display: none;
    margin-top: 6px;
}
.sc-instr-body.open { display: block; }
.sc-instr-body textarea {
    width: 100%;
    min-height: 60px;
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    color: var(--sc-text);
    background: var(--sc-bg);
}
.sc-instr-body textarea:focus { outline: none; border-color: var(--sc-accent); }

/* Aspect-ratio icon buttons */
.sc-ratio-control .seg-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px 6px;
}
.sc-ratio-control .seg-option .ratio-icon {
    display: block;
    opacity: 0.55;
    transition: opacity 0.15s;
}
.sc-ratio-control .seg-option:hover .ratio-icon,
.sc-ratio-control .seg-option.active .ratio-icon {
    opacity: 1;
}
.sc-ratio-control .seg-option span {
    font-size: 10px;
    line-height: 1;
}

/* ============================================================
   STAGE 2: OUTLINE
   ============================================================ */
.sc-stage-outline {
    flex-direction: column;
}

/* Characters panel (in content area) */
.sc-outline-characters {
    border-bottom: 1px solid var(--sc-border);
    background: var(--sc-bg-card);
    padding: 0 24px;
}
.sc-outline-characters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}
.sc-outline-characters-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--sc-text);
    padding: 0;
}
.sc-outline-characters-toggle .chevron {
    font-size: 10px;
    transition: transform 0.2s;
}
.sc-outline-characters-toggle.open .chevron {
    transform: rotate(90deg);
}
.sc-outline-characters-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--sc-text-muted);
    margin-left: 4px;
}
.sc-outline-characters-body {
    display: none;
    padding-bottom: 12px;
}
.sc-outline-characters-body.open {
    display: block;
}
.sc-outline-characters .sc-character-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 8px;
}

.sc-outline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--sc-border);
    background: var(--sc-bg-card);
    gap: 16px;
    flex-wrap: wrap;
}
.sc-outline-count {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--sc-text);
}
.sc-outline-count-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.sc-outline-count-controls button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    background: var(--sc-bg-card);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: var(--sc-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.sc-outline-count-controls button:hover {
    border-color: var(--sc-accent);
    color: var(--sc-accent);
}
.sc-outline-count-num {
    min-width: 28px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--sc-accent);
}
.sc-outline-actions {
    display: flex;
    gap: 8px;
}
.sc-outline-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
}
.sc-outline-list {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
/* View mode: single column (list) */
.sc-outline-list.view-list {
    grid-template-columns: 1fr;
    max-width: 700px;
    margin: 0 auto;
}
/* View mode: horizontal scroll */
.sc-outline-list.view-horizontal {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    flex-wrap: nowrap;
    gap: 16px;
    padding-bottom: 12px;
}
.sc-outline-list.view-horizontal .sc-beat-card {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
}
.sc-outline-list.view-horizontal .sc-beat-insert-btn {
    writing-mode: vertical-lr;
    min-width: auto;
    padding: 8px 4px;
    white-space: nowrap;
}
/* View toggle buttons */
.sc-outline-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--sc-bg);
    border-radius: 6px;
    padding: 2px;
    border: 1px solid var(--sc-border);
}
.sc-outline-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--sc-text-muted);
    transition: all 0.15s;
}
.sc-outline-view-btn:hover {
    color: var(--sc-text);
}
.sc-outline-view-btn.active {
    background: var(--sc-bg-card);
    color: var(--sc-accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Beat cards */
.sc-beat-card {
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 16px;
    position: relative;
    transition: all 0.15s;
    cursor: default;
}
.sc-beat-card:hover { border-color: #c7d2fe; }
.sc-beat-card.dragging {
    opacity: 0.5;
    border-color: var(--sc-accent);
    box-shadow: var(--sc-shadow-md);
}
.sc-beat-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.sc-beat-card-drag {
    cursor: grab;
    color: var(--sc-text-muted);
    font-size: 16px;
    padding: 2px 4px;
    user-select: none;
}
.sc-beat-card-drag:active { cursor: grabbing; }
.sc-beat-card-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sc-accent-light);
    color: var(--sc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.sc-beat-card-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--sc-text);
}
.sc-beat-card-actions {
    display: flex;
    gap: 4px;
}
.sc-beat-card-actions button {
    background: none;
    border: none;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--sc-text-muted);
    font-size: 13px;
    transition: all 0.15s;
}
.sc-beat-card-actions button:hover { background: #f1f5f9; color: var(--sc-text); }
.sc-beat-card-actions button.delete:hover { background: #fee2e2; color: var(--sc-danger); }
.sc-beat-card-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--sc-text);
    width: 100%;
    border: 1px solid transparent;
    border-radius: var(--sc-radius-sm);
    padding: 6px 8px;
    background: transparent;
    resize: none;
    font-family: inherit;
    min-height: 44px;
    transition: all 0.15s;
}
.sc-beat-card-text:focus {
    outline: none;
    border-color: var(--sc-accent);
    background: var(--sc-bg);
}
.sc-beat-card-visual {
    margin-top: 8px;
    font-size: 12px;
    color: var(--sc-text-muted);
    font-style: italic;
    padding: 6px 8px;
    background: #f8fafc;
    border-radius: var(--sc-radius-sm);
    border-left: 3px solid var(--sc-border);
}
.sc-beat-insert-btn {
    align-self: center;
    padding: 4px 12px;
    border: 1px dashed var(--sc-border);
    border-radius: 20px;
    background: transparent;
    color: var(--sc-text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    margin: -2px 0;
}
/* Hide insert buttons in grid (2-col) — they break the grid layout */
.sc-outline-list:not(.view-list):not(.view-horizontal) .sc-beat-insert-btn {
    display: none;
}
/* In list mode, show normally */
.sc-outline-list.view-list .sc-beat-insert-btn {
    display: block;
}
.sc-beat-insert-btn:hover {
    border-color: var(--sc-accent);
    color: var(--sc-accent);
    background: var(--sc-accent-light);
}

/* Loading skeleton for outline */
.sc-outline-loading {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 700px;
}
.sc-outline-skeleton {
    height: 80px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: sc-shimmer 1.5s infinite;
    border-radius: var(--sc-radius);
}
@keyframes sc-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   STAGE 3: CANVAS (Filmstrip + Main + Sidebar)
   ============================================================ */
.sc-stage-canvas {
    flex-direction: row;
}

/* ══════════════════════════════════════════════════════════════
   STAGE 3: PRODUCTION
   ══════════════════════════════════════════════════════════════ */
.sc-stage-production {
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    background: var(--sc-bg);
}
.sc-production-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}
.sc-production-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* Cards */
.sc-prod-card {
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 18px;
}
.sc-prod-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.sc-prod-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--sc-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.sc-prod-card-header .sc-prod-card-title {
    margin-bottom: 0;
}
/* Labels & inputs */
.sc-prod-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--sc-text-muted);
    margin-bottom: 4px;
}
.sc-prod-hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--sc-text-muted);
    opacity: 0.7;
}
/* Inline select + play button row */
.sc-select-preview-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sc-select-preview-row .sc-select {
    flex: 1;
    min-width: 0;
}
.sc-preview-play-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    background: var(--sc-bg-card);
    color: var(--sc-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 0;
}
.sc-preview-play-btn:hover {
    background: var(--sc-accent);
    color: #fff;
    border-color: var(--sc-accent);
}
.sc-preview-play-btn.playing {
    background: color-mix(in srgb, var(--sc-accent) 15%, transparent);
    border-color: var(--sc-accent);
    color: var(--sc-accent);
}
.sc-preview-play-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.sc-preview-icon {
    width: 14px;
    height: 14px;
    pointer-events: none;
}
.sc-prod-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    font-size: 13px;
    background: var(--sc-bg-input, var(--sc-bg));
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    color: var(--sc-text);
    outline: none;
    transition: border-color 0.15s;
}
.sc-prod-input:focus {
    border-color: var(--sc-accent);
}
.sc-prod-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    font-size: 13px;
    background: var(--sc-bg-input, var(--sc-bg));
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    color: var(--sc-text);
    outline: none;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
}
.sc-prod-textarea:focus {
    border-color: var(--sc-accent);
}
/* Toggle row (checkbox + label) */
.sc-prod-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--sc-text);
    cursor: pointer;
    margin-bottom: 10px;
    user-select: none;
}
.sc-prod-toggle-row input[type="checkbox"] {
    accent-color: var(--sc-accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}
/* iOS-style toggle switch */
.sc-prod-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
    flex-shrink: 0;
}
.sc-prod-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.sc-prod-switch-slider {
    position: absolute;
    inset: 0;
    background: var(--sc-border);
    border-radius: 22px;
    transition: background 0.2s;
}
.sc-prod-switch-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.sc-prod-switch input:checked + .sc-prod-switch-slider {
    background: var(--sc-accent);
}
.sc-prod-switch input:checked + .sc-prod-switch-slider::before {
    transform: translateX(18px);
}
/* Title suggestions */
.sc-prod-suggest-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 8px;
}
.sc-prod-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.sc-prod-suggestion-card {
    padding: 10px 12px;
    background: var(--sc-bg);
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.sc-prod-suggestion-card:hover {
    border-color: var(--sc-accent);
    background: color-mix(in srgb, var(--sc-accent) 6%, var(--sc-bg));
}
.sc-prod-suggestion-card.selected {
    border-color: var(--sc-accent);
    background: color-mix(in srgb, var(--sc-accent) 10%, var(--sc-bg));
}
.sc-prod-suggestion-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--sc-text);
}
.sc-prod-suggestion-subtitle {
    font-size: 12px;
    color: var(--sc-text-muted);
    margin-top: 2px;
}
/* Collapsed body (end page off by default) */
.sc-prod-collapsed {
    display: none;
}
/* Responsive */
@media (max-width: 680px) {
    .sc-production-layout {
        grid-template-columns: 1fr;
    }
    .sc-stage-production {
        padding: 16px;
    }
}

/* Filmstrip (left) */
.sc-filmstrip {
    width: var(--sc-filmstrip-width);
    min-width: 80px;
    max-width: 300px;
    background: var(--sc-bg-sidebar);
    border-right: 1px solid var(--sc-border);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    position: relative;
    flex-shrink: 0;
}
/* Drag-to-resize handle on right edge */
.sc-filmstrip-resize {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 5;
    background: transparent;
    transition: background 0.15s;
}
.sc-filmstrip-resize:hover,
.sc-filmstrip-resize.dragging {
    background: var(--sc-accent);
    opacity: 0.4;
}
.sc-filmstrip-item {
    width: 100%;
    border-radius: var(--sc-radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.15s;
    background: var(--sc-bg);
}
.sc-filmstrip-item:hover { border-color: #c7d2fe; }
.sc-filmstrip-item.active { border-color: var(--sc-accent); box-shadow: 0 0 0 2px var(--sc-accent-light); }
.sc-filmstrip-item img {
    width: 100%;
    height: auto;
    display: block;
}
.sc-filmstrip-item .sc-film-num {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
}
.sc-filmstrip-item .sc-film-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
}
.sc-film-status.done { background: var(--sc-success); color: #fff; }
.sc-film-status.generating {
    background: var(--sc-warning);
    color: #fff;
    animation: sc-pulse-ring 1.5s ease-out infinite;
}
.sc-film-status.failed { background: var(--sc-danger); color: #fff; }
.sc-filmstrip-item.dragging { opacity: 0.4; }
.sc-filmstrip-add {
    width: 100%;
    height: 44px;
    border-radius: var(--sc-radius-sm);
    border: 2px dashed var(--sc-border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sc-text-muted);
    font-size: 18px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.sc-filmstrip-add:hover {
    border-color: var(--sc-accent);
    color: var(--sc-accent);
}

/* Canvas center (main display) */
.sc-canvas-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.sc-canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--sc-bg-card);
    border-bottom: 1px solid var(--sc-border);
    flex-wrap: wrap;
}
.sc-canvas-display {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    position: relative;
}
.sc-canvas-display img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--sc-radius);
    box-shadow: var(--sc-shadow-md);
}
.sc-canvas-caption {
    padding: 12px 20px;
    border-top: 1px solid var(--sc-border);
    background: var(--sc-bg-card);
}
.sc-canvas-caption textarea {
    width: 100%;
    border: 1px solid transparent;
    border-radius: var(--sc-radius-sm);
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    font-family: inherit;
    color: var(--sc-text);
    background: transparent;
    min-height: 40px;
    transition: all 0.15s;
}
.sc-canvas-caption textarea:focus {
    outline: none;
    border-color: var(--sc-accent);
    background: var(--sc-bg);
}
.sc-canvas-caption-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sc-text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

/* Canvas sidebar (right) */
.sc-canvas-sidebar {
    width: var(--sc-sidebar-width);
    border-left: 1px solid var(--sc-border);
    background: var(--sc-bg-sidebar);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.sc-canvas-sidebar-section h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sc-text-muted);
    margin: 0 0 10px 0;
    font-weight: 600;
}

/* Video settings in sidebar */
.sc-video-setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}
.sc-video-setting-row label {
    flex: 0 0 80px;
    color: var(--sc-text-secondary);
    font-weight: 500;
}
.sc-video-setting-row select,
.sc-video-setting-row input[type="checkbox"] {
    font-size: 12px;
}
.sc-video-setting-row select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    color: var(--sc-text);
    background: var(--sc-bg-card);
}

/* Transcript panel in sidebar */
.sc-sidebar-transcript {
    font-size: 13px;
    line-height: 1.6;
    color: var(--sc-text-secondary);
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: var(--sc-bg);
    border-radius: var(--sc-radius-sm);
    border: 1px solid var(--sc-border);
}

/* ============================================================
   VIEW MODE SWITCHER + PANEL NAV
   ============================================================ */
.sc-view-switcher {
    display: flex;
    gap: 2px;
    background: var(--sc-bg);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    padding: 2px;
}
.sc-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--sc-text-muted);
    transition: all 0.15s;
}
.sc-view-btn:hover { color: var(--sc-text); background: var(--sc-bg-card); }
.sc-view-btn.active { color: var(--sc-accent); background: var(--sc-bg-card); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.sc-view-btn svg { pointer-events: none; }

.sc-toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--sc-border);
    flex-shrink: 0;
}

.sc-panel-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sc-panel-counter {
    font-size: 12px;
    font-weight: 600;
    color: var(--sc-text-secondary);
    min-width: 44px;
    text-align: center;
}

/* ============================================================
   CANVAS VIEW CONTAINERS
   ============================================================ */
.sc-view-single,
.sc-view-timeline,
.sc-view-storyboard {
    display: none;
}
.sc-view-single.active,
.sc-view-timeline.active,
.sc-view-storyboard.active {
    display: flex;
}

/* Single view — scrollable so tall images are never clipped */
.sc-view-single {
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    position: relative;
    background: var(--sc-bg);
}

/* ============================================================
   TIMELINE VIEW — swimlane layout
   ============================================================ */
.sc-view-timeline {
    overflow: hidden;
    background: var(--sc-bg);
    display: flex;
    flex-direction: column;
    /* CSS variables for swimlane dimensions */
    --tl-panel-w: 160px;
    --tl-panel-h: 130px;
    --tl-narration-h: 85px;
    --tl-bgm-h: 34px;
    --tl-gap: 8px;
    --tl-label-w: 64px;
}

/* Outer wrapper: labels col + scrollable swimlane area */
.sc-tl-wrapper {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
}

/* Left-hand row labels */
.sc-tl-labels-col {
    flex: 0 0 var(--tl-label-w);
    display: flex;
    flex-direction: column;
    padding: 20px 0 8px;
    border-right: 1px solid var(--sc-border);
    background: var(--sc-bg-sidebar);
}
.sc-tl-row-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sc-text-muted);
    white-space: nowrap;
}
.sc-tl-labels-col .sc-tl-row-label:nth-child(1) {
    height: var(--tl-panel-h);
    align-items: flex-start;
    padding-top: 4px;
}
.sc-tl-labels-col .sc-tl-row-label:nth-child(2) {
    height: var(--tl-narration-h);
    margin-top: var(--tl-gap);
}
.sc-tl-labels-col .sc-tl-row-label:nth-child(3) {
    height: var(--tl-bgm-h);
    margin-top: var(--tl-gap);
}

/* Horizontal scrolling content area */
.sc-tl-scroll {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 20px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: var(--tl-gap);
    scrollbar-width: thin;
}

/* Each horizontal swimlane row */
.sc-tl-row {
    display: flex;
    gap: var(--tl-gap);
    flex-shrink: 0;
}

/* ----- Panel row ----- */
.sc-tl-row-panels { height: var(--tl-panel-h); align-items: flex-start; }
.sc-tl-panel {
    flex: 0 0 var(--tl-panel-w);
    height: var(--tl-panel-h);
    border-radius: var(--sc-radius-sm);
    border: 2px solid var(--sc-border);
    background: var(--sc-bg-card);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}
.sc-tl-panel:hover {
    border-color: var(--sc-accent-light);
    transform: translateY(-2px);
    box-shadow: var(--sc-shadow-md);
}
.sc-tl-panel.active {
    border-color: var(--sc-accent);
    box-shadow: 0 0 0 2px var(--sc-accent-light);
}
.sc-tl-panel img {
    width: 100%;
    flex: 1;
    object-fit: cover;
    display: block;
}
.sc-tl-num {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    pointer-events: none;
}
.sc-tl-panel-type {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    pointer-events: none;
}
.sc-tl-panel.sc-tl-loading {
    cursor: default;
    pointer-events: none;
    border-style: dashed;
    background: linear-gradient(90deg, var(--sc-bg-card) 25%, var(--sc-bg-sidebar) 50%, var(--sc-bg-card) 75%);
    background-size: 200% 100%;
    animation: sc-shimmer 1.5s linear infinite;
}
.sc-tl-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    border: 2px solid var(--sc-border);
    border-top-color: var(--sc-accent);
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}

/* ----- Narration row ----- */
.sc-tl-row-narration { height: var(--tl-narration-h); align-items: stretch; }
.sc-tl-narration-cell {
    flex: 0 0 var(--tl-panel-w);
    height: var(--tl-narration-h);
    border-radius: var(--sc-radius-sm);
    border: 1px solid var(--sc-border);
    background: var(--sc-bg-card);
    padding: 6px 8px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--sc-text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    cursor: default;
    box-sizing: border-box;
}
.sc-tl-narration-cell.sc-tl-empty-cell {
    color: var(--sc-text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ----- BGM track row ----- */
.sc-tl-row-bgm { height: var(--tl-bgm-h); align-items: center; }
.sc-tl-bgm-track {
    height: 26px;
    border-radius: 99px;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--sc-accent) 40%, transparent),
        color-mix(in srgb, var(--sc-accent-light) 30%, transparent));
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--sc-text-secondary);
    min-width: 100px;
}
.sc-tl-bgm-off {
    height: 26px;
    border-radius: 99px;
    background: var(--sc-bg-card);
    border: 1px dashed var(--sc-border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 11px;
    color: var(--sc-text-muted);
    font-style: italic;
    min-width: 100px;
}

/* Empty-state placeholder */
.sc-tl-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--sc-text-muted);
    font-size: 14px;
    font-style: italic;
    padding: 40px 0;
}
/* Generating placeholder in storyboard view */
.sc-storyboard-cell.sc-generating {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-style: dashed;
    border-color: var(--sc-border);
    background: linear-gradient(90deg, var(--sc-bg-card) 25%, var(--sc-bg-sidebar) 50%, var(--sc-bg-card) 75%);
    background-size: 200% 100%;
    animation: sc-shimmer 1.5s linear infinite;
    cursor: default;
    pointer-events: none;
}
.sc-storyboard-cell.sc-generating::after {
    content: '';
    width: 28px;
    height: 28px;
    border: 3px solid var(--sc-border);
    border-top-color: var(--sc-accent);
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}
/* ============================================================
   STORYBOARD VIEW (comic book grid)
   ============================================================ */
.sc-view-storyboard {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: var(--sc-bg);
    scrollbar-width: thin;
}
.sc-storyboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.sc-storyboard-cell {
    position: relative;
    border-radius: var(--sc-radius);
    overflow: hidden;
    border: 2px solid var(--sc-border);
    background: var(--sc-bg-card);
    cursor: pointer;
    transition: all 0.2s;
}
.sc-storyboard-cell:hover {
    border-color: var(--sc-accent-light);
    transform: scale(1.02);
    box-shadow: var(--sc-shadow-md);
}
.sc-storyboard-cell.active {
    border-color: var(--sc-accent);
    box-shadow: 0 0 0 2px var(--sc-accent-light);
}
.sc-storyboard-cell img {
    width: 100%;
    height: auto;
    display: block;
}
.sc-storyboard-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}
.sc-storyboard-cell:hover .sc-storyboard-overlay {
    opacity: 1;
}
.sc-storyboard-num {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 1px 5px;
    border-radius: 3px;
    align-self: flex-start;
}
.sc-storyboard-caption {
    font-size: 11px;
    line-height: 1.3;
    color: rgba(255,255,255,0.9);
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.sc-storyboard-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
    min-height: 200px;
    color: var(--sc-text-muted);
    font-size: 14px;
    font-style: italic;
}

/* ============================================================
   BOTTOM ACTION BAR
   ============================================================ */
.sc-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--sc-bottom-bar-height);
    background: var(--sc-bg-card);
    border-top: 1px solid var(--sc-border);
    gap: 12px;
    flex-shrink: 0;
}
.sc-bottom-left, .sc-bottom-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Shared Buttons ── */
.sc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    background: var(--sc-bg-card);
    color: var(--sc-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.sc-btn:hover { border-color: #c7d2fe; background: #f8fafc; }
.sc-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.sc-btn-primary {
    background: var(--sc-accent);
    color: #fff;
    border-color: var(--sc-accent);
}
.sc-btn-primary:hover { background: var(--sc-accent-hover); border-color: var(--sc-accent-hover); }
.sc-btn-primary:disabled { background: var(--sc-accent); opacity: 0.5; }
.sc-btn-danger {
    color: var(--sc-danger);
    border-color: #fecaca;
}
.sc-btn-danger:hover { background: #fef2f2; border-color: var(--sc-danger); }
.sc-btn-success {
    background: var(--sc-success);
    color: #fff;
    border-color: var(--sc-success);
}
.sc-btn-success:hover { background: #059669; }
.sc-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}
.sc-btn-icon {
    padding: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--sc-text-muted);
    border-radius: var(--sc-radius-sm);
    transition: all 0.15s;
}
.sc-btn-icon:hover { background: #f1f5f9; color: var(--sc-text); }

/* ============================================================
   GENERATION OVERLAY (Creative Prelude)
   ============================================================ */
/* ============================================================
   GENERATION STATUS STRIP (non-blocking toolbar indicator)
   ============================================================ */
.sc-gen-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    flex-shrink: 0;
}
.sc-gen-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sc-accent);
    flex-shrink: 0;
    animation: sc-pulse-dot 1.2s ease-in-out infinite;
}
@keyframes sc-pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.35; transform: scale(0.65); }
}
.sc-gen-label {
    font-size: 12px;
    color: var(--sc-text-secondary);
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-gen-mini-progress {
    width: 52px;
    height: 3px;
    background: var(--sc-border);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}
.sc-gen-mini-bar {
    height: 100%;
    background: var(--sc-accent);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}
.sc-btn-stop {
    background: transparent;
    border: 1px solid var(--sc-border);
    color: var(--sc-text-secondary);
    transition: border-color 0.15s, color 0.15s;
}
.sc-btn-stop:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: color-mix(in srgb, #ef4444 8%, transparent);
}
.sc-btn-accent {
    background: transparent;
    border: 1px solid var(--sc-accent);
    color: var(--sc-accent);
    transition: background 0.15s, color 0.15s;
}
.sc-btn-accent:hover {
    background: var(--sc-accent);
    color: white;
}
/* Stopped strip */
.sc-gen-stopped {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--sc-text-secondary);
}

.sc-generating-overlay {
    position: absolute;
    inset: 0;
    background: rgba(248,250,252,0.92);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 20;
    backdrop-filter: blur(4px);
}
.sc-generating-overlay.active { display: flex; }
.sc-generating-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--sc-border);
    border-top-color: var(--sc-accent);
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}
@keyframes sc-spin {
    to { transform: rotate(360deg); }
}
.sc-generating-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--sc-text-secondary);
}
.sc-generating-progress {
    width: 200px;
    height: 4px;
    background: var(--sc-border);
    border-radius: 2px;
    overflow: hidden;
}
.sc-generating-progress-bar {
    height: 100%;
    background: var(--sc-accent);
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.sc-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    padding: 40px;
}
.sc-lightbox.active { display: flex; }
.sc-lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--sc-radius);
}
.sc-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    transition: background 0.15s;
}
.sc-lightbox-close:hover { background: rgba(255,255,255,0.3); }
.sc-lightbox-caption {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    max-width: 600px;
    text-align: center;
}

/* ============================================================
   VIDEO MODAL
   ============================================================ */
.sc-video-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    padding: 40px;
}
.sc-video-modal.active { display: flex; }
.sc-video-modal video {
    max-width: 90vw;
    max-height: 75vh;
    border-radius: var(--sc-radius);
}
.sc-video-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
}
.sc-video-modal-actions {
    display: flex;
    gap: 12px;
}
.sc-video-modal-actions a {
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--sc-radius-sm);
    font-size: 13px;
    transition: all 0.15s;
}
.sc-video-modal-actions a:hover { background: rgba(255,255,255,0.15); }

/* ============================================================
   SAMPLE STORY MODAL
   ============================================================ */
.sc-sample-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.sc-sample-modal.active { display: flex; }
.sc-sample-modal-content {
    background: var(--sc-bg-card);
    border-radius: var(--sc-radius-lg);
    padding: 28px;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--sc-shadow-lg);
    position: relative;
}
.sc-sample-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 4px;
}
.sc-sample-header h3 { font-size: 18px; margin: 0; color: var(--sc-text); flex: 1 1 100%; }
.sc-sample-subtitle {
    font-size: 12px;
    color: var(--sc-text-secondary);
    margin: 4px 0 0 0;
    line-height: 1.4;
    flex: 1 1 100%;
}
.sc-sample-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--sc-text-muted);
    padding: 4px;
    position: absolute;
    top: 16px;
    right: 16px;
}
.sc-sample-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.sc-sample-card {
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}
.sc-sample-card:hover {
    border-color: var(--sc-accent);
    background: var(--sc-accent-light);
}
.sc-sample-icon { font-size: 28px; margin-bottom: 8px; }
.sc-sample-card h4 { font-size: 13px; margin: 0 0 4px 0; color: var(--sc-text); }
.sc-sample-card p { font-size: 11px; color: var(--sc-text-secondary); margin: 0 0 8px 0; line-height: 1.4; }
.sc-sample-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    margin-bottom: 8px;
}
.sc-sample-badge {
    font-size: 9px;
    font-weight: 600;
    color: var(--sc-accent);
    background: var(--sc-accent-light);
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
}
.sc-sample-duration {
    font-size: 10px;
    color: var(--sc-text-muted);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.sc-toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
.sc-toast {
    background: var(--sc-text);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--sc-shadow-lg);
    animation: sc-toast-in 0.3s ease;
    max-width: 400px;
    text-align: center;
}
.sc-toast.out { animation: sc-toast-out 0.3s ease forwards; }
@keyframes sc-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes sc-toast-out {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */
.sc-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    text-align: center;
    color: var(--sc-text-muted);
}
.sc-empty-state svg { opacity: 0.3; }
.sc-empty-state h3 { color: var(--sc-text-secondary); font-size: 16px; margin: 0; }
.sc-empty-state p { font-size: 13px; max-width: 350px; margin: 0; line-height: 1.5; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet (< 1200px) — settings panel stacks below, mobile tab bar shows */
@media (max-width: 1199px) {
    .sc-main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }
    .sc-source-panel { min-height: auto; }
    .sc-config-panel { max-width: none; border-left: none; border-top: 1px solid var(--sc-border); }
    .mobile-tab-bar { display: flex; }
    /* When settings tab active on mobile, hide source and show config */
    .workspace-grid.mobile-tab-settings .sc-source-panel { display: none; }
    .workspace-grid.mobile-tab-settings ~ .sc-config-panel,
    .sc-main.mobile-show-settings .sc-config-panel { display: block; }
    .workspace-grid.mobile-tab-prompt .sc-config-panel { display: none; }
    .workspace-grid.mobile-tab-prompt .sc-source-panel { display: flex; }
    /* Filmstrip stays but shrinks */
    .sc-filmstrip { width: 60px; padding: 6px; }
    .sc-filmstrip-item { width: 48px; height: 48px; }
}

/* Mobile (< 768px) — filmstrip horizontal */
@media (max-width: 767px) {
    .sc-stage-canvas { flex-direction: column; }
    .sc-filmstrip {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid var(--sc-border);
        padding: 6px;
        height: auto;
    }
    .sc-filmstrip-item { width: 48px; height: 48px; }
    .sc-stage-input { padding: 12px; }
    .sc-source-panel .panel-body { padding: 12px; padding-bottom: 56px; }
    .sc-outline-body { padding: 16px; }
    .sc-outline-list { grid-template-columns: 1fr; }
    .sc-outline-view-toggle { display: none; }
    .sc-sample-grid { grid-template-columns: 1fr; }
    .sc-bottom-bar { padding: 0 12px; flex-wrap: wrap; height: auto; padding: 8px 12px; }
    .sc-nav-title { font-size: 14px; }
    .sc-progress { padding: 0 12px; height: 40px; }
    .sc-progress-step { padding: 6px 8px; font-size: 12px; }
}

/* Quick Create area */
.sc-quick-area { display: none; }
.sc-quick-area.active { display: flex; flex-direction: column; gap: 16px; flex: 1; }

.sc-quick-textarea {
    width: 100%;
    min-height: 220px;
    flex: 1;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    background: var(--sc-bg-card);
    color: var(--sc-text);
    resize: vertical;
    font-family: inherit;
}
.sc-quick-textarea:focus {
    outline: none;
    border-color: var(--sc-accent);
    box-shadow: 0 0 0 3px var(--sc-accent-light);
}
.sc-quick-textarea::placeholder {
    color: var(--sc-text-muted);
    font-style: italic;
}

.sc-quick-panels {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--sc-text-muted);
}
.sc-quick-panels label {
    white-space: nowrap;
}
.sc-quick-slider {
    width: 120px;
    accent-color: var(--sc-accent);
}
.sc-quick-panels-val {
    font-weight: 600;
    color: var(--sc-text);
    min-width: 20px;
    text-align: center;
}

/* Title page segmented toggle in quick-controls row */
.sc-quick-title-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--sc-text-muted);
}
.sc-quick-title-label {
    white-space: nowrap;
}
.sc-title-page-seg {
    display: flex;
    background: var(--sc-bg-input, var(--sc-bg-card));
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    overflow: hidden;
}
.sc-title-seg-opt {
    padding: 3px 10px;
    font-size: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sc-text-muted);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.sc-title-seg-opt:hover {
    background: color-mix(in srgb, var(--sc-accent) 10%, transparent);
    color: var(--sc-text);
}
.sc-title-seg-opt.active {
    background: var(--sc-accent);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   QUICK CREATE COUNTDOWN BANNER
   ═══════════════════════════════════════════════════════════════ */
.sc-quick-countdown {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: color-mix(in srgb, var(--sc-accent) 10%, var(--sc-bg-card));
    border: 1px solid color-mix(in srgb, var(--sc-accent) 30%, var(--sc-border));
    border-radius: var(--sc-radius);
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--sc-text);
}
.sc-quick-countdown strong {
    color: var(--sc-accent);
}

/* ═══════════════════════════════════════════════════════════════
   OUTLINE HEADER TEXT
   ═══════════════════════════════════════════════════════════════ */
.sc-outline-header-text {
    font-size: 13px;
    color: var(--sc-text-muted);
    padding: 0 24px 8px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   RECORD AUTO-ANALYZE TOGGLE
   ═══════════════════════════════════════════════════════════════ */
.sc-record-auto-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--sc-text-muted);
    cursor: pointer;
}
.sc-record-auto-toggle input[type="checkbox"] {
    accent-color: var(--sc-accent);
}

/* ============================================================
   STYLE-OPTIONS-GROUP (Custom Instructions Panel — matches index.html)
   ============================================================ */
.sc-source-panel .style-options-group {
    margin: 0;
    border: 1.5px solid var(--sc-border);
    border-radius: var(--sc-radius);
    overflow: hidden;
}
.sc-source-panel .style-options-header {
    padding: 8px 14px;
    background: var(--sc-bg-sidebar);
    border-bottom: 1px solid var(--sc-border);
}
.sc-source-panel .style-options-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sc-text-muted);
}
.sc-source-panel .style-options-body {
    padding: 8px 0 4px;
}
.sc-source-panel .custom-instructions-inline {
    padding: 0;
}
.sc-source-panel .custom-instructions-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--sc-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 14px;
    width: 100%;
    text-align: left;
    transition: color 0.2s;
}
.sc-source-panel .custom-instructions-toggle:hover {
    color: var(--sc-text);
}
.sc-source-panel .custom-instructions-toggle .chevron {
    font-size: 10px;
    transition: transform 0.2s;
}
.sc-source-panel .custom-instructions-toggle.open .chevron {
    transform: rotate(90deg);
}
.sc-source-panel .custom-instructions-body {
    display: none;
    padding: 0 14px;
}
.sc-source-panel .custom-instructions-body.open {
    display: block;
    padding: 0 14px 8px;
}
.sc-source-panel .custom-instructions-body textarea {
    width: 100%;
    min-height: 60px;
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    color: var(--sc-text);
    background: var(--sc-bg);
}
.sc-source-panel .custom-instructions-body textarea:focus {
    outline: none;
    border-color: var(--sc-accent);
}

/* ============================================================
   CLEAR BUTTON (matches index.html clear-editor-btn)
   ============================================================ */
.sc-source-panel .clear-editor-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--sc-bg-sidebar);
    border: 1px solid var(--sc-border);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--sc-text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.sc-source-panel .clear-editor-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ============================================================
   BOTTOM BAR — hide on input stage, show on outline/canvas
   ============================================================ */
.sc-stage-input ~ .sc-bottom-bar-hidden {}

/* ============================================================
   NARRATION REVIEW OVERLAY (Stage 3 — post-image, pre-video)
   ============================================================ */

/* The canvas stage needs relative positioning for the overlay */
.sc-stage-canvas { position: relative; }

.sc-narration-review-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: var(--sc-bg-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: sc-narration-slide-in 0.3s ease;
}

@keyframes sc-narration-slide-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sc-narration-review-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--sc-border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.sc-narration-review-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--sc-text);
    margin: 0 0 3px;
}

.sc-narration-review-subtitle {
    font-size: 12px;
    color: var(--sc-text-secondary);
    margin: 0;
}

.sc-narration-voice-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--sc-accent);
    background: var(--sc-accent-light);
    padding: 5px 10px;
    border-radius: var(--sc-radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.sc-narration-review-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sc-narration-panel-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sc-narration-panel-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--sc-bg-sidebar);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 12px;
    transition: border-color 0.15s;
}

.sc-narration-panel-row:focus-within {
    border-color: var(--sc-accent);
}

.sc-narration-panel-thumb {
    width: 80px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--sc-radius-sm);
    flex-shrink: 0;
    background: var(--sc-border);
}

.sc-narration-panel-num {
    width: 80px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--sc-text-muted);
    background: var(--sc-border);
    border-radius: var(--sc-radius-sm);
    flex-shrink: 0;
}

.sc-narration-panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sc-narration-panel-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--sc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sc-narration-panel-text {
    width: 100%;
    min-height: 64px;
    padding: 8px 10px;
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    font-size: 13px;
    line-height: 1.6;
    color: var(--sc-text);
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
}

.sc-narration-panel-text:focus {
    outline: none;
    border-color: var(--sc-accent);
}

.sc-narration-instructions-section {
    background: var(--sc-bg-sidebar);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 14px;
}

.sc-narration-instructions-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--sc-text-secondary);
    margin-bottom: 8px;
}

.sc-narration-instructions-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--sc-bg-card);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    font-size: 13px;
    line-height: 1.5;
    color: var(--sc-text);
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
}

.sc-narration-instructions-input:focus {
    outline: none;
    border-color: var(--sc-accent);
}

.sc-narration-review-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--sc-border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    background: var(--sc-bg-card);
}

.sc-narration-footer-note {
    flex: 1;
    font-size: 12px;
    color: var(--sc-text-muted);
}

.sc-narration-regen-overlay {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--sc-bg-card) 90%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    color: var(--sc-text-secondary);
    z-index: 10;
}
