/* 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.05);
    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;
}

/* 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;
}

/* 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;
}

.dimensions-container {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dimensions-container .input-group {
    flex: 1;
    margin-bottom: 0;
}

.dimension-lock-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-bottom: 0;
}

.dimension-lock-btn svg {
    width: 20px;
    height: 20px;
}

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

.dimension-lock-btn.locked {
    background: rgba(0, 255, 163, 0.15);
    border-color: #00ffa3;
    color: #00ffa3;
}

.dimension-lock-btn.locked:hover {
    background: rgba(0, 255, 163, 0.25);
}

.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;
}

/* Wrapper to keep category buttons and smart resize in one line */
.preset-controls-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: nowrap;
}

/* Preset Category Toggle Buttons */
.preset-category-toggle {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0;
}

.category-toggle-btn {
    background: transparent;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #666;
}

.category-toggle-btn svg {
    width: 24px;
    height: 24px;
    transition: all 0.2s;
}

.category-toggle-btn span {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

.category-toggle-btn:hover {
    color: #00ffa3;
    opacity: 0.8;
}

.category-toggle-btn.active {
    color: #00ffa3;
}

/* Smart Resize Toggle - styled same as category buttons */
.smart-resize-toggle {
    justify-content: center;
    margin-bottom: 0;
    padding: 0;
    border: none;
    margin-left: 0;
}

.smart-resize-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #666;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s;
    padding: 0.4rem;
    background: transparent;
}

.smart-resize-label:hover {
    color: #00ffa3;
    opacity: 0.8;
}

.smart-resize-label input[type="checkbox"] {
    display: none;
}

#smartResizeUnlockIcon {
    display: block;
    color: #666;
}

#smartResizeLockIcon {
    display: none;
}

.smart-resize-label input[type="checkbox"]:checked ~ #smartResizeUnlockIcon {
    display: none;
}

.smart-resize-label input[type="checkbox"]:checked ~ #smartResizeLockIcon {
    display: block;
    color: #00ffa3;
}

.smart-resize-label input[type="checkbox"]:checked ~ span {
    color: #00ffa3;
}

.smart-resize-label svg {
    width: 24px;
    height: 24px;
    display: block;
    margin: 0 auto;
    transition: all 0.2s;
}

.smart-resize-label span {
    text-align: center;
    white-space: nowrap;
}

.smart-resize-label .info-icon {
    display: none;
}

/* Preset Categories */
.preset-category {
    margin-bottom: 0;
}

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

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.875rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.preset-btn:hover {
    background: rgba(0, 255, 163, 0.05);
    border-color: #00ffa3;
    transform: translateY(-2px);
}

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

.preset-btn.active .preset-label {
    color: #00ffa3;
}

.preset-btn.active .preset-size {
    color: #00ffa3;
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.preset-size {
    font-size: 0.75rem;
    color: #888;
}

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

.transform-group-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #888;
    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;
}

/* Desktop: slider and reset button on separate lines */
.slider-reset-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-reset-container .btn-secondary {
    width: 100%;
}

.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 */

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

.canvas-placeholder {
    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: block;
}

/* Smart Crop Position Sliders */
.smart-crop-slider {
    position: absolute;
    z-index: 50;
    padding: 0.5rem;
}

.smart-crop-slider-horizontal {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

.smart-crop-slider-horizontal input[type="range"] {
    width: 250px;
    padding: 0;
}

.smart-crop-slider-vertical {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    height: 200px;
}

.smart-crop-slider-vertical input[type="range"] {
    width: 200px;
    height: 8px;
    padding: 0;
    transform: rotate(-90deg);
    transform-origin: center;
}

.smart-crop-slider input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

.smart-crop-slider input[type="range"]::-webkit-slider-track {
    background: #333;
    height: 6px;
    border-radius: 3px;
}

.smart-crop-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(135deg, #00ffa3 0%, #00d4aa 100%);
    height: 20px;
    width: 20px;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 255, 163, 0.4);
    transition: all 0.2s;
}

.smart-crop-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 255, 163, 0.6);
}

.smart-crop-slider input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.smart-crop-slider input[type="range"]::-moz-range-track {
    background: #333;
    height: 6px;
    border-radius: 3px;
}

.smart-crop-slider input[type="range"]::-moz-range-thumb {
    background: linear-gradient(135deg, #00ffa3 0%, #00d4aa 100%);
    height: 20px;
    width: 20px;
    border-radius: 50%;
    border: none;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 255, 163, 0.4);
}

.smart-crop-slider .slider-label {
    display: none;
}

/* 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;
}

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

.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; }


/* ============================================
   MODALS & OVERLAYS
   ============================================ */
.loading-overlay {
    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;
}

.loading-content {
    text-align: center;
}

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

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

.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) {
    /* 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 */
    .settings-panel-content {
        padding: 0.5rem 0.6rem;
    }
    
    .input-group {
        margin-bottom: 0.4rem;
    }
    
    .input-group label {
        font-size: 0.65rem;
        margin-bottom: 0.2rem;
    }
    
    .input-group input[type="number"],
    .input-group select {
        padding: 0.35rem 0.4rem;
        font-size: 0.75rem;
        height: 28px;
    }
    
    #percentagePanel .settings-panel-content {
        padding: 0.4rem 0.5rem;
    }
    
    .ratio-buttons {
        gap: 0.3rem;
    }
    
    .ratio-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .setting-group label {
        font-size: 0.75rem;
    }
    
    .setting-control input,
    .setting-control select {
        font-size: 0.875rem;
        padding: 0.5rem;
    }
    
    /* 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 {
        padding: 0.4rem 0.5rem;
    }
    
    #dimensionsPanel .dimensions-container {
        display: flex;
        gap: 0.25rem;
        margin-bottom: 0;
    }
    
    #dimensionsPanel .dimensions-container .input-group {
        flex: 1;
        margin-bottom: 0;
    }
    
    #dimensionsPanel .dimensions-container .input-group label {
        font-size: 0.6rem;
        margin-bottom: 0.15rem;
    }
    
    #dimensionsPanel .dimensions-container .input-group input {
        padding: 0.3rem 0.35rem;
        font-size: 0.7rem;
        height: 28px;
    }
    
    #dimensionsPanel .dimension-lock-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }
    
    #dimensionsPanel .dimension-lock-btn svg {
        width: 14px;
        height: 14px;
    }
    
    /* Preset section - keep all 4 items in one line on mobile */
    #presetsPanel .settings-panel-content {
        padding: 0.4rem 0.5rem;
    }
    
    .preset-controls-wrapper {
        gap: 0.3rem;
        margin-bottom: 0.4rem;
    }
    
    .preset-category-toggle {
        gap: 0.3rem;
        margin-bottom: 0;
    }
    
    .smart-resize-toggle {
        margin-bottom: 0;
    }
    
    .category-toggle-btn,
    .smart-resize-label {
        padding: 0.2rem;
    }
    
    .category-toggle-btn svg,
    .smart-resize-label svg {
        width: 16px;
        height: 16px;
    }
    
    .category-toggle-btn span,
    .smart-resize-label span {
        font-size: 0.55rem;
    }
    
    /* Horizontal scrollable preset buttons */
    .preset-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;
    }
    
    .preset-buttons::-webkit-scrollbar {
        display: none;
    }
    
    .preset-btn {
        flex: 0 0 auto;
        min-width: 100px;
        padding: 0.35rem 0.4rem;
        scroll-snap-align: start;
    }
    
    .preset-label {
        font-size: 0.65rem;
    }
    
    .preset-size {
        font-size: 0.55rem;
    }
    
    /* 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);
    }
    
    /* Hide transform group labels on mobile */
    .transform-group-label {
        display: none;
    }
    
    /* Transform Panel Mobile Optimization */
    
    /* Display both transform groups side by side to get all 4 buttons in one line */
    .transform-groups-wrapper {
        display: flex;
        flex-direction: row;
        gap: 0.3rem;
        margin-bottom: 0.3rem;
    }
    
    .transform-groups-wrapper .transform-group {
        flex: 1;
        margin-bottom: 0 !important;
    }
    
    .transform-groups-wrapper .transform-buttons {
        display: flex;
        flex-wrap: nowrap !important;
        gap: 0.3rem;
    }
    
    .transform-groups-wrapper .transform-btn {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        padding: 0.35rem 0.2rem !important;
        flex-direction: column !important;
        gap: 0.15rem !important;
    }
    
    .transform-groups-wrapper .transform-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .transform-groups-wrapper .transform-btn span {
        font-size: 0.55rem;
    }
    
    /* Transform panel - compact for 130px panel height */
    #transformPanel .settings-panel-content {
        padding: 0.4rem 0.5rem;
    }
    
    #transformPanel .straighten-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.2rem;
    }
    
    #transformPanel .straighten-header label {
        font-size: 0.6rem;
        margin: 0;
    }
    
    #transformPanel .straighten-reset-btn {
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
        height: auto;
    }
    
    /* Slider + Reset Transform button on same line */
    #transformPanel .slider-reset-container {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.3rem !important;
        align-items: center !important;
        margin-bottom: 0 !important;
    }
    
    #transformPanel .slider-reset-container .slider {
        flex: 1 !important;
        margin: 0 !important;
        height: 4px !important;
    }
    
    #transformPanel .slider-reset-container .btn-secondary {
        flex-shrink: 0 !important;
        padding: 0.3rem 0.4rem !important;
        font-size: 0.55rem !important;
        white-space: nowrap !important;
        width: auto !important;
    }
    
}
