/* Responsive shell refinements layered on top of Orange's existing utility styles. */

body {
    min-height: 100dvh;
    padding: clamp(0.5rem, 1.4vw, 1rem) !important;
}

body > .max-w-6xl {
    width: min(94vw, 1480px) !important;
    max-width: 1480px !important;
    height: min(88dvh, 980px) !important;
    min-height: min(620px, calc(100dvh - 1rem)) !important;
}

body > .max-w-6xl > div:first-child {
    width: clamp(13rem, 19vw, 18rem) !important;
}

body > .max-w-6xl > div:nth-child(2) {
    padding: clamp(1.5rem, 3.5vw, 4rem) !important;
}

#ui-container {
    max-width: min(46rem, 100%) !important;
}

#result-layer {
    max-width: 64rem;
    margin-inline: auto;
}

#result-layer > div:first-child {
    max-height: min(62dvh, 720px) !important;
    min-height: 0;
}

#result-layer > div:last-child {
    flex-wrap: wrap;
}

#result-layer > div:last-child > button {
    min-width: max-content;
}

@media (min-width: 1600px) and (min-height: 900px) {
    body > .max-w-6xl {
        width: min(92vw, 1560px) !important;
        max-width: 1560px !important;
        height: min(90dvh, 1040px) !important;
    }

    #ui-container {
        max-width: 50rem !important;
    }
}

@media (max-height: 760px) and (min-width: 761px) {
    body > .max-w-6xl {
        height: calc(100dvh - 1rem) !important;
        min-height: 0 !important;
    }

    body > .max-w-6xl > div:first-child {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    body > .max-w-6xl > div:first-child img {
        width: 4.75rem !important;
        height: 4.75rem !important;
    }

    body > .max-w-6xl > div:first-child h1 {
        font-size: 1.5rem !important;
    }

    body > .max-w-6xl > div:first-child > div:first-child {
        margin-bottom: 1.25rem !important;
        gap: 0.35rem !important;
    }

    body > .max-w-6xl > div:nth-child(2) {
        padding: 1.25rem 2rem !important;
    }

    #ui-container,
    #dynamic-inputs {
        gap: 1rem !important;
    }

    #dropzone,
    #dropzone2,
    #image-preview,
    #image2-preview {
        height: min(13rem, 32dvh) !important;
    }

    #prompt-input {
        min-height: 6.5rem;
    }
}

@media (max-width: 900px) and (min-width: 641px) {
    body > .max-w-6xl > div:first-child {
        width: 12rem !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    body > .max-w-6xl > div:first-child img {
        width: 5rem !important;
        height: 5rem !important;
    }

    body > .max-w-6xl > div:nth-child(2) {
        padding: 1.5rem !important;
    }
}

@media (max-width: 640px) {
    body {
        display: block !important;
        padding: 0.5rem !important;
        overflow-y: auto !important;
    }

    body > .max-w-6xl {
        width: 100% !important;
        max-width: none !important;
        min-height: calc(100dvh - 1rem) !important;
        height: auto !important;
        flex-direction: column !important;
        border-radius: 1.25rem !important;
        overflow: visible !important;
    }

    body > .max-w-6xl > div:first-child {
        width: 100% !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 0.75rem !important;
        border-right: 0 !important;
        border-bottom: 1px solid rgb(39 39 42) !important;
        gap: 0.75rem;
    }

    body > .max-w-6xl > div:first-child > div:first-child {
        width: auto !important;
        margin: 0 !important;
        flex-direction: row !important;
        gap: 0.5rem !important;
        flex-shrink: 0;
    }

    body > .max-w-6xl > div:first-child img {
        width: 2.75rem !important;
        height: 2.75rem !important;
    }

    body > .max-w-6xl > div:first-child h1 {
        font-size: 1.25rem !important;
        padding: 0 !important;
    }

    body > .max-w-6xl > div:first-child > div:nth-child(2) {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 0.5rem !important;
        margin: 0 !important;
        padding-bottom: 0.1rem;
    }

    #tool-tabs {
        flex-direction: row !important;
        gap: 0.5rem !important;
        margin-top: 0 !important;
    }

    #tool-tabs button {
        width: auto !important;
        white-space: nowrap;
        padding: 0.65rem 0.85rem !important;
    }

    body > .max-w-6xl > div:first-child > div:last-child,
    #vram-warning,
    body > .max-w-6xl > div:first-child label {
        display: none !important;
    }

    body > .max-w-6xl > div:nth-child(2) {
        overflow: visible !important;
        padding: 1.25rem !important;
        justify-content: flex-start !important;
        min-height: 0;
    }

    #ui-container,
    #dynamic-inputs {
        gap: 1.25rem !important;
    }

    #image-upload-container > div {
        flex-direction: column !important;
    }

    #dropzone,
    #dropzone2,
    #image-preview,
    #image2-preview {
        height: 12rem !important;
    }

    #aspect-ratios {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #generate-btn {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    #generating-layer,
    #result-layer {
        height: auto !important;
        min-height: 60dvh;
    }

    #result-layer {
        gap: 1rem !important;
    }

    #result-layer > div:first-child {
        min-height: 18rem;
        max-height: 60dvh !important;
    }

    #result-layer > div:last-child {
        width: 100%;
        gap: 0.5rem !important;
    }

    #result-layer > div:last-child > button {
        flex: 1 1 calc(50% - 0.5rem) !important;
        padding: 0.85rem 1rem !important;
        font-size: 0.875rem !important;
    }

    #download-btn {
        flex-basis: 100% !important;
    }
}
