/* =========================================
   1. GLOBAL VARIABLES
   ========================================= */
:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --secondary: #E11D48;
    --dark-bg: #020617;
    --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;
    --error: #EF4444;
}

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

.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);
    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: 20px;
    position: relative;
}

.preview-stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* =========================================
   3. CROP TOOLS & CONTROLS
   ========================================= */

/* Aspect Ratio Grid */
.aspect-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.aspect-btn {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.aspect-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

/* Custom Inputs Panel */
.custom-inputs-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 12px;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

.input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    padding: 8px 30px 8px 10px;
    color: white;
    font-size: 0.9rem;
    -moz-appearance: textfield;
    appearance: textfield;
}

.input-wrapper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.input-wrapper .unit {
    position: absolute;
    right: 28px;
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

/* Spinner Buttons */
.spinner-btns {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
}

.spin-btn {
    flex: 1;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
}

.spin-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.spin-btn.up {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tool Grid (Rotate/Flip/Grid) */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.tool-btn {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

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

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* =========================================
   4. CANVAS & PREVIEW
   ========================================= */
.crop-canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#cropCanvas {
    max-width: calc(100vw - 720px);
    max-height: calc(100vh - 200px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    cursor: crosshair;
}

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

.zoom-btn {
    background: transparent;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px;
}

.zoom-btn:hover {
    color: white;
}

.zoom-btn.active {
    color: var(--primary);
}

#zoomLevel {
    font-size: 0.85rem;
    color: white;
    min-width: 45px;
    text-align: center;
}

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

/* Result View */
.collage-preview-wrapper {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
}

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

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

.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(--error);
    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);
}

/* Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

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

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

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

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

/* Overlay & Modals */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal-content {
    background: #1a1a1a;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    border: 1px solid var(--border-color);
}

.modal-icon-wrapper {
    font-size: 2rem;
    color: var(--error);
    margin-bottom: 15px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

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


/* =========================================
   RESPONSIVE MEDIA QUERIES - CROP 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: 400px;
        min-height: 400px;
        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;
    }

    /* Canvas & Crop Area */
    #cropCanvas {
        max-width: 100% !important;
        max-height: 350px !important;
        touch-action: none;
    }

    .crop-canvas-wrapper {
        padding: 10px;
    }

    .collage-image {
        max-height: 350px;
    }

    /* Zoom Pill */
    .zoom-pill {
        bottom: 15px;
        padding: 4px 12px;
        gap: 8px;
        border-radius: 25px;
    }

    .zoom-btn {
        font-size: 0.8rem;
        padding: 4px;
    }

    #zoomLevel {
        font-size: 0.8rem;
        min-width: 40px;
    }

    .divider {
        height: 12px;
    }

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

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

    .aspect-btn {
        padding: 8px 6px;
        font-size: 0.8rem;
        border-radius: 6px;
    }

    /* Custom Inputs */
    .custom-inputs-panel {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
        margin-top: 10px;
    }

    #customInputs>div {
        gap: 8px !important;
    }

    .input-group label {
        font-size: 0.7rem;
        margin-bottom: 5px;
    }

    .input-wrapper {
        border-radius: 6px;
    }

    .input-wrapper input {
        padding: 8px 28px 8px 8px;
        font-size: 0.85rem;
    }

    .input-wrapper .unit {
        right: 24px;
        font-size: 0.75rem;
    }

    .spinner-btns {
        width: 22px;
    }

    .spin-btn {
        font-size: 0.55rem;
    }

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

    .tool-btn {
        font-size: 1rem;
        border-radius: 6px;
    }

    /* File Meta */
    .file-meta-row {
        margin-bottom: 7px;
        font-size: 0.85rem;
        flex-wrap: wrap;
    }

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

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

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

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

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

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

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

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

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

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

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

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

    .modal-icon-wrapper {
        font-size: 1.8rem;
        margin-bottom: 12px;
    }

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

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

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

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

    /* Action Stack */
    .action-stack {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
}

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

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

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

    #cropCanvas {
        max-height: 300px !important;
    }

    .collage-image {
        max-height: 300px;
    }

    .zoom-pill {
        bottom: 12px;
        padding: 3px 10px;
        gap: 6px;
        border-radius: 20px;
    }

    .zoom-btn {
        font-size: 0.75rem;
        padding: 3px;
    }

    #zoomLevel {
        font-size: 0.75rem;
        min-width: 35px;
    }

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

    .aspect-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .aspect-btn {
        padding: 7px 5px;
        font-size: 0.75rem;
        border-radius: 5px;
    }

    .custom-inputs-panel {
        gap: 8px;
        padding: 10px;
        margin-top: 8px;
    }

    #customInputs>div {
        gap: 6px !important;
    }

    .input-group label {
        font-size: 0.65rem;
        margin-bottom: 4px;
    }

    .input-wrapper input {
        padding: 7px 26px 7px 7px;
        font-size: 0.8rem;
    }

    .input-wrapper .unit {
        right: 22px;
        font-size: 0.7rem;
    }

    .spinner-btns {
        width: 20px;
    }

    .spin-btn {
        font-size: 0.5rem;
    }

    .tool-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .tool-btn {
        font-size: 0.95rem;
        border-radius: 5px;
    }

    .file-meta-row {
        margin-bottom: 6px;
        font-size: 0.8rem;
    }

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

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

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

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

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

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

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

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

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

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

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

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

    .modal-icon-wrapper {
        font-size: 1.6rem;
        margin-bottom: 10px;
    }

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

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

    .modal-actions {
        gap: 6px;
        margin-top: 14px;
    }

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

    .action-stack {
        gap: 8px;
    }
}

/* 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: 450px;
        min-height: 450px;
    }

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

    #cropCanvas {
        max-width: 100% !important;
        max-height: 400px !important;
    }

    .collage-image {
        max-height: 400px;
    }

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

    .tool-grid {
        gap: 10px;
    }

    .panel-content {
        padding: 18px;
    }

    .panel-footer {
        padding: 18px;
    }

    .zoom-pill {
        bottom: 20px;
    }
}

/* Medium Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .studio-wrapper {
        grid-template-columns: 280px 1fr 280px;
        gap: 14px;
        padding: 0 16px 16px 16px;
        margin-top: 90px;
    }

    .panel-content {
        padding: 18px;
    }

    .panel-footer {
        padding: 18px;
    }

    .canvas-container {
        padding: 25px;
    }

    #cropCanvas {
        max-width: calc(100vw - 620px) !important;
        max-height: calc(100vh - 220px) !important;
    }

    .aspect-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .custom-inputs-panel {
        grid-template-columns: 1fr 1fr;
    }
}

/* Large Tablets/Small Desktops (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .studio-wrapper {
        grid-template-columns: 280px 1fr 280px;
        gap: 14px;
        padding: 0 16px 16px 16px;
    }

    #cropCanvas {
        max-width: calc(100vw - 640px) !important;
    }
}


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

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

    #cropCanvas {
        max-height: 270px !important;
    }

    .collage-image {
        max-height: 270px;
    }

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

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

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

    .zoom-pill {
        bottom: 10px;
        padding: 3px 10px;
    }
}

/* Touch Devices - Improve Interaction */
@media (hover: none) and (pointer: coarse) {

    .aspect-btn,
    .tool-btn,
    .zoom-btn {
        min-height: 44px;
        /* iOS touch target guideline */
    }

    .tool-btn {
        aspect-ratio: 1;
        min-width: 44px;
    }

    #cropCanvas {
        cursor: default !important;
    }

    .zoom-pill {
        padding: 6px 14px;
    }

    .zoom-btn {
        padding: 6px;
        min-width: 36px;
        min-height: 36px;
    }

    .input-wrapper input {
        font-size: 16px !important;
        /* Prevent iOS zoom on focus */
    }
}

/* Ad Section Positioning - Bottom of Page */
.ads-section {
    width: 100%;
    padding: 40px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.ad-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

@media (max-width: 768px) {
    .ads-section {
        padding: 30px 16px;
        margin-top: 30px;
    }
}

@media (max-width: 480px) {
    .ads-section {
        padding: 20px 12px;
        margin-top: 20px;
    }
}

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

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

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    #cropCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}