* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --accent: #4895ef;
    --success: #4cc9f0;
    --dark: #2b2d42;
    --light: #f8f9fa;
    --gray: #adb5bd;
    --danger: #e63946;
    --warning: #ff9e00;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

html,
body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    -ms-text-size-adjust: none;
    text-size-adjust: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    min-height: 100dvh;
    color: var(--dark);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    overflow: hidden;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.app-container {
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#comparisonCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: move;
    transform-origin: 0 0;
    /* Mobile touch improvements */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#floatingDownloadBtn {
    display: none;
}

/* Mobile-specific canvas improvements */
@media (max-width: 768px) {
    #comparisonCanvas {
        cursor: default;
        /* Remove cursor on mobile */
    }

    .canvas-container {
        /* Ensure proper touch handling */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

.comparison-slider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: var(--primary);
    cursor: ew-resize;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transform: translateX(-50%);
    /* Mobile touch improvements */
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Ensure slider is always interactive */
    pointer-events: auto;
}

.comparison-slider::before {
    content: "";
    position: absolute;
    width: 46px;
    height: 46px;
    background: var(--primary);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Mobile touch improvements */
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    /* Ensure the touch target is interactive */
    pointer-events: auto;
    /* Add transition for smooth visual feedback */
    transition: all 0.2s ease;
}

.comparison-slider::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 38px;
    height: 38px;
    background-image: url('../assets/divider.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    /* Mobile touch improvements */
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
}

/* Mobile-specific comparison slider improvements */
@media (max-width: 768px) {
    .comparison-slider {
        width: 6px;
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
        pointer-events: auto;
    }

    .comparison-slider::before {
        width: 50px;
        height: 50px;
        /* Larger touch target */
        /* Ensure the touch target is interactive */
        pointer-events: auto;
        touch-action: none;
    }

    .comparison-slider::after {
        width: 32px;
        /* Larger image for mobile */
        height: 32px;
        /* Keep pointer events disabled for the image */
        pointer-events: none;
    }
}

.upload-section {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    z-index: 20;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    max-width: 500px;
    width: 90%;
}

.upload-section.drag-over {
    background: rgba(233, 236, 239, 0.95);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.upload-section h2 {
    margin-bottom: 25px;
    color: var(--dark);
    font-size: 1.8rem;
}

.upload-icon {
    font-size: 5rem;
    color: var(--accent);
    margin-bottom: 25px;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.upload-section:hover .upload-icon {
    transform: translateY(-5px);
    opacity: 1;
}

.file-input {
    display: none;
}

.browse-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 20px 0;
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.browse-btn:hover {
    background: var(--secondary);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

.control-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--card-bg);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: var(--shadow);
    z-index: 30;
    max-width: 350px;
    width: 100%;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.control-panel.hidden {
    transform: translateY(150%);
}

.panel-section {
    flex: 1;
}

.panel-section h3 {
    margin-bottom: 15px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
}

.panel-section h3 i {
    color: var(--primary);
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.3s ease;
    /* iOS Safari improvements */
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x;
    user-select: auto !important;
    -webkit-user-select: auto !important;
    pointer-events: auto !important;
}

input[type="range"]:hover {
    background: #ced4da;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.4);
    transition: all 0.2s ease;
    border: 3px solid white;
    /* iOS Safari improvements */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--secondary);
}

/* Firefox slider thumb */
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.4);
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
    background: var(--secondary);
}

.value-display {
    width: 60px;
    text-align: center;
    background: var(--light);
    padding: 7px;
    border-radius: 6px;
    font-weight: bold;
    color: var(--primary);
    border: 2px solid #e9ecef;
    font-size: 0.95rem;
}

select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    background: white;
    font-size: 1rem;
    color: var(--dark);
    font-weight: 500;
    transition: all 0.3s ease;
}

select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(72, 149, 239, 0.2);
}

.actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.btn {
    padding: 14px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(108, 117, 125, 0.4);
}

.download-btn {
    background: var(--success);
    color: white;
}

.download-btn:hover {
    background: #3ab9d9;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(76, 201, 240, 0.3);
}

.download-btn:disabled {
    background: var(--gray);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.stats {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.stat-item {
    background: var(--light);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
    border-left: 3px solid var(--accent);
    flex: 1;
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--dark);
    margin-bottom: 2px;
}

.stat-value-large {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary);
}

.format-info {
    margin-top: 10px;
    padding: 10px;
    background: #e7f5ff;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #1864ab;
    border-left: 4px solid var(--accent);
}



.hidden {
    display: none;
}

.app-title {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.app-title .app-title-text {
    font-size: 3rem;
    margin-bottom: 5px;
    background: linear-gradient(to right, #fff, #ffdd00);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.app-title p {
    font-size: 1rem;
    opacity: 0.9;
}

.info-box {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 10px 15px;
    color: white;
    font-size: 0.7rem;
    z-index: 100;
}

.format-badge {
    display: inline-block;
    padding: 3px 8px;
    background: var(--accent);
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 8px;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 8px;
    display: flex;
    gap: 8px;
    z-index: 100;
    width: fit-content;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--dark);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.zoom-btn:hover {
    background: white;
    transform: scale(1.1);
}

.encoder-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.encoder-option {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    background: #f8f8f8;
}

.encoder-option:hover {
    background: #e8f4ff;
    border-color: #4a90e2;
}

.encoder-option.selected {
    background: #d1e7ff;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.encoder-option .format-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.encoder-option .format-desc {
    font-size: 0.8em;
    color: #666;
}

.loading-indicator {
    display: none;
    text-align: center;
    padding: 10px;
    color: #1a73e8;
}

.optimization-stats .stat-value-large.red {
    color: #e53935;
}

.optimization-stats .stat-value-large.green {
    color: #43a047;
}

.format-controls {
    display: flex;
    justify-content: space-around;
}

#formatSelect {
    max-width: calc(70% - 10px);
    margin-right: 10px;
}

#applyToAllBtn {
    max-width: 30%;
    padding: 10px 2px;
}

/* Mobile-specific styles */
@media (max-width: 768px) {

    /* Reorganize layout */
    .app-container {
        flex-direction: column;
        /* height: auto; */
        min-height: 100dvh;
        overflow: auto;
        justify-content: space-between;
    }

    .canvas-container {
        position: relative;
        height: 50vh;
        flex-shrink: 0;
    }

    .control-panel {
        position: relative;
        width: 100%;
        max-width: 100%;
        bottom: auto;
        right: auto;
        left: auto;
        top: auto;
        transform: none !important;
        border-radius: 0;
        padding: 15px;
        margin-top: auto;
    }

    .control-panel.hidden {
        display: none;
    }

    /* Adjust title */
    .app-title {
        position: relative;
        text-align: center;
        width: 100%;
        left: 0;
        top: 0;
        padding: 15px;
        background: rgba(0, 0, 0, 0.3);
    }

    .app-title .app-title-text {
        font-size: 2rem;
        justify-content: center;
        margin: 0;
    }

    #tagline {
        margin: 10px 0 5px;
    }

    /* Adjust upload section */
    .upload-section {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        margin: 0 auto;
        max-width: 90%;
    }

    /* Adjust zoom controls */
    .zoom-controls {
        position: absolute;
        /* bottom: 45vh; */
        top: 50vh;
        height: fit-content;
        z-index: 1001;
    }

    /* Adjust stats grid */
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value-large {
        font-size: 1.2rem;
    }

    /* Adjust info box */
    .info-box {
        position: relative;
        width: 100%;
        left: 0;
        bottom: 0;
        border-radius: 0;
        text-align: center;
        padding: 5vh 10px 5vh;
        font-size: 0.6rem;
    }

    /* Adjust buttons */
    .btn {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .browse-btn {
        padding: 12px 20px;
    }

    /* Hide drag notice on mobile */
    #dragNotice {
        display: none !important;
    }
}

@media (max-width: 480px) {

    /* Further adjustments for very small screens */
    .upload-section {
        padding: 25px;
    }

    .upload-section h2 {
        font-size: 1.4rem;
    }

    .upload-icon {
        font-size: 4rem;
    }

    .control-panel {
        padding: 15px 10px;
    }

    .panel-section h3 {
        font-size: 1.1rem;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-item2,
    .stat-item4 {
        border-left: none;
        border-right: 4px solid var(--accent);
    }

    .actions {
        flex-direction: column;
    }

    .format-controls .btn {
        width: 100%;
        padding: 12px 15px;
    }

    .slider-container {
        gap: 10px;
    }

    .value-display {
        width: 50px;
    }

    .quality-group {
        margin-bottom: 0;
    }

    /* Format controls styles */
    .format-controls {
        align-items: center;
        margin-top: 8px;
    }

    .format-controls select {
        flex: 1;
        min-width: 0;
    }

    .format-controls .btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    /* Mobile ZIP estimation adjustments */
    .zip-estimation {
        margin-top: 15px;
        padding: 12px;
    }

    .zip-estimation h4 {
        font-size: 0.9rem;
    }

    .zip-stat-label,
    .zip-stat-value {
        font-size: 0.8rem;
    }
}

/* Image Gallery Styles */
.image-gallery {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--shadow);
    z-index: 30;
    max-width: 400px;
    width: 100%;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-height: 300px;
    height: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid var(--light);
    flex-shrink: 0;
}

.gallery-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 20px;
    min-height: 0;
}

.gallery-header h3 {
    color: var(--dark);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.gallery-header h3 i {
    color: var(--primary);
}

.clear-all-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.clear-all-btn:hover {
    background: #c62828;
    transform: translateY(-2px);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    width: 100%;
}

.gallery-item {
    background: var(--light);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
    will-change: transform;
    transform: translateZ(0);
    opacity: 0.8;
}

.gallery-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    opacity: 1;
}

.gallery-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
    opacity: 1;
}

.gallery-image {
    position: relative;
    width: 100%;
    height: 80px;
    overflow: hidden;
}

.gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.gallery-overlay {
    display: flex;
    gap: 10px;
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay,
.gallery-item:focus-within .gallery-overlay {
    opacity: 1;
}

.download-individual-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    background: var(--success);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.download-individual-btn:hover {
    background: #3ab9d9;
    transform: scale(1.1);
}

.remove-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.remove-btn:hover {
    background: #c62828;
    transform: scale(1.1);
}

.gallery-info {
    padding: 8px;
}

.gallery-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-settings {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.6rem;
}

.quality-indicator {
    color: var(--primary);
    font-weight: 600;
}

.format-indicator {
    color: var(--accent);
    font-weight: 500;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--accent);
    margin-top: 10px;
    font-style: italic;
}

/* Error Modal */
.error-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.error-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.error-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #554fe7, #3f37c9);
    color: white;
}

.error-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.error-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.error-modal-body {
    padding: 10px 24px;
    line-height: 1.6;
    color: #333;
    white-space: pre-line;
    max-height: 60vh;
    overflow-y: auto;
}

.error-modal-body p {
    margin: 0;
    font-size: 1rem;
}

.error-section h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-item {
    padding: 5px 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

.file-item.valid {
    color: #28a745;
}

.file-item.invalid {
    color: #dc3545;
}

.text-success {
    color: #28a745 !important;
}

.text-danger {
    color: #dc3545 !important;
}

.text-warning {
    color: #ffc107 !important;
}

.text-info {
    color: #17a2b8 !important;
}

.text-secondary {
    color: #6c757d !important;
}

.btn-success {
    background: #28a745;
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
    background: #218838;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.btn-danger:hover {
    background: #c82333;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

/* Remove focus outlines from error modal buttons */
.error-modal-footer .btn:focus {
    outline: none;
    box-shadow: none;
}

.error-modal-footer .btn:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Remove focus outlines from all buttons */
.btn:focus {
    outline: none;
    box-shadow: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.error-modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: center;
    background: #f8f9fa;
    gap: 10px;
}

.error-modal-footer .btn {
    min-width: 80px;
}

/* Mobile adjustments for error modal */
@media (max-width: 768px) {
    .error-modal-content {
        width: 95%;
        max-width: none;
    }

    .error-modal-header {
        padding: 16px 20px 12px;
    }

    .error-modal-header h3 {
        font-size: 1.1rem;
    }

    .error-modal-body {
        padding: 20px;
        /* max-height: 250px; */
    }

    .error-modal-footer {
        padding: 12px 20px 16px;
    }
}

/* Mobile adjustments for gallery */
@media (max-width: 768px) {
    .image-gallery {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        max-width: 100%;
        min-height: 250px;
        height: 250px;
        border-radius: 0;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .gallery-image {
        height: 70px;
    }

    .gallery-header h3 {
        font-size: 1.1rem;
    }

    .clear-all-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Mobile-specific remove button visibility */
    .gallery-overlay {
        opacity: 1 !important;
        top: 4px;
        right: 4px;
    }

    .download-individual-btn,
    .remove-btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
        backdrop-filter: blur(4px);
    }

    .download-individual-btn {
        background: rgba(76, 201, 240, 0.9);
    }

    .download-individual-btn:hover,
    .download-individual-btn:focus {
        background: var(--success);
        transform: scale(1.1);
    }

    .remove-btn {
        background: rgba(230, 57, 70, 0.9);
    }

    .remove-btn:hover,
    .remove-btn:focus {
        background: var(--danger);
        transform: scale(1.1);
    }
}

@media (max-width: 480px) {
    .image-gallery {
        min-height: 220px;
        height: 220px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .gallery-image {
        height: 60px;
    }

    .gallery-name {
        font-size: 0.7rem;
    }

    .gallery-settings {
        font-size: 0.5rem;
        margin-top: 2px;
    }

    .download-individual-btn,
    .remove-btn {
        width: 20px;
        height: 20px;
        font-size: 8px;
        backdrop-filter: blur(4px);
    }

    .download-individual-btn {
        background: rgba(76, 201, 240, 0.9);
    }

    .download-individual-btn:hover,
    .download-individual-btn:focus {
        background: var(--success);
        transform: scale(1.1);
    }

    .remove-btn {
        background: rgba(230, 57, 70, 0.9);
    }

    .remove-btn:hover,
    .remove-btn:focus {
        background: var(--danger);
        transform: scale(1.1);
    }

    /* Ensure overlay is always visible on small screens */
    .gallery-overlay {
        opacity: 1 !important;
        top: 2px;
        right: 2px;
    }

    .format-controls .btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* Mobile-specific slider improvements */
@media (max-width: 768px) {
    input[type="range"] {
        height: 8px;
        /* Larger touch target */
        margin: 10px 0;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        /* Larger thumb for mobile */
        height: 24px;
        border: 2px solid white;
    }

    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        border: 2px solid white;
    }

    .slider-container {
        gap: 20px;
        /* More space for touch */
    }

    .value-display {
        width: 70px;
        /* Larger display for mobile */
        padding: 10px;
        font-size: 1rem;
    }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {

    /* Prevent unwanted touch behaviors */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Ensure comparison slider is always visible and interactive */
    .comparison-slider {
        opacity: 1 !important;
        visibility: visible !important;
        z-index: 1000 !important;
    }

    /* Allow text selection in specific areas */
    .gallery-name,
    .stat-label,
    .error-modal-body {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }

    /* Improve touch targets */
    .btn,
    .browse-btn {
        min-height: 36px;
        /* iOS recommended minimum touch target */
        min-width: 36px;
    }

    .zoom-btn {
        height: 30px;
        width: 30px;
        min-height: 30px;
        min-width: 30px;
    }

    /* Improve slider touch experience */
    .slider-container {
        padding: 10px 0;
    }

    /* Better mobile layout */
    .control-panel {
        padding: 20px 15px;
    }

    .panel-section {
        margin-bottom: 20px;
    }

    /* Improve format controls on mobile */
    .format-controls {
        /* flex-direction: column; */
        gap: 10px;
    }

    .format-controls select,
    .format-controls .btn {
        width: 100%;
        max-width: none;
        margin: 0;
    }
}

/* iOS Safari specific improvements */
.ios-safari input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
}

.ios-safari input[type="range"]::-webkit-slider-track {
    appearance: none;
    -webkit-appearance: none;
    background: #dee2e6;
    height: 8px;
    border-radius: 4px;
}

.ios-safari input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.4);
    margin-top: -8px;
}

/* Prevent zoom on input focus in iOS */
.ios-safari input,
.ios-safari select,
.ios-safari textarea {
    font-size: 16px !important;
}

/* Mobile device specific improvements */
.mobile-device .comparison-slider {
    /* Larger touch target for mobile */
    width: 8px;
    /* Ensure proper touch handling */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
}

.mobile-device .comparison-slider::before {
    width: 60px;
    height: 60px;
    /* Ensure the touch target is interactive */
    pointer-events: auto;
    touch-action: none;
}

.mobile-device .comparison-slider::after {
    width: 36px;
    /* Larger image for mobile devices */
    height: 36px;
    /* Keep pointer events disabled for the image */
    pointer-events: none;
}

/* Improve touch feedback */
.mobile-device .btn:active,
.mobile-device .browse-btn:active,
.mobile-device .zoom-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Better mobile scrolling */
.mobile-device .gallery-scroll-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.floating-download-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-btn {
    background: var(--success, #4cc9f0);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.floating-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    opacity: 0.7;
}