/* ==========================================================
   NewsVid Studio — Production UI
   Full-width layout · Dark & Light themes
   ========================================================== */

:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --accent: #e11d48;
    --accent-2: #be123c;
    --accent-grad: linear-gradient(135deg, #e11d48, #7c3aed);
    --accent-glow: rgba(225, 29, 72, 0.22);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;

    --tr: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark theme (default) ---------- */
html[data-theme="dark"] {
    --bg: #0b0f1a;
    --bg-soft: #111827;
    --panel: #151c2c;
    --panel-2: #1b2337;
    --border: #253049;
    --text: #eef2ff;
    --text-2: #9aa5c0;
    --text-3: #64708c;
    --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
    --chip-bg: rgba(255, 255, 255, 0.04);
    --overlay: rgba(4, 8, 18, 0.72);
    --input-bg: #101625;
}

/* ---------- Light theme (matches login page) ---------- */
html[data-theme="light"] {
    --bg: #ffffff;
    --bg-soft: #fdf2f4;
    --panel: #ffffff;
    --panel-2: #fff5f7;
    --border: #e5e7eb;
    --text: #111827;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --shadow: 0 16px 48px rgba(17, 24, 39, 0.08);
    --shadow-sm: 0 4px 20px rgba(17, 24, 39, 0.06);
    --chip-bg: #ffffff;
    --overlay: rgba(17, 24, 39, 0.45);
    --input-bg: #f9fafb;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(225, 29, 72, 0.10), transparent 60%),
        radial-gradient(900px 400px at 5% 10%, rgba(124, 58, 237, 0.08), transparent 55%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    transition: background 0.3s ease, color 0.3s ease;
}

html[data-theme="light"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.025'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

html[data-theme="light"] .app,
html[data-theme="light"] .app-shell {
    position: relative;
    z-index: 1;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ==========================================================
   App shell — full width
   ========================================================== */
.app {
    --page-gutter-left: clamp(72px, 12vw, 140px);
    --page-gutter-right: clamp(72px, 12vw, 140px);
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-left: var(--page-gutter-left);
    padding-right: var(--page-gutter-right);
}

.app > main,
.app > .workspace {
    flex: 1;
}

@media (max-width: 900px) {
    .app {
        --page-gutter-left: clamp(24px, 5vw, 48px);
        --page-gutter-right: clamp(24px, 5vw, 48px);
    }
}

@media (max-width: 640px) {
    .app {
        --page-gutter-left: clamp(16px, 4vw, 24px);
        --page-gutter-right: clamp(16px, 4vw, 24px);
    }
}

/* ==========================================================
   Topbar
   ========================================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent-grad);
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-name em {
    font-style: normal;
    color: var(--accent);
}

.brand-tag { font-size: 0.72rem; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--chip-bg);
    color: var(--text-2);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tr);
    white-space: nowrap;
}

.chip i {
    font-size: 0.8rem;
}

.chip:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }

.chip.connected { border-color: var(--success); color: var(--success); }

.chip-user {
    border-color: var(--border);
    color: var(--text-2);
    cursor: default;
}

.chip-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.chip-link {
    text-decoration: none;
    color: var(--text-2);
}

.chip-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.schedule-box {
    margin-top: 20px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel-2);
}

.schedule-box label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    margin-bottom: 12px;
}

.schedule-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.schedule-row input[type="datetime-local"] {
    flex: 1;
    min-width: 220px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-family: inherit;
}

.schedule-hint {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-2);
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--chip-bg);
    color: var(--text-2);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: var(--tr);
    font-size: 0.95rem;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: rotate(15deg); }

html[data-theme="dark"] .theme-icon-dark { display: none; }
html[data-theme="light"] .theme-icon-light { display: none; }

/* ==========================================================
   Workflow strip — pill capsule style
   ========================================================== */
.workflow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    padding: clamp(24px, 3vw, 36px) 0 26px;
    background: transparent;
    border: none;
}

.workflow-step {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text-2);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.22s ease, box-shadow 0.22s ease, padding 0.22s ease;
    box-shadow: 0 2px 10px rgba(17, 24, 39, 0.05);
    flex-shrink: 0;
}

.workflow-step.active {
    border-color: #fecdd3;
    box-shadow: 0 10px 32px rgba(225, 29, 72, 0.16);
    padding: 10px 22px;
}

.workflow-step.completed {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.workflow-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.84rem;
    font-weight: 800;
    background: #fff1f3;
    color: var(--accent);
    flex-shrink: 0;
    transition: background 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

.workflow-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
}

.workflow-step.active .workflow-label {
    color: var(--text);
}

.workflow-step.completed .workflow-label {
    color: var(--text);
}

.workflow-step.completed .workflow-num {
    background: #16a34a;
    color: #fff;
    font-size: 0.78rem;
}

.workflow-step.completed .workflow-num i {
    font-size: 0.72rem;
}

.workflow-line.filled {
    background: #86efac;
}

.workflow-line {
    width: clamp(20px, 5vw, 72px);
    height: 2px;
    margin: 0 6px;
    background: #e5e7eb;
    border-radius: 2px;
    flex-shrink: 0;
}

html[data-theme="dark"] .workflow-step {
    background: var(--panel);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .workflow-step.active {
    box-shadow: 0 10px 32px rgba(225, 29, 72, 0.22);
}

html[data-theme="dark"] .workflow-num {
    background: rgba(225, 29, 72, 0.15);
}

html[data-theme="dark"] .workflow-step.completed {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
}

html[data-theme="dark"] .workflow-line {
    background: #334155;
}

html[data-theme="dark"] .workflow-line.filled {
    background: rgba(34, 197, 94, 0.45);
}

@media (max-width: 640px) {
    .workflow {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .workflow-line {
        display: none;
    }
}

/* ==========================================================
   Workspace — single full-width column
   ========================================================== */
.workspace {
    display: flex;
    flex-direction: column;
    gap: 22px;
    align-items: stretch;
    width: 100%;
    flex: 1;
}

html[data-theme="light"] .panel {
    border-color: #e5e7eb;
    box-shadow: 0 4px 24px rgba(17, 24, 39, 0.05);
}

html[data-theme="light"] .dropzone {
    background: #fff5f7;
    border-color: #fecdd3;
}

html[data-theme="light"] .dropzone:hover,
html[data-theme="light"] .dropzone.dragover {
    border-color: var(--accent);
    background: #fff1f3;
}

html[data-theme="light"] .count-badge {
    background: #fff5f7;
    border-color: #fecdd3;
    color: var(--accent);
}

.panel {
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 2.5vw, 36px);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--tr), box-shadow var(--tr);
}

.panel.active { border-color: var(--accent); box-shadow: var(--shadow); }

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

.panel-step {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: var(--accent);
}

.panel-title h2 {
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.panel-title h2 i { color: var(--accent); font-size: 1rem; }

.count-badge {
    padding: 8px 14px;
    border-radius: var(--radius-full);
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 700;
}

/* ==========================================================
   Dropzone
   ========================================================== */
.dropzone {
    position: relative;
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--panel-2);
    cursor: pointer;
    transition: var(--tr);
    overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 7%, var(--panel-2));
}

.file-input-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-inner { padding: 40px 24px; text-align: center; }

.dropzone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--accent-grad);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 10px 30px var(--accent-glow);
}

.dropzone-title { font-weight: 700; font-size: 1.05rem; }
.dropzone-sub { color: var(--text-2); font-size: 0.9rem; margin-top: 4px; }

.dropzone-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    background: var(--chip-bg);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.8rem;
}

/* ==========================================================
   Gallery
   ========================================================== */
.gallery-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0 12px;
    color: var(--text-2);
    font-size: 0.86rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
}

.image-thumb {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border);
    cursor: grab;
    transition: var(--tr);
}

.image-thumb:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.image-thumb.dragging { opacity: 0.5; cursor: grabbing; }

.image-thumb img { width: 100%; height: 100%; object-fit: cover; }

.image-thumb-order {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-grad);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
}

.image-thumb-actions {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    opacity: 0;
    transition: var(--tr);
}

.image-thumb:hover .image-thumb-actions { opacity: 1; }

.image-thumb-actions button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--tr);
}

.image-thumb-actions button:hover:not(:disabled) { background: var(--accent); }
.image-thumb-actions button[data-action="remove"]:hover { background: var(--danger); }
.image-thumb-actions button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ==========================================================
   Script / inputs
   ========================================================== */
.script-box textarea,
.field textarea {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    resize: vertical;
    transition: var(--tr);
}

.script-box textarea { min-height: 220px; }
.field textarea { min-height: 110px; }

.script-box textarea:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.char-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-3);
}

.hint-inline { display: inline-flex; align-items: center; gap: 6px; }

.voice-picker {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.voice-picker-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.voice-select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
}

.voice-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.voice-picker-hint {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--text-3);
}

.voice-picker-hint a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.voice-picker-hint a:hover { text-decoration: underline; }

.step-intro {
    color: var(--text-2);
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 18px;
    max-width: 720px;
}

.studio-voice-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 22px;
    align-items: start;
}

.studio-voice-picker {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.studio-voice-subhead {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.studio-voice-list-wrap {
    margin-top: 18px;
}

.studio-voice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.studio-voice-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tr);
}

.studio-voice-chip:hover,
.studio-voice-chip.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.studio-voice-chip .chip-check {
    color: #059669;
    font-size: 0.78rem;
}

.studio-voice-empty {
    padding: 18px 8px;
}

.studio-voice-create {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: var(--panel-2);
}

.studio-voice-create-hint {
    color: var(--text-3);
    font-size: 0.82rem;
    margin-bottom: 14px;
}

.studio-voice-manage {
    margin-top: 14px;
    font-size: 0.82rem;
}

.studio-voice-manage a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.studio-voice-manage a:hover { text-decoration: underline; }

.studio-voice-banner {
    margin-bottom: 16px;
}

#voiceContinueBtn {
    margin-top: 20px;
}

.selected-voice-badge {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
    font-size: 0.86rem;
    color: var(--text-2);
}

.selected-voice-badge strong {
    color: var(--text);
}

.voice-preview-row {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.voice-preview-row .selected-voice-badge {
    margin-top: 0;
}

.caption-toggle-row {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent) 5%, var(--panel));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.caption-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.caption-toggle-copy strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
}

.caption-toggle-copy span {
    color: var(--text-3);
    font-size: 0.8rem;
}

.caption-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 6px 12px 6px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--text-2);
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
}

.caption-switch {
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #f87171;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.caption-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.caption-toggle.is-on {
    color: #059669;
    border-color: color-mix(in srgb, #059669 35%, var(--border));
}

.caption-toggle.is-on .caption-switch {
    background: #22c55e;
}

.caption-toggle.is-on .caption-switch::after {
    transform: translateX(18px);
}

.caption-toggle.is-off {
    color: #e11d48;
}

@media (max-width: 900px) {
    .studio-voice-layout {
        grid-template-columns: 1fr;
    }
}

.field { margin-bottom: 18px; }

.field > label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--tr);
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 10px 28px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(225, 29, 72, 0.35); }

.btn-ghost {
    background: var(--chip-bg);
    border: 1px solid var(--border);
    color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    box-shadow: 0 10px 28px rgba(34, 197, 94, 0.3);
}

.btn-success:hover:not(:disabled) { transform: translateY(-2px); }

.btn-publish {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #fff;
    box-shadow: 0 10px 28px rgba(244, 63, 94, 0.35);
}

.btn-publish:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(244, 63, 94, 0.45); }

.btn-xl { padding: 15px 28px; font-size: 1rem; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: var(--radius-sm); }

/* ==========================================================
   Render / progress / preview
   ========================================================== */
.render-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.progress-wrap { margin-top: 20px; }

.progress-track {
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--panel-2);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    background: var(--accent-grad);
    transition: width 0.5s ease;
}

.progress-label {
    margin-top: 10px;
    color: var(--text-2);
    font-size: 0.88rem;
    text-align: center;
}

.preview-wrap {
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.phone-frame {
    width: min(300px, 80%);
    border-radius: 28px;
    padding: 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.phone-frame video {
    width: 100%;
    aspect-ratio: 9 / 16;
    border-radius: 20px;
    display: block;
    background: #000;
}

/* ==========================================================
   Platforms
   ========================================================== */
.platforms {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.platform {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 10px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--panel-2);
    cursor: pointer;
    text-align: center;
    transition: var(--tr);
}

.platform:hover { border-color: var(--accent); transform: translateY(-2px); }

.platform input { position: absolute; opacity: 0; pointer-events: none; }

.platform-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    color: #fff;
}

.platform-icon.ig { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.platform-icon.yt { background: #ff0000; }
.platform-icon.fb { background: #1877f2; }

.platform-icon-sm {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 1rem;
    flex-shrink: 0;
}

.platform-icon-md {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 1.3rem;
}

.platform-name { font-weight: 700; font-size: 0.9rem; }

.platform-status { font-size: 0.72rem; color: var(--text-3); }
.platform-status.connected { color: var(--success); font-weight: 600; }

.platform.active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--panel-2));
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 25%, transparent);
}

.platform.active::after {
    content: "\2713";
    position: absolute;
    top: 8px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    display: grid;
    place-items: center;
}

.platform.unavailable { opacity: 0.45; cursor: not-allowed; }
.platform.unavailable:hover { transform: none; border-color: var(--border); }

.publish-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- published links ---------- */
.publish-links {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--panel-2);
    border: 1px solid var(--border);
}

.publish-links h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
}

.publish-link-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.publish-link-item:last-child { border-bottom: none; }

.publish-link-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.publish-link-body strong {
    font-size: 0.92rem;
    color: var(--text);
}

.publish-link-body span {
    font-size: 0.86rem;
    color: var(--text-2);
}

.publish-link-body a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
    font-size: 0.86rem;
}

.publish-link-body a:hover { text-decoration: underline; }

.publish-link-fail .publish-link-body span { color: var(--danger); }

.modal-block.modal-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.modal-block.modal-platforms span {
    font-weight: 600;
    color: var(--text);
}

/* ==========================================================
   Footer
   ========================================================== */
.footer {
    text-align: center;
    padding: 26px 0 20px;
    margin-top: auto;
    color: var(--text-3);
    font-size: 0.82rem;
}

.footer p {
    margin: 0;
}

/* ==========================================================
   Toast
   ========================================================== */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translate(-50%, 120px);
    max-width: min(520px, 90vw);
    padding: 14px 22px;
    border-radius: var(--radius-md);
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
}

.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--accent); }

/* ==========================================================
   Modals
   ========================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(8px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    width: min(560px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.modal-wide { width: min(880px, 100%); }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-head h3 { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.modal-head h3 i { color: var(--accent); }

.modal-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--text-2);
    cursor: pointer;
    transition: var(--tr);
}

.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body { padding: 20px 24px; }

.modal-block {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.88rem;
}

.modal-caption { white-space: pre-wrap; }

.modal-note { margin-top: 14px; font-size: 0.8rem; color: var(--text-3); }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 22px;
}

/* ==========================================================
   History
   ========================================================== */
.history-list { display: flex; flex-direction: column; gap: 14px; }

.history-item {
    display: grid;
    grid-template-columns: 92px 1fr auto;
    gap: 16px;
    padding: 14px;
    border-radius: var(--radius-md);
    background: var(--panel-2);
    border: 1px solid var(--border);
}

.history-thumb {
    width: 92px;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: #000;
    border: 1px solid var(--border);
}

.history-meta { min-width: 0; }

.history-meta h4 { font-size: 0.95rem; margin-bottom: 4px; }

.history-meta .h-text {
    color: var(--text-2);
    font-size: 0.84rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-meta .h-info { color: var(--text-3); font-size: 0.76rem; margin-top: 6px; }

.history-links { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }

.history-link-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.82rem;
}

.history-link-row a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
    line-height: 1.45;
}

.history-link-row a:hover { text-decoration: underline; }

.history-link-row span { color: var(--text-2); line-height: 1.45; }

.history-link-fail .pub-fail { color: var(--danger); }

.history-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.history-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-2);
}

.history-empty i { font-size: 2.2rem; color: var(--accent); margin-bottom: 14px; display: block; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 720px) {
    .topbar { justify-content: center; }
    .topbar-left { width: 100%; display: flex; justify-content: center; }
    .workflow { flex-wrap: wrap; }
    .workflow-line { display: none; }
    .platforms { grid-template-columns: 1fr; }
    .platform { flex-direction: row; justify-content: flex-start; padding: 12px 16px; }
    .history-item { grid-template-columns: 72px 1fr; }
    .history-actions { grid-column: 1 / -1; flex-direction: row; }
    .render-actions .btn, .publish-row .btn { width: 100%; }
}
