/* ========================================
   CSS Variables & Design System
   ======================================== */
:root {
    /* Enhanced Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --accent: #06b6d4;

    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary-gradient: linear-gradient(135deg, #f472b6 0%, #fb7185 100%);
    --accent-gradient: linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%);

    --bg-primary: #0b0b15;
    --bg-secondary: #121225;
    --bg-tertiary: #1e1e38;
    --bg-glass: rgba(30, 30, 56, 0.7);
    --bg-overlay: rgba(11, 11, 21, 0.9);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

    /* System Spacing - More Professional Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 60px;
}

/* ========================================
   App Layout
   ======================================== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 150px;
    /* Space for fixed controls */
}

/* ========================================
   Header - Fixed Support
   ======================================== */
.app-header {
    background: var(--bg-secondary);
    padding: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 24px;
    height: 24px;
    color: var(--primary);
    stroke-width: 2;
}

.logo h1 {
    font-size: 18px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.export-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.export-btn:active:not(:disabled) {
    transform: translateY(0);
}

.export-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}


.menu-container {
    position: relative;
}

.menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.menu-btn:hover {
    background: var(--bg-tertiary);
}

.menu-btn svg {
    width: 24px;
    height: 24px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    padding: 4px;
    animation: fadeIn 0.2s ease-out;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.menu-item:hover {
    background: var(--bg-tertiary);
}

.menu-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ========================================
   Preview Container
   ======================================== */
.preview-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 15px 0;
    background: var(--bg-primary);
    position: relative;
    min-height: 200px;
}


.video-wrapper {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16/9;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-lg);
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ========================================
   Playback Controls (Sleek Floating Bar)
   ======================================== */
/* ========================================
   Bottom Controls Container
   ======================================== */
.bottom-controls-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

/* Timeline Toolbar (Now in bottom container) */
.timeline-toolbar {
    height: 40px;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.playback-controls-fixed {
    position: relative;
    /* Changed from fixed */
    bottom: auto;
    left: auto;
    right: auto;
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    /* Compact padding */
    background: var(--bg-secondary);
    border-top: none;
    /* Container has border */
    box-shadow: none;
    /* Container has shadow */
    z-index: auto;
}

.control-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

.time-display {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========================================
   Timeline Component - NEW ARCHITECTURE
   ======================================== */
.timeline-container {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 320px;
    overflow: hidden;
}


/* Timeline Toolbar Styles moved to Bottom Container Block */


.timeline-left-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.timeline-info {
    display: flex;
    align-items: center;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.timeline-info .divider {
    color: var(--text-muted);
}


.tl-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tl-btn:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

/* Zoom Controls in Toolbar */
.timeline-right-group {
    display: flex;
    align-items: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
    background: transparent;
    border: none;
    width: auto;
    height: 100%;
    flex-shrink: 0;
}

.tl-btn-zoom {
    width: 22px;
    height: 22px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tl-btn-zoom:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

#newZoomRange {
    width: 100px;
    height: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Timeline Main Layout */
.timeline-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.timeline-sidebar-container {
    width: 140px;
    min-width: 140px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    /* Ensure content doesn't overflow when shrinking */
}



.timeline-sidebar-container.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.timeline-sidebar-container.collapsed .timeline-sidebar {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.timeline-sidebar-container.collapsed #globalAddTrackBtn {
    display: none;
}

.timeline-sidebar-header {
    height: 30px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tl-btn-header {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tl-btn-header:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.timeline-sidebar {
    width: 100%;
    /* Fill container */
    background: transparent;
    border-right: none;
    display: flex;
    flex-direction: column;
    padding-top: 0;
    flex: 1;
    /* Push footer down */
    overflow: hidden;
    /* JS Syncs scroll */
}

/* Removed check .timeline-sidebar.hidden as it is now on container */



.track-header {
    height: 60px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.track-header .track-name-area {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1;
    margin-right: 2px;
    overflow: hidden;
}

.track-header .name-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.track-header .track-name {
    font-weight: 700;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
    line-height: 1.2;
}

.track-name-input {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: inherit;
    font-weight: 700;
    padding: 2px;
    border-radius: 2px;
    outline: none;
    width: 100%;
}

.track-header .track-type {
    font-size: 10px;
    color: var(--text-muted);
}

.tl-btn-delete {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    /* Circle looks better for delete */
    background: #ef4444;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding-bottom: 2px;
    /* Visual adjustment for minus alignment */
}

.tl-btn-delete.hidden {
    display: none;
}

.track-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tl-btn-tiny {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 2px;
    cursor: pointer;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.tl-btn-tiny:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tl-btn-tiny svg {
    width: 12px;
    height: 12px;
}

.tl-btn-global-add {
    width: 32px;
    height: 32px;
    background: #22c55e;
    /* Green */
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px auto;
    /* Center horizontally */
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tl-btn-global-add:hover {
    background: #16a34a;
    color: #ffffff;
    transform: scale(1.05);
}

.track-controls-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.tl-btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tl-btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.tl-btn-icon.muted {
    color: #ef4444;
}

.track-header.dragging-track {
    opacity: 0.8;
    background: var(--bg-tertiary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    cursor: grabbing;
}

/* Timeline Content Area */
.timeline-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    overflow-y: hidden;
    background: #151525;
    position: relative;
    cursor: crosshair;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.timeline-content-wrapper::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.timeline-ruler-container {
    height: 40px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    position: relative;
    z-index: 15;
    flex-shrink: 0;
}

#timelineRulerCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.timeline-tracks-viewport {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: visible;
    /* Let wrapper handle horizontal scroll */
}

.timeline-tracks-viewport::-webkit-scrollbar {
    display: none;
}

.timeline-tracks-content {
    min-height: 100%;
    position: relative;
}

.track-canvas-wrapper {
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    background: rgba(255, 255, 255, 0.02);
}

.track-canvas-wrapper.active {
    background: rgba(99, 102, 241, 0.05);
}

.track-canvas {
    display: block;
    cursor: inherit;
}

/* Playhead (Scrubber) */
.new-playhead {
    position: absolute;
    top: 0;
    left: 0;
    height: calc(100% - 40px);
    width: 1px;
    z-index: 100;
    pointer-events: none;
}

.playhead-tooltip {
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Courier New', Courier, monospace;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.new-playhead.show-tooltip .playhead-tooltip {
    opacity: 1;
}

.playhead-handle {
    width: 13px;
    height: 18px;
    background: var(--secondary);
    position: absolute;
    bottom: -18px;
    /* Move down into ruler */
    left: -6px;
    clip-path: polygon(0% 100%, 100% 100%, 100% 40%, 50% 0%, 0% 40%);
    pointer-events: auto;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 20;
}

.playhead-handle:active {
    cursor: grabbing;
}

.playhead-line {
    width: 1px;
    height: 100%;
    background: var(--secondary);
    box-shadow: 0 0 4px rgba(236, 72, 153, 0.5);
}


.toolbar-fixed {
    position: fixed;
    bottom: 72px;
    left: 0;
    right: 0;
    z-index: 1999;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 0 15px 15px 15px;
    /* Add padding bottom to separate from playback */
    background: transparent;
    /* "Menu area ... float like playback". Playback has full width BG. */
    pointer-events: none;
    /* Let clicks pass through if empty */
}

.toolbar-fixed .tool-btn {
    pointer-events: auto;
    /* Re-enable for buttons */
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.timeline-container {
    padding-bottom: 20px;
    /* Space for scrollbar if needed */
}



.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 10px;
    cursor: pointer;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Modals
   ======================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: fadeIn var(--transition-base);
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp var(--transition-base);
}

.modal-handle {
    display: none;
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    margin: var(--space-3) auto 0;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Form Elements - High End
   ======================================== */
.form-group {
    margin-bottom: var(--space-6);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Range Input Modernization */
.form-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin: var(--space-4) 0;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-picker {
    display: flex;
    gap: var(--spacing-sm);
}

.color-picker input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: #667eea;
}

/* ========================================
   Filter & Effect Grids
   ======================================== */
.filter-grid,
.effect-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

.filter-item,
.effect-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.filter-item:hover,
.effect-item:hover {
    transform: scale(1.05);
}

.filter-preview,
.effect-preview {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.filter-item.active .filter-preview,
.effect-item.active .effect-preview {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.filter-item span,
.effect-item span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Filter Styles */
.filter-grayscale {
    filter: grayscale(100%);
}

.filter-sepia {
    filter: sepia(100%);
}

.filter-vintage {
    filter: sepia(50%) contrast(1.2) brightness(0.9);
}

.filter-cool {
    filter: hue-rotate(180deg) saturate(1.5);
}

.filter-warm {
    filter: sepia(30%) saturate(1.4);
}

/* ========================================
   Export Progress
   ======================================== */
.export-progress {
    margin-top: var(--spacing-md);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    width: 0%;
    transition: width var(--transition-base);
}

.progress-text {
    margin-top: var(--spacing-sm);
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    -webkit-background-clip: text;
    /* Added for cross-browser compatibility */
    background-clip: text;
}

/* ========================================
   Responsive Design - Unified Breakpoints
   ======================================== */

/* Desktop & Large Screens Defaults above */

/* Tablet & Smaller (Max 1024px) */
@media (max-width: 1024px) {
    .app-container {
        padding: 0 15px;
    }
}

/* Standard Mobile (Max 480px) */
@media (max-width: 480px) {
    body {
        padding-bottom: 84px;
    }

    .app-header {
        padding: 15px 0;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .logo h1 {
        font-size: 1.125rem;
    }

    .preview-container {
        padding: 15px 0;
        min-height: 200px;
    }


    .video-wrapper {
        border-radius: var(--radius-sm);
    }

    /* Bottom Sheet Modals */
    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-width: none;
        max-height: 80vh;
        animation: slideFromBottom 0.35s cubic-bezier(0.33, 1, 0.68, 1);
    }

    @keyframes slideFromBottom {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-handle {
        display: block;
    }

    .modal-header {
        padding: var(--space-2) var(--space-6) var(--space-6);
    }

    /* Fixed Bar Mobile Adjustments */
    .playback-controls-fixed {
        bottom: 0 !important;
        bottom: env(safe-area-inset-bottom, 0) !important;
        left: 0 !important;
        right: 0 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 5000 !important;
        /* Extremely high to beat anything else */
        height: 60px !important;
        background: var(--bg-secondary) !important;
        transform: none !important;
        width: 100% !important;
        border-top: 1px solid var(--border-highlight) !important;
        padding: 0 15px !important;
    }

    .toolbar {
        padding: var(--space-3);
        gap: var(--space-3);
    }

    .tool-btn {
        padding: var(--space-3);
        border-radius: var(--radius-md);
    }

    /* Multi-Track Timeline Mobile */
    .timeline-layer-panel {
        width: 80px;
    }

    .layer-name {
        font-size: 11px;
    }

    .timeline-track {
        height: 50px;
    }

    .layer-item {
        height: 50px;
        padding: 0 8px;
    }

    .timeline-header {
        margin-bottom: 8px;
    }

    .timeline-title {
        font-size: 13px;
    }

    .layer-toggle-btn,
    .zoom-btn {
        width: 28px;
        height: 28px;
    }

    .layer-toggle-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* Ultra-Compact Mobile (iPhone SE/320px) */
@media (max-width: 325px) {
    .app-header {
        padding: 15px 0;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .export-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
    }

    .preview-container {
        padding: 15px 0;
        min-height: 180px;
    }

    .timeline-container {
        padding: 15px 0;
    }

    .timeline-content {
        height: 60px;
    }

    .toolbar {
        gap: var(--space-1);
    }

    .tool-btn span {
        display: none;
    }
}

/* ========================================
   Interactive Utilities
   ======================================== */
@media (hover: none) {

    button:active,
    .tool-btn:active,
    .control-btn:active {
        transform: scale(0.96);
        opacity: 0.8;
    }
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: var(--space-2);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* モバイル表示でズームスライダーを非表示 */
@media (max-width: 768px) {
    .timeline-zoom-control {
        display: none;
    }
}

/* ========================================
   Project Management (Splash & Modals)
   ======================================== */

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: auto;
}

.splash-screen[style*="display: none"] {
    pointer-events: none !important;
    visibility: hidden !important;
}

.splash-content {
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.splash-logo {
    margin-bottom: 3rem;
}

.splash-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    stroke: var(--primary);
}

.splash-logo h1 {
    font-size: 3rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.splash-logo p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.splash-actions {
    display: flex;
    gap: 1.5rem;
    flex-direction: column;
    min-width: 300px;
}

.splash-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.splash-btn svg {
    width: 24px;
    height: 24px;
}

.splash-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.splash-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.splash-btn.secondary {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.splash-btn.secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: transform 0.3s;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
}

.input-group input[type="text"]:focus {
    border-color: var(--primary);
    outline: none;
}

.folder-select-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.folder-select-btn:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.folder-label {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 1rem;
}

.btn-text:hover {
    color: white;
}

.btn-primary:text-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Enhanced Create Button */
#createNewProject {
    background: var(--primary-gradient);
    color: white;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#createNewProject:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
    filter: brightness(1.1);
}

#createNewProject:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Playhead Styles */
.new-playhead {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: #ef4444;
    z-index: 50;
    pointer-events: none;
}

.playhead-handle {
    position: absolute;
    top: 134px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    background: transparent;
    border: none;
    cursor: grab;
    pointer-events: auto;
    z-index: 55;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.playhead-handle svg {
    width: 16px;
    height: 10px;
    display: block;
}

.playhead-handle:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.1);
}

.playhead-tooltip {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 52;
}

.new-playhead.show-tooltip .playhead-tooltip {
    opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border: 3px solid var(--bg-primary);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Timeline Horizontal Scrollbar - Larger & Distinct */
.timeline-content-wrapper::-webkit-scrollbar {
    height: 32px;
    /* Even larger for mobile touch */
}

.timeline-content-wrapper::-webkit-scrollbar-track {
    background: #0f0f1a;
    border-top: 1px solid var(--border-color);
}

.timeline-content-wrapper::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border: 3px solid #0f0f1a;
    border-radius: 12px;
    min-width: 60px;
}

.timeline-content-wrapper::-webkit-scrollbar-thumb:hover {
    background: #ffffff;
}