/* ═══════════════════════════════════════
   SpeakDeck — Design System
   Swiss/editorial: light, hairline structure,
   ink on warm off-white, one considered accent.
   ═══════════════════════════════════════ */

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

:root {
    /* ── Core palette ── */
    --bg:              #FBFBFA;
    --surface:         #FFFFFF;
    --surface-subtle:  #F5F5F2;
    --surface-pressed: #EEEEEA;
    --ink:             #161614;
    --text-secondary:  #565650;
    --text-tertiary:   #85857D;
    --border:          #E3E3DD;
    --border-strong:   #CECEC6;
    --accent:          #C23B2E;
    --accent-hover:    #A93228;
    --accent-soft:     #F6E7E4;
    --accent-ink:      #7F241E;
    --success:         #247A4D;
    --success-soft:    #E7F1EA;
    --warning:         #8A6100;
    --warning-soft:    #F5EDDA;
    --error:           #B42318;
    --error-soft:      #FBEBE8;
    --focus:           rgba(194,59,46,.34);
    --selection:       #F6D8D1;

    /* ── Radius ── */
    --r-xs: 2px;
    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 10px;

    /* ── Motion ── */
    --ease-out:   cubic-bezier(.16, 1, .3, 1);
    --dur-fast:   120ms;
    --dur-med:    180ms;

    /* ── Elevation (only floating layers) ── */
    --shadow-pop: 0 16px 40px rgba(22,22,20,.10), 0 1px 2px rgba(22,22,20,.06);

    /* ── Type ── */
    --font-ui:   'Switzer', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* ── Layout ── */
    --content-max: 1184px;
    --bar-h: 56px;

    /* ── Legacy aliases (kept for inline markup / rendered snippets) ── */
    --text:           var(--ink);
    --text-primary:   var(--ink);
    --primary:        var(--accent);
    --border-hover:   var(--border-strong);
    --card:           var(--surface);
    --card-bg:        var(--surface);
    --radius:         var(--r-md);
    --radius-lg:      var(--r-lg);
    --spring:         var(--ease-out);
    --ease:           var(--ease-out);
}

html { color-scheme: light; background: var(--bg); }

body {
    min-height: 100vh;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.53;
    letter-spacing: -0.005em;
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
#file-input { display: none; }

::selection { background: var(--selection); }

/* ── Scrollbar ── */
* { scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ═══════ App Bar ═══════ */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(251,251,250,.86);
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.app-bar-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 32px;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.02em;
    text-decoration: none;
    color: var(--ink);
    flex-shrink: 0;
}
.app-brand svg { display: block; }

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-tertiary);
    min-width: 0;
}

.crumb-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 0;
    transition: color var(--dur-fast) var(--ease-out);
}
.crumb-link:hover { color: var(--ink); }
.crumb-sep { color: var(--border-strong); font-size: 12px; }
.crumb-current { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Trust signal in the bar */
.app-bar-trust {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    letter-spacing: 0;
}
.app-bar-trust::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
}

/* Icon buttons (self-check, etc.) */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
    flex-shrink: 0;
}
.theme-toggle-btn:hover {
    background: var(--surface-subtle);
    color: var(--ink);
    border-color: var(--border-strong);
}

/* ═══════ Layout ═══════ */
.main {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 32px 72px;
    position: relative;
}

.screen {
    display: none;
    animation: fadeUp 260ms var(--ease-out) both;
}
.screen.is-active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* ═══════ Hero (left-weighted) ═══════ */
.hero {
    padding: 56px 0 32px;
    max-width: 720px;
}

.hero-title {
    font-size: clamp(1.9rem, 4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.032em;
    line-height: 1.06;
    text-wrap: balance;
    margin-bottom: 14px;
}

.hero-subtitle {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    max-width: 60ch;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* Quiet trust / feature line under the hero */
.hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-bottom: 40px;
    list-style: none;
    font-size: 13px;
    color: var(--text-tertiary);
}
.hero-points li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.hero-points li::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* ═══════ Mode tabs (underline) ═══════ */
.mode-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    max-width: 720px;
}

.mode-tab {
    position: relative;
    padding: 10px 4px 12px;
    margin-right: 20px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--dur-med) var(--ease-out);
}
.mode-tab::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur-med) var(--ease-out);
}
.mode-tab:hover:not(.active) { color: var(--ink); }
.mode-tab.active { color: var(--ink); font-weight: 600; }
.mode-tab.active::after { transform: scaleX(1); }

/* ═══════ Upload / import panel ═══════ */
.upload-card {
    max-width: 640px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

.upload-zone {
    padding: 44px 32px;
    text-align: center;
    cursor: pointer;
    transition: background var(--dur-med) var(--ease-out), border-color var(--dur-med) var(--ease-out);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-lg);
    margin: 16px;
}

.upload-zone:hover { background: var(--surface-subtle); }

.upload-zone.drag-over {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: scale(1.004);
}

.upload-zone.file-chosen {
    display: none;
}

.upload-zone.file-chosen .upload-icon-wrap,
.upload-zone.file-chosen .upload-label,
.upload-zone.file-chosen .upload-hint { display: none; }

.upload-icon-wrap {
    color: var(--text-tertiary);
    margin-bottom: 14px;
    transition: color var(--dur-med) var(--ease-out);
}
.upload-zone:hover .upload-icon-wrap,
.upload-zone.drag-over .upload-icon-wrap { color: var(--accent); }

.upload-label { font-size: 15px; font-weight: 500; color: var(--ink); }
.upload-label strong { color: var(--accent); font-weight: 600; }
.upload-hint { font-size: 13px; color: var(--text-tertiary); margin-top: 5px; }

/* Selected file row */
.upload-form { padding: 4px 24px 24px; }
.upload-form.hidden { display: none; }

.selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    background: var(--success-soft);
    border: 1px solid #CFE3D6;
    border-radius: var(--r-md);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
}

.selected-file-info {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}
.selected-file-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.change-file-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    transition: background var(--dur-fast) var(--ease-out);
}
.change-file-btn:hover { background: var(--accent-soft); }

.form-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* ═══════ Forms ═══════ */
.form-group { display: flex; flex-direction: column; }

.form-group label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 10px 13px;
    min-height: 40px;
    font-size: 14px;
    color: var(--ink);
    transition: border-color var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-tertiary); }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2385857D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 13px) center;
    padding-right: 36px;
    cursor: pointer;
}

select option { background: var(--surface); color: var(--ink); }

.color-picker-row { display: flex; align-items: center; gap: 0.75rem; }

/* Narration toggle */
.toggle-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
    color: var(--ink);
}
.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    cursor: pointer;
    padding: 0;
    border-radius: var(--r-sm);
    accent-color: var(--accent);
}
.duration-row { margin-top: 0.5rem; }
.duration-input { width: 100px; }

.color-input {
    width: 40px !important;
    height: 40px;
    padding: 2px !important;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md) !important;
    cursor: pointer;
    background: var(--surface);
}

/* ═══════ Buttons ═══════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary,
.btn-success {
    color: #fff;
    background: var(--accent);
}
.btn-primary:hover,
.btn-success:hover { background: var(--accent-hover); }

.btn-ghost {
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-subtle); border-color: var(--text-tertiary); }

.btn-danger {
    color: #fff;
    background: var(--error);
}
.btn-danger:hover { background: #9A1E15; }

.btn-small { height: 32px; padding: 0 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: var(--r-sm); white-space: nowrap; }

.voice-select-row { display: flex; gap: 8px; align-items: center; }
.voice-select-row select { flex: 1; min-width: 0; }

.btn-block { width: 100%; }

.btn.is-loading { pointer-events: none; opacity: 0.7; }
.btn.is-loading::after {
    content: ""; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
    border-radius: 50%; animation: spin .65s linear infinite; margin-left: 6px;
}

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

/* ═══════ Projects list ═══════ */
.projects-section {
    padding-top: 32px;
    margin-top: 32px;
    border-top: 1px solid var(--border);
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 16px;
    color: var(--text-tertiary);
}

.job-list { display: flex; flex-direction: column; }

.job-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 4px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out);
}
.job-card:first-child { border-top: 1px solid var(--border); }
.job-card:hover { background: var(--surface-subtle); }

.job-card-name { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.job-card-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 3px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.job-card-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.job-card-left { min-width: 0; flex: 1; padding-left: 8px; }

/* Status: dot + label */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    background: var(--surface-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-uploaded  { color: var(--text-secondary); }
.badge-scripting { color: var(--warning);  background: var(--warning-soft); border-color: #E9DCBE; }
.badge-complete  { color: var(--success);  background: var(--success-soft); border-color: #CFE3D6; }
.badge-generating{ color: var(--accent);   background: var(--accent-soft);  border-color: #EDCFC9; }
.badge-error     { color: var(--error);    background: var(--error-soft);   border-color: #F0D2CE; }

.badge-generating::before { animation: dotPulse 1.5s var(--ease-out) infinite; }
@keyframes dotPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ═══════ Stepper ═══════ */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 32px 0 28px;
}

.step {
    display: flex;
    align-items: center;
    gap: 9px;
    opacity: 0.5;
    transition: opacity 250ms var(--ease-out);
}
.step.active, .step.done { opacity: 1; }

.step-indicator {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--surface);
    color: var(--text-tertiary);
    border: 1.5px solid var(--border-strong);
    transition: all 250ms var(--ease-out);
}

.step.active .step-indicator {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.step.done .step-indicator {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.step-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.step.active .step-label { color: var(--ink); font-weight: 600; }
.step.done .step-label { color: var(--ink); }

.step-connector {
    width: 44px;
    height: 1px;
    margin: 0 12px;
    background: var(--border-strong);
    transition: background 300ms var(--ease-out);
}
.step-connector.active { background: var(--accent); }

/* ═══════ Editor Grid ═══════ */
.editor-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

.preview-panel { display: flex; flex-direction: column; gap: 10px; }

.slide-frame {
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px;
}

.slide-frame img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: contain;
    border-radius: var(--r-sm);
    background: var(--surface-subtle);
}

.slide-counter {
    text-align: center;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ═══════ Script Panel ═══════ */
.script-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.script-toolbar {
    display: flex;
    justify-content: flex-end;
    min-height: 20px;
    font-size: 12px;
}

.save-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--success);
    font-weight: 500;
    animation: fadeIn 200ms;
}

.save-status-saving {
    color: var(--text-tertiary);
    font-weight: 400;
    animation: fadeIn 200ms;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.save-status.hidden,
.save-status-saving.hidden { display: none; }

.script-panel textarea {
    flex: 1;
    min-height: 300px;
    padding: 16px 18px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--ink);
    resize: none;
    line-height: 1.7;
    font-size: 14.5px;
    transition: border-color var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}

.script-panel textarea::placeholder { color: var(--text-tertiary); }
.script-panel textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
}

.script-meta-bar {
    display: flex;
    gap: 18px;
    padding: 0 4px;
}

.meta-item {
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ═══════ Filmstrip ═══════ */
.filmstrip-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.filmstrip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 6px 2px;
    flex: 1;
    scrollbar-width: none;
}
.filmstrip::-webkit-scrollbar { display: none; }

.filmstrip-arrow {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.filmstrip-arrow:hover { background: var(--surface-subtle); color: var(--ink); }

.thumb {
    position: relative;
    flex-shrink: 0;
    width: 88px;
    height: 50px;
    border-radius: var(--r-md);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    outline: 2px solid transparent;
    outline-offset: 1px;
    transition: outline-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
    background: var(--surface-subtle);
}

.thumb:hover { border-color: var(--border-strong); }

.thumb.active {
    border-color: var(--accent);
    outline-color: var(--accent);
}

.thumb.scripted::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 2px var(--surface);
}

.thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.thumb-num {
    position: absolute;
    bottom: 2px;
    left: 5px;
    font-size: 9px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    z-index: 1;
}

.thumb-done { display: none; }

/* ═══════ Bottom Bar ═══════ */
.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border);
}

.bottom-bar.hidden { display: none; }

.bottom-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ring-progress svg { display: block; }
#ring-circle {
    transition: stroke-dashoffset 600ms var(--ease-out), stroke 300ms;
}

.bottom-bar-info {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.bottom-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══════ Generation Overlay ═══════ */
.gen-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22,22,20,0.32);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeIn 200ms;
}
.gen-overlay.hidden { display: none; }

.gen-card {
    text-align: center;
    max-width: 400px;
    padding: 36px 32px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-pop);
}

.gen-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--surface-pressed);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.gen-status {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 18px;
}

.gen-bar {
    height: 5px;
    border-radius: 999px;
    background: var(--surface-pressed);
    overflow: hidden;
    margin-bottom: 14px;
}

.gen-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 300ms var(--ease-out);
    position: relative;
}

.gen-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ═══════ Completion Card ═══════ */
.completion {
    margin-top: 20px;
    animation: fadeUp 320ms var(--ease-out) both;
}
.completion.hidden { display: none; }

.completion-inner {
    text-align: center;
    padding: 44px 32px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border);
}

.completion-check {
    margin-bottom: 16px;
}

.completion-inner h3 {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 8px;
}

.completion-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.completion-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.result-video {
    display: block;
    width: 100%;
    max-width: 480px;
    max-height: 60vh;
    margin: 0 auto 24px;
    border-radius: 12px;
    background: #000;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* ═══════ Modal ═══════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(22,22,20,0.32);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms, visibility 200ms;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    width: min(100%, 500px);
    padding: 24px;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-pop);
    transform: translateY(8px);
    opacity: 0;
    transition: transform 220ms var(--ease-out), opacity 220ms var(--ease-out);
}
.modal-overlay.active .modal { transform: none; opacity: 1; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.modal-header h3 { font-size: 1.1875rem; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.modal-close:hover { background: var(--surface-subtle); color: var(--ink); }

.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal .form-group { margin-bottom: 16px; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ═══════ Toasts ═══════ */
.toast-region {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-pop);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
    white-space: nowrap;
}
.toast::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.toast.visible { opacity: 1; transform: none; }
.toast-success { color: var(--success); }
.toast-error   { color: var(--error); }

/* ═══════ Focus ═══════ */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.hidden { display: none !important; }

/* ═══════ Cost Badge ═══════ */
.cost-badge {
    padding: 3px 10px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 500;
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid #E9DCBE;
    letter-spacing: 0;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ═══════ Usage Section ═══════ */
.usage-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.usage-summary {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.usage-stat {
    font-size: 13px;
    color: var(--text-secondary);
}

.usage-stat strong {
    color: var(--ink);
    font-weight: 600;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.usage-table-wrap {
    border-radius: var(--r-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.usage-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
}

.usage-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.usage-table th:not(:first-child),
.usage-table td:not(:first-child) {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.usage-table tr:last-child td { border-bottom: none; }

.usage-table td:first-child { color: var(--ink); font-weight: 500; }

/* ═══════ Responsive ═══════ */
@media (max-width: 768px) {
    .main { padding: 0 16px 40px; }
    .app-bar-inner { padding: 0 16px; }
    .hero { padding: 32px 0 24px; }
    .hero-subtitle { font-size: 15px; }
    .form-fields { grid-template-columns: 1fr; }
    .editor-grid { grid-template-columns: 1fr; }
    .stepper { gap: 0; }
    .step-label { display: none; }
    .step-connector { width: 28px; margin: 0 8px; }
    .bottom-bar { flex-direction: column; gap: 12px; }
    .bottom-bar-right { width: 100%; }
    .bottom-bar-right .btn { flex: 1; }
    .completion-actions { flex-direction: column; }
    .breadcrumbs { display: none; }
    .app-bar-trust { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .upload-zone.drag-over { transform: none; }
}

/* ═══════ Script card ═══════ */
.script-card,
.shorts-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    max-width: 720px;
}

.script-input {
    width: 100%;
    min-height: 240px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.65;
    padding: 1rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}

.script-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
}

.script-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.script-hint code {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.1em 0.4em;
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* ═══════ Theme grid (generated-video themes — product feature) ═══════ */
.form-group-wide {
    grid-column: 1 / -1;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}

.theme-card {
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    outline: 2px solid transparent;
    outline-offset: 1px;
    transition: border-color var(--dur-med) var(--ease-out), outline-color var(--dur-med) var(--ease-out);
    text-align: left;
}

.theme-card:hover {
    border-color: var(--text-tertiary);
}

.theme-card.selected {
    border-color: var(--accent);
    outline-color: var(--accent);
}

.theme-preview {
    aspect-ratio: 16 / 9;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    overflow: hidden;
}

.theme-preview-title {
    font-weight: 700;
    font-size: 0.55rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.theme-preview-body {
    font-size: 0.4rem;
    line-height: 1.3;
    opacity: 0.85;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.theme-card-name {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* ═══════ Loading Skeleton ═══════ */
.skeleton-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 4px;
    border-bottom: 1px solid var(--border);
}
.skeleton-card:first-child { border-top: 1px solid var(--border); }

.skeleton-line {
    height: 14px;
    border-radius: var(--r-sm);
    background: var(--surface-subtle);
    position: relative;
    overflow: hidden;
}

.skeleton-line::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(22,22,20,0.04), transparent);
    animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skeleton-line-name { width: 160px; }
.skeleton-line-meta { width: 100px; height: 10px; margin-top: 8px; }
.skeleton-line-badge { width: 84px; height: 26px; border-radius: 999px; }

/* ═══════ Empty State ═══════ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state-icon {
    color: var(--text-tertiary);
    margin-bottom: 14px;
}

.empty-state-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-bottom: 5px;
}

.empty-state-text {
    font-size: 13px;
    color: var(--text-tertiary);
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ═══════ Delete Button on Job Cards ═══════ */
.job-card-delete {
    width: 30px;
    height: 30px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.job-card-delete:hover {
    background: var(--error-soft);
    color: var(--error);
}

.job-card-delete:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ═══════ Error Message on Job Cards ═══════ */
.job-card-error {
    font-size: 12px;
    color: var(--error);
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.job-card-fade-out {
    transition: opacity 300ms, transform 300ms;
    opacity: 0;
    transform: translateX(-10px);
}

/* ═══════ Gen Overlay Actions ═══════ */
.gen-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.gen-status-warn {
    color: var(--warning);
}

/* ═══════ Gen Phase Stepper ═══════ */
.gen-phases {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 24px;
}

.gen-phase {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    transition: color 300ms var(--ease-out);
}

.gen-phase.active { color: var(--accent); font-weight: 600; }
.gen-phase.done { color: var(--success); }

.gen-phase-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    transition: all 300ms var(--ease-out);
}

.gen-phase.active .gen-phase-dot {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
    animation: pulse 1.5s ease-in-out infinite;
}

.gen-phase.done .gen-phase-dot {
    background: var(--success);
    border-color: var(--success);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--focus); }
    50% { box-shadow: 0 0 0 6px transparent; }
}

.gen-phase-line {
    width: 32px;
    height: 1px;
    background: var(--border-strong);
    margin: 0 10px;
    transition: background 300ms var(--ease-out);
}

.gen-elapsed {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ═══════ Portrait Mode Editor ═══════ */
.editor-portrait .editor-grid {
    grid-template-columns: 0.6fr 1fr;
}

.editor-portrait .slide-frame img {
    aspect-ratio: 9/16;
}

.editor-portrait .thumb {
    width: 36px;
    height: 64px;
}

/* ═══════ Shorts mode ═══════ */
.style-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.visual-style-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.vs-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 16px;
    cursor: pointer;
    text-align: center;
    outline: 2px solid transparent;
    outline-offset: 1px;
    transition: border-color var(--dur-med) var(--ease-out), outline-color var(--dur-med) var(--ease-out);
}
.vs-card:hover { border-color: var(--text-tertiary); }
.vs-card.selected { border-color: var(--accent); outline-color: var(--accent); }
.vs-icon { display: flex; justify-content: center; margin-bottom: 10px; color: var(--text-tertiary); }
.vs-icon svg { width: 22px; height: 22px; }
.vs-card.selected .vs-icon { color: var(--accent); }
.vs-name { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.vs-card.selected .vs-name { color: var(--ink); }

.style-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 12px;
    cursor: pointer;
    text-align: center;
    outline: 2px solid transparent;
    outline-offset: 1px;
    transition: border-color var(--dur-med) var(--ease-out), outline-color var(--dur-med) var(--ease-out);
}
.style-card:hover { border-color: var(--text-tertiary); }
.style-card.selected { border-color: var(--accent); outline-color: var(--accent); }

.style-preview {
    font-size: 30px;
    font-weight: 800;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    margin-bottom: 8px;
    background: #1b1b19;
}
.style-preview-clean { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.style-preview-accent { color: #FFD700; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.style-preview-boxed { color: #fff; background: var(--accent); border-radius: var(--r-md); }

.style-card-name { font-size: 12px; font-weight: 500; color: var(--text-secondary); }

.bg-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.bg-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    outline: 2px solid transparent;
    outline-offset: 1px;
    transition: border-color var(--dur-med) var(--ease-out), outline-color var(--dur-med) var(--ease-out);
}
.bg-card:hover { border-color: var(--text-tertiary); }
.bg-card.selected { border-color: var(--accent); outline-color: var(--accent); }

.bg-thumb {
    width: 100%;
    aspect-ratio: 9/16;
    object-fit: cover;
    border-radius: var(--r-sm);
    background: var(--surface-subtle);
}
.bg-card-body { text-align: left; padding: 0 4px 2px; }
.bg-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
}
.bg-card-desc {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-tertiary);
}

.music-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background var(--dur-med) var(--ease-out);
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(22,22,20,.2);
    transition: transform var(--dur-med) var(--ease-out);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.music-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}
.music-selector select { flex: 1; }

/* Footage switching */
#footage-panel {
    grid-column: 2;
}

.footage-controls { margin-top: 1rem; }
.footage-toggle { margin-bottom: 0.5rem; }
.footage-search-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.footage-search-row input { flex: 1; }
.footage-results {
    display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.footage-thumb {
    border: 1px solid var(--border);
    outline: 2px solid transparent;
    outline-offset: 1px;
    border-radius: var(--r-md);
    overflow: hidden; cursor: pointer; padding: 0;
    background: var(--surface-subtle); width: calc(20% - 0.4rem); aspect-ratio: 9/16;
    transition: outline-color var(--dur-med) var(--ease-out);
}
.footage-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.footage-thumb:hover { outline-color: var(--accent); }
.footage-loading { color: var(--text-tertiary); padding: 1rem; text-align: center; width: 100%; }
.footage-tags-group .form-input { width: 100%; }

@media (max-width: 768px) {
    #footage-panel {
        grid-column: 1;
    }
}
