/* Mobile library layout control and its compact two-column card treatment. */
#libraryView .library-view-mode {
    display: none;
}

@media (max-width: 768px) {
    #libraryView #librarySelectionToolbar {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        box-sizing: border-box;
        justify-content: space-between;
        width: 100%;
        margin: 0 0 12px;
    }

    #libraryView .library-view-mode {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        margin-right: auto;
        color: var(--text-secondary);
    }

    #libraryView .library-view-mode-label {
        font-size: 11px;
        font-weight: 600;
        white-space: nowrap;
    }

    #libraryView .library-view-mode-options {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        padding: 2px;
        border: 1px solid color-mix(in srgb, var(--text-primary) 9%, transparent);
        border-radius: 10px;
        background: color-mix(in srgb, var(--text-primary) 4%, transparent);
    }

    #libraryView .library-view-mode-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 30px;
        padding: 0;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: var(--text-secondary);
        cursor: pointer;
        transition: background-color 140ms ease, color 140ms ease;
    }

    #libraryView .library-view-mode-button svg {
        width: 17px;
        height: 17px;
    }

    #libraryView .library-view-mode-button:hover,
    #libraryView .library-view-mode-button:focus-visible {
        color: var(--text-primary);
        outline: none;
    }

    #libraryView .library-view-mode-button[aria-pressed="true"] {
        background: color-mix(in srgb, var(--accent-color) 16%, var(--bg-sidebar));
        color: var(--accent-color);
    }

    #libraryView.library-selection-mode #libraryViewMode {
        display: none;
    }

    #libraryView.library-empty-visible #libraryViewMode {
        display: none;
    }

    #libraryView.library-grid-view #documentsGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        align-items: start;
        gap: 12px !important;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card {
        min-width: 0;
        padding: 9px;
        border-radius: 12px;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card .document-thumbnail {
        height: 72px;
        margin-bottom: 8px;
        border-radius: 8px;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card .document-thumbnail svg {
        width: 42px;
        height: 42px;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card .document-thumbnail .file-type-badge {
        right: 5px;
        bottom: 5px;
        padding: 3px 6px;
        font-size: 9px;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card .document-name {
        display: -webkit-box;
        min-height: 2.6em;
        margin-bottom: 5px;
        overflow: hidden;
        font-size: 12px;
        line-height: 1.3;
        text-overflow: ellipsis;
        white-space: normal;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card .document-meta {
        gap: 4px;
        font-size: 10px;
    }

    #libraryView.library-grid-view #documentsGrid > .document-card .document-date {
        display: none;
    }

    #libraryView.library-grid-view #documentsGrid > .folder-card {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        align-items: center !important;
        text-align: center !important;
    }

    #libraryView.library-grid-view #documentsGrid > .folder-card .folder-visual {
        height: auto !important;
        min-height: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        background-image: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    #libraryView.library-grid-view #documentsGrid > .folder-card .classic-folder-svg {
        width: 84px !important;
    }

    #libraryView.library-grid-view #documentsGrid > .folder-card .folder-card-actions {
        top: 10px !important;
        right: 10px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #libraryView .library-view-mode-button {
        transition: none;
    }
}
