/* Size the app to its embed, not to a second full browser-height panel. */
.recadre-embed {
    height: var(--recadre-available-height, 75vh);
    min-height: 0;
    width: 100%;
}

#recadre-root,
#recadre-root > div {
    height: 100% !important;
    min-height: 0;
    width: 100%;
}

#recadre-root,
#recadre-root > div,
#recadre-root .recadre-crop-stage {
    overflow: hidden;
}

#recadre-root .recadre-crop-stage {
    min-width: 0;
    min-height: 0;
}

#recadre-root .recadre-crop-media {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 0;
}

#recadre-root .recadre-crop-media > img,
#recadre-root .recadre-crop-media > video {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: contain;
}

#recadre-root > div > header {
    padding: 12px 16px;
    gap: 8px;
}

#recadre-root > div > header > div:has(h1:empty) {
    display: none;
}

#recadre-root > div > header > div:last-child {
    margin-left: auto;
}

#recadre-root .max-w-2xl {
    height: 100%;
    min-height: 0;
    max-height: 100%;
}

/* The modal's header and padding must also come out of the height budget. */
#bento-recadre-modal .bento-recadre-dialog {
    height: 90vh;
    height: 90dvh;
    max-height: calc(100dvh - 24px);
}

#bento-recadre-modal .bento-recadre-header {
    flex: 0 0 auto;
}

#bento-recadre-modal .bento-recadre-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#bento-recadre-modal .bento-recadre-frame {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
}

#bento-recadre-modal .recadre-embed {
    flex: 1 1 0;
    height: 100%;
    min-height: 0;
}

@media (max-width: 640px), (max-height: 650px) {
    #recadre-root > div > header {
        padding: 8px;
    }

    #recadre-root .recadre-crop-stage {
        /* Smaller preview gaps leave room for video controls and thumbnails. */
        gap: 8px;
    }

    #recadre-root .recadre-preview-panel {
        padding: 8px;
    }

    #recadre-root .recadre-preset-bar > div:first-child {
        padding: 4px 8px;
    }

    #recadre-root .recadre-media-strip {
        padding: 8px 12px;
        gap: 12px;
    }

    #recadre-root .recadre-media-strip .w-16,
    #recadre-root .recadre-media-strip > button {
        width: 40px;
        height: 40px;
    }

    #recadre-root div:has(> #widthInput),
    #recadre-root div:has(> #heightInput) {
        gap: 4px;
    }

    #recadre-root div:has(> div > #widthInput) {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    #bento-recadre-modal .bento-recadre-dialog {
        width: calc(100% - 16px);
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
        max-height: calc(100dvh - 16px);
    }

    #bento-recadre-modal .bento-recadre-header {
        padding: 8px 12px;
    }

    #bento-recadre-modal .bento-recadre-status {
        margin-bottom: 0;
        font-size: 12px;
    }

    #bento-recadre-modal .bento-recadre-body {
        padding: 4px;
    }

    #bento-recadre-modal .bento-recadre-frame {
        padding: 4px;
    }
}
