/* Gallery Page Styles */
main {
    padding-top: 106px;
}

.ai-main-content {
    margin-top: 0px;
}

/* Gallery button overrides - inherits .new-chat-btn base styles from ai.css */
/* Secondary style: transparent with border, no confetti animations */
.gallery-btn.active {
    background-color: rgba(0,0,0,0.05);
    color: var(--color-text, #333);
    border-color: var(--color-border, #d1d5db);
}

[data-theme="dark"] .gallery-btn.active {
    background-color: rgba(255,255,255,0.08);
    color: #e5e7eb;
}

/* Gallery main content area */
.gallery-main {
    padding: 20px;
    overflow-y: auto;
    height: calc(100vh - 160px);
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.gallery-header h1,
.gallery-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-text, #111827);
    flex: 1;
    text-align: center;
}

.gallery-filters {
    display: flex;
    gap: 8px;
}

.gallery-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9999px;
    border: 1px solid var(--color-border, #e5e7eb);
    background: var(--color-card-bg, #fff);
    color: var(--color-text, #374151);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.gallery-filter-btn:hover {
    background: rgba(0,0,0,0.03);
    border-color: var(--color-border, #d1d5db);
}

.gallery-filter-btn.active {
    background: var(--color-theme-1);
    border-color: var(--color-theme-1);
    color: #fff;
}

[data-theme="dark"] .gallery-filter-btn {
    background: #0b1220;
    border-color: rgba(255,255,255,0.14);
    color: #e5e7eb;
}

[data-theme="dark"] .gallery-filter-btn:hover {
    background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .gallery-filter-btn.active {
    background: var(--color-theme-1);
    border-color: var(--color-theme-1);
    color: #fff;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (min-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Gallery Card */
.gallery-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-card-bg, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    aspect-ratio: 1 / 1;
}

.gallery-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.gallery-card:focus-visible {
    outline: 2px solid var(--color-theme-1);
    outline-offset: 2px;
}

[data-theme="dark"] .gallery-card {
    background: #0b1220;
    border-color: rgba(255,255,255,0.14);
}

[data-theme="dark"] .gallery-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.gallery-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: flex-end;
    padding: 12px;
}

.gallery-card:hover .gallery-card-overlay {
    opacity: 1;
}

.gallery-card-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
}

.gallery-card-action {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.9);
    color: #374151;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.gallery-card-action:hover {
    background: #fff;
    transform: scale(1.1);
}

.gallery-card-action.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.gallery-card-action svg {
    width: 18px;
    height: 18px;
}

/* Loading indicator in card */
.gallery-card-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-card-bg, #f3f4f6);
}

.gallery-card-loading::after {
    content: "";
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--color-theme-1);
    border-radius: 50%;
    animation: gallery-spin 0.8s linear infinite;
}

[data-theme="dark"] .gallery-card-loading {
    background: #0b1220;
}

[data-theme="dark"] .gallery-card-loading::after {
    border-color: rgba(255,255,255,0.1);
    border-top-color: var(--color-theme-1);
}

@keyframes gallery-spin {
    to { transform: rotate(360deg); }
}

/* Gallery loading state */
.gallery-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    gap: 16px;
    color: var(--color-text-secondary, #6b7280);
}

.gallery-loading.hidden {
    display: none;
}

.gallery-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--color-theme-1);
    border-radius: 50%;
    animation: gallery-spin 0.8s linear infinite;
}

[data-theme="dark"] .gallery-loading-spinner {
    border-color: rgba(255,255,255,0.1);
    border-top-color: var(--color-theme-1);
}

/* Empty state */
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 16px;
    text-align: center;
    color: var(--color-text-secondary, #6b7280);
}

.gallery-empty.hidden {
    display: none;
}

.gallery-empty svg {
    opacity: 0.4;
    margin-bottom: 16px;
}

.gallery-empty h2 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text, #374151);
}

.gallery-empty p {
    margin: 0 0 24px 0;
    max-width: 320px;
}

.gallery-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--color-theme-1);
    color: #fff;
    border-radius: 9999px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s ease;
}

.gallery-cta-btn:hover {
    background: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Sentinel for infinite scroll */
.gallery-sentinel {
    height: 1px;
    width: 100%;
}

/* Lightbox Modal */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox.hidden {
    display: none;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.9);
}

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-50%) scale(1.05);
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-actions {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 10;
}

.lightbox-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 9999px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    backdrop-filter: blur(8px);
}

.lightbox-action-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.lightbox-action-btn.lightbox-delete:hover {
    background: rgba(220,38,38,0.8);
}

.lightbox-counter {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    z-index: 10;
}

/* Delete confirmation modal */
.gallery-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 3100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gallery-confirm-modal.hidden {
    display: none;
}

.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.confirm-modal-content {
    position: relative;
    background: var(--color-card-bg, #fff);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.confirm-modal-content h3 {
    margin: 0 0 12px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text, #111827);
}

.confirm-modal-content p {
    margin: 0 0 24px 0;
    color: var(--color-text-secondary, #6b7280);
    line-height: 1.5;
}

.confirm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--color-border, #e5e7eb);
    background: transparent;
    color: var(--color-text, #374151);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background: rgba(0,0,0,0.03);
}

.btn-danger {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    background: #dc2626;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.btn-danger:hover {
    background: #b91c1c;
}

[data-theme="dark"] .confirm-modal-content {
    background: #0b1220;
    border: 1px solid rgba(255,255,255,0.14);
}

[data-theme="dark"] .confirm-modal-content h3 {
    color: #e5e7eb;
}

[data-theme="dark"] .btn-secondary {
    border-color: rgba(255,255,255,0.14);
    color: #e5e7eb;
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255,255,255,0.06);
}

/* Toast notifications */
.gallery-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-card-bg, #fff);
    color: var(--color-text, #111);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    z-index: 3200;
    opacity: 0;
    transition: all 0.3s ease;
}

.gallery-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.gallery-toast.success {
    border-left: 4px solid #10b981;
}

.gallery-toast.error {
    border-left: 4px solid #dc2626;
}

[data-theme="dark"] .gallery-toast {
    background: #0b1220;
    color: #e5e7eb;
    border-color: rgba(255,255,255,0.14);
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .gallery-main {
        margin-left: 0;
        padding: 16px;
        padding-bottom: 24px;
        height: auto;
        min-height: 0;
        max-height: none;
        overflow-y: visible;
    }

    /* Add bottom padding when selection toolbar is visible */
    .gallery-main:has(~ .selection-toolbar:not(.hidden)),
    body:has(.selection-toolbar:not(.hidden)) .gallery-main {
        padding-bottom: 80px;
    }

    .gallery-header {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        padding-left: 16px;
        padding-right: 150px; /* leave room for filter pills on the right */
        position: relative;
    }

    .gallery-header h1,
    .gallery-title {
        font-size: 1.5rem;
        text-align: center;
    }

    .gallery-filters {
        position: absolute;
        right: 16px;
        left: auto;
        top: 50%;
        transform: translateY(-50%);
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .gallery-card-overlay {
        opacity: 1;
    }

    .gallery-card-actions {
        gap: 6px;
    }

    .gallery-card-action {
        width: 28px;
        height: 28px;
    }

    .gallery-card-action svg {
        width: 14px;
        height: 14px;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-actions {
        flex-wrap: wrap;
        justify-content: center;
        padding: 0 10px;
        gap: 8px;
    }

    .lightbox-action-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .lightbox-action-btn span {
        display: none;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .gallery-sentinel {
        height: 20px;
    }

    /* Selection toolbar mobile */
    .selection-toolbar {
        padding: 10px 16px;
    }

    .selection-toolbar-content {
        gap: 12px;
    }

    .selection-count {
        font-size: 0.9rem;
    }

    .selection-toolbar-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .selection-toolbar-btn.text-btn span,
    .selection-toolbar-btn.danger span {
        display: none;
    }

    .selection-toolbar-btn.danger {
        padding: 10px;
    }

    /* Selection checkbox mobile */
    .gallery-card-checkbox {
        width: 22px;
        height: 22px;
        top: 6px;
        left: 6px;
    }

    .gallery-card-checkbox svg {
        width: 12px;
        height: 12px;
    }
}

/* Touch-friendly gestures indicator */
@media (hover: none) and (pointer: coarse) {
    .gallery-card-overlay {
        opacity: 1;
        background: none;
    }

    .gallery-card-action {
        width: 28px;
        height: 28px;
        background: rgba(255,255,255,0.95);
    }

    .gallery-card-action svg {
        width: 14px;
        height: 14px;
    }

    /* Show checkbox on touch devices */
    .gallery-card-checkbox {
        opacity: 0.6;
        transform: scale(0.95);
    }

    .selection-mode .gallery-card-checkbox {
        opacity: 1;
        transform: scale(1);
    }

    /* Prevent text selection during drag */
    .selection-mode {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Selection checkbox on cards */
.gallery-card-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: 2px solid rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transform: scale(0.9);
    transition: all 0.2s ease;
    z-index: 10;
    pointer-events: auto;
    cursor: pointer;
}

.gallery-card:hover .gallery-card-checkbox {
    opacity: 0.8;
    transform: scale(1);
}

.gallery-card-checkbox:hover {
    opacity: 1;
    transform: scale(1.1);
}

.gallery-card-checkbox svg {
    width: 14px;
    height: 14px;
    color: #fff;
    opacity: 0;
}

.selection-mode .gallery-card-checkbox {
    opacity: 1;
    transform: scale(1);
}

.gallery-card.selected .gallery-card-checkbox {
    background: var(--color-theme-1);
    border-color: var(--color-theme-1);
}

.gallery-card.selected .gallery-card-checkbox svg {
    opacity: 1;
}

/* Selection mode card styles */
.selection-mode .gallery-card {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.selection-mode .gallery-card:hover {
    transform: none;
    box-shadow: none;
}

.gallery-card.selected {
    box-shadow: 0 0 0 3px var(--color-theme-1);
}

.gallery-card.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(var(--color-theme-1-rgb, 79, 70, 229), 0.15);
    pointer-events: none;
    border-radius: 11px;
}

/* Hide card overlay actions in selection mode */
.selection-mode .gallery-card-overlay {
    display: none;
}

/* Selection Toolbar */
.selection-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-card-bg, #fff);
    border-top: 1px solid var(--color-border, #e5e7eb);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 2000;
    padding: 12px 20px;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.selection-toolbar.hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.selection-toolbar-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.selection-count {
    font-weight: 600;
    color: var(--color-text, #111827);
    flex: 1;
}

.selection-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selection-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--color-border, #e5e7eb);
    background: transparent;
    color: var(--color-text, #374151);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.selection-toolbar-btn:hover {
    background: rgba(0,0,0,0.03);
}

.selection-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.selection-toolbar-btn.text-btn {
    border: none;
    padding: 10px 12px;
}

.selection-toolbar-btn.danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.selection-toolbar-btn.danger:hover:not(:disabled) {
    background: #b91c1c;
}

.selection-toolbar-btn.danger:disabled {
    background: #fca5a5;
    border-color: #fca5a5;
}

[data-theme="dark"] .selection-toolbar {
    background: #0b1220;
    border-color: rgba(255,255,255,0.14);
}

[data-theme="dark"] .selection-count {
    color: #e5e7eb;
}

[data-theme="dark"] .selection-toolbar-btn {
    border-color: rgba(255,255,255,0.14);
    color: #e5e7eb;
}

[data-theme="dark"] .selection-toolbar-btn:hover {
    background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .gallery-card-checkbox {
    background: rgba(30,30,40,0.9);
    border-color: rgba(255,255,255,0.3);
}

[data-theme="dark"] .gallery-card.selected .gallery-card-checkbox {
    background: var(--color-theme-1);
    border-color: var(--color-theme-1);
}

/* Skeleton loading for cards */
.gallery-card-skeleton {
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

[data-theme="dark"] .gallery-card-skeleton {
    background: linear-gradient(90deg, #1a1a2e 25%, #16213e 50%, #1a1a2e 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Fix white space at bottom of gallery on mobile/tablet */
@media (max-width: 767px) {
    /* Override overflow-x:hidden rules that cause white space when filters reduce content */
    body.ai-route:has(.gallery-main),
    body.ai-route:has(.gallery-main) .app,
    body.ai-route:has(.gallery-main) .ai-container {
        overflow-x: visible !important;
    }
    .ai-container:has(.gallery-main) {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    .ai-container:has(.gallery-main) .ai-main-content {
        overflow: visible !important;
        height: auto !important;
    }
    .gallery-main {
        overflow: visible !important;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    body.ai-route:has(.gallery-main),
    body.ai-route:has(.gallery-main) .app,
    body.ai-route:has(.gallery-main) .ai-container {
        overflow-x: visible !important;
        overflow-y: auto !important;
    }
    .ai-container:has(.gallery-main) {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    .ai-container:has(.gallery-main) .ai-main-content {
        overflow: visible !important;
        height: auto !important;
    }
    .gallery-main {
        overflow: visible !important;
    }
}

/* Files list view */
.files-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Visibility toggles (scoped to Gallery Files view) */
.files-view.hidden { display: none !important; }
.files-dropdown.hidden { display: none !important; }
.files-loading.hidden { display: none !important; }
.files-empty.hidden { display: none !important; }

.files-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.files-search {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 9999px;
    padding: 6px 10px;
    background: var(--color-card-bg, #fff);
}
.files-search svg { opacity: 0.6; }

.files-search-input {
    border: none;
    outline: none;
    font-size: 0.95rem;
    min-width: 220px;
    background: transparent;
    color: var(--color-text, #111827);
}

.files-filter-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.files-control-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 9999px;
    background: var(--color-card-bg, #fff);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text, #374151);
    transition: all 0.15s ease;
}

.files-control-btn:hover {
    background: rgba(0,0,0,0.03);
}

.files-filter-dropdown,
.files-sort-dropdown {
    position: relative;
}

.files-dropdown {
    position: absolute;
    margin-top: 6px;
    background: var(--color-card-bg, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    padding: 6px;
    z-index: 20;
}

.files-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--color-text, #374151);
    cursor: pointer;
    font-size: 0.9rem;
}

.files-dropdown-item:hover {
    background: rgba(0,0,0,0.04);
}

.files-dropdown-item.active {
    background: var(--color-theme-1);
    color: #fff;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
    background: var(--color-card-bg, #fff);
    transition: all 0.15s ease;
}

.file-row:hover {
    background: rgba(0,0,0,0.03);
    border-color: var(--color-border, #e5e7eb);
}
.file-row.selected {
    background: rgba(237,118,24,0.08);
    border-color: var(--color-border, #e5e7eb);
}

.file-thumb {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-card-bg, #f3f4f6);
    display: grid;
    place-items: center;
}
.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.file-icon .ic { opacity: 0.7; }

.file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

.file-size {
    margin-left: 8px;
    color: var(--color-text-secondary, #6b7280);
    font-size: 0.85rem;
}

.files-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    color: var(--color-text-secondary, #6b7280);
}

.files-empty {
    text-align: center;
    color: var(--color-text-secondary, #6b7280);
    padding: 48px 12px;
}

.files-sentinel { height: 1px; }

/* Row actions (delete) */
.file-row-actions {
    margin-left: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.file-row-delete {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary, #6b7280);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.1s ease, visibility 0.1s ease;
}
.file-row:hover .file-row-delete {
    visibility: visible;
    opacity: 1;
}
.file-row-delete:hover {
    background: #fee2e2;
    color: #dc2626;
}
[data-theme="dark"] .file-row-delete:hover {
    background: rgba(220,38,38,0.15);
    color: #f87171;
}

/* Dark mode for Files view */
[data-theme="dark"] .files-search,
[data-theme="dark"] .files-control-btn {
    background: #0b1220;
    border-color: rgba(255,255,255,0.14);
    color: #e5e7eb;
}
[data-theme="dark"] .files-dropdown {
    background: #0b1220;
    border-color: rgba(255,255,255,0.14);
}
[data-theme="dark"] .file-row:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.14);
}
[data-theme="dark"] .file-thumb {
    background: #0b1220;
}

/* Responsive tweaks */
@media (max-width: 767px) {
    .files-search-input { min-width: 140px; }
    .file-size { font-size: 0.8rem; }
}