#video-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #1c1c1e;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.ve-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    color: #fff;
    font-family: inherit;
}

.ve-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #262629;
    flex-shrink: 0;
}
.ve-title {
    font-weight: 700;
    font-size: 14px;
    color: #ddd;
}
.ve-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ve-add-wrap {
    position: absolute;
    left: 16px;
    bottom: 12px;
    z-index: 10;
}
.ve-add {
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    background: #7c5cff;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.ve-add:disabled {
    opacity: .6;
    cursor: wait;
}
.ve-add-menu {
    position: absolute;
    z-index: 20;
    bottom: calc(100% + 8px);
    max-height: min(360px, calc(var(--ve-stage-height, 400px) - 76px));
    box-sizing: border-box;
    overflow-y: auto;
    left: 0;
    width: 230px;
    padding: 7px;
    border: 1px solid #46464b;
    border-radius: 12px;
    background: #2b2b2f;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
}
.ve-add-menu[hidden] { display: none; }
.ve-add-menu button {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 7px;
    padding: 9px 10px;
    background: transparent;
    color: #f4f4f5;
    text-align: left;
    cursor: pointer;
}
.ve-add-menu button:hover { background: #3b3b40; }
.ve-add-divider {
    height: 1px;
    margin: 5px 4px;
    background: #444449;
}
.ve-add-caption {
    padding: 4px 10px 2px;
    color: #8d8d93;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.ve-version-control {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #47474b;
    border-radius: 8px;
    padding: 8px 12px;
    background: #303034;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}
.ve-version-control svg, .ve-fullscreen svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ve-version-control select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.ve-version-control:focus-within { outline: 2px solid #ad97ff; outline-offset: 2px; }
.ve-version-control:has(select:disabled) { opacity: .55; }
.ve-version-control select:disabled { cursor: wait; }
.ve-fullscreen {
    position: absolute;
    right: 16px;
    bottom: 12px;
    z-index: 10;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    background: #3a3a3d;
    color: #fff;
}
.ve-fullscreen:hover { background: #48484c; }

.ve-close,
.ve-export {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.ve-close {
    background: #3a3a3d;
    color: #fff;
}
.ve-export {
    background: #7c5cff;
    color: #fff;
}
.ve-export:disabled {
    opacity: 0.5;
    cursor: default;
}

.ve-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.ve-stage-wrap {
    flex: 1;
    box-sizing: border-box;
    padding: 56px 20px 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    overflow: hidden;
    position: relative;
}

#ve-preview-surface {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 0 1px #333;
}

#ve-video-layer,
#ve-canvas {
    position: absolute;
    inset: 0;
}

#ve-video-layer {
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

#ve-media-decoder-host {
    position: absolute;
    width: 2px;
    height: 2px;
    left: 0;
    top: 0;
    overflow: hidden;
    pointer-events: none;
}
#ve-canvas {
    z-index: 2;
    background: transparent;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
}

.ve-inspector {
    width: 300px;
    flex-shrink: 0;
    background: #232326;
    padding: 14px;
    overflow-y: auto;
    font-size: 13px;
}
.ve-inspector h4 {
    margin: 0 0 12px;
    font-size: 13px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ve-field {
    margin-bottom: 12px;
}
.ve-field label {
    display: block;
    margin-bottom: 4px;
    color: #aaa;
    font-size: 12px;
}
.ve-field input[type="text"],
.ve-field input[type="number"],
.ve-field textarea,
.ve-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 8px;
    border-radius: 6px;
    border: 1px solid #3d3d40;
    background: #2c2c2f;
    color: #fff;
    font-size: 13px;
}
.ve-field textarea {
    resize: vertical;
    min-height: 50px;
}
.ve-field-row {
    display: flex;
    gap: 8px;
}
.ve-field-row .ve-field {
    flex: 1;
}
.ve-field input[type="color"] {
    width: 100%;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: none;
    cursor: pointer;
}
.ve-empty-hint {
    color: #777;
    font-size: 13px;
    line-height: 1.5;
}
.ve-thumb {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
    display: block;
    background: #111;
}
.ve-delete-element {
    width: 100%;
    margin-top: 8px;
    border: 1px solid #713c42;
    border-radius: 7px;
    padding: 8px 10px;
    background: #3a2528;
    color: #ffb4bb;
    cursor: pointer;
}
.ve-delete-element:hover { background: #4a292d; }

.ve-transport {
    position: relative;
    flex-shrink: 0;
    background: #262629;
    padding: 10px 16px 14px;
    display: grid;
    grid-template-columns: 36px 46px minmax(0, 1fr);
    grid-template-rows: minmax(0, auto) auto;
    align-items: flex-start;
    gap: 12px;
}
.ve-play {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #7c5cff;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    margin-top: 20px;
}
.ve-time {
    flex-shrink: 0;
    font-size: 12px;
    color: #aaa;
    width: 46px;
    margin-top: 28px;
}

.ve-timeline {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 220px;
    position: relative;
    background: #1c1c1e;
    border-radius: 8px;
    padding: 8px 0;
    overscroll-behavior: contain;
}
.ve-timeline-stack {
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
}
.ve-timeline-tools {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 5px;
    min-width: 0;
    padding: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid #343947;
    border-radius: 10px;
    background: #1b1e27;
    scrollbar-width: thin;
    scrollbar-color: #4b5266 transparent;
}
.ve-tool-button {
    flex: 0 0 auto;
    min-width: 62px;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 5px 8px;
    background: transparent;
    color: #cbd2e2;
    cursor: pointer;
    font: 500 10px "Roboto", sans-serif;
    white-space: nowrap;
}
.ve-tool-button:hover {
    border-color: #4c5367;
    background: #2a2f3b;
    color: #fff;
}
.ve-tool-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ve-tool-button:disabled {
    opacity: .35;
    cursor: default;
}
.ve-tool-button[aria-busy="true"] svg { animation: ve-tool-pulse .8s ease-in-out infinite alternate; }
.ve-tool-split { color: #dfd5ff; }
.ve-tools-divider {
    flex: 0 0 1px;
    align-self: stretch;
    margin: 4px 3px;
    background: #3c4251;
}
@keyframes ve-tool-pulse { to { opacity: .35; transform: scale(.9); } }
.ve-ruler {
    position: sticky;
    top: 0;
    z-index: 4;
    width: 100%;
    height: 24px;
    margin-bottom: 6px;
    border-bottom: 1px solid #333;
    background: #1c1c1ef2;
    box-shadow: 0 3px 8px #0005;
}
.ve-ruler-tick {
    position: absolute;
    top: 0;
    font-size: 10px;
    color: #777;
    transform: translateX(-50%);
}
.ve-track {
    position: relative;
    width: 100%;
    height: 44px;
    margin-bottom: 5px;
    overflow: hidden;
    background: #222225;
    border-radius: 4px;
}
.ve-track-label {
    position: absolute;
    left: -0;
    top: 0;
    font-size: 10px;
    color: #666;
    padding: 2px 4px;
    pointer-events: none;
    z-index: 2;
}
.ve-bar {
    position: absolute;
    top: 3px;
    bottom: 3px;
    box-sizing: border-box;
    border-radius: 7px;
    cursor: grab;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
}
.ve-bar.selected {
    box-shadow: inset 0 0 0 2px #fff;
}
.ve-bar-handle {
    display: none;
    position: absolute;
    top: 50%;
    bottom: auto;
    width: 10px;
    height: calc(100% - 8px);
    box-sizing: border-box;
    border: 2px solid #fff;
    border-radius: 3px;
    background: #252833;
    box-shadow: 0 0 0 1px #0008;
    transform: translateY(-50%);
    cursor: ew-resize;
    z-index: 2;
}
.ve-bar.selected .ve-bar-handle { display: block; }
.ve-bar-handle::after {
    content: "";
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 50%;
    width: 1px;
    background: #ffffffaa;
    transform: translateX(-50%);
}
.ve-bar-handle.left { left: 3px; }
.ve-bar-handle.right { right: 3px; }

.ve-playhead {
    position: absolute;
    width: 2px;
    background: #ff4d4f;
    z-index: 25;
    pointer-events: none;
    box-shadow: 0 0 0 1px #0005;
}
.ve-playhead::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 2px 2px 50% 50%;
    background: #ff4d4f;
    transform: translateX(-50%);
}
.ve-playhead[hidden] { display: none; }
.ve-timeline-content { position: relative; min-height: 100%; }

.edit-video-btn {
    align-self: flex-start;
    margin-top: 6px;
    padding: 8px 14px;
    border: solid 1px #ddd;
    border-radius: 6px;
    background: #fff;
    color: #222;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.edit-video-btn:hover {
    background: #f2f2f2;
}

@media (max-width: 760px) {
    .ve-title { display: none; }
}

.ve-timeline[hidden] { display: none; }
.ve-transport-resizable { box-sizing: border-box; }
.ve-transport-resizable { grid-template-rows: minmax(0, 1fr) auto; }
.ve-transport-resizable .ve-timeline-stack { height: 100%; }
.ve-transport-resizable .ve-timeline { box-sizing: border-box; height: auto; min-height: 0; max-height: none; }
.ve-timeline-resizer {
    position: absolute;
    top: -6px;
    left: 0;
    right: 0;
    height: 12px;
    z-index: 20;
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
}
.ve-timeline-resizer::after {
    content: "";
    position: absolute;
    top: 4px;
    left: calc(50% - 24px);
    width: 48px;
    height: 4px;
    border-radius: 4px;
    background: #697086;
}
.ve-timeline-resizer:hover::after, .ve-timeline-resizer:focus-visible::after { background: #ad97ff; }
.ve-timeline-resizer:focus-visible { outline: 2px solid #ad97ff; outline-offset: -2px; }

/* Editor controls */
.ve-shell { background: #13151b; font-family: "Roboto", system-ui, sans-serif; }
.ve-topbar { background: #1b1e27; border-bottom: 1px solid #303442; padding: 12px 18px; gap: 14px; }
.ve-topbar-actions { flex-wrap: wrap; gap: 8px; }
.ve-title { letter-spacing: -.02em; font-size: 15px; }
.ve-add, .ve-export { background: #8267ee; box-shadow: 0 3px 12px #0002; }
.ve-add:hover, .ve-export:hover { background: #937bf6; }
.ve-add-menu { width: 252px; padding: 9px; background: #222632; border-color: #414759; border-radius: 14px; box-shadow: 0 18px 54px #0007; }
.ve-add-menu button { padding: 11px 12px; border-radius: 8px; font-size: 13px; }
.ve-add-menu button:hover { background: #35314e; }
.ve-add-caption { color: #a8adbe; padding-top: 8px; }
.ve-add-divider { background: #3a3e4d; }
.ve-body { min-height: 0; }
.ve-stage-wrap { min-width: 0; background: radial-gradient(ellipse at center, #202530, #101217); }
.ve-inspector { width: 328px; box-sizing: border-box; padding: 18px 14px; background: #191c24; border-left: 1px solid #303442; scrollbar-width: thin; scrollbar-color: #41485c transparent; }
.ve-inspector-heading { display: flex; gap: 11px; align-items: center; padding: 0 4px 18px; }
.ve-inspector-heading > div { min-width: 0; flex: 1; }
.ve-inspector-heading small { display: block; color: #959caf; font-size: 11px; margin-bottom: 4px; }
.ve-inspector-heading h4 { color: #f2f3fa; font-size: 15px; margin: 0; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
.ve-inspector-close {
    display: none;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 1px solid #4b5266;
    border-radius: 11px;
    background: #292e3a;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}
.ve-type-dot { width: 10px; height: 30px; border-radius: 5px; flex-shrink: 0; }
.ve-property-section { padding: 14px; margin-bottom: 12px; background: #222631; border: 1px solid #323847; border-radius: 12px; }
.ve-property-section h5 { font: 600 11px "Roboto", sans-serif; text-transform: uppercase; letter-spacing: .07em; color: #b7bfd1; margin: 0 0 14px; }
.ve-property-section > .ve-field:last-child, .ve-property-section > .ve-field-row:last-child .ve-field { margin-bottom: 0; }
.ve-field { min-width: 0; }
.ve-field label { color: #adb5c8; font-size: 11px; margin-bottom: 6px; }
.ve-field input[type="text"], .ve-field input[type="number"], .ve-field textarea, .ve-field select { border: 1px solid #424a5d; background: #191d27; border-radius: 7px; padding: 9px; color: #edf0fa; font: 15px "Roboto", sans-serif; }
.ve-field textarea { min-height: 90px; line-height: 1.5; }
.ve-field input[type="color"] { height: 36px; background: #191d27; padding: 3px; border: 1px solid #424a5d; }
.ve-shell button:focus-visible, .ve-shell input:focus-visible, .ve-shell textarea:focus-visible, .ve-shell select:focus-visible { outline: 2px solid #ad97ff; outline-offset: 2px; }
.ve-align-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.ve-align-actions button { border: 1px solid #4b5266; border-radius: 7px; background: #2d3342; color: #e1e6f4; padding: 8px 4px; cursor: pointer; font: 12px "Roboto", sans-serif; }
.ve-align-actions button:last-child { grid-column: 1 / -1; }
.ve-align-actions button:hover { background: #40385b; border-color: #937bf6; }
.ve-align-actions button[aria-pressed="true"] { color: #e5dcff; background: #473967; border-color: #a08adf; }
.ve-field-hint { font-size: 10px; line-height: 1.5; color: #99a4bb; margin: -3px 0 14px; }
.ve-delete-element { background: transparent; border-color: #694650; color: #f8aab8; padding: 10px; }
.ve-transport { background: #1b1e27; border-top: 1px solid #303442; }
.ve-bar,
.ve-bar-handle { touch-action: none; }

.ve-fullscreen-preview {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    background: #000;
}
.ve-fullscreen-preview[hidden] { display: none; }
.ve-fullscreen-preview video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.ve-fullscreen-close {
    position: fixed;
    top: max(14px, env(safe-area-inset-top, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    z-index: 2;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid #ffffff66;
    border-radius: 13px;
    background: #17171bcc;
    color: #fff;
    font-size: 21px;
    cursor: pointer;
}
@media (max-width: 900px) {
    .ve-topbar { padding: 10px; }
    .ve-inspector { width: 290px; padding: 12px 10px; }
}
@media (max-width: 600px) {
    #video-editor-overlay,
    .ve-shell {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
    }
    .ve-topbar { align-items: flex-start; }
    .ve-topbar-actions { justify-content: flex-end; }
    .ve-body { flex-direction: column; overflow: hidden; }
    .ve-stage-wrap { flex: 1 1 auto; min-height: 200px; }
    .ve-inspector {
        display: none;
        position: fixed;
        inset: auto 0 0;
        z-index: 80;
        width: 100%;
        height: 50vh;
        height: 50dvh;
        max-height: 50dvh;
        padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        box-sizing: border-box;
        border-top: 1px solid #303442;
        border-left: 0;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -12px 36px #0009;
        background: #191c24;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    .ve-inspector.is-open { display: block; }
    .ve-inspector-heading {
        position: sticky;
        top: -12px;
        z-index: 2;
        margin: -12px -12px 12px;
        padding: 12px;
        border-bottom: 1px solid #303442;
        background: #191c24f2;
        backdrop-filter: blur(12px);
    }
    .ve-inspector-close { display: grid; place-items: center; }
    .ve-transport { padding: 6px 10px; }
    .ve-timeline { max-height: 180px; }
    .ve-timeline-stack { gap: 6px; }
    .ve-timeline-tools { padding: 5px; gap: 3px; }
    .ve-tool-button { min-width: 54px; min-height: 46px; padding: 4px 6px; font-size: 9px; }
    .ve-tool-button svg { width: 21px; height: 21px; }
    .ve-timeline-content {
        margin-left: 50%;
        margin-right: 50%;
    }
    .ve-track { height: 50px; }
    .ve-bar.selected { padding-right: 22px; padding-left: 22px; }
    .ve-bar-handle { width: 16px; }
    .ve-bar:not(.selected),
    .ve-bar:not(.selected) .ve-bar-handle {
        touch-action: none;
    }
    .ve-timeline { touch-action: none; }
}

/* Shared loading/export overlay stays above the editor and fullscreen preview. */
#ve-progress-overlay { position:fixed; inset:0; z-index:100000; display:grid; place-items:center; background:rgba(16,20,32,.65); padding:24px; cursor:wait; }
.ve-progress-card { width:min(420px,100%); padding:28px; border-radius:20px; background:#fff; color:#252638; box-shadow:0 20px 70px #0004; display:flex; flex-direction:column; gap:18px; font:15px/1.5 system-ui,sans-serif; }
.ve-progress-card strong { font-size:18px; }
.ve-progress-card progress { width:100%; height:10px; border:0; border-radius:8px; accent-color:#7651d5; }
.ve-progress-card span { color:#6b7080; font-size:13px; min-height:20px; }

/* Undo / redo */
.ve-history {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #3a3a3d;
    color: #fff;
    cursor: pointer;
}
.ve-history svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ve-history:hover:not(:disabled) { background: #48484c; }
.ve-history:disabled { opacity: .35; cursor: default; }

.ve-draft-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 16px;
    background: #3a3220;
    color: #f5e2b8;
    font-size: 13px;
    flex-shrink: 0;
}
.ve-draft-notice button {
    border: 1px solid #f5e2b8;
    background: transparent;
    color: inherit;
    border-radius: 6px;
    padding: 4px 10px;
    font: inherit;
    cursor: pointer;
}
