/* NEW 4-BAR LAYOUT FOR CROP TOOL */

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a0a0a;
    color: #fff;
    overflow-x: hidden;
    overflow-y: auto;
    /* Prevent bounce/overscroll on iOS */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar - Desktop with mouse only (not touch devices) */
@media (hover: hover) and (pointer: fine) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    ::-webkit-scrollbar-track {
        background: #1a1a1a;
        border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb {
        background: linear-gradient(135deg, #00ffa3 0%, #00d4aa 100%);
        border-radius: 4px;
        transition: background 0.3s ease;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(135deg, #00d4aa 0%, #00b894 100%);
    }

    /* Firefox Scrollbar */
    * {
        scrollbar-width: thin;
        scrollbar-color: #00ffa3 #1a1a1a;
    }
}

/* Main Tool Container - Fits viewport, scrollable content below */
.tool-container {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================
   1. TOP TOOLBAR - Tool-specific styles only
   (Base toolbar styles are in common.css)
   ============================================ */
.session-btn {
    background: transparent;
    border: none;
    color: #ff8800;
}

.session-btn:hover {
    background: rgba(255, 136, 0, 0.2);
}

.cached-images-btn {
    background: transparent;
    border: none;
    color: #ff8800;
}

.cached-images-btn:hover {
    background: rgba(255, 136, 0, 0.15);
    color: #ff9922;
}

/* ============================================
   2. MAIN AREA (Left Sidebar + Canvas + Right Sidebar)
   ============================================ */
.main-area {
    flex: 1;
    display: grid;
    grid-template-columns: 60px 1fr 60px;
    overflow: hidden;
    position: relative;
    /* Background and transition now in common.css */
}

/* LEFT SIDEBAR (Settings Icons) */
.left-sidebar {
    background: linear-gradient(180deg, #1a1a1a 0%, #2d2d2d 100%);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    padding: 1rem 0.5rem;
    gap: 0.5rem;
    z-index: 100;
}

/* Hide mobile sidebar on desktop */
.mobile-sidebar {
    display: none;
}

.settings-btn {
    width: 100%;
    min-height: 50px;
    background: transparent;
    border: none;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    transition: all 0.2s;
    color: #888;
    padding: 0.5rem 0.25rem;
}

.settings-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.settings-btn span {
    font-size: 0.625rem;
    font-weight: 500;
    text-align: center;
    word-wrap: break-word;
    line-height: 1.2;
}

.settings-btn:hover,
.settings-btn.active {
    background: rgba(0, 255, 163, 0.08);
    color: #00ffa3;
}

/* Settings Panels (Slide from left sidebar's right edge) */
/* Note: Positioning and animation now handled in common.css */
.settings-panel {
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    /* Background now in common.css */
}

.settings-panel-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #00ffa3;
}

.close-panel {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 4px;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-panel:hover {
    background: rgba(255, 0, 0, 0.1);
    border-color: #ff0000;
    color: #ff0000;
}

.settings-panel-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Format Selection Section */
.quality-format-section {
    margin-bottom: 1.5rem;
}

.quality-format-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.quality-format-btn {
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.quality-format-btn svg {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: inherit;
}

.quality-format-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    flex: 1;
    text-align: center;
}

.quality-format-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: inherit;
}

.quality-format-desc {
    font-size: 0.65rem;
    font-weight: 400;
    color: #666;
    line-height: 1.2;
}

.quality-format-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #666;
    transform: translateY(-2px);
}

.quality-format-btn.active {
    background: rgba(0, 255, 163, 0.08);
    border-color: #00ffa3;
    color: #00ffa3;
}

.quality-format-btn.active .quality-format-desc {
    color: #00d4aa;
}

.input-hint {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.5rem;
}

/* Aspect Ratio Buttons */
.ratio-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.ratio-btn {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ratio-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #666;
}

.ratio-btn.active {
    background: transparent;
    border-color: #00ffa3;
    color: #00ffa3;
}

/* Shape Buttons */
.shape-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.shape-btn {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.shape-btn svg {
    width: 24px;
    height: 24px;
    color: inherit;
}

.shape-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #666;
}

.shape-btn.active {
    background: transparent;
    border-color: #00ffa3;
    color: #00ffa3;
}

.shape-info {
    margin-bottom: 1rem;
}

/* Transform Buttons */
.transform-group {
    margin-bottom: 0.5rem;
}

.straighten-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.straighten-header label {
    font-size: 0.875rem;
    color: #888;
}

.straighten-reset-btn {
    padding: 0.25rem 0.625rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #444;
    border-radius: 4px;
    color: #888;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    height: 24px;
    line-height: 1;
}

.straighten-reset-btn:hover {
    background: rgba(0, 255, 163, 0.1);
    border-color: #00ffa3;
    color: #00ffa3;
}

.straighten-reset-btn:active {
    transform: scale(0.95);
}

.transform-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.transform-btn {
    flex: 1;
    min-width: calc(50% - 0.25rem);
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.transform-btn svg {
    width: 24px;
    height: 24px;
    color: inherit;
}

.transform-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #666;
    color: #fff;
}

.transform-btn:active {
    transform: scale(0.95);
}

.transform-info {
    margin-bottom: 1rem;
}

/* Input Groups */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.input-group input[type="number"],
.input-group select {
    width: 100%;
    padding: 0.625rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 0.875rem;
}

.input-group select {
    cursor: pointer;
}

.input-group select option {
    background: #000;
    color: #fff;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 255, 163, 0.1);
}

.input-group select option:hover {
    background: #000;
    color: #00ffa3;
}

.input-group select option:checked {
    background: #000;
    color: #00ffa3;
    font-weight: 600;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
    outline: none;
    border-color: #00ffa3;
}

.slider {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #00ffa3;
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #00ffa3;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #00ffa3 0%, #00d4aa 50%, #00b894 100%);
    color: #000;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 255, 163, 0.2);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 255, 163, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid #00ffa3;
    color: #00ffa3;
}

.btn-outline:hover {
    background: rgba(0, 255, 163, 0.15);
}

.btn-secondary {
    background: linear-gradient(135deg, #444 0%, #555 100%);
    color: #fff;
    border: 1px solid #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #555 0%, #666 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 255, 163, 0.1);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

/* CENTER CANVAS AREA */
/* Note: grid-column positioning now handled in common.css */
/* Canvas background and layout now defined in common.css with radial dot pattern */

/* View All Images Button */
.canvas-view-all-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 255, 163, 0.3);
    border-radius: 8px;
    color: #00ffa3;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    font-family: 'Inter', sans-serif;
}

.canvas-view-all-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.canvas-view-all-btn:hover {
    background: rgba(0, 255, 163, 0.15);
    border-color: #00ffa3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 163, 0.3);
}

.canvas-view-all-btn:active {
    transform: translateY(0);
}

@keyframes fadeInButton {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile adjustments for View All button */
@media (max-width: 768px) {
    .canvas-view-all-btn {
        top: 0.5rem;
        left: 0.5rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }
    
    .canvas-view-all-btn svg {
        width: 14px;
        height: 14px;
    }
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
}

/* Dedicated Grid Area - Separate from canvas for multi-image view */
.grid-area {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    position: absolute;
    top: 0;
    left: 0;
}

.grid-area.active {
    display: block;
}

.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    color: #666;
}

.canvas-placeholder svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: #444;
}

.canvas-placeholder .upload-text {
    font-size: 0.875rem;
    color: #888;
    margin-bottom: 0.25rem;
}

.canvas-placeholder h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #888;
    margin-bottom: 0.5rem;
    min-height: 30px;
}

.canvas-placeholder p {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.canvas-placeholder .supported-formats {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 1.5rem;
}

.canvas-placeholder .btn {
    margin-top: 0.5rem;
    width: auto;
    min-width: 300px;
    min-height: 50px;
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

#canvas {
    max-width: 100%;
    max-height: 100%;
    display: none;
}

#canvas.visible {
    display: block;
}

#canvasConverted {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    display: none;
    z-index: 2;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 200;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #333;
    border-top: 4px solid #00ffa3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loadingText {
    color: #00ffa3;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-selection {
    position: absolute;
    border: 2px solid #00ffa3;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: all;
    z-index: 2;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #00ffa3;
    border: 2px solid #000;
    border-radius: 50%;
    z-index: 3;
}

.crop-handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.crop-handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.crop-handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }
.crop-handle.t { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.b { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.l { left: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle.r { right: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* Shape overlay for crop selection */
.shape-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.crop-selection.shape-circle {
    border-radius: 50%;
}

.crop-selection.shape-rounded {
    border-radius: 20%;
}

/* Hide border and box-shadow for complex shapes (heart, star, triangle, pentagon, hexagon) */
.crop-selection.shape-complex {
    border: none;
    /* Remove box-shadow - will use SVG mask instead */
    box-shadow: none;
}

/* SVG mask overlay for complex shapes */
.shape-mask-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.shape-mask-overlay svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}


/* ============================================
   MODALS & OVERLAYS
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(var(--vh, 1vh) * 100);
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 1px solid #333;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    overflow: hidden;
}

.modal-content.modal-preview {
    max-width: 90vw;
    max-height: 90vh;
}

.modal-preview-body {
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.preview-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #000;
    border-radius: 8px;
    padding: 1rem;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    color: #fff;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 0, 0, 0.1);
    border-color: #ff0000;
    color: #ff0000;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Drag and drop for canvas area */
.canvas-area.dragover {
    background: rgba(0, 255, 163, 0.05);
    border: 2px dashed #00ffa3;
}


/* ============================================
   MOBILE RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    /* Shape buttons - 4 per row on mobile */
    .shape-buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.35rem;
    }
    
    .shape-btn {
        padding: 0.4rem 0.25rem;
        gap: 0.25rem;
        font-size: 0.65rem;
    }
    
    .shape-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .shape-btn span {
        font-size: 0.6rem;
        line-height: 1;
    }
    
    /* Mobile layout - prevent URL bar bounce */
    .tool-container {
        display: flex;
        flex-direction: column;
        /* Use dvh (dynamic viewport height) for better mobile browser support */
        height: 100dvh;
        height: calc(var(--vh, 1vh) * 100);
        /* Initially prevent scroll - only allow when SEO content opens */
        overflow: hidden;
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
    }
    
    /* Allow scroll only when SEO content is visible */
    .tool-container.allow-scroll {
        overflow-y: auto;
        position: relative;
    }
    
    /* Top toolbar stays at top */
    .top-toolbar {
        order: 1;
        flex-shrink: 0;
    }
    
    /* Main area in middle */
    .main-area {
        order: 3;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        min-height: 300px;
    }
    
    /* When panel opens, it overlays from bottom */
    .main-area.panel-open {
        /* Panel overlays, no padding needed */
    }
    
    /* Canvas takes available space */
    .canvas-area {
        flex: 1;
        min-height: 0; /* Allow flex to shrink */
        grid-column: auto;
        display: flex;
        flex-direction: column;
    }
    
    .main-area.panel-open .canvas-area {
        grid-column: auto;
        /* When panel is open (130px height), reduce canvas area */
        flex: 1;
        min-height: 0;
        max-height: calc(100% - 130px);
    }
    
    .canvas-wrapper {
        flex: 1;
        min-height: 0;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile Button Size Fix */
    .canvas-placeholder .btn {
        width: auto;
        min-width: 200px;
        min-height: 48px;
        padding: 0.75rem 1.75rem;
        font-size: 0.9375rem;
    }
    
    .canvas-placeholder h3 {
        font-size: 1rem;
    }
    
    .canvas-placeholder svg {
        width: 48px;
        height: 48px;
    }
    
    /* Hide desktop sidebar on mobile */
    .desktop-sidebar {
        display: none !important;
    }
    
    /* Show mobile sidebar on mobile - Settings bar at bottom */
    .mobile-sidebar {
        display: flex;
        order: 4;
        position: relative;
        width: 100%;
        height: 60px;
        flex-direction: row;
        justify-content: center;
        border-right: none;
        border-top: 1px solid #333;
        padding: 0.5rem;
        gap: 0.75rem;
        flex-shrink: 0;
        z-index: 200;
    }
    
    .settings-btn {
        width: 38px;
        height: 38px;
        gap: 1px;
    }
    
    .settings-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .settings-btn span {
        font-size: 0.55rem;
    }
    
    /* Mobile active state - only icon and text green */
    .mobile-sidebar .settings-btn.active {
        color: #00ffa3 !important;
    }
    
    .mobile-sidebar .settings-btn:hover {
        color: #00ffa3 !important;
    }
    
    /* Settings panels adjust for mobile - slide from bottom */
    .settings-panel {
        top: auto;
        left: 0 !important;
        right: 0;
        bottom: -130px;
        width: 100%;
        height: 130px;
        border-right: none;
        border-top: 1px solid #333;
        border-radius: 12px 12px 0 0;
        overflow-y: auto;
    }
    
    .settings-panel.active {
        bottom: 0px;
        left: 0 !important;
    }
    
    /* Hide entire panel header on mobile for compact design */
    .settings-panel-header {
        display: none;
    }
    
    /* Compact mobile controls - optimized for 130px panel */
    .settings-panel-content {
        padding: 0.4rem 0.5rem;
    }
    
    /* Horizontal scrollable aspect ratio buttons */
    .ratio-buttons {
        display: flex;
        flex-direction: row;
        gap: 0.3rem;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.3rem;
    }
    
    .ratio-buttons::-webkit-scrollbar {
        display: none;
    }
    
    .ratio-btn {
        flex: 0 0 auto;
        min-width: 65px;
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
        scroll-snap-align: start;
    }
    
    /* Scroll dots indicator */
    .scroll-dots {
        display: flex;
        justify-content: center;
        gap: 0.3rem;
        margin-top: 0.4rem;
        padding: 0.15rem 0;
    }
    
    .scroll-dot {
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: #444;
        transition: all 0.3s;
    }
    
    .scroll-dot.active {
        background: #00ffa3;
        transform: scale(1.2);
    }
    
    /* Horizontal scrollable shape buttons */
    .shape-buttons {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding-bottom: 0.5rem !important;
        grid-template-columns: none !important;
    }
    
    .shape-buttons::-webkit-scrollbar {
        display: none !important;
    }
    
    .shape-btn {
        flex: 0 0 auto !important;
        min-width: 80px !important;
        scroll-snap-align: start !important;
    }
    
    /* Format Panel - Compact for 130px */
    #formatPanel .settings-panel-content {
        padding: 0.4rem 0.5rem;
    }
    
    /* Responsive format buttons on mobile - fit within panel */
    .quality-format-buttons {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.25rem !important;
        overflow-x: visible !important;
        overflow-y: hidden !important;
        flex-wrap: nowrap !important;
        scrollbar-width: none !important;
        padding: 0 0.25rem !important;
        grid-template-columns: none !important;
    }
    
    .quality-format-buttons::-webkit-scrollbar {
        display: none !important;
    }
    
    .quality-format-btn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 0.3rem 0.2rem !important;
        flex-direction: column !important;
        gap: 0.1rem !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .quality-format-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
    
    .quality-format-text {
        align-items: center !important;
        text-align: center !important;
        gap: 0 !important;
    }
    
    .quality-format-name {
        font-size: 0.55rem !important;
        line-height: 1 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide descriptions on mobile */
    .quality-format-desc {
        display: none !important;
    }
    
    .quality-format-section {
        margin-bottom: 0.25rem !important;
    }
    
    .input-group {
        margin-bottom: 0.25rem !important;
    }
    
    .input-group label {
        font-size: 0.6rem !important;
        margin-bottom: 0.15rem !important;
        line-height: 1.2 !important;
    }
    
    /* Mobile Quality Slider - Compact */
    .slider {
        height: 4px !important;
        margin: 0 !important;
    }
    
    .slider::-webkit-slider-thumb {
        width: 12px !important;
        height: 12px !important;
    }
    
    .slider::-moz-range-thumb {
        width: 12px !important;
        height: 12px !important;
    }
    
    /* Advanced Panel - Compact for 130px */
    #advancedPanel .settings-panel-content {
        padding: 0.4rem 0.5rem;
    }
    
    #advancedPanel .input-group {
        margin-bottom: 0.2rem;
    }
    
    #advancedPanel .input-group input[type="number"],
    #advancedPanel .input-group select {
        padding: 0.3rem 0.35rem;
        font-size: 0.7rem;
        height: 28px;
    }
    
    #advancedPanel .checkbox-label {
        font-size: 0.65rem;
        gap: 0.4rem;
    }
    
    #advancedPanel .checkbox-label input[type="checkbox"] {
        width: 14px;
        height: 14px;
    }
    
    #advancedPanel .input-hint {
        font-size: 0.55rem;
        margin-top: 0.1rem;
    }
    
    /* Compact Output Panel - Format + Quality on same line */
    #outputPanel .settings-panel-content {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    #outputPanel .format-quality-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    #outputPanel .format-buttons {
        display: flex;
        gap: 0.35rem;
        flex-wrap: nowrap;
    }
    
    #outputPanel .format-btn {
        flex: 0 0 auto;
        padding: 0.4rem 0.6rem;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid #444;
        border-radius: 6px;
        color: #888;
        font-size: 0.7rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        white-space: nowrap;
    }
    
    #outputPanel .format-btn:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: #666;
    }
    
    #outputPanel .format-btn.active {
        background: rgba(0, 255, 163, 0.15);
        border-color: #00ffa3;
        color: #00ffa3;
    }
    
    #outputPanel .quality-slider-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    #outputPanel .quality-slider-container label {
        font-size: 0.65rem;
        margin: 0;
    }
    
    /* Dimension inputs side by side on mobile */
    #dimensionsPanel .settings-panel-content {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    #dimensionsPanel .input-group:nth-child(1),
    #dimensionsPanel .input-group:nth-child(2) {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        margin-bottom: 0.5rem;
    }
    
    #dimensionsPanel .btn {
        width: 100%;
    }
    
    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .setting-group label {
        font-size: 0.65rem;
    }
    
    .setting-control input,
    .setting-control select {
        font-size: 0.75rem;
        padding: 0.35rem 0.4rem;
    }
    
    
    /* Larger crop handles for mobile touch */
    .crop-handle {
        width: 20px;
        height: 20px;
    }
    
    .crop-handle.tl { top: -10px; left: -10px; }
    .crop-handle.tr { top: -10px; right: -10px; }
    .crop-handle.bl { bottom: -10px; left: -10px; }
    .crop-handle.br { bottom: -10px; right: -10px; }
    .crop-handle.t { top: -10px; }
    .crop-handle.b { bottom: -10px; }
    .crop-handle.l { left: -10px; }
    .crop-handle.r { right: -10px; }
}

/* ============================================
   MULTIPLE IMAGES GRID LAYOUT
   ============================================ */

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    width: 100%;
    align-content: start;
    box-sizing: border-box;
}

.image-card {
    position: relative;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 1px solid #333;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 255, 163, 0.15);
    border-color: #00ffa3;
}

.image-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.image-card-delete {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    background: rgba(255, 0, 0, 0.8);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: all 0.2s;
}

.image-card:hover .image-card-delete {
    opacity: 1;
}

.image-card-delete:hover {
    background: rgba(255, 0, 0, 1);
    transform: scale(1.1);
}

.image-card-delete svg {
    width: 16px;
    height: 16px;
}

.image-card-status {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    width: 32px;
    height: 32px;
    background: rgba(0, 255, 163, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.image-card-status svg {
    width: 18px;
    height: 18px;
    color: #000;
}

.image-card-info {
    padding: 1rem;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

.image-card-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-card-meta {
    font-size: 0.75rem;
    color: #888;
}

.conversion-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.format-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.format-from {
    background: rgba(255, 255, 255, 0.1);
    color: #888;
}

.format-to {
    background: rgba(0, 255, 163, 0.2);
    color: #00ffa3;
}

.arrow-icon {
    width: 16px;
    height: 16px;
    color: #666;
}

/* Mobile Grid Adjustments */
@media (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }
    
    .image-card-delete {
        opacity: 1;
        width: 28px;
        height: 28px;
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .image-card-delete svg {
        width: 14px;
        height: 14px;
    }
    
    .image-card-name {
        font-size: 0.75rem;
    }
    
    .image-card-meta {
        font-size: 0.65rem;
    }
}
