/* ============================================================
   Video Editor — "Rich Light" (unified spec v1)
   Category accent: video = blue. Tokens in style.css :root (§A);
   page accent scope declared here per §D.
   ============================================================ */
:root { --pg: var(--cat-video); --pg-hover: #1d4ed8; --pg-text: var(--cat-video-text);
        --pg-subtle: var(--cat-video-bg); --pg-border: var(--cat-video-border);
        --pg-ring: rgba(37, 99, 235, 0.16); }

/* Editor Main Layout */
.editor-main {
    padding-top: 60px;
    min-height: 100vh;
    background: var(--bg-inset);
}

.editor-section {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
}

/* ============================================================
   Toolbar — docked 48px app-bar "lid" (§C.12)
   ============================================================ */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 12px;
    margin: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: 0 1px 8px rgba(30, 27, 75, 0.04);
    position: relative;
    z-index: 20;
    gap: 12px;
    flex-shrink: 0;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-center {
    flex: 1;
    justify-content: center;
}

/* Toolbar buttons inherit the shared ghost/primary system (style.css).
   Export inherits the gradient primary — no local overrides. */
.toolbar-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 6px;
}

/* Center status chip (§C.12) */
.video-info {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: 4px 12px;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
}

/* ============================================================
   Editor Container — panes divided by hairlines, not floating cards
   ============================================================ */
.editor-container {
    display: flex;
    flex: 1;
    gap: 0;
    overflow: hidden;
}

/* Empty state: dim the options panel until a video loads (progressive
   enhancement via :has(); JS owns interactivity — dim only). */
.editor-container:has(#video-upload-placeholder:not([style*="none"])) .options-panel {
    opacity: 0.5;
}

/* ============================================================
   Tools Panel (left sidebar) — §C.12
   ============================================================ */
.tools-panel {
    width: 200px;
    background: var(--wash-panel);
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    padding: 12px 8px;
    overflow-y: auto;
    flex-shrink: 0;
}

.tools-section {
    margin-bottom: 20px;
}

.tools-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.3;
    color: var(--text-muted);
    margin-bottom: 0;
    padding: 0 8px 6px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 32px;
    padding: 0 8px;
    background: none;
    border: none;
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    text-align: left;
}

.tool-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    stroke-width: 1.75;
    color: var(--text-muted);
}

.tool-btn:hover {
    background: var(--bg-inset);
    color: var(--text-primary);
}

/* Active tool: category-accented — the signature move (§C.12) */
.tool-btn.active {
    background: var(--pg-subtle);
    color: var(--pg-text);
    font-weight: 600;
    box-shadow: inset 2.5px 0 0 var(--pg), inset 0 0 0 1px var(--pg-border);
}

.tool-btn.active svg {
    color: var(--pg);
}

.tool-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Disabled audio tools (no audio track) — honest state kept */
.tool-btn.tool-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================================
   Preview Area — dark stage, lit deliberately (§E3)
   ============================================================ */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-inset);
    overflow: hidden;
    min-width: 0;
}

.video-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 20px;
    background: radial-gradient(120% 90% at 50% 0%, #20242c 0%, #16181d 50%, #0f1114 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    border-radius: 0;
}

/* Upload Placeholder — dark-adapted dropzone on the stage */
.video-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 520px;
    padding: 48px 40px;
    position: relative;
    background: linear-gradient(180deg, #1d2129 0%, #181b21 100%);
    border: 1.5px dashed #3a4150;
    border-radius: var(--r-xl);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    transition: border-color var(--t-base), background var(--t-base), box-shadow var(--t-base);
}

.video-upload-placeholder:hover {
    border-color: #4b5563;
}

.video-upload-placeholder .file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.video-upload-placeholder:focus-within {
    box-shadow: var(--focus-ring);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 400px;
    pointer-events: none;
}

/* Empty-state icon tile — dark-stage variant of .dz-icon (§C.13 / §E3) */
.dz-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    /* Shared category gradient, muted through a dark-stage scrim so the
       tile stays subtle while the hue derives from the token. */
    background: linear-gradient(rgba(24, 27, 33, 0.80), rgba(24, 27, 33, 0.88)), var(--cat-video-grad);
    color: #60a5fa;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.28);
    transition: transform var(--t-lift), box-shadow var(--t-lift);
}

.dz-icon svg {
    width: 28px;
    height: 28px;
    margin: 0;
}

.upload-content h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #f2f3f6;
    margin-bottom: 8px;
}

.upload-content p {
    font-size: 0.875rem;
    color: #a1a7b3;
    margin-bottom: 20px;
    line-height: 1.6;
}

.upload-hint {
    font-size: 0.8125rem;
    color: #a1a7b3;
    margin-top: 14px;
    margin-bottom: 6px;
}

.supported-formats {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #a1a7b3; /* matches adjacent hint text; clears AA on the dark stage */
    margin-bottom: 0;
}

/* Dropzone CTA: inherits gradient primary lg from the shared system */
.upload-button {
    pointer-events: auto;
    position: relative;
    z-index: 2;
}

/* Drag state (video-editor.js toggles `drag-over`) */
.video-upload-placeholder.drag-over {
    border-style: solid;
    border-color: #3b82f6;
    background: linear-gradient(180deg, #1c2333, #171d2a);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.22), 0 0 56px rgba(37, 99, 235, 0.35);
}

.video-upload-placeholder.drag-over .dz-icon {
    color: #93c5fd;
}

/* ============================================================
   Video Player — floats on the stage (§E3)
   ============================================================ */
.video-player-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-player {
    max-width: 100%;
    max-height: calc(100vh - 350px);
    border-radius: 8px;
    background: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.40), 0 16px 40px rgba(0, 0, 0, 0.50),
                0 0 0 1px rgba(255, 255, 255, 0.06);
    transition: transform var(--t-base);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity var(--t-base);
    cursor: pointer;
    border-radius: 8px;
}

.video-player-container:hover .video-overlay {
    opacity: 1;
}

.video-overlay.hidden {
    display: none;
}

.play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--cat-video-grad);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform var(--t-lift), box-shadow var(--t-lift);
}

.play-btn svg {
    width: 24px;
    height: 24px;
}

.play-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.play-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ============================================================
   Video Controls — transport bar (§E3)
   ============================================================ */
.video-controls {
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 8px rgba(30, 27, 75, 0.04);
    position: relative;
    z-index: 5;
}

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

/* Transport buttons: shared ghost variant; local sizing only */
.control-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.control-btn svg {
    width: 16px;
    height: 16px;
}

.control-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* JS toggles `muted` on the volume control */
.control-btn.muted {
    color: var(--text-disabled);
}

.time-display {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    min-width: 88px;
    white-space: nowrap;
}

.progress-container {
    flex: 1;
    position: relative;
    height: 32px;
    display: flex;
    align-items: center;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    cursor: pointer;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--cat-video-grad);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--pg);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-xs);
    left: 0%;
}

.progress-handle:active {
    cursor: grabbing;
}

/* Trim Markers on the seek bar — category accent */
.trim-marker {
    position: absolute;
    top: -6px;
    width: 4px;
    height: 16px;
    background: var(--pg);
    border-radius: 2px;
    cursor: ew-resize;
    z-index: 10;
}

.trim-marker.start {
    left: 0%;
}

.trim-marker.end {
    right: 0;
}

.trim-region {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(37, 99, 235, 0.16);
    border-left: 2px solid var(--pg);
    border-right: 2px solid var(--pg);
    pointer-events: none;
}

/* Cut tool shows a "removed" region — STAYS red (semantic) */
.trim-region.cut-mode {
    background: rgba(217, 45, 32, 0.2);
    border: 1px solid var(--error-strong);
}

.volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

/* Slider thumb — brand gradient (§C.5) */
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--grad-btn);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40);
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40), 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.volume-slider:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ============================================================
   Timeline — light, restrained; clips are light-blue cards (§E3)
   ============================================================ */
.timeline-container {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 8px 12px;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.timeline-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.3;
}

.timeline-zoom {
    display: flex;
    align-items: center;
    gap: 4px;
}

.timeline-zoom-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
}

.timeline-zoom-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

#timeline-zoom-level {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
}

.timeline {
    position: relative;
    height: 80px;
    background: #f7f8fb;
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 3px rgba(30, 27, 75, 0.04);
}

.timeline-ruler {
    position: relative;
    height: 20px;
    background: var(--bg-inset);
    border-bottom: 1px solid var(--border);
}

/* Timeline ruler ticks (JS-built) */
.ruler-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    white-space: nowrap;
}
.ruler-tick:first-child { transform: translateX(0); }
.ruler-tick:last-child { transform: translateX(-100%); }

.timeline-track {
    height: 60px;
    padding: 4px;
}

.timeline-clip {
    position: relative;
    height: 100%;
    background: linear-gradient(180deg, #dbeafe, #bfdbfe);
    border: 1px solid #93c5fd;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.15);
    overflow: hidden;
}

.clip-thumbnails {
    display: flex;
    height: 100%;
    gap: 2px;
}

.clip-thumbnail {
    height: 100%;
    background-size: cover;
    background-position: center;
    flex: 1;
}

/* Visual Trim Handles */
.trim-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    background: var(--cat-video-grad);
    border-radius: 3px;
    cursor: ew-resize;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trim-handle-left {
    left: 0;
}

.trim-handle-right {
    right: 0;
}

.trim-handle-bar {
    width: 2px;
    height: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
}

.trim-handle:hover {
    /* Token gradient darkened by a neutral scrim (no one-off hue pair) */
    background: linear-gradient(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18)), var(--cat-video-grad);
}

.trim-handle:hover .trim-handle-bar {
    background: #fff;
}

.trim-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(23, 24, 28, 0.45);
    pointer-events: none;
    z-index: 15;
}

.trim-overlay-left {
    left: 0;
    width: 0;
    border-radius: var(--r-xs) 0 0 var(--r-xs);
}

.trim-overlay-right {
    right: 0;
    width: 0;
    border-radius: 0 var(--r-xs) var(--r-xs) 0;
}

/* Playhead stays near-black */
.timeline-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #17181c;
    z-index: 10;
    left: 0;
    pointer-events: none;
}

.timeline-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #17181c;
}

/* ============================================================
   Options Panel (right) — §C.12
   ============================================================ */
.options-panel {
    width: 272px;
    background: #fff;
    border-left: 1px solid var(--border);
    border-radius: 0;
    box-shadow: -1px 0 8px rgba(30, 27, 75, 0.03);
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.options-content {
    animation: fadeIn 160ms var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.options-content h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    position: relative;
    padding-left: 11px;
}

.options-content h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--pg), var(--pg-hover));
}

.option-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 14px;
}

.option-group {
    margin-bottom: 14px;
}

.option-group label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.option-input,
.option-select,
.time-input {
    width: 100%;
    height: 32px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    box-shadow: inset 0 1px 2px rgba(30, 27, 75, 0.04), 0 1px 1px rgba(30, 27, 75, 0.03);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.option-input::placeholder,
.time-input::placeholder {
    color: var(--text-disabled);
}

.time-input {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.option-input:focus,
.option-select:focus,
.time-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
    background: #fff;
}

.option-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236f7683' stroke-width='1.5'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center;
}

.time-input-group {
    display: flex;
    gap: 8px;
}

.time-input-group .time-input {
    flex: 1;
    min-width: 0;
}

/* Set-to-current-time: shared secondary variant; local sizing only */
.set-time-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
}

.set-time-btn svg {
    width: 16px;
    height: 16px;
}

.set-time-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Sliders — brand-gradient thumb (§C.5) */
.option-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
}

.option-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--grad-btn);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40);
    cursor: pointer;
}

.option-slider::-webkit-slider-thumb:hover {
    transform: none;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.40), 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.option-slider:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Legacy trim duration block (kept selector) */
.trim-duration {
    font-size: 0.8125rem;
    color: var(--text-secondary); /* --text-muted dips below AA on --bg-inset */
    padding: 10px 12px;
    background: var(--bg-inset);
    border-radius: var(--r-sm);
    margin-bottom: 14px;
    text-align: center;
}

#trim-duration-display {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    font-weight: 500;
}

/* Trim duration display row */
.trim-duration-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0;
    padding: 8px 10px;
    background: var(--bg-inset);
    border-radius: var(--r-xs);
    font-size: 0.75rem;
    color: var(--text-secondary); /* --text-muted dips below AA on --bg-inset */
}

.trim-duration-row #trim-duration-display {
    font-weight: 500;
    color: var(--text-primary);
}

/* Apply button: full-width gradient primary (shared recipe) */
.apply-btn {
    width: 100%;
    margin-top: 16px;
}

/* ============================================================
   Speed Options — 4-col grid of mono chips
   ============================================================ */
.speed-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.speed-btn {
    height: 28px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.speed-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ============================================================
   Rotate / Flip — 2-col secondary tiles
   ============================================================ */
.rotate-buttons,
.flip-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.rotate-btn,
.flip-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    font-size: 11px;
}

.rotate-btn svg,
.flip-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.rotate-btn:focus-visible,
.flip-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.rotate-btn.full-width {
    grid-column: 1 / -1;
    width: 100%;
    flex-direction: row;
    padding: 10px 12px;
}

/* Tile micro-interaction (§C.12) */
.rotate-btn,
.flip-btn,
.speed-btn,
.filter-btn,
.set-time-btn {
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
                transform var(--t-lift), box-shadow var(--t-lift);
}

.rotate-btn:hover,
.flip-btn:hover,
.speed-btn:hover,
.filter-btn:hover,
.set-time-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 2px rgba(30, 27, 75, 0.05), 0 4px 12px rgba(30, 27, 75, 0.08);
}

.rotate-btn:active,
.flip-btn:active,
.speed-btn:active,
.filter-btn:active,
.set-time-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-xs);
}

/* Selected chips/tiles — category-accented (§C.12) */
.speed-btn.active,
.flip-btn.active,
.filter-btn.active {
    background: var(--pg-subtle);
    border-color: var(--pg);
    color: var(--pg-text);
    font-weight: 600;
    box-shadow: 0 0 0 3px var(--pg-ring);
}

.flip-btn.active svg {
    color: var(--pg);
}

/* ============================================================
   Checkbox — brand gradient when checked (§C.5)
   ============================================================ */
.checkbox-group {
    margin-top: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.checkbox-custom {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xs);
    position: relative;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--grad-btn);
    border-color: transparent;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.35);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4.5px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.checkbox-label input:focus-visible + .checkbox-custom {
    box-shadow: var(--focus-ring);
}

.checkbox-text {
    font-size: 0.8125rem;
    color: var(--text-primary);
}

/* ============================================================
   Filters Grid
   ============================================================ */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.filter-btn {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    cursor: pointer;
}

.filter-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Muted preview swatch; per-filter `filter:` classes differentiate it */
.filter-preview {
    width: 100%;
    height: 44px;
    background: linear-gradient(135deg, #8896ab, #5b6b84, #31405c);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
}

.filter-preview.grayscale {
    filter: grayscale(100%);
}

.filter-preview.sepia {
    filter: sepia(100%);
}

.filter-preview.vintage {
    filter: sepia(50%) contrast(90%) brightness(90%);
}

.filter-preview.cold {
    filter: saturate(80%) hue-rotate(180deg);
}

.filter-preview.warm {
    filter: sepia(35%) saturate(140%) brightness(105%);
}

.filter-preview.dramatic {
    filter: contrast(130%) saturate(120%);
}

.filter-preview.invert {
    filter: invert(100%);
}

.filter-btn span {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.filter-btn.active span {
    color: var(--pg-text);
    font-weight: 600;
}

/* ============================================================
   Operations Queue — §E3
   ============================================================ */
.ops-queue {
    border-top: 1px solid var(--border);
    border-bottom: none;
    margin-top: 20px;
    padding: 16px 0 0;
}

.ops-queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.ops-queue-header h4 {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.3;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ops-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    padding: 1px 6px;
    background: var(--pg-subtle);
    color: var(--pg-text);
    border-radius: var(--r-full);
    box-shadow: inset 0 0 0 1px var(--pg-border);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    text-transform: none;
}

.ops-clear-btn {
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.ops-clear-btn:hover:not(:disabled) {
    color: var(--error);
    border-color: var(--error-border);
    background: var(--error-subtle);
}

.ops-clear-btn:disabled {
    color: var(--text-disabled);
    border-color: var(--border);
    background: var(--bg-subtle);
    cursor: not-allowed;
}

.ops-clear-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ops-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.op-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    background: #f7f8fb;
    border: none;
    border-left: 2px solid var(--pg-border);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.op-label {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-remove {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

.op-remove:hover {
    background: var(--error-subtle);
    color: var(--error);
}

.op-remove:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.op-empty {
    padding: 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-style: normal;
}

.ops-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin: 10px 0 0;
}

/* ============================================================
   Export Section
   ============================================================ */
.export-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.export-section h4 {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.3;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ============================================================
   Modal — §C.10
   ============================================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* video-editor.js shows/hides this modal via inline style.display only,
       so neutralize style.css's default opacity:0/visibility:hidden state
       (which expects a .show class this page never adds). */
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 27, 75, 0.45);
}

.modal-content {
    position: relative;
    background: #fff;
    border: 1px solid rgba(30, 27, 75, 0.05);
    border-radius: var(--r-xl);
    width: 400px;
    max-width: 90%;
    box-shadow: var(--e4);
    /* Cancel style.css's .show-driven translateY(20px) resting state and
       provide the entrance motion via a keyframe instead (mirrors image editor). */
    transform: none;
    animation: modalSlideIn 160ms var(--ease);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

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

/* Export Progress — gradient ring (§E3) */
.export-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
}

.progress-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-circle .progress-bg {
    fill: none;
    stroke: #edeef4;
    stroke-width: 6;
}

.progress-circle .progress-fill {
    fill: none;
    stroke: url(#ov-export-grad);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.3s var(--ease);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.export-status {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ============================================================
   Toast Notifications — white cards with a colored edge (§C.9)
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 12px 14px;
    background: #fff;
    border: 1px solid var(--border-lifted);
    border-left-width: 3px;
    border-radius: var(--r-md);
    box-shadow: var(--e3);
    animation: slideIn 0.3s var(--ease) forwards;
    max-width: 360px;
    opacity: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast.fade-out {
    animation: slideOut 0.5s var(--ease) forwards;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error-strong);
}

.toast.info {
    border-left-color: var(--accent);
}

.toast.warning {
    border-left-color: var(--warn-text);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* ============================================================
   Crop overlay (interactive crop box — dark scheme kept)
   ============================================================ */
.crop-overlay {
    position: absolute;
    z-index: 10;
    cursor: default;
}

.crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    cursor: move;
}

.crop-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(255,255,255,0.4) 1px, transparent 1px),
        linear-gradient(to right, rgba(255,255,255,0.4) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.4) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.4) 1px, transparent 1px);
    background-size: 100% 100%;
    background-position: 33.33% 0, 66.66% 0, 0 33.33%, 0 66.66%;
    background-repeat: no-repeat;
}

.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--pg);
    border-radius: 3px;
    z-index: 2;
}
.crop-handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
    .options-panel {
        width: 240px;
    }

    .tools-panel {
        width: 180px;
    }
}

@media (max-width: 992px) {
    .editor-container {
        flex-direction: column;
    }

    .tools-panel {
        width: 100%;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .tools-section {
        margin-bottom: 0;
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
    }

    .tools-section-title {
        display: none;
    }

    .tool-btn span {
        display: none;
    }

    .tool-btn {
        width: auto;
        padding: 0 8px;
    }

    /* Horizontal-strip active tool (§C.12) */
    .tool-btn.active {
        box-shadow: inset 0 -2.5px 0 var(--pg);
        background: var(--pg-subtle);
    }

    .options-panel {
        width: 100%;
        max-height: 250px;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 768px) {
    .toolbar-btn span {
        display: none;
    }

    .video-info {
        display: none;
    }

    .time-display {
        font-size: 0.6875rem;
        min-width: 72px;
    }

    .volume-slider {
        width: 60px;
    }

    .video-upload-placeholder {
        padding: 40px 20px;
    }
}

/* ============================================================
   Advanced / multi-clip additions (waveform, panels, results)
   ============================================================ */

/* Audio waveform overlaid on the timeline filmstrip */
.waveform-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    opacity: 0.85;
    display: none;
    mix-blend-mode: multiply;
}

/* Two-column field rows inside option panels */
.two-col {
    display: flex;
    gap: 10px;
}
.two-col > .option-group {
    flex: 1;
    min-width: 0;
}

/* Multi-line text field, matches .option-input */
.option-textarea {
    resize: vertical;
    min-height: 44px;
    font-family: var(--font-sans);
    line-height: 1.4;
}

/* Visible file inputs inside panels */
.file-input-visible {
    display: block;
    width: 100%;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 6px 0;
}
.file-input-visible::file-selector-button {
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--pg-text);
    background: var(--pg-subtle);
    border: 1px solid var(--pg-border);
    border-radius: var(--r-sm);
    padding: 6px 12px;
    margin-right: 10px;
    cursor: pointer;
    transition: background var(--t-fast);
}
.file-input-visible::file-selector-button:hover {
    background: #dbeafe;
}

/* Secondary "ghost" button used for add-range and result actions */
.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--pg-text);
    background: #fff;
    border: 1px solid var(--pg-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.ghost-btn:hover {
    background: var(--pg-subtle);
}
.ghost-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}
.ghost-btn.full-width {
    width: 100%;
    margin: 4px 0 8px;
}

/* Compact lists for marked ranges / added clips */
.mini-list {
    list-style: none;
    margin: 8px 0 12px;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mini-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    background: #f7f8fb;
    border-left: 2px solid var(--pg-border);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-primary);
}
.mini-item span {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mini-remove {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.mini-remove:hover {
    background: var(--error-subtle);
    color: var(--error);
}
.mini-remove:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Result card shown after a compose/subtitle/transcribe operation */
.result-card {
    margin-top: 14px;
    padding: 12px;
    background: var(--pg-subtle);
    border: 1px solid var(--pg-border);
    border-radius: var(--r-md, 10px);
}
.result-msg {
    margin: 0 0 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--pg-text);
}
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* "Coming soon" fade placeholder */
.coming-soon-note {
    color: var(--text-muted);
    font-style: italic;
}
.coming-soon-btn {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 520px) {
    .two-col { flex-direction: column; gap: 0; }
}

/* ============================================================
   Live Preview — hint bar, original/edits toggle, text overlay
   ============================================================ */

/* Floating chip on the dark stage announcing the approximate preview,
   with a toggle to reveal the untouched source. */
.preview-hint-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 32px);
    padding: 5px 6px 5px 12px;
    background: rgba(23, 24, 28, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--r-full);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.preview-hint-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #d7dae1;
    white-space: nowrap;
}

.preview-hint-text svg {
    flex-shrink: 0;
    color: #93c5fd;
}

.preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #e8eaef;
    white-space: nowrap;
    cursor: pointer;
    border-radius: var(--r-full);
    border-left: 1px solid rgba(255, 255, 255, 0.14);
    transition: color var(--t-fast);
}

.preview-toggle:hover {
    color: #fff;
}

.preview-toggle input {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: #3b82f6;
}

.preview-toggle input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--r-xs);
}

/* Approximate caption/text overlay layered over the video rectangle */
.preview-text-overlay {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 6;
    display: flex;
    justify-content: center;
    padding: 0 6%;
    pointer-events: none;
    text-align: center;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: clamp(14px, 3.4vw, 30px);
    line-height: 1.25;
    color: #fff;
    /* Legible on any frame — mimics a subtitle burn-in outline */
    text-shadow:
        0 0 3px rgba(0, 0, 0, 0.9),
        1px 1px 0 rgba(0, 0, 0, 0.85),
        -1px 1px 0 rgba(0, 0, 0, 0.85),
        1px -1px 0 rgba(0, 0, 0, 0.85),
        -1px -1px 0 rgba(0, 0, 0, 0.85);
    word-break: break-word;
}

.preview-text-overlay.pos-bottom {
    bottom: 7%;
    align-items: flex-end;
}

.preview-text-overlay.pos-middle {
    top: 50%;
    transform: translateY(-50%);
    align-items: center;
}

.preview-text-overlay.pos-top {
    top: 7%;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .preview-hint-text {
        display: none;
    }
    .preview-toggle {
        border-left: none;
    }
}
