.bbp-photo-upload-wrap {
    margin: 20px 0;
}

.bbp-photo-upload-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
}

.bbp-photo-upload-counter {
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .06);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.bbp-photo-dropzone {
    position: relative;
    display: flex;
    min-height: 170px;
    padding: 26px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed rgba(0, 0, 0, .22);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(0, 0, 0, .018), rgba(0, 0, 0, .035));
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease, opacity .15s ease;
    box-sizing: border-box;
}

.bbp-photo-dropzone:hover,
.bbp-photo-dropzone:focus,
.bbp-photo-dropzone.is-dragging {
    border-color: currentColor;
    background: rgba(0, 0, 0, .05);
    outline: none;
}

.bbp-photo-dropzone.is-dragging {
    transform: scale(1.01);
}

.bbp-photo-dropzone.is-processing {
    opacity: .7;
    cursor: progress;
}

.bbp-photo-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.bbp-photo-dropzone-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, .18);
    background: rgba(255, 255, 255, .7);
    font-size: 30px;
    line-height: 1;
}

.bbp-photo-dropzone-title {
    font-size: 16px;
    font-weight: 700;
}

.bbp-photo-dropzone-subtitle {
    margin-top: 3px;
    font-size: 13px;
}

.bbp-photo-dropzone-limits,
.bbp-photo-upload-server-note,
.bbp-photo-upload-feature-note,
.bbp-photo-upload-status {
    margin-top: 8px;
    font-size: 12px;
    opacity: .78;
}

.bbp-photo-upload-server-note,
.bbp-photo-upload-feature-note {
    padding: 9px 11px;
    border-radius: 7px;
}

.bbp-photo-upload-server-note {
    background: rgba(255, 165, 0, .10);
}

.bbp-photo-upload-feature-note {
    background: rgba(0, 120, 200, .07);
}

.bbp-photo-upload-status {
    min-height: 1em;
    font-weight: 600;
}

.bbp-photo-upload-errors {
    margin-top: 8px;
}

.bbp-photo-upload-error {
    padding: 8px 10px;
    margin-top: 5px;
    border-radius: 6px;
    background: rgba(180, 0, 0, .08);
    font-size: 13px;
}

.bbp-photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
    margin-top: 13px;
}

.bbp-photo-preview-item {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .10);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.bbp-photo-preview-item.is-sorting {
    z-index: 20;
    opacity: .82;
    transform: scale(.98);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}

.bbp-photo-preview-media {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: rgba(0, 0, 0, .05);
}

.bbp-photo-preview-media img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.bbp-photo-remove,
.bbp-photo-sort-handle {
    position: absolute;
    z-index: 3;
    top: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 31px;
    height: 31px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .72);
    color: #fff;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, .18);
}

.bbp-photo-remove {
    right: 7px;
    font-size: 22px;
}

.bbp-photo-sort-handle {
    left: 7px;
    font-size: 15px;
    letter-spacing: -3px;
    cursor: grab;
    touch-action: none;
}

.bbp-photo-sort-handle:active {
    cursor: grabbing;
}

.bbp-photo-remove:hover,
.bbp-photo-remove:focus,
.bbp-photo-sort-handle:hover,
.bbp-photo-sort-handle:focus {
    background: rgba(0, 0, 0, .92);
    color: #fff;
    outline: 2px solid rgba(255, 255, 255, .75);
    outline-offset: 1px;
}

.bbp-photo-preview-meta,
.bbp-photo-preview-badge {
    position: absolute;
    left: 7px;
    bottom: 7px;
    max-width: calc(100% - 14px);
    padding: 4px 7px;
    overflow: hidden;
    border-radius: 5px;
    background: rgba(0, 0, 0, .72);
    color: #fff;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bbp-photo-caption-input {
    width: calc(100% - 16px) !important;
    margin: 8px !important;
    padding: 7px 8px !important;
    border: 1px solid rgba(0, 0, 0, .16) !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
}

.bbp-photo-preview-item.is-removed {
    display: none;
}

/* Forum gallery */
.bbp-photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 9px;
    margin: 16px 0 9px;
    max-width: 900px;
}

.bbp-photo-gallery-card {
    min-width: 0;
    margin: 0;
}

.bbp-photo-gallery-item {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(0, 0, 0, .06);
    aspect-ratio: 4 / 3;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}

.bbp-photo-gallery-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform .22s ease, filter .22s ease;
}

.bbp-photo-gallery-item:hover img,
.bbp-photo-gallery-item:focus img {
    transform: scale(1.025);
    filter: brightness(.92);
}

.bbp-photo-gallery-item:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.bbp-photo-gallery-zoom {
    position: absolute;
    right: 9px;
    bottom: 9px;
    display: flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .62);
    color: #fff;
    font-size: 21px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .18s ease, transform .18s ease;
}

.bbp-photo-gallery-item:hover .bbp-photo-gallery-zoom,
.bbp-photo-gallery-item:focus .bbp-photo-gallery-zoom {
    opacity: 1;
    transform: translateY(0);
}

.bbp-photo-gallery-caption {
    padding: 6px 3px 0;
    font-size: 12px;
    line-height: 1.4;
    opacity: .8;
}

.bbp-photo-gallery[data-count="1"] {
    display: block;
    max-width: 720px;
}

.bbp-photo-gallery[data-count="1"] .bbp-photo-gallery-item {
    aspect-ratio: 16 / 10;
}

.bbp-photo-gallery[data-count="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bbp-photo-gallery[data-count="3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bbp-photo-gallery[data-count="3"] .bbp-photo-gallery-card:first-child {
    grid-row: span 2;
}

.bbp-photo-gallery[data-count="3"] .bbp-photo-gallery-card:first-child .bbp-photo-gallery-item {
    height: 100%;
    aspect-ratio: auto;
    min-height: 100%;
}

/* Lightbox */
html.bbp-photo-lightbox-open,
html.bbp-photo-lightbox-open body {
    overflow: hidden;
}

.bbp-photo-lightbox {
    position: fixed;
    z-index: 999999;
    inset: 0;
    display: none;
}

.bbp-photo-lightbox.is-open {
    display: block;
}

.bbp-photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .90);
    backdrop-filter: blur(5px);
}

.bbp-photo-lightbox-dialog {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(48px, 80px) 1fr minmax(48px, 80px);
    grid-template-rows: 1fr auto;
    align-items: center;
    padding: 30px 16px 16px;
    box-sizing: border-box;
    pointer-events: none;
}

.bbp-photo-lightbox-stage {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 120px);
    pointer-events: auto;
}

.bbp-photo-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .4);
}

.bbp-photo-lightbox-close,
.bbp-photo-lightbox-nav {
    border: 0;
    background: rgba(255, 255, 255, .11);
    color: #fff;
    cursor: pointer;
    pointer-events: auto;
    transition: background .15s ease, transform .15s ease;
}

.bbp-photo-lightbox-close:hover,
.bbp-photo-lightbox-close:focus,
.bbp-photo-lightbox-nav:hover,
.bbp-photo-lightbox-nav:focus {
    background: rgba(255, 255, 255, .22);
    color: #fff;
    outline: none;
}

.bbp-photo-lightbox-close {
    position: absolute;
    z-index: 2;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 30px;
    line-height: 1;
}

.bbp-photo-lightbox-nav {
    width: 48px;
    height: 56px;
    justify-self: center;
    border-radius: 10px;
    font-size: 30px;
}

.bbp-photo-lightbox-prev {
    grid-column: 1;
    grid-row: 1;
}

.bbp-photo-lightbox-next {
    grid-column: 3;
    grid-row: 1;
}

.bbp-photo-lightbox-footer {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    min-height: 36px;
    padding-top: 10px;
    color: #fff;
    pointer-events: auto;
}

.bbp-photo-lightbox-caption {
    max-width: 75%;
    font-size: 13px;
    line-height: 1.45;
}

.bbp-photo-lightbox-count {
    margin-left: auto;
    font-size: 12px;
    opacity: .75;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .bbp-photo-preview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bbp-photo-gallery,
    .bbp-photo-gallery[data-count="2"],
    .bbp-photo-gallery[data-count="3"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bbp-photo-gallery[data-count="3"] .bbp-photo-gallery-card:first-child {
        grid-row: auto;
        grid-column: span 2;
    }

    .bbp-photo-gallery[data-count="3"] .bbp-photo-gallery-card:first-child .bbp-photo-gallery-item {
        aspect-ratio: 16 / 9;
    }

    .bbp-photo-dropzone {
        min-height: 140px;
        padding: 20px 12px;
    }

    .bbp-photo-lightbox-dialog {
        grid-template-columns: 42px 1fr 42px;
        padding: 56px 6px 10px;
    }

    .bbp-photo-lightbox-stage {
        height: calc(100vh - 145px);
    }

    .bbp-photo-lightbox-nav {
        width: 38px;
        height: 48px;
        font-size: 24px;
        background: rgba(0, 0, 0, .38);
    }

    .bbp-photo-lightbox-footer {
        gap: 10px;
    }

    .bbp-photo-lightbox-caption {
        max-width: 70%;
    }
}

@media (max-width: 440px) {
    .bbp-photo-preview-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .bbp-photo-gallery,
    .bbp-photo-gallery[data-count="2"],
    .bbp-photo-gallery[data-count="3"] {
        gap: 6px;
    }

    .bbp-photo-gallery-item {
        border-radius: 7px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bbp-photo-dropzone,
    .bbp-photo-preview-item,
    .bbp-photo-gallery-item img,
    .bbp-photo-gallery-zoom,
    .bbp-photo-lightbox-close,
    .bbp-photo-lightbox-nav {
        transition: none !important;
    }
}
