/* File actions: a quiet, intentional choice before opening or downloading. */
.library-file-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(10, 11, 13, 0.58);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: library-file-dialog-in 160ms ease-out;
}

.library-file-dialog {
    position: relative;
    width: min(420px, calc(100vw - 32px));
    max-height: min(820px, calc(100vh - 32px));
    overflow: auto;
    padding: 26px;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--bg-secondary, var(--bg-sidebar, #242321));
    color: var(--text-primary);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

.library-file-dialog-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}

.library-file-dialog-close:hover,
.library-file-dialog-close:focus-visible {
    background: var(--bg-hover);
    color: var(--text-primary);
    outline: none;
}

.library-file-dialog-icon {
    display: grid;
    width: 50px;
    height: 50px;
    margin-bottom: 18px;
    place-items: center;
    border: 1px solid var(--border-color);
    border-radius: 13px;
    background: var(--bg-hover);
    color: var(--text-primary);
}

.library-file-dialog-icon .thumb-icon {
    width: 28px;
    height: 28px;
}

.library-file-dialog-icon .file-type-badge {
    display: none;
}

.library-file-dialog-copy {
    padding-right: 24px;
}

.library-file-dialog-eyebrow {
    display: block;
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.library-file-dialog-copy h2 {
    margin: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -0.015em;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-file-dialog-copy p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.library-file-dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 24px;
}

.library-file-dialog-action {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 10px 13px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.library-file-dialog-action svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.library-file-dialog-action:hover,
.library-file-dialog-action:focus-visible {
    border-color: var(--text-secondary);
    background: var(--bg-hover);
    outline: none;
    transform: translateY(-1px);
}

.library-file-dialog-action--primary {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: var(--accent-text, #fff);
}

.library-file-dialog-action--primary:hover,
.library-file-dialog-action--primary:focus-visible {
    border-color: var(--accent-color);
    background: var(--accent-color);
    filter: brightness(1.06);
}

.library-file-dialog-action--compact {
    min-height: 38px;
    margin-top: 14px;
    padding-inline: 16px;
}

.library-file-dialog-overlay--preview .library-file-dialog {
    width: min(900px, calc(100vw - 32px));
}

.library-file-preview-body {
    display: grid;
    min-height: 150px;
    margin-top: 22px;
    overflow: hidden;
    place-items: center;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary, #171717);
}

.library-file-preview-image {
    display: block;
    width: 100%;
    max-height: 58vh;
    object-fit: contain;
}

.library-file-preview-frame {
    display: block;
    width: 100%;
    height: min(62vh, 680px);
    border: 0;
    background: #fff;
}

.library-file-preview-text {
    box-sizing: border-box;
    width: 100%;
    max-height: 58vh;
    margin: 0;
    overflow: auto;
    padding: 18px;
    color: var(--text-primary);
    font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.library-file-preview-loading,
.library-file-preview-empty {
    padding: 34px 24px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
    text-align: center;
}

.library-file-preview-empty p {
    margin: 0;
}

@keyframes library-file-dialog-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 560px) {
    .library-file-dialog {
        padding: 22px;
    }

    .library-file-dialog-actions {
        grid-template-columns: 1fr;
    }
}

body.light-mode .library-file-dialog-overlay {
    background: rgba(32, 35, 40, 0.28);
}

body.light-mode .library-file-preview-body {
    background: #f5f6f7;
}

/* Uploaded files use the same open, compact treatment as Library folders. */
#libraryView #documentsGrid > .document-card:not(.folder-card) {
    min-height: 0 !important;
    align-items: center !important;
    padding: 8px 6px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: center !important;
    transition: transform 140ms ease !important;
}

#libraryView #documentsGrid > .document-card:not(.folder-card):hover {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: translateY(-1px) !important;
}

#libraryView #documentsGrid > .document-card:not(.folder-card) .document-thumbnail {
    box-sizing: border-box;
    width: 104px !important;
    height: 82px !important;
    flex: 0 0 82px;
    margin: 0 auto !important;
    border-radius: 8px !important;
    background: transparent !important;
}

#libraryView #documentsGrid > .document-card:not(.folder-card) .document-thumbnail .thumbnail-image {
    border-radius: 8px;
}

#libraryView #documentsGrid > .document-card:not(.folder-card) .document-thumbnail > svg {
    width: 42px;
    height: 42px;
}

#libraryView #documentsGrid > .document-card:not(.folder-card) .card-owner-avatar,
#libraryView #documentsGrid > .document-card:not(.folder-card) .document-meta {
    display: none !important;
}

#libraryView #documentsGrid > .document-card:not(.folder-card) .document-name {
    width: 100%;
    max-width: 128px;
    margin: 8px 0 0 !important;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#libraryView .library-file-menu-btn {
    position: absolute;
    top: 2px;
    right: 50%;
    z-index: 11;
    display: grid;
    width: 28px;
    height: 28px;
    margin-right: -66px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 140ms ease, background-color 140ms ease, color 140ms ease;
}

#libraryView .document-card:not(.folder-card):hover .library-file-menu-btn,
#libraryView .document-card:not(.folder-card):focus-within .library-file-menu-btn,
#libraryView .library-file-menu-btn[aria-expanded="true"] {
    opacity: 1;
}

#libraryView .library-file-menu-btn svg {
    width: 17px;
    height: 17px;
}

#libraryView .library-file-menu-btn:hover,
#libraryView .library-file-menu-btn:focus-visible,
#libraryView .library-file-menu-btn[aria-expanded="true"] {
    background: color-mix(in srgb, var(--text-primary) 9%, transparent);
    color: var(--text-primary);
    outline: none;
}

#libraryView .library-file-menu {
    position: absolute;
    top: 28px;
    right: calc(50% - 78px);
    z-index: 20;
    min-width: 136px;
    padding: 5px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary, var(--bg-sidebar, #242321));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
    text-align: left;
}

#libraryView .library-file-menu[hidden] {
    display: none !important;
}

#libraryView .library-file-delete-action {
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #ef8a83;
    font: inherit;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

#libraryView .library-file-delete-action:hover,
#libraryView .library-file-delete-action:focus-visible {
    background: rgba(239, 78, 70, 0.14);
    outline: none;
}

@media (hover: none) {
    #libraryView .document-card:not(.folder-card) .library-file-menu-btn {
        opacity: 1;
    }
}
