.bnine-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.bnine-overlay-open {
    display: flex;
    opacity: 1;
}
.bnine-dialog {
    background: var(--bs-body-bg, #fff);
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.bnine-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}
.bnine-dialog-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--bs-body-color, #212529);
}
.bnine-dialog-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    color: var(--bs-secondary-color, #666);
    padding: 0 4px;
}
.bnine-dialog-close:hover {
    color: var(--bs-body-color, #000);
}
.bnine-dialog-body {
    padding: 16px;
    overflow: auto;
    flex: 1;
}

/*== Gallery ================================================================*/
.file-gallery-grid {
    columns: 4 200px;
    column-gap: 0.75rem;
}
.file-gallery-item {
    position: relative;
    border-radius: 0.375rem;
    overflow: hidden;
    background: var(--bs-tertiary-bg, #f8f9fa);
    break-inside: avoid;
    margin-bottom: 0.75rem;
}
.file-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}
.file-gallery-item .file-gallery-delete {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.file-gallery-item:hover .file-gallery-delete {
    opacity: 1;
}
.file-gallery-file {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: inherit;
}
.file-gallery-file:hover {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

/*== Gallery select mode ====================================================*/
.file-gallery-item.selectable {
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.file-gallery-item.selectable:hover {
    border-color: var(--bs-primary);
}
.file-gallery-item.selectable.selected {
    border-color: var(--bs-success);
    box-shadow: 0 0 0 2px var(--bs-success);
}
.file-gallery-item .select-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: rgba(255,255,255,0.9);
    border: 2px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 5;
}
.file-gallery-item.selectable:hover .select-checkbox,
.file-gallery-item.selectable.selected .select-checkbox {
    opacity: 1;
}
.file-gallery-item.selectable.selected .select-checkbox {
    background: var(--bs-success);
    border-color: var(--bs-success);
    color: #fff;
}
.file-gallery-item .select-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 4;
}
.file-gallery-item.selectable.selected .select-overlay {
    display: flex;
}
