/* =========================================
   1. GLOBAL & STUDIO SETUP
   ========================================= */
:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --secondary: #E11D48;
    --dark-bg: #0F172A;
    --card-bg: #0F172A;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --studio-bg: #0a0a0a;
    --panel-bg: rgba(20, 20, 20, 0.95);
    --canvas-bg: #121212;
    --border-color: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --success-color: #22c55e;
}

/* Studio Layout */
.studio-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr 320px;
    grid-template-rows: calc(100vh - 110px);
    gap: 16px;
    padding: 0 20px 20px 20px;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 100px;
}

/* Panels */
.studio-panel {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    min-height: 60px;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.badge-pro {
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.panel-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
}

/* Center Canvas */
.studio-canvas {
    background-color: var(--canvas-bg);
    /* Checkerboard pattern */
    background-image:
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 20px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

/* Upload Area */
.upload-area-large {
    text-align: center;
    padding: 60px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area-large:hover {
    border-color: var(--primary);
    background: rgba(249, 115, 22, 0.05);
}

.upload-icon-large {
    font-size: 5rem;
    color: rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
}

.upload-area-large:hover .upload-icon-large {
    color: var(--primary);
}

/* =========================================
   COMPARE SLIDER (BEFORE / AFTER)
   ========================================= */
.preview-stage {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

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

.compare-container {
    position: relative;
    line-height: 0;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
}

.preview-image {
    max-height: calc(100vh - 250px);
    max-width: 100%;
    display: block;
    object-fit: contain;
}

/* Original Image (Top Layer - Clipped) */
.img-wrapper-original {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 50%;
    overflow: hidden;
    border-right: 2px solid var(--primary);
    background-color: transparent;
    z-index: 10;
}

.img-original {
    height: 100%;
    width: auto;
    max-width: none;
}

/* Slider Handle */
.slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 40px;
    transform: translateX(-50%);
    cursor: col-resize;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary);
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.8);
}

.handle-button {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.5);
    border: 3px solid white;
    font-size: 1.2rem;
}

/* Wipe Animation Class */
.wipe-effect {
    transition: all 1.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* =========================================
   MANUAL EDITOR STYLES
   ========================================= */
.editor-stage {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

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

#editorCanvas {
    display: block;
    position: absolute;
    z-index: 10;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Ghost Overlay (Original Image for Restore) */
.ghost-overlay {
    position: absolute;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.canvas-wrapper.restore-active .ghost-overlay {
    opacity: 0.5;
}

/* Custom Brush Cursor */
.brush-cursor {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    display: none;
}

/* =========================================
   CONTROL PANEL SECTIONS
   ========================================= */
.control-section {
    margin-bottom: 20px;
}

.section-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.tool-desc-text {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* Slider Groups */
.slider-group-compact {
    margin-bottom: 16px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 8px;
}

.slider-label .val {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.range-slider {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.5);
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.5);
}

/* Floating Toolbar */
.editor-toolbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    border: 1px solid var(--border-color);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
}

.tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.tool-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.tool-btn.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
}

.tool-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mini Sliders in Toolbar */
.slider-control {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.slider-control label {
    font-size: 0.65rem;
    color: #aaa;
    text-transform: uppercase;
    margin-left: 2px;
}

.slider-control input[type="range"] {
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* =========================================
   UTILITY & BUTTONS
   ========================================= */
.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #EA580C);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

/* Download Button (Gradient) */
#downloadBtn {
    background: linear-gradient(135deg, #F97316 0%, #db2777 100%) !important;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    color: white;
    transition: all 0.3s;
}

#downloadBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.6);
}

/* File Info & Empty States */
.file-meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.file-meta-row .label {
    color: var(--text-muted);
}

.file-meta-row .value {
    color: white;
    font-weight: 600;
}

.info-card-small {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
}

.info-card-small p {
    font-size: 0.8rem;
    color: #ccc;
    margin: 0;
    line-height: 1.4;
}

.info-box-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    opacity: 0.6;
}

.info-box-empty i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

.panel-divider {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

.cost-indicator {
    font-size: 0.85rem;
    color: #ffd700;
    text-align: center;
    margin-bottom: 12px;
}

/* Success Box */
.success-message-box {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* File Info Section */
.file-info-section {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.file-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.85rem;
}

.file-info-label {
    color: var(--text-muted);
    font-weight: 500;
}

.file-info-value {
    color: var(--text-main);
    font-weight: 600;
}

.info-card-small {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.info-card-small p {
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0;
    color: var(--text-muted);
}

.info-card-small strong {
    color: var(--text-main);
}

/* Loading */
.progress-container-floating {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    padding: 20px 40px;
    border-radius: 12px;
    text-align: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.progress-bar {
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 100%;
    border-radius: 3px;
    animation: pulse-bar 1.5s infinite;
}

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

@keyframes pulse-bar {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Scan Overlay */
.ai-scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent 0%, rgba(249, 115, 22, 0.2) 45%, rgba(249, 115, 22, 0.6) 50%, rgba(249, 115, 22, 0.2) 55%, transparent 100%);
    background-size: 200% 100%;
    z-index: 20;
    display: none;
    pointer-events: none;
}

.scanning-active .ai-scan-overlay {
    display: block;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

/* Responsive */


/* =========================================
   RESPONSIVE MEDIA QUERIES - BACKGROUND REMOVER TOOL
   ========================================= */

/* Extra Small Devices (320px - 480px) */
@media (max-width: 480px) {
    :root {
        --panel-width: 100%;
        --header-height: 60px;
    }

    .studio-wrapper {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 0 12px 12px 12px;
        margin-top: 70px;
        height: auto;
        overflow: visible;
    }

    /* Canvas First */
    .studio-canvas {
        order: 1;
        height: 420px;
        min-height: 420px;
        border-radius: 12px;
    }

    .canvas-container {
        padding: 15px;
    }

    .upload-area-large {
        padding: 30px 20px;
        border-radius: 12px;
    }

    .upload-icon-large {
        font-size: 3rem;
        margin-bottom: 16px;
    }

    .upload-area-large h2 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }

    .upload-area-large p {
        font-size: 0.85rem;
    }

    /* Preview Images */
    .preview-image {
        max-height: 360px !important;
    }

    #previewSimple {
        max-height: 360px !important;
    }

    /* Compare Container */
    .compare-container {
        border-radius: 6px;
    }

    /* Comparison Slider */
    .slider-handle {
        width: 36px;
        transform: translateX(-50%);
    }

    .handle-button {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        border-width: 2px;
    }

    .handle-line {
        width: 2px;
    }

    /* Editor Canvas */
    #editorCanvas {
        max-width: 100%;
        max-height: 360px;
    }

    /* Brush Cursor */
    .brush-cursor {
        border-width: 1.5px;
    }

    /* Ghost Overlay */
    .ghost-overlay {
        max-width: 100%;
        max-height: 360px;
    }

    /* Editor Toolbar (Floating) */
    .editor-toolbar {
        bottom: 15px;
        padding: 10px 18px;
        gap: 12px;
        border-radius: 40px;
        flex-wrap: wrap;
        max-width: 95%;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .toolbar-section {
        gap: 8px;
    }

    .toolbar-divider {
        height: 20px;
    }

    .slider-control {
        gap: 1px;
    }

    .slider-control label {
        font-size: 0.6rem;
    }

    .slider-control input[type="range"] {
        width: 70px;
        height: 3px;
    }

    .slider-control input[type="range"]::-webkit-slider-thumb {
        width: 11px;
        height: 11px;
    }

    /* Left Panel Second */
    .studio-panel:first-of-type {
        order: 2;
        height: auto;
        min-height: auto;
    }

    /* Right Panel Third */
    .studio-panel:last-of-type {
        order: 3;
        height: auto;
        min-height: auto;
    }

    /* Panel Headers */
    .panel-header {
        padding: 12px 16px;
        min-height: 50px;
    }

    .panel-header h3 {
        font-size: 0.9rem;
        gap: 6px;
    }

    .badge-pro {
        font-size: 0.65rem;
        padding: 2px 5px;
    }

    .panel-content {
        padding: 16px;
    }

    .panel-footer {
        padding: 16px;
    }

    /* File Info Section */
    .file-info-section {
        padding: 12px;
        border-radius: 8px;
    }

    .file-info-row {
        margin-bottom: 9px;
        font-size: 0.85rem;
        flex-wrap: wrap;
        gap: 4px;
    }

    .file-info-label {
        font-size: 0.8rem;
    }

    .file-info-value {
        font-size: 0.85rem;
    }

    /* Web-Ready Score */
    .web-ready-score-row {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 8px;
        margin-top: 12px;
    }

    .score-display {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .score-ring {
        width: 50px;
        height: 50px;
    }

    .score-value {
        font-size: 1.1rem;
    }

    .score-tips {
        font-size: 0.75rem;
        width: 100%;
    }

    /* Info Cards */
    .info-card-small {
        padding: 12px;
        border-radius: 8px;
        margin-top: 12px;
    }

    .info-card-small i {
        font-size: 1rem !important;
        margin-bottom: 6px !important;
    }

    .info-card-small p {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .info-card-small strong {
        font-size: 0.85rem;
    }

    /* Success Message */
    .success-message-box {
        padding: 9px;
        font-size: 0.85rem;
        border-radius: 6px;
    }

    /* Tool Grid */
    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .tool-grid .tool-btn {
        aspect-ratio: 1;
        font-size: 1rem;
    }

    .tool-desc-text {
        font-size: 0.75rem;
        margin-top: 6px;
    }

    /* Slider Groups */
    .slider-group-compact {
        margin-bottom: 14px;
    }

    .slider-label {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }

    .slider-label .val {
        font-size: 0.8rem;
    }

    .range-slider {
        height: 5px;
    }

    .range-slider::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
    }

    .range-slider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }

    /* Section Labels */
    .section-label {
        font-size: 0.7rem;
        margin-bottom: 10px;
    }

    .control-section {
        margin-bottom: 16px;
    }

    /* Buttons */
    .btn-full,
    .btn-primary,
    .btn-outline,
    .btn-danger {
        padding: 11px 14px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 7px 14px;
        font-size: 0.8rem;
    }

    .btn-text {
        font-size: 0.85rem !important;
        padding: 8px !important;
    }

    #downloadBtn {
        font-size: 0.95rem;
        gap: 8px;
    }

    .flex.gap-2 {
        gap: 6px;
    }

    /* Progress Container */
    .progress-container-floating {
        padding: 16px 30px;
        min-width: 180px;
    }

    .loader-spinner {
        width: 35px;
        height: 35px;
        margin-bottom: 12px;
    }

    .progress-text {
        font-size: 0.85rem;
    }

    .progress-bar {
        height: 5px;
    }

    /* Info Boxes */
    .info-box-empty {
        padding: 40px 20px;
        font-size: 0.9rem;
    }

    .info-box-empty i {
        font-size: 2rem !important;
        margin-bottom: 12px !important;
    }

    /* Cost Indicator */
    .cost-indicator {
        font-size: 0.8rem;
        margin-bottom: 10px;
    }

    .panel-divider {
        margin: 16px 0;
    }

    /* Action Stack */
    .action-stack {
        gap: 10px;
    }

    .action-stack .mt-2 {
        margin-top: 6px !important;
    }

    /* Modal */
    .custom-modal-content {
        padding: 25px 20px;
        max-width: 90%;
        border-radius: 10px;
    }

    .modal-icon-wrapper {
        width: 50px;
        height: 50px;
        margin-bottom: 16px;
    }

    .modal-icon-wrapper i {
        font-size: 1.5rem;
    }

    .custom-modal-content h3 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }

    .custom-modal-content p {
        font-size: 0.85rem;
        margin-bottom: 20px;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .modal-actions .btn {
        width: 100%;
        padding: 10px;
    }

    /* Related Tools */
    .related-tools {
        margin-top: 1.5rem;
        padding: 1rem;
        border-radius: 6px;
    }

    .related-tools h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .related-tools-list {
        gap: 0.5rem;
    }

    .related-tool-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        gap: 0.4rem;
        border-radius: 15px;
    }

    .related-tool-link i {
        font-size: 0.8rem;
    }

    /* Scan Overlay */
    .ai-scan-overlay {
        background-size: 150% 100%;
    }
}

/* Tiny Devices (320px - 374px) */
@media (max-width: 374px) {
    .studio-wrapper {
        padding: 0 8px 8px 8px;
        gap: 10px;
        margin-top: 60px;
    }

    .studio-canvas {
        height: 370px;
        min-height: 370px;
    }

    .canvas-container {
        padding: 12px;
    }

    .upload-area-large {
        padding: 25px 15px;
    }

    .upload-icon-large {
        font-size: 2.5rem;
        margin-bottom: 12px;
    }

    .upload-area-large h2 {
        font-size: 1.1rem;
        margin-bottom: 6px;
    }

    .upload-area-large p {
        font-size: 0.8rem;
    }

    .upload-area-large .btn {
        padding: 10px 20px;
        font-size: 0.85rem;
    }

    .preview-image,
    #previewSimple {
        max-height: 310px !important;
    }

    #editorCanvas,
    .ghost-overlay {
        max-height: 310px !important;
    }

    .slider-handle {
        width: 32px;
    }

    .handle-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        border-width: 1.5px;
    }

    .editor-toolbar {
        bottom: 12px;
        padding: 8px 14px;
        gap: 10px;
        border-radius: 35px;
    }

    .tool-btn {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .toolbar-section {
        gap: 6px;
    }

    .toolbar-divider {
        height: 18px;
    }

    .slider-control label {
        font-size: 0.55rem;
    }

    .slider-control input[type="range"] {
        width: 60px;
        height: 3px;
    }

    .slider-control input[type="range"]::-webkit-slider-thumb {
        width: 10px;
        height: 10px;
    }

    .panel-header {
        padding: 10px 12px;
        min-height: 45px;
    }

    .panel-header h3 {
        font-size: 0.85rem;
        gap: 5px;
    }

    .badge-pro {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    .panel-content {
        padding: 12px;
    }

    .panel-footer {
        padding: 12px;
    }

    .file-info-section {
        padding: 10px;
        border-radius: 6px;
    }

    .file-info-row {
        margin-bottom: 8px;
        font-size: 0.8rem;
    }

    .file-info-label {
        font-size: 0.75rem;
    }

    .file-info-value {
        font-size: 0.8rem;
    }

    .web-ready-score-row {
        padding: 10px;
        margin-top: 10px;
        gap: 8px;
    }

    .score-ring {
        width: 45px;
        height: 45px;
    }

    .score-value {
        font-size: 1rem;
    }

    .score-tips {
        font-size: 0.7rem;
    }

    .info-card-small {
        padding: 10px;
        border-radius: 6px;
        margin-top: 10px;
    }

    .info-card-small i {
        font-size: 0.95rem !important;
        margin-bottom: 5px !important;
    }

    .info-card-small p {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .info-card-small strong {
        font-size: 0.8rem;
    }

    .success-message-box {
        padding: 8px;
        font-size: 0.8rem;
    }

    .tool-grid {
        gap: 5px;
    }

    .tool-grid .tool-btn {
        font-size: 0.95rem;
    }

    .tool-desc-text {
        font-size: 0.7rem;
        margin-top: 5px;
    }

    .slider-group-compact {
        margin-bottom: 12px;
    }

    .slider-label {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }

    .slider-label .val {
        font-size: 0.75rem;
    }

    .range-slider {
        height: 4px;
    }

    .range-slider::-webkit-slider-thumb {
        width: 15px;
        height: 15px;
    }

    .range-slider::-moz-range-thumb {
        width: 15px;
        height: 15px;
    }

    .section-label {
        font-size: 0.65rem;
        margin-bottom: 8px;
    }

    .control-section {
        margin-bottom: 14px;
    }

    .btn-full,
    .btn-primary,
    .btn-outline,
    .btn-danger {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .btn-text {
        font-size: 0.8rem !important;
        padding: 6px !important;
    }

    #downloadBtn {
        font-size: 0.9rem;
        gap: 7px;
    }

    .flex.gap-2 {
        gap: 5px;
    }

    .progress-container-floating {
        padding: 14px 25px;
        min-width: 160px;
    }

    .loader-spinner {
        width: 30px;
        height: 30px;
        margin-bottom: 10px;
    }

    .progress-text {
        font-size: 0.8rem;
    }

    .progress-bar {
        height: 4px;
    }

    .info-box-empty {
        padding: 30px 15px;
        font-size: 0.85rem;
    }

    .info-box-empty i {
        font-size: 1.8rem !important;
        margin-bottom: 10px !important;
    }

    .cost-indicator {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }

    .panel-divider {
        margin: 14px 0;
    }

    .action-stack {
        gap: 8px;
    }

    .custom-modal-content {
        padding: 20px 16px;
        border-radius: 8px;
    }

    .modal-icon-wrapper {
        width: 45px;
        height: 45px;
        margin-bottom: 14px;
    }

    .modal-icon-wrapper i {
        font-size: 1.3rem;
    }

    .custom-modal-content h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .custom-modal-content p {
        font-size: 0.8rem;
        margin-bottom: 18px;
    }

    .modal-actions {
        gap: 6px;
    }

    .modal-actions .btn {
        padding: 9px;
        font-size: 0.85rem;
    }

    .related-tools {
        margin-top: 1.2rem;
        padding: 0.8rem;
    }

    .related-tools h3 {
        font-size: 0.85rem;
    }

    .related-tools-list {
        gap: 0.4rem;
    }

    .related-tool-link {
        padding: 0.35rem 0.7rem;
        font-size: 0.75rem;
    }

    .ai-scan-overlay {
        background-size: 120% 100%;
    }
}

/* Small Tablets (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    .studio-wrapper {
        display: flex;
        flex-direction: column;
        gap: 14px;
        padding: 0 16px 16px 16px;
        margin-top: 80px;
        height: auto;
        overflow: visible;
    }

    .studio-canvas {
        order: 1;
        height: 480px;
        min-height: 480px;
    }

    .studio-panel:first-of-type {
        order: 2;
        height: auto;
    }

    .studio-panel:last-of-type {
        order: 3;
        height: auto;
    }

    .canvas-container {
        padding: 20px;
    }

    .upload-area-large {
        padding: 50px 30px;
    }

    .preview-image,
    #previewSimple {
        max-height: 420px !important;
    }

    #editorCanvas,
    .ghost-overlay {
        max-height: 420px !important;
    }

    .slider-handle {
        width: 38px;
    }

    .handle-button {
        width: 38px;
        height: 38px;
    }

    .editor-toolbar {
        bottom: 20px;
        padding: 11px 20px;
    }

    .tool-btn {
        width: 38px;
        height: 38px;
    }

    .panel-content {
        padding: 18px;
    }

    .panel-footer {
        padding: 18px;
    }

    .tool-grid {
        gap: 8px;
    }
}





/* Landscape Orientation for Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .studio-wrapper {
        margin-top: 60px;
    }

    .studio-canvas {
        height: 320px;
        min-height: 320px;
    }

    .preview-image,
    #previewSimple {
        max-height: 270px !important;
    }

    #editorCanvas,
    .ghost-overlay {
        max-height: 270px !important;
    }

    .upload-area-large {
        padding: 25px 20px;
    }

    .upload-icon-large {
        font-size: 2.5rem;
    }

    .info-box-empty {
        padding: 30px 15px;
    }

    .slider-handle {
        width: 32px;
    }

    .handle-button {
        width: 32px;
        height: 32px;
    }

    .editor-toolbar {
        bottom: 10px;
        padding: 8px 16px;
        gap: 10px;
    }

    .tool-btn {
        width: 32px;
        height: 32px;
    }
}

/* Touch-Friendly Enhancements */
@media (hover: none) and (pointer: coarse) {
    .slider-handle {
        width: 44px;
        /* iOS touch target guideline */
    }

    .handle-button {
        width: 44px;
        height: 44px;
    }

    .tool-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .range-slider {
        height: 6px;
        /* Thicker for easier grabbing */
    }

    .range-slider::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .range-slider::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }

    /* Always show brush cursor on touch devices */
    .brush-cursor {
        display: block !important;
        opacity: 0.7;
    }

    /* Larger touch feedback for editor tools */
    .tool-grid .tool-btn {
        aspect-ratio: 1;
        min-width: 50px;
        min-height: 50px;
    }
}

/* High DPI Canvas Rendering */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    #editorCanvas,
    .ghost-overlay {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Prevent Horizontal Scroll on Mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .studio-wrapper {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Ensure editor toolbar doesn't overflow */
    .editor-toolbar {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: calc(100% - 24px);
    }
}

/* Editor Canvas Performance Optimization */
@media (max-width: 480px) {
    #editorCanvas {
        will-change: transform;
    }

    .canvas-wrapper {
        will-change: transform;
    }
}

/* Brush Cursor Visibility on Mobile */
@media (max-width: 768px) {
    .brush-cursor {
        border-width: 2px;
        background-color: rgba(255, 255, 255, 0.3);
    }
}

/* Modal Improvements for Very Small Screens */
@media (max-width: 360px) {
    .custom-modal-overlay {
        padding: 15px;
    }

    .custom-modal-content {
        width: 100%;
        padding: 18px 14px;
    }

    .modal-icon-wrapper {
        width: 40px;
        height: 40px;
        margin-bottom: 12px;
    }

    .modal-icon-wrapper i {
        font-size: 1.1rem;
    }
}

/* Slider Handle Better Visibility on Touch */
@media (max-width: 480px) {
    .handle-button {
        box-shadow: 0 0 15px rgba(249, 115, 22, 0.6), 0 0 30px rgba(0, 0, 0, 0.3);
    }

    .handle-line {
        box-shadow: 0 0 10px rgba(249, 115, 22, 0.9);
    }
}

/* Editor Toolbar Stacking on Tiny Screens */
@media (max-width: 360px) {
    .editor-toolbar {
        flex-direction: column;
        padding: 8px 12px;
        gap: 8px;
        border-radius: 20px;
    }

    .toolbar-section {
        width: 100%;
        justify-content: center;
    }

    .toolbar-divider {
        width: 100%;
        height: 1px;
    }

    .slider-control {
        width: 100%;
    }

    .slider-control input[type="range"] {
        width: 100%;
    }
}

/* Comparison Slider Better Touch Area */
@media (max-width: 480px) {
    .slider-handle {
        /* Expand touch area beyond visual size */
        padding: 10px;
        margin: -10px;
    }
}

/* Success Message Box Responsive */
@media (max-width: 374px) {
    .success-message-box {
        font-size: 0.75rem;
    }

    .success-message-box i {
        font-size: 0.9rem;
    }
}

/* Web-Ready Score Better Layout on Mobile */
@media (min-width: 481px) {
    .web-ready-score-row {
        flex-direction: row;
        align-items: center;
    }

    .score-display {
        flex-shrink: 0;
    }
}

/* Related Tools Grid on Very Small Screens */
@media (max-width: 360px) {
    .related-tools-list {
        flex-direction: column;
    }

    .related-tool-link {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================
   INTERNAL LINK STYLES - SEO & UX
   ========================================= */
.internal-link,
a.internal-link {
    color: var(--primary);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
    border-bottom: 1px solid transparent;
    padding-bottom: 1px;
}

.internal-link:hover,
a.internal-link:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary);
}

.internal-link:focus,
a.internal-link:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Inline content links (within paragraphs) */
p .internal-link,
.tool-desc .internal-link,
.footer-tagline .internal-link {
    font-weight: 500;
    border-bottom: 1px dotted rgba(249, 115, 22, 0.4);
}

p .internal-link:hover,
.tool-desc .internal-link:hover,
.footer-tagline .internal-link:hover {
    border-bottom-style: solid;
    border-bottom-color: var(--primary);
}

/* Related tools section */
.related-tools {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(249, 115, 22, 0.05);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
}

.related-tools h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.related-tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.related-tool-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    border-radius: 20px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.related-tool-link:hover {
    background: rgba(249, 115, 22, 0.2);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.related-tool-link i {
    font-size: 0.875rem;
    color: var(--primary);
}

/* =========================================
   LOADING ANIMATION FOR REMOVE BUTTON
   ========================================= */
#removeBtn .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Button loading state */
#removeBtn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

#removeBtn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
}

/* =========================================
   UTILITY CLASSES
   ========================================= */
.checkerboard-bg {
    background-color: #1a1a1a;
    background-image:
        linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.action-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 8px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.85rem;
}

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

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-text:hover {
    color: var(--text-main);
}

/* =========================================
   CUSTOM MODAL STYLES
   ========================================= */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.custom-modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-icon-wrapper {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    background: rgba(251, 191, 36, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(251, 191, 36, 0.3);
}

.modal-icon-wrapper i {
    font-size: 1.8rem;
    color: #fbbf24;
}

.custom-modal-content h3 {
    font-size: 1.4rem;
    margin-bottom: 12px;
    color: var(--text-main);
}

.custom-modal-content p {
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    padding: 10px 20px;
    font-size: 0.95rem;
}

/* =========================================
   ANIMATIONS
   ========================================= */
.floating-anim {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.btn-glow {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
    }

    50% {
        box-shadow: 0 4px 25px rgba(249, 115, 22, 0.6);
    }
}