/* ==========================================================================
   Velora Studio — Video Editor
   Structure: tokens → base → topbar → rail → panel → stage → transport →
              timeline → controls → responsive
   ========================================================================== */

/* ---- Tokens -------------------------------------------------------------- */
:root {
    --ved-bg: #0b0d14;
    --ved-surface: #131725;
    --ved-surface-2: #1a1f31;
    --ved-surface-3: #222842;
    --ved-border: #272d45;
    --ved-border-soft: #1e2338;
    --ved-text: #eaecf6;
    --ved-text-dim: #9aa2c0;
    --ved-primary: #7c6cff;
    --ved-primary-soft: rgba(124, 108, 255, 0.16);
    --ved-cyan: #34d3ee;
    --ved-pink: #f472b6;
    --ved-danger: #ff5d6c;
    --ved-ok: #35d07f;
    --ved-radius: 14px;
    --ved-radius-sm: 10px;
    --ved-radius-pill: 999px;
    --ved-rail-w: 92px;
    --ved-panel-w: 320px;
    --ved-topbar-h: 60px;
    --ved-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    --ved-font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body.ved-body-root {
    margin: 0;
    font-family: var(--ved-font);
    color: var(--ved-text);
    background: radial-gradient(1200px 700px at 15% -10%, #1b2140 0%, var(--ved-bg) 55%) fixed;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ved-muted { color: var(--ved-text-dim); }
.ved-hint { color: var(--ved-text-dim); font-size: 13px; line-height: 1.5; margin: 4px 2px; }

/* ---- App shell ----------------------------------------------------------- */
.ved-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}
.ved-main {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

/* ---- Topbar -------------------------------------------------------------- */
.ved-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--ved-topbar-h);
    padding: 0 14px;
    background: rgba(19, 23, 37, 0.9);
    border-bottom: 1px solid var(--ved-border);
    backdrop-filter: blur(12px);
    flex: 0 0 auto;
    z-index: 40;
}
.ved-brand {
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ved-text);
    text-decoration: none;
    font-size: 17px;
    white-space: nowrap;
}
.ved-brand span { color: var(--ved-primary); margin-left: 6px; }
.ved-topbar-spacer { flex: 1 1 auto; }
.ved-topbar-actions { display: flex; align-items: center; gap: 8px; }
.ved-badge {
    font-size: 12px;
    color: var(--ved-text-dim);
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    padding: 5px 10px;
    border-radius: var(--ved-radius-pill);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ved-topbar .ved-rail-toggle { display: none; }

/* ---- Rail (left tools) --------------------------------------------------- */
.ved-rail {
    flex: 0 0 var(--ved-rail-w);
    width: var(--ved-rail-w);
    background: var(--ved-surface);
    border-right: 1px solid var(--ved-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    z-index: 30;
}
.ved-rail-head {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ved-text-dim);
    padding: 14px 12px 8px;
}
.ved-rail-tools {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 10px 16px;
    overflow-y: auto;
    min-height: 0;
}
.ved-tool-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ved-text-dim);
    border-radius: var(--ved-radius-sm);
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ved-tool-btn svg { width: 22px; height: 22px; }
.ved-tool-btn:hover { background: var(--ved-surface-2); color: var(--ved-text); }
.ved-tool-btn.is-active {
    background: var(--ved-primary-soft);
    border-color: rgba(124, 108, 255, 0.5);
    color: #fff;
}
.ved-tool-btn.is-coming { opacity: 0.5; }

/* ---- Panel --------------------------------------------------------------- */
.ved-panel {
    flex: 0 0 var(--ved-panel-w);
    width: var(--ved-panel-w);
    background: var(--ved-surface);
    border-right: 1px solid var(--ved-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    z-index: 29;
}
.ved-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ved-border-soft);
    font-weight: 600;
    font-size: 14px;
    flex: 0 0 auto;
}
.ved-panel-body { padding: 16px; overflow-y: auto; min-height: 0; }
.ved-panel-head .ved-icon-btn { display: none; }

/* ---- Stage --------------------------------------------------------------- */
.ved-stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--ved-bg);
}
.ved-preview-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    min-height: 0;
}
.ved-preview {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    width: 100%;
    background: #05060a;
    border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius);
    overflow: hidden;
    box-shadow: var(--ved-shadow);
}
.ved-canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.ved-dropzone {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 24px;
    background: radial-gradient(600px 300px at 50% 40%, rgba(124, 108, 255, 0.14), transparent 70%);
}
.ved-dropzone.is-dragover { background: rgba(124, 108, 255, 0.14); }
.ved-dropzone h2 { margin: 6px 0 0; font-size: 18px; }
.ved-dropzone p { margin: 0; font-size: 13px; }
.ved-dropzone-icon svg { width: 46px; height: 46px; stroke-width: 1.5; color: var(--ved-primary); }
.ved-dropzone[hidden] { display: none; }

/* ---- Transport ----------------------------------------------------------- */
.ved-transport {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--ved-border-soft);
    background: rgba(19, 23, 37, 0.6);
    flex: 0 0 auto;
}
.ved-transport-spacer { flex: 1 1 auto; }
.ved-time-readout {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--ved-text);
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-pill);
    padding: 6px 12px;
    margin-left: 6px;
}
.ved-time-sep { color: var(--ved-text-dim); margin: 0 4px; }

/* ---- Timeline ------------------------------------------------------------ */
.ved-timeline { flex: 0 0 auto; padding: 12px 16px 18px; background: var(--ved-surface); border-top: 1px solid var(--ved-border); }
.ved-track {
    position: relative;
    height: 66px;
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-sm);
    overflow: hidden;
    cursor: pointer;
    touch-action: none;
}
.ved-track-clips { position: absolute; inset: 0; display: flex; }
.ved-clip {
    position: absolute;
    top: 8px;
    bottom: 8px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(124, 108, 255, 0.55), rgba(124, 108, 255, 0.28));
    border: 1px solid rgba(124, 108, 255, 0.7);
    overflow: hidden;
    min-width: 2px;
}
.ved-clip.is-active { background: linear-gradient(180deg, rgba(52, 211, 238, 0.6), rgba(52, 211, 238, 0.3)); border-color: var(--ved-cyan); }
.ved-clip-gap { position: absolute; top: 8px; bottom: 8px; background: repeating-linear-gradient(45deg, #1a1f31, #1a1f31 6px, #222842 6px, #222842 12px); border-radius: 4px; }
.ved-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--ved-pink);
    box-shadow: 0 0 0 1px rgba(244, 114, 182, 0.4), 0 0 12px rgba(244, 114, 182, 0.7);
    pointer-events: none;
    transform: translateX(-1px);
}
.ved-playhead::before {
    content: "";
    position: absolute;
    top: -1px; left: 50%; transform: translateX(-50%);
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--ved-pink);
}

/* ---- Buttons ------------------------------------------------------------- */
.ved-btn {
    appearance: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--ved-text);
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-pill);
    padding: 9px 16px;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}
.ved-btn:hover { background: var(--ved-surface-3); }
.ved-btn:active { transform: translateY(1px); }
.ved-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ved-btn-primary {
    background: linear-gradient(135deg, var(--ved-primary), #5b7bff);
    border-color: transparent;
    color: #fff;
}
.ved-btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--ved-primary), #5b7bff); }
.ved-btn-ghost { background: transparent; }
.ved-btn-danger { color: var(--ved-danger); border-color: rgba(255, 93, 108, 0.4); }
.ved-btn-block { width: 100%; justify-content: center; }

.ved-icon-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--ved-radius-pill);
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    color: var(--ved-text);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
    flex: 0 0 auto;
}
.ved-icon-btn svg { width: 20px; height: 20px; }
.ved-icon-btn:hover { background: var(--ved-surface-3); }
.ved-icon-btn:active { transform: translateY(1px); }
.ved-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ved-play { background: linear-gradient(135deg, var(--ved-primary), #5b7bff); border-color: transparent; color: #fff; }
.ved-play svg { fill: currentColor; stroke: none; }

/* ---- Controls (inside panels) ------------------------------------------- */
.ved-field { margin-bottom: 16px; }
.ved-field:last-child { margin-bottom: 0; }
.ved-field > label,
.ved-field-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--ved-text-dim);
    margin-bottom: 7px;
    letter-spacing: 0.02em;
}
.ved-field-label output { color: var(--ved-text); font-variant-numeric: tabular-nums; }
input[type="range"].ved-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: var(--ved-surface-3);
    outline: none;
    cursor: pointer;
}
input[type="range"].ved-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--ved-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
input[type="range"].ved-range::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ved-primary);
}
.ved-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ved-chip {
    appearance: none;
    font: inherit;
    font-size: 12px;
    color: var(--ved-text);
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-pill);
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.ved-chip:hover { background: var(--ved-surface-3); }
.ved-chip.is-active { background: var(--ved-primary-soft); border-color: rgba(124,108,255,0.6); color: #fff; }
.ved-row { display: flex; gap: 8px; }
.ved-row > * { flex: 1 1 0; }
.ved-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ved-switch {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 10px 12px;
    background: var(--ved-surface-2); border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-sm); margin-bottom: 10px; font-size: 13px;
}
.ved-switch input { width: 18px; height: 18px; accent-color: var(--ved-primary); }
.ved-text-input, .ved-select {
    width: 100%;
    font: inherit;
    font-size: 13px;
    color: var(--ved-text);
    background: var(--ved-surface-2);
    border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-sm);
    padding: 10px 12px;
    outline: none;
}
.ved-text-input:focus, .ved-select:focus { border-color: var(--ved-primary); }
.ved-note {
    font-size: 12px; color: var(--ved-text-dim);
    background: var(--ved-surface-2); border: 1px dashed var(--ved-border);
    border-radius: var(--ved-radius-sm); padding: 10px 12px; margin-top: 12px; line-height: 1.5;
}

/* ---- Ratio tool ---------------------------------------------------------- */
.ved-ratio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.ved-grid-2[hidden] { display: none; }
.ved-ratio-option {
    appearance: none; font: inherit; text-align: left; cursor: pointer;
    display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
    background: var(--ved-surface-2); border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-sm); padding: 10px; color: var(--ved-text);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.ved-ratio-option:hover { background: var(--ved-surface-3); }
.ved-ratio-option.is-active { border-color: var(--ved-primary); background: var(--ved-primary-soft); }
.ved-ratio-option strong { font-size: 13px; }
.ved-ratio-hint { font-size: 11px; color: var(--ved-text-dim); line-height: 1.3; }
.ved-ratio-shape {
    display: block; width: 42px; margin-bottom: 4px; aspect-ratio: 16 / 9;
    border: 1.5px dashed var(--ved-text-dim); border-radius: 3px;
}
.ved-ratio-option.is-active .ved-ratio-shape { border-color: var(--ved-primary); border-style: solid; }

/* ---- Merge tool ---------------------------------------------------------- */
.ved-merge-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ved-merge-item {
    display: flex; align-items: center; gap: 8px;
    background: var(--ved-surface-2); border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius-sm); padding: 8px 10px;
}
.ved-merge-item.is-active { border-color: var(--ved-primary); background: var(--ved-primary-soft); }
.ved-merge-main {
    appearance: none; font: inherit; cursor: pointer; text-align: left;
    display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0;
    background: transparent; border: none; color: var(--ved-text); padding: 0;
}
.ved-merge-index {
    flex: 0 0 auto; width: 22px; height: 22px; border-radius: var(--ved-radius-pill);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; background: var(--ved-surface-3); color: var(--ved-text-dim);
}
.ved-merge-item.is-active .ved-merge-index { background: var(--ved-primary); color: #fff; }
.ved-merge-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ved-merge-len { flex: 0 0 auto; font-size: 11px; color: var(--ved-text-dim); font-variant-numeric: tabular-nums; }
.ved-merge-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.ved-merge-actions .ved-icon-btn { width: 30px; height: 30px; }
.ved-merge-actions .ved-icon-btn svg { width: 16px; height: 16px; }

.ved-clip-index { position: absolute; left: 5px; top: 4px; font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, 0.85); }

/* ---- Toasts -------------------------------------------------------------- */
.ved-toasts {
    position: fixed;
    right: 16px; bottom: 16px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 80; pointer-events: none;
}
.ved-toast {
    background: var(--ved-surface-3);
    border: 1px solid var(--ved-border);
    border-left: 3px solid var(--ved-primary);
    color: var(--ved-text);
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--ved-radius-sm);
    box-shadow: var(--ved-shadow);
    max-width: 320px;
    animation: ved-toast-in 0.2s ease;
}
.ved-toast.is-error { border-left-color: var(--ved-danger); }
.ved-toast.is-ok { border-left-color: var(--ved-ok); }
@keyframes ved-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Progress overlay ---------------------------------------------------- */
.ved-progress {
    position: fixed; inset: 0; z-index: 90;
    display: flex; align-items: center; justify-content: center;
    background: rgba(6, 8, 14, 0.72); backdrop-filter: blur(4px);
}
.ved-progress-card {
    width: min(360px, 86vw);
    background: var(--ved-surface); border: 1px solid var(--ved-border);
    border-radius: var(--ved-radius); padding: 22px; text-align: center; box-shadow: var(--ved-shadow);
}
.ved-progress-bar { height: 8px; border-radius: 999px; background: var(--ved-surface-3); overflow: hidden; margin: 14px 0 8px; }
.ved-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ved-primary), var(--ved-cyan)); transition: width 0.15s linear; }
.ved-progress[hidden] { display: none; }

.ved-rail-scrim { display: none; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1100px) {
    :root { --ved-rail-w: 78px; --ved-panel-w: 280px; }
    .ved-tool-btn { font-size: 10px; }
}

@media (max-width: 860px) {
    /* Rail becomes a left drawer */
    .ved-rail {
        position: fixed;
        top: var(--ved-topbar-h);
        bottom: 0;
        left: 0;
        width: 240px;
        flex-basis: 240px;
        transform: translateX(-102%);
        transition: transform 0.22s ease;
        box-shadow: var(--ved-shadow);
        z-index: 60;
    }
    .ved-rail.is-open { transform: none; }
    .ved-rail-tools { flex-direction: row; flex-wrap: wrap; padding: 12px; }
    .ved-rail-tools .ved-tool-btn { flex: 1 1 44%; flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 13px; }
    .ved-topbar .ved-rail-toggle { display: inline-flex; }
    .ved-rail-scrim { display: block; position: fixed; inset: var(--ved-topbar-h) 0 0 0; background: rgba(0,0,0,0.5); z-index: 55; }
    .ved-rail-scrim[hidden] { display: none; }

    /* Panel becomes a bottom sheet */
    .ved-panel {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        width: auto; flex-basis: auto;
        max-height: 62vh;
        border-radius: 18px 18px 0 0;
        border-top: 1px solid var(--ved-border);
        border-right: none;
        transform: translateY(102%);
        transition: transform 0.24s ease;
        box-shadow: var(--ved-shadow);
        z-index: 70;
    }
    .ved-panel.is-open { transform: none; }
    .ved-panel-head .ved-icon-btn { display: inline-flex; }
    .ved-panel-body { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

    .ved-topbar { gap: 8px; padding: 0 10px; }
    .ved-brand { font-size: 15px; }
    .ved-badge { display: none; }
    .ved-topbar-actions .ved-btn-ghost { display: none; }
    .ved-preview-wrap { padding: 10px; }
    .ved-transport { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
    .ved-timeline { padding: 10px 10px 14px; }
    .ved-track { height: 56px; }
}

@media (max-width: 480px) {
    .ved-topbar-actions .ved-btn { padding: 8px 12px; font-size: 12px; }
    .ved-time-readout { font-size: 12px; padding: 5px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
