.betterattachments-image-link,
.betterattachments-lightbox-trigger {
    cursor: zoom-in;
}

html.betterattachments-lightbox-open,
html.betterattachments-lightbox-open body {
    overflow: hidden;
}

.betterattachments-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(0, 0, 0, .86);
    box-sizing: border-box;
}

.betterattachments-lightbox.is-open {
    display: flex;
}

.betterattachments-lightbox-dialog {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    width: min(96vw, 1500px);
    height: min(94vh, 1000px);
    color: #f5f5f5;
}

.betterattachments-lightbox-stage {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
}

.betterattachments-lightbox-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 8px 35px rgba(0, 0, 0, .45);
}

.betterattachments-lightbox-close,
.betterattachments-lightbox-nav {
    border: 0;
    background: rgba(20, 20, 20, .7);
    color: #fff;
    cursor: pointer;
    line-height: 1;
}

.betterattachments-lightbox-close {
    position: absolute;
    z-index: 2;
    top: .35rem;
    right: .35rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 0;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-align: center;
}

.betterattachments-lightbox-close::before,
.betterattachments-lightbox-close::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform-origin: center;
}

.betterattachments-lightbox-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.betterattachments-lightbox-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}


.betterattachments-lightbox-nav {
    align-self: center;
    width: 48px;
    height: 64px;
    border-radius: 8px;
    font-size: 2rem;
}

.betterattachments-lightbox-prev {
    grid-column: 1;
    grid-row: 1;
    margin-right: .75rem;
}

.betterattachments-lightbox-next {
    grid-column: 3;
    grid-row: 1;
    margin-left: .75rem;
}

.betterattachments-lightbox-footer {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-top: .75rem;
    min-height: 1.5rem;
    font-size: .95rem;
}

.betterattachments-lightbox-caption {
    overflow-wrap: anywhere;
}

.betterattachments-lightbox-counter {
    flex: 0 0 auto;
    opacity: .75;
}

@media (max-width: 700px) {
    .betterattachments-lightbox {
        padding: .75rem;
    }

    .betterattachments-lightbox-dialog {
        width: 100%;
        height: 96vh;
        grid-template-columns: 38px minmax(0, 1fr) 38px;
    }

    .betterattachments-lightbox-nav {
        width: 36px;
        height: 52px;
        font-size: 1.4rem;
    }

    .betterattachments-lightbox-prev {
        margin-right: .25rem;
    }

    .betterattachments-lightbox-next {
        margin-left: .25rem;
    }
}

.betterattachments-inline-card-hidden {
    display: none !important;
}

/* Optional administrator diagnostics. */
#betterattachments-debug-panel {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 2147483647;
    width: min(440px, calc(100vw - 28px));
    max-height: 46vh;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0;
    border: 1px solid rgba(127,127,127,.45);
    border-radius: 10px;
    background: rgba(20,20,22,.96);
    color: #f5f5f5;
    box-shadow: 0 8px 28px rgba(0,0,0,.35);
    font: 12px/1.45 monospace;
}

.betterattachments-debug-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 8px 8px 12px;
    border-bottom: 1px solid rgba(127,127,127,.25);
}

.betterattachments-debug-head strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: inherit;
}

.betterattachments-debug-head span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#betterattachments-debug-panel button {
    min-height: 26px;
    padding: 2px 8px;
    border: 1px solid rgba(127,127,127,.4);
    border-radius: 6px;
    background: rgba(255,255,255,.08);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

#betterattachments-debug-panel .betterattachments-debug-close {
    width: 28px;
    padding: 0;
    font-size: 18px;
    line-height: 24px;
}

#betterattachments-debug-panel pre {
    max-height: calc(46vh - 44px);
    overflow: auto;
    margin: 0;
    padding: 10px 12px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    color: inherit;
}

/* Video poster thumbnails */
.betterattachments-video-card .attachments_top,
.betterattachments-video-card .qra_post_attachment_thumb,
.betterattachments-video-thumb {
    position: relative;
}

.betterattachments-video-poster {
    display: block;
    width: auto;
    max-width: min(100%, 480px);
    height: auto;
    object-fit: contain;
}

.betterattachments-video-card .attachments_top::after,
.betterattachments-video-card .qra_post_attachment_thumb::after,
.betterattachments-video-thumb::after {
    content: '\25B6';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.58);
    color: #fff;
    font-size: 22px;
    line-height: 52px;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

.betterattachments-video-thumb img { max-width: 100%; height: auto; border-radius: 6px; }

/* dev12: Gallery-style server-rendered video attachment cards. */
.betterattachments-video-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0 4px;
}

.betterattachments-video-attachment-card {
    display: inline-flex;
    flex-direction: column;
    width: 240px;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid rgba(127, 127, 127, .32);
    border-radius: 8px;
    background: var(--window-bg, rgba(255, 255, 255, .06));
    box-sizing: border-box;
}

.betterattachments-video-preview {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: rgba(0, 0, 0, .10);
    text-decoration: none;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.betterattachments-video-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 0;
}

.betterattachments-video-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, .68);
    box-shadow: 0 1px 5px rgba(0, 0, 0, .28);
    pointer-events: none;
}

.betterattachments-video-play::after {
    content: '';
    position: absolute;
    left: 18px;
    top: 13px;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 14px solid #fff;
}

.betterattachments-video-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px 9px;
    min-width: 0;
}

.betterattachments-video-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.betterattachments-video-stats {
    display: block;
    font-size: .88em;
    opacity: .72;
}


/* dev12a: first-class poster/fallback state, mirroring Better Gallery. */
.betterattachments-video-fallback {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .12);
}
.betterattachments-video-fallback::before {
    content: '\1F39E';
    font-size: 34px;
    line-height: 1;
    opacity: .72;
}
.betterattachments-video-attachment-card[data-betterattachments-poster-backend="s3"] .betterattachments-video-preview::before,
.betterattachments-video-attachment-card[data-betterattachments-poster-backend="local"] .betterattachments-video-preview::before,
.betterattachments-video-attachment-card[data-betterattachments-poster-backend="legacy"] .betterattachments-video-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}


/* dev12h: dedicated HTML5 video lightbox/player. */
.betterattachments-video-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, .86);
}
.betterattachments-video-lightbox.is-open { display: flex; }
.betterattachments-video-lightbox-dialog {
    position: relative;
    width: min(1100px, 96vw);
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 12px;
    background: #101114;
    box-shadow: 0 18px 60px rgba(0,0,0,.55);
}
.betterattachments-video-lightbox-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    background: #000;
}
.betterattachments-video-lightbox-stage video {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: calc(94vh - 68px);
    background: #000;
}
.betterattachments-video-lightbox-close {
    position: absolute;
    z-index: 3;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 50%;
    background: rgba(0,0,0,.68);
    cursor: pointer;
}
.betterattachments-video-lightbox-close::before,
.betterattachments-video-lightbox-close::after {
    content: '';
    position: absolute;
    left: 18px;
    top: 9px;
    width: 2px;
    height: 20px;
    background: #fff;
}
.betterattachments-video-lightbox-close::before { transform: rotate(45deg); }
.betterattachments-video-lightbox-close::after { transform: rotate(-45deg); }
.betterattachments-video-lightbox-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 14px;
    color: #f5f5f5;
    background: rgba(24,25,29,.98);
}
.betterattachments-video-lightbox-caption {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.betterattachments-video-lightbox-download { flex: 0 0 auto; color: inherit; }
@media (max-width: 700px) {
    .betterattachments-video-lightbox { padding: 10px; }
    .betterattachments-video-lightbox-dialog { width: 100%; max-height: 96vh; }
    .betterattachments-video-lightbox-stage video { max-height: calc(96vh - 62px); }
}

/* dev12n: polished video playback states + optional Better Reactions bridge. */
.betterattachments-video-lightbox-stage {
    position: relative;
}
.betterattachments-video-lightbox-status {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
    background: rgba(0,0,0,.24);
    pointer-events: none;
}
.betterattachments-video-lightbox-status[hidden] { display: none !important; }
.betterattachments-video-lightbox-status.is-error {
    background: rgba(0,0,0,.58);
}
.betterattachments-video-spinner {
    width: 20px;
    height: 20px;
    box-sizing: border-box;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: betterattachments-video-spin .75s linear infinite;
}
.betterattachments-video-lightbox-status.is-error .betterattachments-video-spinner { display: none; }
@keyframes betterattachments-video-spin { to { transform: rotate(360deg); } }

.betterattachments-video-lightbox-info {
    min-width: 0;
    flex: 1 1 auto;
}
.betterattachments-video-lightbox-details {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.25;
    opacity: .68;
}

.betterattachments-attachment-reactions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 1 auto;
    gap: 4px;
    min-height: 34px;
}
.betterattachments-attachment-reactions[hidden] { display: none !important; }
.betterattachments-reaction-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 32px;
    height: 30px;
    padding: 3px 7px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    background: rgba(255,255,255,.07);
    color: inherit;
    cursor: pointer;
    line-height: 1;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.betterattachments-reaction-button:hover,
.betterattachments-reaction-button:focus-visible {
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.34);
}
.betterattachments-reaction-button:active { transform: scale(.96); }
.betterattachments-reaction-button.is-selected {
    background: rgba(255,255,255,.2);
    border-color: rgba(255,255,255,.48);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.betterattachments-reaction-button:disabled { opacity: .55; cursor: not-allowed; }
.betterattachments-reaction-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 1;
}
.betterattachments-reaction-icon img {
    display: block;
    width: 18px;
    height: 18px;
    object-fit: contain;
}
.betterattachments-reaction-count {
    min-width: 0;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    opacity: .82;
}
.betterattachments-reaction-message {
    font-size: 11px;
    line-height: 1.2;
    opacity: .72;
    white-space: nowrap;
}

/* Image lightbox shares the same attachment reaction control. */
.betterattachments-lightbox-footer .betterattachments-attachment-reactions {
    margin-left: auto;
    margin-right: 6px;
}

@media (max-width: 720px) {
    .betterattachments-video-lightbox-footer {
        flex-wrap: wrap;
        gap: 8px 10px;
    }
    .betterattachments-video-lightbox-info {
        flex: 1 1 calc(100% - 110px);
    }
    .betterattachments-video-lightbox-footer .betterattachments-attachment-reactions {
        order: 3;
        flex: 1 1 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 2px;
    }
    .betterattachments-lightbox-footer {
        flex-wrap: wrap;
    }
    .betterattachments-lightbox-footer .betterattachments-attachment-reactions {
        order: 3;
        flex: 1 1 100%;
        justify-content: center;
        margin: 4px 0 0;
        overflow-x: auto;
    }
}

.betterattachments-reaction-note { margin-left: 6px; opacity: .72; font-size: .88em; }

/* dev12s: multi-video navigation and final playback polish. */
.betterattachments-video-lightbox-nav {
    position: absolute;
    z-index: 4;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 58px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 10px;
    background: rgba(0,0,0,.58);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    opacity: .76;
    transition: opacity .15s ease, background .15s ease, transform .15s ease;
}
.betterattachments-video-lightbox-nav:hover,
.betterattachments-video-lightbox-nav:focus-visible {
    opacity: 1;
    background: rgba(0,0,0,.78);
}
.betterattachments-video-lightbox-nav:active {
    transform: translateY(-50%) scale(.96);
}
.betterattachments-video-lightbox-nav[hidden] { display: none !important; }
.betterattachments-video-lightbox-prev { left: 12px; }
.betterattachments-video-lightbox-next { right: 12px; }
.betterattachments-video-lightbox-counter {
    flex: 0 0 auto;
    min-width: 42px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    opacity: .72;
    white-space: nowrap;
}
.betterattachments-video-lightbox-counter[hidden] { display: none !important; }
.betterattachments-video-lightbox[aria-busy="true"] .betterattachments-video-lightbox-stage video {
    opacity: .92;
}
@media (max-width: 720px) {
    .betterattachments-video-lightbox-nav {
        width: 38px;
        height: 50px;
        font-size: 24px;
    }
    .betterattachments-video-lightbox-prev { left: 6px; }
    .betterattachments-video-lightbox-next { right: 6px; }
    .betterattachments-video-lightbox-counter { order: 2; }
    .betterattachments-video-lightbox-download { order: 2; }
}

/* dev12w: live Quick Reply inline-paste progress directly under the editor. */
.betterattachments-qr-paste-status {
    display: none;
    box-sizing: border-box;
    width: 100%;
    margin: 8px 0 10px;
    padding: 9px 11px 10px;
    border: 1px solid rgba(0,0,0,.14);
    border-radius: 8px;
    background: rgba(0,0,0,.035);
    font-size: 12px;
    line-height: 1.35;
}
.betterattachments-qr-paste-status.is-active { display: block; }
.betterattachments-qr-paste-head,
.betterattachments-qr-paste-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.betterattachments-qr-paste-title { font-size: 12px; }
.betterattachments-qr-paste-count,
.betterattachments-qr-paste-percent {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    opacity: .76;
}
.betterattachments-qr-paste-file {
    min-height: 17px;
    margin: 4px 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.betterattachments-qr-paste-progress {
    height: 7px;
    margin: 0 0 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(0,0,0,.12);
}
.betterattachments-qr-paste-progress > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: currentColor;
    opacity: .72;
    transition: width .14s linear;
}
.betterattachments-qr-paste-stage {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .84;
}
.betterattachments-qr-paste-status.has-error {
    border-color: rgba(180,35,35,.35);
}
.betterattachments-qr-paste-status.is-complete .betterattachments-qr-paste-progress > span {
    opacity: .9;
}
@media (max-width: 600px) {
    .betterattachments-qr-paste-head,
    .betterattachments-qr-paste-foot { gap: 8px; }
    .betterattachments-qr-paste-status { padding: 8px 9px 9px; }
}


/* dev12x: pasted files use Better Attachments' editor progress panel instead of redundant SMF Dropzone tiles. */
.betterattachments-pasted-dropzone-hidden { display: none !important; }
.betterattachments-editor-paste-status { margin-top: 8px; }
