/* ===== RESET & VARIABLES ===== */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary: #6366f1;
            --primary-dark: #4f46e5;
            --primary-light: #818cf8;
            --secondary: #ec4899;
            --success: #10b981;
            --danger: #ef4444;
            --warning: #f59e0b;
            --bg-light: #f9fafb;
            --bg-dark: #111827;
            --text-light: #f3f4f6;
            --text-dark: #1f2937;
            --border-light: #e5e7eb;
            --border-dark: #374151;
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 0.75rem;
        }

        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bg-light);
            color: var(--text-dark);
            line-height: 1.6;
            overflow-x: hidden;
        }

        /* ===== HEADER ===== */
        header {
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            padding: 1.5rem;
            box-shadow: var(--shadow-lg);
            position: sticky;
            top: 0;
            z-index: 40;
        }

        .header-container {
            max-width: 1400px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .header-title {
            font-size: 1.75rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .header-title i {
            font-size: 2rem;
        }

        .header-actions {
            display: flex;
            gap: 0.75rem;
            align-items: center;
            flex-wrap: wrap;
        }

        /* ===== TOOLBAR ===== */
        .toolbar {
            background-color: white;
            border-bottom: 1px solid var(--border-light);
            padding: 1rem 1.5rem;
            position: sticky;
            top: 60px;
            z-index: 35;
            box-shadow: var(--shadow-sm);
        }

        .toolbar-container {
            max-width: 1400px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .upload-zone {
            flex: 1;
            min-width: 250px;
        }

        .filter-section {
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
            align-items: center;
        }

        /* ===== BUTTONS ===== */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.625rem 1rem;
            border: none;
            border-radius: var(--radius-md);
            font-size: 0.95rem;
            font-weight: 500;
            cursor: pointer;
            transition: var(--transition);
            font-family: inherit;
            white-space: nowrap;
        }

        .btn-primary {
            background-color: var(--primary);
            color: white;
        }

        .btn-primary:hover {
            background-color: var(--primary-dark);
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

        .btn-secondary {
            background-color: var(--border-light);
            color: var(--text-dark);
        }

        .btn-secondary:hover {
            background-color: var(--border-dark);
            color: white;
        }

        .btn-danger {
            background-color: var(--danger);
            color: white;
        }

        .btn-danger:hover {
            background-color: #dc2626;
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

        .btn-success {
            background-color: var(--success);
            color: white;
        }

        .btn-success:hover {
            background-color: #059669;
        }

        .btn-sm {
            padding: 0.375rem 0.75rem;
            font-size: 0.875rem;
        }

        .btn-icon {
            width: 2.5rem;
            height: 2.5rem;
            padding: 0;
            border-radius: 50%;
        }

        .btn-icon.btn-primary {
            background-color: var(--primary);
            color: white;
        }

        /* ===== UPLOAD ZONE ===== */
        .upload-input {
            display: none;
        }

        .upload-label {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.625rem 1rem;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: var(--transition);
            font-weight: 500;
        }

        .upload-label:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

        /* ===== FILTER BUTTONS ===== */
        .filter-btn {
            padding: 0.625rem 0.875rem;
            border: 2px solid var(--border-light);
            background-color: white;
            color: var(--text-dark);
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: var(--transition);
            font-weight: 500;
            font-size: 0.95rem;
        }

        .filter-btn:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .filter-btn.active {
            background-color: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        /* ===== MAIN CONTENT ===== */
        .main-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 2rem 1.5rem;
        }

        .gallery-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1.5rem;
            animation: fadeIn 0.3s ease-in-out;
        }

        @media (max-width: 768px) {
            .gallery-container {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 1rem;
                padding: 1rem;
            }
        }

        @media (max-width: 480px) {
            .gallery-container {
                grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
                gap: 0.75rem;
            }
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .empty-state {
            grid-column: 1 / -1;
            text-align: center;
            padding: 4rem 2rem;
            color: #9ca3af;
        }

        .empty-state i {
            font-size: 4rem;
            margin-bottom: 1rem;
            opacity: 0.5;
        }

        .empty-state h2 {
            color: var(--text-dark);
            margin-bottom: 0.5rem;
        }

        /* ===== GALLERY ITEMS ===== */
        .gallery-item {
            position: relative;
            overflow: hidden;
            border-radius: var(--radius-lg);
            background-color: white;
            box-shadow: var(--shadow-md);
            cursor: pointer;
            transition: var(--transition);
            aspect-ratio: 1;
            height: 100%;
        }

        .gallery-item:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-xl);
        }

        .gallery-item.selected {
            outline: 3px solid var(--primary);
            outline-offset: -3px;
        }

        .gallery-item-media {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .gallery-item-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: var(--transition);
            gap: 1rem;
        }

        .gallery-item:hover .gallery-item-overlay {
            opacity: 1;
        }

        .gallery-item-badge {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 0.25rem 0.5rem;
            border-radius: var(--radius-sm);
            font-size: 0.75rem;
            font-weight: 600;
            z-index: 10;
        }

        .gallery-item-favorite {
            position: absolute;
            top: 0.5rem;
            left: 0.5rem;
            z-index: 10;
        }

        .gallery-item-favorite i {
            color: var(--secondary);
            text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
        }

        .gallery-item-checkbox {
            position: absolute;
            top: 0.75rem;
            left: 0.75rem;
            z-index: 15;
        }

        .gallery-item-checkbox input {
            width: 1.25rem;
            height: 1.25rem;
            cursor: pointer;
            accent-color: var(--primary);
        }

        /* ===== LIGHTBOX ===== */
        .lightbox-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.95);
            z-index: 100;
            display: none;
            align-items: center;
            justify-content: center;
            animation: fadeIn 0.3s ease-in-out;
        }

        .lightbox-overlay.active {
            display: flex;
        }

        .lightbox-container {
            position: relative;
            max-width: 90vw;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            background-color: white;
            border-radius: var(--radius-lg);
            overflow: hidden;
            box-shadow: var(--shadow-xl);
        }

        /* ===== UPDATED LIGHTBOX CSS ===== */
            .lightbox-media {
                flex: 1 1 auto;
                min-height: 0; /* CRITICAL FIX: Forces flex item to shrink below content size */
                display: flex;
                align-items: center;
                justify-content: center;
                background-color: #000;
                position: relative;
                overflow: hidden; /* Prevents the image from breaking out */
            }

            .lightbox-media img,
            .lightbox-media video {
                width: 100%;
                height: 100%;
                object-fit: contain; /* Ensures the whole image fits without stretching */
            }

        .lightbox-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem;
            background-color: var(--text-dark);
            color: white;
        }

        .lightbox-title {
            flex: 1;
            font-weight: 600;
        }

        .lightbox-close {
            background: none;
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            transition: var(--transition);
            padding: 0.5rem;
        }

        .lightbox-close:hover {
            color: var(--primary);
        }

        .lightbox-footer {
            display: flex;
            gap: 0.5rem;
            padding: 1rem;
            background-color: var(--bg-light);
            flex-wrap: wrap;
            justify-content: center;
        }

        .lightbox-nav {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background-color: rgba(0, 0, 0, 0.6);
            color: white;
            border: none;
            padding: 1rem;
            cursor: pointer;
            font-size: 1.5rem;
            transition: var(--transition);
            z-index: 15;
        }

        .lightbox-nav:hover {
            background-color: rgba(0, 0, 0, 0.8);
        }

        .lightbox-nav.prev {
            left: 1rem;
        }

        .lightbox-nav.next {
            right: 1rem;
        }

        /* ===== CUSTOM MODAL ===== */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 200;
            display: none;
            align-items: center;
            justify-content: center;
            animation: fadeIn 0.2s ease-in-out;
        }

        .modal-overlay.active {
            display: flex;
        }

        .modal {
            background-color: white;
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-xl);
            max-width: 500px;
            width: 90%;
            max-height: 90vh;
            overflow-y: auto;
            animation: slideUp 0.3s ease-out;
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .modal-header {
            padding: 1.5rem;
            border-bottom: 1px solid var(--border-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--text-dark);
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: #9ca3af;
            transition: var(--transition);
        }

        .modal-close:hover {
            color: var(--text-dark);
        }

        .modal-body {
            padding: 1.5rem;
        }

        .modal-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--border-light);
            display: flex;
            gap: 0.75rem;
            justify-content: flex-end;
            flex-wrap: wrap;
        }

        /* ===== EDITOR MODAL ===== */
        .editor-canvas-container {
            position: relative;
            display: inline-block;
            margin-bottom: 1rem;
            max-width: 100%;
        }

        #editorCanvas {
            max-width: 100%;
            max-height: 400px;
            border: 2px solid var(--border-light);
            border-radius: var(--radius-md);
            background-color: #f0f0f0;
            cursor: crosshair;
        }

        .editor-controls {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1rem;
            margin-top: 1rem;
        }

        .form-group {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .form-label {
            font-weight: 600;
            color: var(--text-dark);
            font-size: 0.95rem;
        }

        .form-input,
        .form-select {
            padding: 0.625rem 0.875rem;
            border: 1px solid var(--border-light);
            border-radius: var(--radius-md);
            font-size: 0.95rem;
            font-family: inherit;
            transition: var(--transition);
        }

        .form-input:focus,
        .form-select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
        }

        /* ===== FLOATING ACTION BUTTONS ===== */
        .fab-container {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            display: flex;
            gap: 1rem;
            z-index: 50;
        }

        .fab {
            width: 3.5rem;
            height: 3.5rem;
            border-radius: 50%;
            background-color: var(--primary);
            color: white;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.25rem;
            box-shadow: var(--shadow-lg);
            transition: var(--transition);
        }

        .fab:hover {
            background-color: var(--primary-dark);
            transform: scale(1.1);
        }

        .fab-group {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            align-items: flex-end;
        }

        .fab-label {
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 0.5rem 0.75rem;
            border-radius: var(--radius-md);
            white-space: nowrap;
            font-size: 0.85rem;
            opacity: 0;
            transition: var(--transition);
            pointer-events: none;
        }

        .fab:hover ~ .fab-label,
        .fab-label:hover {
            opacity: 1;
        }

        /* ===== VIDEO PLAYER ===== */
        .custom-video-player {
            position: relative;
            background-color: #000;
            border-radius: var(--radius-md);
            overflow: hidden;
        }

        .video-controls {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
            padding: 1rem;
            display: flex;
            gap: 0.75rem;
            align-items: center;
            opacity: 0;
            transition: var(--transition);
        }

        .custom-video-player:hover .video-controls {
            opacity: 1;
        }

        .video-progress {
            flex: 1;
            height: 0.375rem;
            background-color: rgba(255, 255, 255, 0.3);
            border-radius: var(--radius-sm);
            cursor: pointer;
            position: relative;
        }

        .video-progress-bar {
            height: 100%;
            background-color: var(--primary);
            border-radius: var(--radius-sm);
            width: 0%;
            transition: width 0.1s linear;
        }

        .video-btn {
            background: none;
            border: none;
            color: white;
            cursor: pointer;
            font-size: 1.25rem;
            transition: var(--transition);
            padding: 0.25rem;
        }

        .video-btn:hover {
            color: var(--primary);
        }

        .video-time {
            color: white;
            font-size: 0.875rem;
            min-width: 3.5rem;
            text-align: center;
        }

        .speed-selector {
            background-color: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 0.25rem 0.5rem;
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: 0.875rem;
        }

        /* ===== RESPONSIVE ===== */
        @media (max-width: 768px) {
            .header-container {
                flex-direction: row; /* Forces them to stay inline */
                align-items: center;
                justify-content: space-between;
                flex-wrap: nowrap; /* Prevents wrapping on super small screens */
            }

            .fab-container {
                bottom: 1rem;
                right: 1rem;
            }

            .fab {
                width: 3rem;
                height: 3rem;
                font-size: 1rem;
            }

            .lightbox-container {
                max-width: 95vw;
                max-height: 95vh;
            }

            .modal {
                width: 95%;
            }

            .editor-controls {
                grid-template-columns: 1fr;
            }

            .lightbox-nav {
                padding: 0.75rem;
                font-size: 1.25rem;
            }
        }

        @media (max-width: 480px) {
            .header-title {
                font-size: 1.25rem;
            }

            .header-title i {
                font-size: 1.5rem;
            }

            .modal {
                width: 100%;
                max-height: 100vh;
                border-radius: 0;
            }

            .gallery-container {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* ===== CROP HANDLES ===== */
        .crop-container {
            position: relative;
            display: inline-block;
            margin-bottom: 1rem;
        }

        .crop-image {
            max-width: 100%;
            max-height: 400px;
            display: block;
            border: 2px dashed var(--primary);
            border-radius: var(--radius-md);
        }

        .crop-selection {
            position: absolute;
            border: 2px solid var(--primary);
            background-color: rgba(99, 102, 241, 0.1);
            cursor: move;
        }

        .crop-handle {
            position: absolute;
            width: 10px;
            height: 10px;
            background-color: var(--primary);
            border: 2px solid white;
            border-radius: 50%;
            cursor: pointer;
        }

        /* ===== UTILITY CLASSES ===== */
        .text-center {
            text-align: center;
        }

        .mt-1 {
            margin-top: 0.5rem;
        }

        .mt-2 {
            margin-top: 1rem;
        }

        .mb-1 {
            margin-bottom: 0.5rem;
        }

        .mb-2 {
            margin-bottom: 1rem;
        }

        .d-flex {
            display: flex;
        }

        .gap-1 {
            gap: 0.5rem;
        }

        .gap-2 {
            gap: 1rem;
        }

        .hidden {
            display: none !important;
        }

        .text-muted {
            color: #9ca3af;
        }

        .text-small {
            font-size: 0.875rem;
        }

        /* Scrollbar styling */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-light);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--primary);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--primary-dark);
        }

        /* ===== CUSTOM PRO CHECKMARK ===== */
        .gallery-checkmark {
            position: absolute;
            top: 0.75rem;
            left: 0.75rem;
            width: 1.6rem;
            height: 1.6rem;
            border-radius: 50%;
            border: 2px solid rgba(255, 255, 255, 0.8);
            background-color: rgba(0, 0, 0, 0.4);
            color: transparent; /* Hides the tick when not selected */
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.85rem;
            z-index: 15;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        }

        /* When the item gets the 'selected' class, animate the tick in! */
        .gallery-item.selected .gallery-checkmark {
            background-color: var(--primary);
            border-color: var(--primary);
            color: white;
            transform: scale(1.15);
        }

        /* ===== RESPONSIVE ===== */
        @media (max-width: 768px) {
            
            /* ... keep your existing header-container code here ... */

            /* 1. Force the toolbar to stay in a single row and allow horizontal scrolling */
            .toolbar-container {
                flex-direction: row;
                flex-wrap: nowrap;
                overflow-x: auto; /* Enables touch-swiping */
                padding-bottom: 0.5rem; /* Space for the scroll area */
            }

            /* 2. Remove the strict 250px width so it stops pushing filters down */
            .upload-zone {
                min-width: auto; 
                flex: 0 0 auto; /* Prevent it from shrinking/growing weirdly */
            }

            /* 3. Force the filter buttons to stay side-by-side */
            .filter-section {
                flex-wrap: nowrap; 
                flex: 0 0 auto;
            }

            /* Optional: Hide the ugly scrollbar line for a cleaner "app" feel */
            .toolbar-container::-webkit-scrollbar {
                display: none;
            }

            /* ... keep your existing fab and modal code here ... */
        }