:root {
    --bg-page: #070a12;
    --bg-card: #0f1422;
    --border-subtle: #192236;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-live: #38bdf8;
    --accent-locked: #8b7cf6;

    /* Aliases used by existing Vexlorm rules */
    --bg-main: var(--bg-page);
    --studio-cyan: var(--accent-live);
    --studio-green: #22c55e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Page shell + centered studio header ── */
.vexlorm-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.studio-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 2.5rem;
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    padding: 2rem 1.5rem 0;
    box-sizing: border-box;
}

.studio-header h1 {
    color: #f8fafc;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    max-width: 900px;
    transition: color 0.2s ease, text-shadow 0.25s ease;
}

.studio-header h1:hover {
    color: #fff;
    text-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

.studio-header p {
    color: #94a3b8;
    font-size: 0.95rem;
    max-width: 600px;
    line-height: 1.5;
    margin: 0;
}

/* Legacy hero aliases (unused) kept inert for safety */
.vexlorm-hero,
.vexlorm-hero-version,
.vexlorm-hero-title,
.vexlorm-hero-subhead,
.vexlorm-hero-secondary {
    display: none;
}

/* ── Master Workspace Flex Grid ── */
.vexlorm-workspace {
    display: flex;
    align-items: stretch;
    flex: 1;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 0;
}

/* ── Left Parameter Controls Panel (~320px) ── */
.sidebar-controls {
    width: 320px;
    min-width: 300px;
    max-width: 360px;
    flex-shrink: 0;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-subtle);
    padding: 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
}

.panel-field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    color: #475569;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

/* Quick Export toggle */
.quick-export-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(56, 189, 248, 0.28);
    background: rgba(56, 189, 248, 0.06);
}

.quick-export-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.quick-export-label {
    font-size: 0.82rem;
    font-weight: 800;
    color: #e2e8f0;
}

.quick-export-hint {
    font-size: 0.68rem;
    color: #64748b;
    line-height: 1.35;
}

.quick-export-switch {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.quick-export-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.quick-export-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #1e293b;
    border: 1px solid #334155;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.quick-export-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #94a3b8;
    transition: transform 0.15s ease, background 0.15s ease;
}

.quick-export-switch input:checked + .quick-export-slider {
    background: rgba(56, 189, 248, 0.25);
    border-color: var(--studio-cyan);
}

.quick-export-switch input:checked + .quick-export-slider::before {
    transform: translateX(20px);
    background: var(--studio-cyan);
}

.quick-export-switch input:focus-visible + .quick-export-slider {
    outline: 2px solid var(--studio-cyan);
    outline-offset: 2px;
}

/* Advanced Styling accordion */
.advanced-styling-panel {
    border: 1px dashed #334155;
    border-radius: 10px;
    background: rgba(7, 10, 18, 0.35);
    overflow: hidden;
}

.advanced-styling-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    user-select: none;
}

.advanced-styling-summary::-webkit-details-marker {
    display: none;
}

.advanced-styling-summary-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #cbd5e1;
}

.advanced-styling-summary-title::before {
    content: "▸ ";
    color: var(--studio-cyan);
}

.advanced-styling-panel[open] .advanced-styling-summary-title::before {
    content: "▾ ";
}

.advanced-styling-summary-hint {
    font-size: 0.66rem;
    color: #64748b;
    padding-left: 14px;
}

.advanced-styling-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 4px 14px 16px;
    border-top: 1px solid var(--border-subtle);
}

/* Quick Export: hide advanced styling entirely */
.vexlorm-workspace.is-quick-export .advanced-styling-panel {
    display: none;
}

/* Quick Export: simplify phone chrome to a clean 9:16 frame */
.vexlorm-workspace.is-quick-export .phone-notch {
    display: none;
}

.vexlorm-workspace.is-quick-export .phone-bezel-frame {
    background: #0b0f18;
    border-radius: 16px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    filter: none;
}

.vexlorm-workspace.is-quick-export .phone-device-container {
    filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.5));
}

.vexlorm-workspace.is-quick-export .phone-screen-mask {
    border-radius: 10px;
}

.upload-drop-card {
    position: relative;
    border: 2px dashed #192236;
    background: #090d16;
    border-radius: 8px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-icon {
    color: #38bdf8;
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.upload-primary-text {
    font-size: 0.8rem;
    font-weight: bold;
    color: #f8fafc;
    margin-bottom: 4px;
}

.upload-sub-text {
    font-size: 0.7rem;
    color: #475569;
}

.export-primary-btn {
    width: 100%;
    padding: 12px 14px;
    background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%);
    border: 1px solid #38bdf8;
    border-radius: 8px;
    color: #f8fafc;
    font-family: monospace;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.2);
}

.export-primary-btn:hover {
    filter: brightness(1.06);
}

.dashboard-custom-select {
    width: 100%;
    background: #0f1422;
    border: 1px solid #192236;
    color: #f8fafc;
    padding: 10px 14px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

.clip-zoom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.clip-zoom-row input[type="range"] {
    width: 75%;
    cursor: pointer;
    accent-color: var(--studio-cyan);
}

#clipZoomVal {
    font-size: 0.8rem;
    color: #38bdf8;
    font-family: monospace;
}

.control-module {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.module-heading {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--studio-cyan);
}

.control-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #cbd5e1;
}

.control-label-text {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.slider-readout {
    flex-shrink: 0;
    max-width: 58%;
    font-family: monospace;
    font-size: 0.68rem;
    color: var(--studio-cyan);
    font-weight: 700;
    text-align: right;
    line-height: 1.3;
}

.hex-wheel-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hex-wheel-input {
    width: 42px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.hex-wheel-input::-webkit-color-swatch-wrapper { padding: 2px; }
.hex-wheel-input::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}

.hex-value-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    background: rgba(7, 10, 18, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.82rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.15s ease;
}

.hex-value-input:focus {
    border-color: var(--studio-cyan);
}

.speed-slider {
    width: 100%;
    accent-color: var(--studio-cyan);
    cursor: pointer;
}

.dashboard-custom-select:hover, .dashboard-custom-select:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

.upload-drop-card:hover {
    border-color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.02) !important;
}

.upload-drop-card.drag-active {
    border-color: #22c55e !important;
    background: rgba(34, 197, 94, 0.04) !important;
    transform: scale(0.98);
}

/* ── Drag & Drop Zone ── */
.file-drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 140px;
    padding: 24px 16px;
    background: rgba(7, 10, 18, 0.45);
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.file-drop-zone:hover,
.file-drop-zone:focus {
    border-color: var(--studio-cyan);
    background: rgba(56, 189, 248, 0.04);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.08);
    outline: none;
}

.drop-zone-icon {
    font-size: 1.4rem;
    color: var(--studio-cyan);
    opacity: 0.85;
}

.drop-zone-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #e2e8f0;
    line-height: 1.4;
}

.drop-zone-hint {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 500;
}

.file-input-hidden {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ── Right Preview Canvas Deck (Expands Dynamically) ── */
.preview-canvas-deck {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 40px 32px;
    background:
        radial-gradient(ellipse at center, rgba(56, 189, 248, 0.04) 0%, transparent 55%),
        var(--bg-main);
    min-width: 0;
}

.preview-stage-header {
    text-align: center;
}

.preview-stage-eyebrow {
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--studio-cyan);
    margin-bottom: 6px;
}

.preview-stage-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.3px;
}

/* ── 9:16 Phone Device Mask (360 × 640) ── */
.phone-device-container {
    position: relative;
    overflow: hidden; /* Clips all stray rendering pixels outside the phone template borders */
    width: 360px;
    height: 640px;
    flex-shrink: 0;
    filter: drop-shadow(0 24px 48px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 32px rgba(56, 189, 248, 0.18));
}

.phone-bezel-frame {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, #1a2236 0%, #0b101c 100%);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 12px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 1px rgba(56, 189, 248, 0.08);
}

.phone-notch {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 96px;
    height: 18px;
    background: #070a12;
    border-radius: 12px;
    z-index: 3;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.phone-screen-mask {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.preview-canvas-asset {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background:
        linear-gradient(180deg, #0a0f1a 0%, #070a12 100%);
}

/* ── Responsive Desktop Adaptations ── */
@media (max-width: 1100px) {
    .phone-device-container {
        width: 320px;
        height: 569px; /* maintains ~9:16 */
    }
}

@media (max-width: 920px) {
    .studio-header {
        padding: 1.5rem 1.25rem 0;
        margin-bottom: 1.75rem;
    }

    .studio-header h1 {
        font-size: 1.5rem;
        max-width: none;
    }

    .vexlorm-workspace {
        flex-direction: column;
    }

    .sidebar-controls {
        width: 100%;
        max-width: none;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        padding: 24px 20px;
    }

    .preview-canvas-deck {
        padding: 32px 20px 48px;
        min-height: 70vh;
    }
}

@media (max-width: 420px) {
    .phone-device-container {
        width: 280px;
        height: 498px; /* maintains ~9:16 */
    }

    .phone-bezel-frame {
        border-radius: 20px;
        padding: 10px;
    }

    .phone-screen-mask {
        border-radius: 14px;
    }
}

/* ── Anchored Render Canvas + Future Video Overlay Stack ── */
#vexlormRenderCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 20px; /* Snaps perfectly inside your phone device radius bounds */
    background-color: transparent;
    pointer-events: none;
    z-index: 1;
}

/* ── Phase 3: Structural video alignment over canvas backdrop ── */
#videoLayerOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

#videoLayerOverlay video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--video-zoom, 0.7));
    width: 85%;
    height: 70%;
    object-fit: cover; /* Smart-crop widescreen into the tall vertical card — no stretch */
    object-position: center center;
    border: 2px solid #192236;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.05s linear;
    background: #000;
}

/* Widescreen spill past rounded phone bezels is clipped by:
   .phone-device-container { overflow: hidden; } (Phase 1 master mask) */
