.compact-product-upload .filepond--root[data-style-panel-layout='grid'] .filepond--item {
    width: calc(50% - 0.5rem);
    max-width: 10rem;
}

.compact-product-upload .filepond--image-preview,
.compact-product-upload .filepond--image-preview-wrapper {
    background: #f8fafc;
}

.compact-product-upload .filepond--image-preview canvas {
    object-fit: contain;
}

.compact-product-upload .filepond--item-panel {
    background: #e2e8f0;
}

.compact-product-upload .filepond--image-preview-overlay-idle {
    color: rgb(15 23 42 / 18%);
    mix-blend-mode: normal;
}

.compact-product-upload .filepond--file-wrapper {
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: #f8fafc;
}

.compact-product-upload .filepond--item {
    margin: 0.25rem;
}

.compact-product-upload .filepond--drop-label {
    min-height: 3rem;
    padding: 0.625rem !important;
}

.compact-product-upload .filepond--file-info {
    min-width: 0;
}

.compact-product-upload .filepond--file-info-main {
    display: block;
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .compact-product-upload .filepond--root[data-style-panel-layout='grid'] .filepond--item {
        width: calc(33.333% - 0.5rem);
    }
}

@media (min-width: 1024px) {
    .compact-product-upload .filepond--root[data-style-panel-layout='grid'] .filepond--item {
        width: calc(20% - 0.5rem);
    }
}

@media (min-width: 1440px) {
    .compact-product-upload .filepond--root[data-style-panel-layout='grid'] .filepond--item {
        width: calc(16.666% - 0.5rem);
    }
}

/* Only this picker: keep upload/search and actions visible while the library scrolls. */
.fi-modal-window.mbs-product-image-picker {
    height: calc(100dvh - 2rem);
    overflow: hidden;
}

.mbs-product-image-picker > .fi-modal-header,
.mbs-product-image-picker > .fi-modal-footer {
    flex-shrink: 0;
}

.mbs-product-image-picker > .fi-modal-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.mbs-product-image-picker > .fi-modal-content > .fi-sc {
    flex: 1;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 1rem;
}

.mbs-product-image-picker .fi-grid-col:has(.mbs-product-image-library),
.mbs-product-image-picker .fi-sc-component:has(.mbs-product-image-library),
.mbs-product-image-picker .fi-fo-field:has(.mbs-product-image-library),
.mbs-product-image-picker .fi-fo-field-content-col:has(.mbs-product-image-library),
.mbs-product-image-picker .fi-fo-checkbox-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.mbs-product-image-picker .fi-fo-checkbox-list-search-input-wrp,
.mbs-product-image-picker .fi-fo-checkbox-list-actions {
    flex-shrink: 0;
}

.mbs-product-image-picker .fi-fo-field:has(.mbs-product-image-library) > .fi-fo-field-label-col {
    flex: 0 0 auto;
    height: auto;
}

.mbs-product-image-picker .mbs-product-image-library {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    align-content: start;
    padding: 0.25rem;
}

.mbs-product-image-picker .mbs-product-image-library:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.mbs-product-image-picker .filepond--root {
    max-height: 8rem;
}

@media (max-width: 639px), (max-height: 700px) {
    .fi-modal .fi-modal-window.mbs-product-image-picker > .fi-modal-header,
    .fi-modal .fi-modal-window.mbs-product-image-picker > .fi-modal-content,
    .fi-modal .fi-modal-window.mbs-product-image-picker > .fi-modal-footer {
        padding: 0.75rem 1rem;
    }
}

/* On very short windows, retain scrolling access to every control. */
@media (max-height: 550px) {
    .mbs-product-image-picker > .fi-modal-content {
        overflow-y: auto;
    }

    .mbs-product-image-picker > .fi-modal-content > .fi-sc {
        flex-shrink: 0;
        grid-template-rows: auto auto;
    }

    .mbs-product-image-picker .mbs-product-image-library {
        flex: auto;
        height: 12rem;
    }
}
