/* Version: 2.24.2 - October 03, 2026 */
:root {
    --bg-color: #0a0a0a;
    --surface-color: #1a1a1a;
    --surface-hover: #252525;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --text-color: #f8f9fa;
    --text-muted: #adb5bd;
    --border-color: #343a40;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --favorite-color: #ffc107;
    --workflow-color: #28a745;
    --success-color: #20c997;
    
    /* AI Colors */
    --ai-color: #ff00ff; /* Fuchsia */
    --ai-gradient: linear-gradient(135deg, #ff00ff 0%, #00ffff 100%);
    --ai-surface: rgba(255, 0, 255, 0.1);
    
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
    --sidebar-width: 360px;
}

* {
    box-sizing: border-box;
}
/* --- GLOBAL SCROLLBAR STYLING (Dark & Glass) --- */

/* Firefox Configuration */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Chrome, Edge, Safari Configuration */
::-webkit-scrollbar {
    width: 8px;  /* Vertical scrollbar width */
    height: 8px; /* Horizontal scrollbar height */
}

/* Track (Background) - Transparent/Invisible */
::-webkit-scrollbar-track {
    background: transparent; 
    margin: 4px 0; /* Safe margin at the ends */
}

/* Thumb (The moving handle) */
::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15); /* Subtle translucent white */
    border-radius: 20px; /* Fully rounded capsule */
    border: 2px solid transparent; /* Trick to create padding/spacing around the thumb */
    background-clip: content-box;
}

/* Thumb Hover State */
::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3); /* Brighter and more visible on interaction */
}

/* Corner (Intersection between vertical and horizontal) */
::-webkit-scrollbar-corner {
    background: transparent;
}

html {
    scroll-behavior: smooth;
}

/* --- CUMULATIVE PATCH CSS START --- */
@media (min-width: 1025px) {
    /* Hide the old bulky metadata on desktop gallery cards */
    .gallery-item .file-metadata,
    .gallery-item .file-scanned-time {
        display: none !important;
    }
    
    /* Enable container queries to make text responsive based on card width */
    .gallery-item {
        container-type: inline-size;
    }
    
    /* New Compact Meta on the same line as the Checkmark */
    .desktop-compact-meta {
        position: absolute;
        bottom: 16px;
        left: 15px;
        right: 45px; /* Leave breathing room for the checkmark */
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.75rem;
        color: var(--text-muted);
        z-index: 10;
        pointer-events: none; /* Let clicks pass through to the selection area */
    }
    
    .desktop-compact-meta-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .desktop-info-btn {
        flex-shrink: 0;
        pointer-events: auto; /* Re-enable clicks for the button */
        cursor: pointer;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.65rem;
        font-weight: bold;
        font-family: monospace;
        color: white;
        transition: background 0.2s;
    }
    .desktop-info-btn:hover {
        background: var(--primary-color);
    }
    
    /* Auto-shrink font when switching to Compact Thumbnail Size */
    @container (max-width: 260px) {
        .desktop-compact-meta {
            font-size: 0.65rem;
            bottom: 17px;
            letter-spacing: -0.2px;
        }
    }
}

/* Hide the new compact meta in mobile mode or Focus mode */
@media (max-width: 1024px) {
    .desktop-compact-meta {
        display: none !important;
    }
}
body.focus-mode .desktop-compact-meta {
    display: none !important;
}

/* Force item actions on a single line to save vertical space in compact mode */
.gallery-item .item-actions {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    width: 100% !important;
}

.gallery-item .item-actions a,
.gallery-item .item-actions button {
    flex: 1 !important;
    padding: 0.6rem 0.2rem !important;
    min-width: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* Animation for Focus Status Bar updates */
@keyframes statusBarPop {
    0% { transform: translateX(-50%) translateY(2px) scale(0.97); opacity: 0.8; }
    50% { transform: translateX(-50%) translateY(0px) scale(1.02); opacity: 1; }
    100% { transform: translateX(-50%) translateY(0px) scale(1); opacity: 1; }
}
#focus-status-bar.pop-anim {
    animation: statusBarPop 0.25s ease-out;
}

.item-info { cursor: pointer; }
.item-actions { cursor: default; }

/* --- MOBILE 2-COLUMN MODE STYLES --- */
.mobile-info-icon { display: none; }
@media (min-width: 769px) {
    .opt-mobile-only { display: none !important; }
}
@media (max-width: 768px) {
    .opt-mobile-only { display: flex !important; }
    
    body.mobile-two-cols .gallery-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
    }
    body.mobile-two-cols .item-info > div:first-child {
        display: none !important; /* Completely hide title and metadata on card */
    }
    body.mobile-two-cols .item-info {
        padding: 5px 8px 35px 8px !important; /* Space for the absolute icons at the bottom */
        position: relative;
    }
    body.mobile-two-cols .item-actions {
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 8px !important;
        padding: 2px 4px !important;
        margin: 0 !important;
    }
    body.mobile-two-cols .item-actions a,
    body.mobile-two-cols .item-actions button {
        padding: 8px 2px !important;
        background: transparent !important;
        border: none !important;
        font-size: 1.1rem !important;
    }
    /* Hide Node Summary to keep exactly 3 icons (Fav, DL, Del) as requested */
    body.mobile-two-cols .item-actions button[title="Node Summary"] {
        display: none !important;
    }
    
    /* Info Icon Bottom Left (Mobile 1-col & 2-col) */
    .mobile-info-icon {
        display: flex !important;
        position: absolute;
        bottom: 8px;
        left: 8px;
        width: 26px;
        height: 26px;
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255,255,255,0.3);
        border-radius: 50%;
        justify-content: center;
        align-items: center;
        z-index: 11;
        color: #fff;
        font-size: 12px;
        font-weight: bold;
        font-family: monospace;
        backdrop-filter: blur(5px);
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }
    
    /* Selection Circle Bottom Right (Adjusted to match Info Icon height) */
    body.mobile-two-cols .selection-checkmark {
        bottom: 8px !important;
        right: 8px !important;
        width: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
        border: 1px solid rgba(255,255,255,0.5);
        background: rgba(0,0,0,0.4);
        color: transparent;
        display: flex !important;
        opacity: 1 !important;
    }
    body.mobile-two-cols .gallery-item.selected .selection-checkmark {
        background: var(--primary-color);
        border-color: var(--primary-color);
        color: white;
    }

    /* Hide overlay badges (workflow, duration, rating) on the thumbnail in 2-column mode for cleaner look */
    body.mobile-two-cols .gallery-item .thumbnail-wrapper .workflow-badge,
    body.mobile-two-cols .gallery-item .thumbnail-wrapper .duration-overlay {
        display: none !important;
    }
}
/* --- CUMULATIVE PATCH CSS END --- */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
    margin: 0;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

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

#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.notification {
    background-color: var(--surface-color);
    color: var(--text-color);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border-left: 5px solid var(--primary-color);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    font-weight: 600;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    background-color: var(--success-color);
    color: white;
    border-color: #1a9c77;
}

.notification.error {
    background-color: var(--danger-color);
    color: white;
    border-color: #b32a38;
}

.notification.warning {
    background-color: var(--favorite-color);
    color: #000;
    border-color: #d39e00;
}

.notification.info {
    background-color: var(--primary-color);
    color: white;
    border-color: #0056b3;
}

.notification.path-msg {
    word-break: break-all !important;  
    white-space: pre-wrap !important;  
    text-align: left !important;       
    font-family: monospace;            
    font-size: 0.85rem;                
    line-height: 1.4;
    max-width: 95vw;                   
}
.notification.multiline-msg {
    white-space: pre-wrap !important; /* Forces the \n character to break line */
    text-align: left !important;      /* Aligns multiple lines to the left */
}

/* --- SIDEBAR BASE RESTORATION --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    transition: min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden; /* Prevents sidebar from scrolling itself */
}

/* Prevent link color change after click (Visited state) */
.folder-link, .col-item, .navigation-link {
    color: var(--text-color) !important;
    text-decoration: none !important;
    outline: none;
}

.folder-link:hover, .col-item:hover {
    color: #fff !important;
}

body.sidebar-expanded .sidebar {
    min-width: 600px;
}

.main-content {
    flex-grow: 1;
    padding-bottom: 80px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ### start */
/* ========================================= */
/* === SIDEBAR HEADER (WRAPPER STRATEGY) === */
/* ========================================= */

.sidebar-header {
display: flex;
align-items: center;
/* ABSOLUTE START: Everything starts from the left */
justify-content: flex-start !important; 
width: 100%;
margin-bottom: 1.5rem;
flex-shrink: 0;
padding: 0 4px;
box-sizing: border-box;
min-height: 44px;
/* Allow text to overflow if needed, no more dots/truncation */
overflow: visible; 
}

/* --- LEFT BLOCK (LOGO + TEXTS) --- */
.brand-link {
display: flex;
align-items: center;
text-decoration: none;

/* DIMENSIONS BLOCK */
flex-grow: 0 !important;
flex-shrink: 0 !important;
/* Width: content only. No extra pixels. */
width: fit-content !important; 
max-width: 80%; /* Mobile safety */

/* SPACING */
gap: 10px !important;
margin-right: 0 !important; /* No push from here */
}
.brand-logo {
width: 38px;
height: 38px;
min-width: 38px !important;
object-fit: contain;
flex-shrink: 0;
background-color: #ffcccc;
border-radius: 8px;
box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
margin: 0 !important;
margin-right: 10px !important; /* Fixed space to the right of the logo */
}
.brand-info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start !important; /* Text aligned to the left */
text-align: left !important;

line-height: 1.1;
/* REMOVED OVERFLOW HIDDEN: No more truncation dots */
overflow: visible !important; 
white-space: nowrap;
margin: 0 !important;
}
.brand-link h1 {
margin: 0;
font-size: 1.5rem;
font-weight: 600;
font-family: system-ui, -apple-system, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
letter-spacing: -0.02em; /* Tracking modern */
white-space: nowrap;
overflow: visible !important; 
text-overflow: clip !important; 

background: linear-gradient(135deg, #f0a0ff 0%, #9b30ff 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;

/* Glow modern */
filter: drop-shadow(0 0 8px rgba(155, 48, 255, 0.4))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));

margin-bottom: 2px !important;
}
.version-row-header {
display: flex;
align-items: center;
justify-content: flex-start !important;
gap: 8px; 
margin: 0 !important;
width: 100%;
}

.v-num {
font-size: 0.75rem;
color: rgba(255, 255, 255, 0.5); 
font-family: monospace;
font-weight: 500;
line-height: 1;
}

.header-update-badge {
background: var(--primary-color);
color: white !important;
font-size: 0.6rem;
padding: 2px 6px;
border-radius: 4px;
text-decoration: none;
font-weight: 600;
text-transform: uppercase;
white-space: nowrap;
animation: pulse-update 2s infinite;
display: inline-flex;
align-items: center;
line-height: 1;
}

@keyframes pulse-update {
    0% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(0, 123, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
}

/* --- RIGHT BLOCK (BUTTONS) - CRITICAL MODIFICATION BELOW --- */
.sidebar-actions {
display: flex;
align-items: center;
gap: 5px;
flex-shrink: 0;

/* THIS IS THE KEY: */
/* Push this element all the way to the right. This keeps the logo on the left. */
margin-left: auto !important; 
}

/* 1. Bring Update Badge closer to version number */
.version-row-header {
gap: 4px !important; /* Was 8px, reduced to tighten spacing */
}

/* 2. Remove ghost margins from badge to stick it to the left */
.header-update-badge {
margin-left: 0 !important;
}

@keyframes pulse-update {
    0% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(0, 123, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
}

/* 3. Force text closer to the logo (eliminating dead space) */
.brand-link {
gap: 4px !important; /* Reduced gap between logo and title */
}

#sidebar-minify-btn, #sidebar-expand-btn {
    background: transparent; border: 1px solid var(--glass-border); color: var(--text-muted);
    padding: 0; border-radius: 6px; cursor: pointer; font-size: 0.9rem;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
#sidebar-minify-btn:hover, #sidebar-expand-btn:hover {
    background: var(--surface-hover); color: white; border-color: var(--text-muted);
}

@media (max-width: 1024px) {
    #sidebar-minify-btn, #sidebar-expand-btn { display: none !important; }
    .brand-link h1 { font-size: 1.3rem; }
    .brand-logo { width: 34px; height: 34px; }
}

/* ########## end */
.folder-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.folder-search-input {
    width: 100%;
    background: var(--glass-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.folder-sort-buttons {
    display: flex;
    gap: 0.5rem;
}

.folder-sort-buttons button {
    flex-grow: 1;
    background: var(--surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.folder-sort-buttons button.active {
    background: rgba(0, 123, 255, 0.15) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}
.folder-sort-buttons button:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
}

.folder-tree-container {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}

.folder-tree,
.folder-tree ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.folder-tree li {
    padding-left: 20px;
    position: relative;
}

.folder-tree>li:first-child {
    padding-left: 0;
}

.folder-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s;
    position: relative;
}

.folder-item:hover {
    background-color: var(--surface-hover);
}

.folder-item.active {
    background-color: rgba(0, 123, 255, 0.15) !important;
    border: 1px solid var(--primary-color) !important;
    border-left: 4px solid var(--primary-color) !important; 
    color: white !important;
    font-weight: 600;
}

.toggle-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
}

.toggle-btn.empty {
    visibility: hidden;
}

.folder-link {
    flex-grow: 1;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 25px;
    cursor: pointer;
}

.folder-actions {
    margin-left: auto;
    display: flex;
    opacity: 1;
}

.folder-action-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.folder-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.folder-tree li.collapsed>ul {
    display: none;
}

.folder-tree li.is-hidden {
    display: none;
}

.folder-tree li:not(.collapsed)>.folder-item>.toggle-btn::before {
    content: '▾';
}

.folder-tree li.collapsed>.folder-item>.toggle-btn::before {
    content: '▸';
}

.folder-tree li.no-children>.folder-item>.toggle-btn {
    visibility: hidden;
}

/* --- CREATE FOLDER BUTTON (Redesigned: Glass Style) --- */
#create-folder-btn {
    width: 100%;
    /* Base State: Glass / Transparent */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    
    /* Typography & Layout */
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Flex for centering icon and text */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    
    margin-top: 1rem;
    flex-shrink: 0;
}

/* Hover State: Standard Blue (Consistent with File Operations) */
#create-folder-btn:hover {
    background: rgba(0, 123, 255, 0.15); /* Light Blue Tint */
    border-color: var(--primary-color);   /* Blue Border */
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Active/Click State */
#create-folder-btn:active {
    transform: translateY(0);
    background: rgba(0, 123, 255, 0.25);
}

/* --- MOUNT BUTTON (Unified Style) --- */
#mount-folder-btn {
    width: 100%;
    /* Base Style: Identical to Create Folder (Glass) */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 0.5rem; /* Gap from create button */
    flex-shrink: 0;
}

/* Hover: Green Tint to distinguish functionality */
#mount-folder-btn:hover {
    background: rgba(40, 167, 69, 0.15);
    border-color: var(--workflow-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
}

/* Mobile/Sidebar Hide Logic */
.sidebar.nav-collapsed #mount-folder-btn { display: none; }
body.sidebar-minimized .sidebar #mount-folder-btn { display: none !important; }

/* --- MOUNT MODAL & BROWSER STYLES --- */

/* Info Box - Increased Font */
.mount-info-box {
    background: rgba(0, 123, 255, 0.1);
    border-left: 3px solid var(--primary-color);
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 0.95rem; /* Bigger font */
    color: #ddd;
    line-height: 1.5;
    text-align: left;
}
.mount-info-box strong { color: white; }
.mount-info-box code { 
    background: rgba(0,0,0,0.3); 
    padding: 2px 5px; 
    border-radius: 4px; 
    font-family: monospace; 
    color: var(--favorite-color);
}

/* Filesystem Browser Container */
.fs-browser-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    height: 250px; /* Default height for Desktop */
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    overflow: hidden;
}

/* Browser Header */
.fs-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Path Display */
.fs-path-display {
    flex-grow: 1;
    font-family: monospace;
    font-size: 0.95rem; /* Bigger font */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--primary-color);
    direction: rtl; /* Show end of long paths */
    text-align: left;
}

/* List Area */
.fs-list {
    flex-grow: 1;
    overflow-y: auto;
    list-style: none;
    padding: 5px;
    margin: 0;
}

/* List Items */
.fs-item {
    padding: 10px 12px; /* Taller touch targets */
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s;
    font-size: 1rem; /* Much readable font */
    color: var(--text-color);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.fs-item:last-child { border-bottom: none; }

.fs-item:hover { background: var(--surface-hover); }

.fs-item.is-selected {
    background: rgba(0, 123, 255, 0.2);
    color: white;
    font-weight: bold;
}

.fs-icon { color: var(--favorite-color); font-size: 1.2rem; }
.fs-drive-icon { color: var(--ai-color); font-size: 1.2rem; }

/* --- MOBILE LAYOUT OVERRIDES (Mount Modal Fix) --- */
@media (max-width: 768px) {
    #mount-folder-overlay {
        align-items: flex-start !important;
        padding-top: 5px !important; 
    }
    
    #mount-folder-overlay .smart-dialog-panel {
        /* Let it scroll if screen is small */
        max-height: 98vh; 
        overflow-y: auto; 
        display: block; /* Changed from flex to block to fix overflow issues */
        
        /* HUGE bottom padding to ensure buttons are inside the background */
        padding: 15px 15px 100px 15px !important; 
        
        border-radius: 0 0 16px 16px;
    }

    /* Header adjustments */
    .smart-dialog-panel h3 {
        font-size: 1.1rem;
        margin-bottom: 5px !important; 
        margin-top: 5px !important;
    }
    
    /* Info Box */
    .mount-info-box {
        margin-top: 0 !important;
        margin-bottom: 10px !important;
        font-size: 0.95rem !important;
        line-height: 1.3 !important;
        padding: 10px !important;
    }
    
    /* Browser List height */
    .fs-browser-container {
        height: auto !important; 
        min-height: 200px !important; 
        max-height: 35vh !important;
        margin-bottom: 15px;
    }

    /* Push the bottom boundary further down explicitly */
    .sd-actions {
        margin-bottom: 20px !important;
        padding-bottom: 10px !important;
    }
}

.breadcrumbs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.breadcrumb-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    overflow: hidden;
    flex-grow: 1;
}

.breadcrumb-links a,
.breadcrumb-links span {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}

.breadcrumb-links a:hover {
    color: var(--text-color);
}

.breadcrumb-links span:last-child {
    color: var(--text-color);
    font-weight: 700;
    text-overflow: ellipsis;
    overflow: hidden;
}
/* COPIED FROM HERE */
.gallery-sort-controls {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.gallery-sort-controls .sort-btn {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: var(--surface-hover);
    color: var(--text-color);
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s;
}

.gallery-sort-controls .sort-btn:hover {
    background: var(--surface-color);
}

.gallery-sort-controls .sort-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* --- INFO BADGE (Refined: Active Blue Glass Style) --- */
.file-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    /* Matches the .folder-sort-buttons button.active style */
    background: rgba(0, 123, 255, 0.15) !important;
    border: 1px solid var(--primary-color) !important;
    color: white !important;
    
    /* Glass blur effect for depth */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    
    padding: 4px 14px;
    border-radius: 50px; 
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    
    /* Non-interactive state */
    cursor: default; 
    user-select: none;
    white-space: nowrap;
    
    /* Subtle depth styling */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); 
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Mobile specific positioning for the badge and conditional filter button */
.mobile-meta-row {
    display: none; /* Hidden on desktop */
    width: 100%;
    margin-bottom: 12px;
    padding-left: 2px;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Aligns content to the left */
    gap: 10px; /* Space between button and badge */
}

@media (max-width: 768px) {
    .mobile-meta-row { display: flex; }
    
    /* If the filter button is inside meta-row, make it more compact */
    .mobile-meta-row .filter-main-btn {
        flex-grow: 1; /* Allows the button to take available space */
        max-width: 200px; /* Prevents it from being too wide */
    }
}

.filter-bar {
    padding: 1.5rem 2rem;
}

.filter-bar form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* NEW DESKTOP SEARCH PANEL STYLES */
.search-overlay-panel {
    display: none;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 10px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease-out;
    position: relative;
    z-index: 900;
    
    max-width: calc(100% - 4rem) !important; /* Ensures it stays within main-content padding */
    box-sizing: border-box !important;
    overflow-x: hidden !important; /* Prevents horizontal scroll of the panel itself */
}

.search-overlay-panel.visible {
    display: block;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-form-grid {
    display: grid;
    /* Adaptive columns: they will shrink and wrap automatically */
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
    gap: 1.5rem;
    align-items: start;
    width: 100% !important;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

/* SEARCH SCOPE STYLES */
.search-scope-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

.scope-options {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

/* --- SCOPE SELECTOR VISUALS --- */
.scope-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px 12px; /* Slightly larger for touch */
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex: 1; /* Distribute space evenly */
    justify-content: center;
}

.scope-label:hover {
    background: var(--surface-hover);
    color: var(--text-color);
}

.scope-label.active {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.2); /* Stronger visible color */
    color: white;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.3);
}
        
.scope-label input[type="radio"] {
    margin: 0;
    accent-color: var(--primary-color);
}

/* --- MODERN FILTER PANEL INTERIORS --- */

/* 1. Labels */
.filter-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
    display: block;
}

/* 2. Text & Date Inputs (Glass Style) */
.filter-group input[type="text"],
.filter-group input[type="date"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.2); /* Darker than global glass for contrast */
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0 12px;
    height: 42px; /* Fixed height matches buttons */
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    color-scheme: dark; /* Forces dark calendar picker */
}

.filter-group input[type="text"]:focus,
.filter-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* 3. Scope Selectors (Segmented Control Look) */
.scope-options {
    display: flex;
    background: rgba(0,0,0,0.3);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    gap: 5px;
}

.scope-label {
    flex: 1;
    text-align: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Hide default radio circle */
.scope-label input[type="radio"] {
    display: none; 
}

/* Active State for Scope */
.scope-label.active {
    background: var(--surface-hover);
    color: white;
    border-color: var(--glass-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Special style for Global active */
.scope-label.active {
     background: rgba(0, 123, 255, 0.15);
     border-color: var(--primary-color);
     color: var(--primary-color);
     box-shadow: 0 0 8px rgba(0, 123, 255, 0.3);
     font-weight: bold;
}

/* 4. Recursive Toggle (Chip Style) */
.recursive-wrapper {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.recursive-wrapper:hover { background: rgba(255, 255, 255, 0.08); }

.recursive-wrapper.active {
    background: rgba(0, 123, 255, 0.15);
    border-color: var(--primary-color);
}

.recursive-wrapper.active .recursive-label {
    color: white;
    font-weight: bold;
}

.recursive-wrapper.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

/* 5. Checkboxes (Options Group) */
.filter-group-inline {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-group-inline:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--glass-border);
}

/* Custom Checkbox Size */
.filter-group-inline input[type="checkbox"] {
    width: 18px; 
    height: 18px;
    margin-right: 10px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.filter-group-inline label {
    margin: 0; /* Reset default label margin */
    font-size: 0.9rem;
    color: var(--text-color);
    text-transform: none; /* Normal case for options */
    cursor: pointer;
    font-weight: 500;
}

/* --- ACTION BUTTONS (Apply/Reset) DYNAMIC LAYOUT --- */
.filter-actions-row {
    display: flex !important;
    flex-direction: row !important; /* Always row on desktop */
    justify-content: flex-end !important; /* Align buttons to the right on desktop */
    gap: 12px !important;
    margin-top: 20px !important;
    padding-top: 20px !important;
    border-top: 1px solid var(--glass-border) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.filter-actions-row .glass-btn {
    flex: 0 1 auto !important;    /* Buttons take only the space they need */
    min-width: 140px !important;  /* Minimum width to keep them clickable */
    height: 42px !important;      /* Matches the top toolbar height exactly */
    min-height: 42px !important;
    border-radius: 10px !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    padding: 0 20px !important;
    margin: 0 !important;
    text-transform: none !important;
    box-shadow: var(--shadow-sm) !important;
}

/* Adjustment for the "Actions" group to take more space if needed */
.filter-group:last-child {
    grid-column: 1 / -1; /* Makes the Actions row take the full width of the grid */
    width: 100% !important;
}

/* Red Reset Button Style */
.filter-actions-row .btn-reset {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--danger-color) !important;
    color: var(--danger-color) !important;
}
.filter-actions-row .btn-reset:hover {
    background: var(--danger-color) !important;
    color: white !important;
    transform: translateY(-1px);
}

/* Blue Submit Button Style */
 .filter-actions-row button[type="submit"] {
    background: var(--primary-color) !important; /* Solid but themed */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}
.filter-actions-row button[type="submit"]:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Styling for the new Desktop Toggle Button */
#search-toggle-desktop {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

#search-toggle-desktop:hover {
    background: var(--surface-hover);
}

#search-toggle-desktop.active-filters {
    background: rgba(0, 123, 255, 0.15);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px rgba(0,123,255,0.2);
}

/* --- CUSTOM MULTI-SELECT DROPDOWN (Responsive: Floating Desktop / Push-down Mobile) --- */
.c-multi-select {
    position: relative;
    width: 100%;
}

.c-select-trigger {
    width: 100%;
    background: var(--glass-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
    white-space: nowrap;
    overflow: hidden;
}

.c-select-trigger:hover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.c-select-trigger::after {
    content: '▼';
    font-size: 0.7rem;
    margin-left: 10px;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

/* Rotate arrow when open */
.c-multi-select.open .c-select-trigger::after {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.c-dropdown-menu {
    /* DESKTOP DEFAULT: Absolute (Floating over content) */
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    z-index: 1000; /* High Z-Index to float above other inputs on desktop */
    margin-top: 5px;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    padding: 5px;
}

/* --- MOBILE SPECIFIC: Accordion Style (Push content down) --- */
@media (max-width: 768px) {
    .c-dropdown-menu {
        position: relative; /* Not floating anymore */
        top: 0;
        z-index: 1; /* Normal flow */
        box-shadow: none; /* Flat look */
        background: rgba(0, 0, 0, 0.2); /* Slightly darker bg to distinguish area */
        border: 1px solid var(--glass-border);
        border-top: none; /* Connect visually to trigger */
        margin-top: 0;
        border-radius: 0 0 8px 8px; /* Rounded bottom only */
    }
    
    /* Remove bottom radius from trigger when open on mobile to look connected */
    .c-multi-select.open .c-select-trigger {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: transparent; 
    }
}

.c-dropdown-menu.show {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.c-option-label {
    display: flex;
    align-items: center;
    padding: 10px 12px; /* Larger touch target for mobile */
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    color: var(--text-color);
    font-size: 0.9rem;
    user-select: none;
    border-bottom: 1px solid rgba(255,255,255,0.05); /* Separator lines */
}
.c-option-label:last-child { border-bottom: none; }

.c-option-label:hover {
    background: var(--surface-hover);
}

.c-option-label input[type="checkbox"] {
    margin-right: 12px;
    width: 18px; /* Bigger checkbox for touch */
    height: 18px;
    accent-color: var(--primary-color);
}

.c-select-counter {
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    margin-left: 8px;
    display: none;
}
.c-select-counter.visible {
    display: inline-block;
}

.c-option-label {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    color: var(--text-color);
    font-size: 0.9rem;
    user-select: none;
}

.c-option-label:hover {
    background: var(--surface-hover);
}

.c-option-label input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.c-select-counter {
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    margin-left: 8px;
    display: none;
}
.c-select-counter.visible {
    display: inline-block;
}

#gallery-anchor {
    display: block;
    position: relative;
    top: -20px;
    visibility: hidden;
}

/* Modified: .ai-banner removed from here as it is fully redefined later. Keeping global-search-banner */

.global-search-banner {
    background: rgba(0, 123, 255, 0.1); /* Blue for Standard */
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
    animation: glowBlue 2s infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 0 5px rgba(255, 0, 255, 0.1); }
    to { box-shadow: 0 0 15px rgba(255, 0, 255, 0.4); }
}

@keyframes glowBlue {
    from { box-shadow: 0 0 5px rgba(0, 123, 255, 0.1); }
    to { box-shadow: 0 0 15px rgba(0, 123, 255, 0.4); }
}

/* Deleted: .ai-banner-title - Overwritten by "STILI AI BANNER" block later */

/* --- RECURSIVE SEARCH TOGGLE STYLE --- */
.recursive-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s;
    width: fit-content;
}

.recursive-wrapper:hover {
    background: rgba(255, 255, 255, 0.08);
}

.recursive-wrapper input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.recursive-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    user-select: none;
    cursor: pointer;
}

.recursive-wrapper.active {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
}

.recursive-wrapper.active .recursive-label {
    color: white;
}

/* --- RECURSIVE UI ENHANCEMENT --- */
.recursive-wrapper.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none; /* Prevents clicks when scope is Global */
    filter: grayscale(1);
}

/* New Styles for AI Options and Lightbox */
.ai-search-options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

    /* hide native arrows (Chrome, Safari, Edge, Opera) */
    input[type=number]::-webkit-outer-spin-button,
    input[type=number]::-webkit-inner-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }
    /* hide native arrows (Firefox) */
    input[type=number] {
      -moz-appearance: textfield;
    }

    .ai-limit-container {
        display: flex;
        align-items: center;
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        border-radius: 8px;
        overflow: hidden; /* Keeps borders rounded */
        height: 36px; /* Fixed height for consistency */
    }

    .ai-limit-btn {
        background: transparent;
        border: none;
        color: var(--ai-color);
        font-size: 1.2rem;
        font-weight: bold;
        width: 30px;
        height: 100%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
    }

    .ai-limit-btn:hover {
        background: rgba(255, 0, 255, 0.2);
        color: white;
    }

    .ai-limit-input {
        background: transparent;
        border: none;
        border-left: 1px solid var(--glass-border);
        border-right: 1px solid var(--glass-border);
        color: white;
        width: 50px;
        height: 100%;
        font-size: 1rem;
        text-align: center;
        font-weight: bold;
        outline: none;
    }

    .ai-limit-input:focus {
        background: rgba(255, 255, 255, 0.05);
    }

.ai-banner-actions button {
    background: transparent;
    border: 1px solid var(--ai-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.global-search-banner .ai-banner-actions button {
    border-color: var(--primary-color);
}
.global-search-banner .ai-banner-actions button:hover {
    background: var(--primary-color);
}

.ai-banner-actions button:hover {
    background: var(--ai-color);
}

.gallery-container {
    display: grid;
    /* Use variable with 320px fallback */
    grid-template-columns: repeat(auto-fill, minmax(var(--grid-item-size, 320px), 1fr));
    gap: 2rem;
    padding: 2rem;
    min-height: 50vh;
    align-items: start; 
}

.gallery-item {
    background: var(--glass-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    height: fit-content; 
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.gallery-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.2);
}

.gallery-item.focused {
    outline: 4px solid var(--text-color)!important;
    outline-offset: 4px!important;
}

/* Disable selection in Global AI Mode */

.selection-checkmark {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--text-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 11;
    transition: all 0.3s;
    color: transparent;
    cursor: pointer;
    font-size: 12px;
    backdrop-filter: blur(10px);
}

.gallery-item.selected .selection-checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.thumbnail-link {
    cursor: pointer;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    background: var(--surface-color);
    overflow: hidden;
}

.thumbnail-wrapper img,
.thumbnail-wrapper video {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.3s;
}

.gallery-item:hover .thumbnail-wrapper img,
.gallery-item:hover .thumbnail-wrapper video {
    transform: scale(1.05);
}

.item-info {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-bottom: 48px;
}

.item-info p {
    margin: 0;
    word-wrap: break-word;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.file-metadata {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.file-metadata span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* --- GALLERY ITEM ACTIONS (Refined: Ghost/Glass Style) --- */

.item-actions a,
.item-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    
    /* Base State: Transparent/Dark Glass */
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    color: var(--text-muted); /* Grey icon by default */
    
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem; /* Slightly bigger icons */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(5px);
}

/* Hover: Light up background */
.item-actions a:hover,
.item-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Specific: Delete Button (Red only on Hover) */
.item-actions .delete-btn {
    /* Reset old solid styles */
    background: rgba(255, 255, 255, 0.03); 
    border-color: rgba(255, 255, 255, 0.1);
}

.item-actions .delete-btn:hover {
    background: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
}

/* Specific: Favorite Button (Gold when active) */
.favorite-btn.favorited {
    color: var(--favorite-color); /* Gold Icon */
    border-color: var(--favorite-color);
    background: rgba(255, 193, 7, 0.1); /* Subtle Gold Tint */
}
@media (hover: hover) {
    .favorite-btn:hover {
        color: var(--favorite-color) !important;
        border-color: var(--favorite-color) !important;
        background: rgba(255, 193, 7, 0.1);
    }
}

.duration-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.workflow-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--workflow-color);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    text-decoration: none;
    font-weight: 600;
}

.ai-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--ai-color);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 10;
    text-transform: uppercase;
}

#drag-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1002;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}

#drag-drop-overlay.visible {
    display: block;
    opacity: 1;
}

#drop-zone-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    z-index: 1003;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    max-height: 80vh;
}

#drop-zone-panel.visible {
    display: flex;
}

#drop-zone-panel h3 {
    margin: 0;
    padding: 1rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    flex-shrink: 0;
}

#drop-zone-folders {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    min-height: 0;
    flex-grow: 1;
}

#cancel-drop-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 1rem;
    cursor: pointer;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    font-weight: 600;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

#loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s;
}

.loader {
    border: 4px solid var(--surface-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

#lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#lightbox-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    z-index: 2001;
}

#lightbox-prev {
    left: 30px;
}

#lightbox-next {
    right: 30px;
}

#lightbox-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2002;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
}

#lightbox-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    word-break: break-word;
    hyphens: auto;
    max-width: 90vw;
}

#lightbox-folder-name {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-top: 0.2rem;
    font-weight: 600;
    opacity: 0.9;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#lightbox-toolbar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

#lightbox-toolbar button,
#lightbox-toolbar a {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    backdrop-filter: blur(10px);
}

#lightbox-toolbar button:hover,
#lightbox-toolbar a:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* AI Caption Icon in Lightbox */
#lightbox-caption-icon {
    color: var(--ai-color);
    border-color: var(--ai-color);
}

#lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 6rem 1rem 6rem; /* Added bottom padding for caption */
}

#lightbox-media {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 80vh;
    /* Prevent accidental blue selection highlight */
    user-select: none;
    -webkit-user-select: none;
}

#lightbox-media img,
#lightbox-media video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    cursor: grab;
    /* Prevent accidental blue selection highlight and ghost drag */
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

#lightbox-ai-caption {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    max-height: 40vh; 
    
    /* Flex layout to manage fixed header and scrollable content */
    display: none; 
    flex-direction: column;
    overflow: hidden; 
    
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ai-color);
    border-radius: 12px;
    /* Reduced padding on container, moved to content */
    padding: 10px; 
    
    z-index: 2020;
    color: #eee;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: 0 10px 40px rgba(0,0,0,0.7);
}

#lightbox-ai-caption.visible {
    display: flex; /* Important: flex for layout */
    animation: slideUpCaption 0.3s ease-out;
}

/* New container for scrolling text */
#lightbox-ai-text-scroll {
    overflow-y: auto; /* Only this div scrolls */
    flex-grow: 1;
    padding: 10px 15px; /* Internal padding for text */
    margin-top: 5px;
    padding-right: 5px; /* Space for scrollbar */
}

/* Internal scrollbar style */
#lightbox-ai-text-scroll::-webkit-scrollbar {
    width: 6px;
}
#lightbox-ai-text-scroll::-webkit-scrollbar-thumb {
    background-color: var(--ai-color);
    border-radius: 3px;
}

@keyframes slideUpCaption {
    from { transform: translate(-50%, 50px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.caption-close-btn {
    position: absolute;
    top: 5px;
    right: 10px;
    background: rgba(10, 10, 10, 0.5); /* Light background for readability over text */
    border-radius: 50%;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10; /* Always on top */
}

.caption-close-btn:hover {
    color: var(--danger-color);
    background: rgba(255, 255, 255, 0.1);
}

/* --- PREMIUM GO TO TOP BUTTON (Fixed Contrast & Mobile) --- */
#backToTopBtn {
    display: none;
    position: fixed;
    bottom: 40px;
    right: 30px;
    z-index: 1900;
    
    /* Base Sphere: Darker and opaque for contrast on light images */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(10, 10, 10, 0.9); /* Almost black, highly readable */
    border: 1px solid rgba(255, 255, 255, 0.15); /* Border to stand out on dark background */
    color: var(--primary-color); /* Blue Arrow */
    
    /* Glass Effects */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    
    /* Deep shadow to pop on light backgrounds */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
    
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* Disable tap highlight on mobile */
    -webkit-tap-highlight-color: transparent;
}

/* --- DESKTOP HOVER ONLY --- */
@media (hover: hover) {
    #backToTopBtn:hover {
        background: var(--primary-color); /* Turns Blue */
        border-color: var(--primary-color);
        color: white; /* White Arrow */
        transform: translateY(-5px) scale(1.1);
        box-shadow: 0 10px 25px rgba(0, 123, 255, 0.5); /* Blue Glow */
    }
}

/* --- ACTIVE STATE (Click/Tap) --- */
/* Tactile feedback for mobile and desktop on click */
#backToTopBtn:active {
    transform: scale(0.9);
    background: rgba(30, 30, 30, 1); /* Slightly lighter on touch */
}

/* Mobile Positioning Override */
@media (max-width: 768px) {
    #backToTopBtn {
        bottom: 25px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}

/* --- STYLISH LOAD MORE BUTTON (Robust Centering) --- */
#load-more-container {
    /* Supports both Flex and Block (if changed via JS) */
    display: flex; 
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important; /* Fallback if it becomes display:block */
    
    width: 100% !important;
    padding: 2rem 20px 8rem 20px !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    clear: both;
}

#load-more-btn {
    /* Glass Base */
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    /* Shape & Size */
    padding: 12px 40px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto !important; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    white-space: nowrap; 
    max-width: 100%;
}
/* Hover Effect */
#load-more-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 123, 255, 0.2);
}
/* Active/Loading Effect */
#load-more-btn:active,
#load-more-btn:disabled {
    transform: scale(0.98);
    background: rgba(0, 0, 0, 0.2);
    border-color: transparent;
    color: var(--text-muted);
    box-shadow: none;
    cursor: wait;
}
/* Arrow Animation on Hover */
#load-more-btn .arrow-icon {
    transition: transform 0.3s ease;
}
#load-more-btn:hover .arrow-icon {
    transform: translateY(3px);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

#node-summary-overlay,
#upload-overlay,
#sync-overlay,
#ai-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#node-summary-overlay {
    z-index: 2100;
}

#upload-overlay {
    z-index: 2200;
}

#ai-search-overlay {
    z-index: 2250;
}

#sync-overlay {
    z-index: 2300;
    display: none;
    opacity: 1;
    pointer-events: all;
}

#node-summary-overlay.visible,
#upload-overlay.visible,
#ai-search-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.node-summary-panel,
#upload-panel,
#sync-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 90vw;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* AI Modal Styles */
.ai-modal-panel {
    background: var(--surface-color);
    border: 1px solid var(--ai-color);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.2);
    width: 90vw;
    max-width: 500px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transform: scale(0.95);
    transition: transform 0.3s;
    position: relative;
}

#ai-search-overlay.visible .ai-modal-panel {
    transform: scale(1);
}

.ai-modal-header {
    text-align: center;
    color: white;
}

.ai-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ai-search-textarea {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
}

.ai-search-textarea:focus {
    outline: none;
    border-color: var(--ai-color);
    box-shadow: 0 0 10px rgba(255,0,255,0.2);
}

.ai-scope-selector {
    display: flex;
    background: var(--glass-bg);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.ai-scope-option {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s;
}

.ai-scope-option.active {
    background: var(--ai-color);
    color: white;
    font-weight: bold;
}

.ai-search-submit {
    background: var(--ai-gradient);
    border: none;
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 15px rgba(255,0,255,0.3);
}

.ai-search-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255,0,255,0.5);
}

.ai-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.node-summary-panel {
    max-width: 900px;
    max-height: 85vh;
}

#upload-panel {
    max-width: 600px;
    max-height: 85vh;
}

#sync-panel {
    max-width: 500px;
    padding: 2rem;
    align-items: center;
    text-align: center;
}

#node-summary-overlay.visible .node-summary-panel,
#upload-overlay.visible #upload-panel {
    transform: scale(1);
}

.node-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--surface-color);
}

.node-summary-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.node-summary-header .close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

#node-summary-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.summary-node-item {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.summary-node-header {
    color: white;
    padding: 0.75rem 1rem;
    font-weight: bold;
    font-size: 0.9rem;
}

.summary-node-header small {
    opacity: 0.8;
    font-weight: normal;
    margin-left: 0.5rem;
}

.summary-node-params {
    list-style: none;
    margin: 0;
    padding: 1rem;
    background: var(--glass-bg);
}

.summary-node-params li {
    padding: 0.5rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.summary-node-params li:last-child {
    border-bottom: none;
}

.summary-node-params strong {
    color: var(--text-color);
    margin-right: 0.5rem;
}

.summary-node-params code {
    color: var(--text-muted);
    word-break: break-all;
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 5px;
    border-radius: 4px;
}

#refresh-btn {
    margin-left: auto;
}

.upload-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.upload-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.upload-header p {
    margin: 0.5rem 0 0;
    color: var(--text-muted);
}

.upload-body {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

#drop-zone.dragover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
    transform: scale(1.02);
}

#drop-zone p {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0 0 1rem 0;
}

#file-upload-btn {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}

#file-list {
    list-style: none;
    padding: 0;
    margin-top: 1.5rem;
    max-height: 200px;
    overflow-y: auto;
}

#file-list li {
    background: var(--glass-bg);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.upload-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.upload-footer button {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

#upload-cancel-btn {
    background: var(--surface-hover);
    color: var(--text-color);
}

#upload-submit-btn {
    background: var(--success-color);
    color: white;
}

#upload-progress-container {
    display: none;
    margin-top: 1rem;
}

#upload-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

#upload-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--primary-color);
    transition: width 0.2s;
}

#upload-file-input {
    display: none;
}

#sync-message {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 500;
}

#sync-progress-bar {
    width: 100%;
    height: 10px;
    background-color: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

#sync-progress-fill {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

#mobile-filter-toggle {
    display: none;
    width: 100%;
    background: var(--surface-hover);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
}

.mobile-actions-only {
    display: none;
}

/* --- WHITESPACE PRESERVATION FIX --- */
/* Sidebar Folders */
.folder-link {
    white-space: pre-wrap !important;
    word-break: break-word;
}
/* Gallery Item Titles */
.item-info p {
    white-space: pre-wrap !important;
    word-break: break-word;
}
/* Lightbox Title */
#lightbox-title {
    white-space: pre-wrap !important;
    word-break: break-word;
}
/* Upload file list */
#file-list li span:first-child {
    white-space: pre-wrap !important;
}

/* --- MODERN FLOATING SELECTION BAR --- */
#selection-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    /* Default hidden state: Moved down and not scaled */
    transform: translateX(-50%) translateY(150%) scale(1);
    width: 90%;
    max-width: 600px;
    
    /* ... (leave all other aesthetic properties background, border, etc. unchanged) ... */
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--primary-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1001;
    
    /* MODIFICATION: Added transform-origin to scale from bottom/center */
    transform-origin: bottom center; 
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Active State: Usa la variabile --ui-zoom-scale calcolata via JS */
#selection-bar.visible {
    transform: translateX(-50%) translateY(0) scale(var(--ui-zoom-scale, 1));
}

/* Left Side: Close & Counter */
.sel-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#selection-counter {
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    margin: 0;
    padding: 0;
}

/* Right Side: Actions */
.sel-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon Buttons Style */
.sel-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

.sel-btn.danger {
    color: #ff6b6b;
}
.sel-btn.danger:hover {
    background: var(--danger-color);
    color: white;
}

.sel-btn.close-x {
    border: 1px solid rgba(255,255,255,0.2);
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

/* --- DROP-UP MENU ("More" Actions) --- */
.sel-more-menu {
    position: absolute;
    bottom: 100%; /* Sits on top of the bar */
    right: 0;
    margin-bottom: 10px;
    width: 200px;
    background: #252525;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    padding: 5px;
    animation: slideUpMenu 0.2s ease-out;
}

.sel-more-menu.show {
    display: flex;
}

@keyframes slideUpMenu {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Menu Items */
.sel-more-menu button {
    background: transparent;
    border: none;
    color: #eee;
    padding: 12px 15px;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.sel-more-menu button:hover {
    background: rgba(255,255,255,0.1);
}

.sel-separator {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 4px 0;
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    #selection-bar {
        width: 95%;
        bottom: 20px;
        padding: 8px 12px;
    }
    .sel-more-menu {
        right: 10px; /* Slight offset on mobile */
    }
}

@media (max-width: 1024px) {
    /* 1. NOTIFICATIONS: Positioned lower and centered to avoid browser URL bar overlap */
    #notification-container {
        top: 120px !important; 
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        align-items: center !important;
        width: 85% !important;
        z-index: 10001 !important;
    }

    .notification {
        transform: translateY(-20px);
        border-left: none;
        border-bottom: 5px solid var(--primary-color);
        text-align: center;
        box-shadow: var(--shadow-lg);
        width: 100%;
    }

    /* 2. SIDEBAR HEADER: SmartGallery title on Left, Folders Button on Right */

    .sidebar-actions {
        display: none !important; /* Completely hide to remove ghost space on mobile */
    }

    /* 3. WIDTH CONTROLS: Strictly hide desktop expansion/minify icons on mobile */
    #sidebar-minify-btn, 
    #sidebar-expand-btn {
        display: none !important;
    }
    
    /* 4. MOBILE NAVIGATION LOGIC */
    body.sidebar-expanded-mobile .sidebar {
        position: fixed;
        width: 100%;
        min-width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        transform: translateX(0);
        z-index: 1005;
    }

    body.sidebar-expanded-mobile .main-content {
        display: none;
    }

    body:not(.sidebar-expanded-mobile) {
        flex-direction: column;
    }

    .sidebar.nav-collapsed .folder-controls,
    .sidebar.nav-collapsed .folder-tree-container,
    .sidebar.nav-collapsed #create-folder-btn,
    .sidebar.nav-collapsed .sidebar-footer { /* Added footer here to hide it */
        display: none;
    }

/* NEW START */
    /* 1. Force Sidebar to 100% screen width */
    .sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100vw !important;
    }

    /* 2. Hide original footer user row on mobile */
    .sidebar-user-row {
        display: none !important;
    }

    /* 3. New Compact Mobile User Badge Styles */
    .mobile-user-compact {
        display: flex;
        align-items: center;
        gap: 6px; 
        background: rgba(255, 255, 255, 0.08);
        padding: 4px 10px 4px 4px !important; 
        border-radius: 50px;
        border: 1px solid var(--glass-border);
        margin-left: auto;
        width: fit-content; 
        max-width: none; 
        flex-shrink: 0;
        margin-left: 10px!important;
    }

    .mobile-user-compact .avatar {
        cursor: pointer; /* Show it's clickable */
        transition: transform 0.2s;
    }
    
    .mobile-user-compact .avatar:active {
        transform: scale(0.9); /* Tactile feedback on tap */
    }

    .mobile-manage-btn {
        background: none;
        border: none;
        color: var(--favorite-color); /* Gold color for visibility */
        padding: 0 4px;
        cursor: pointer;
        font-size: 1rem;
        display: flex;
        align-items: center;
        border-right: 1px solid var(--glass-border);
        margin-right: 2px;
    }

    .mobile-user-compact .avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: var(--primary-color);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.7rem;
        font-weight: bold;
        color: white;
        flex-shrink: 0;
    }

    .mobile-user-compact .username {
        font-size: 0.75rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--text-color);
        display: none !important;
    }
    
    .mobile-logout-x {
        color: var(--danger-color);
        text-decoration: none;
        font-weight: bold;
        font-size: 1.1rem;
        padding-left: 4px;
        border-left: 1px solid var(--glass-border);
    }
    
    /* NEW END */
 
}

 /* Ensure desktop still sees the footer row */
@media (min-width: 1025px) {
    .mobile-user-compact { display: none !important; }
}

@media (max-width: 768px) {
    .breadcrumbs {
        flex-direction: column;
        align-items: stretch;
        padding: 0.5rem 1rem; 
    }

    .gallery-sort-controls {
        justify-content: space-between; 
        width: 100%;
        gap: 0.3rem; 
        flex-wrap: wrap; 
    }

    .gallery-sort-controls .sort-btn,
    .gallery-sort-controls .file-count-badge {
        padding: 0.4rem 0.5rem !important;
        font-size: 0.75rem !important;
        flex-grow: 1; 
        text-align: center;
        justify-content: center;
        white-space: nowrap;
    }

    .filter-bar form {
        grid-template-columns: 1fr;
    }

    #mobile-filter-toggle {
        display: block;
        margin-bottom: 1rem;
    }

    /* --- FIX: Allow panel to be visible on mobile when toggled --- */
    .search-overlay-panel {
        margin: 10px !important;
        width: auto !important;
        padding: 1rem !important;
        box-sizing: border-box !important;
        max-width: calc(100vw - 20px) !important;
    }
    .search-overlay-panel.visible {
        display: block !important;
    }
    .date-row {
        flex-direction: column !important; /* Stack them */
        gap: 10px !important;
    }
    .date-row > div {
        min-width: 100% !important; /* Full width */
    }
    .filter-actions-row {
        flex-direction: column-reverse !important; /* Apply on top, Reset below */
        gap: 10px !important;
    }

    .filter-actions-row .glass-btn {
        width: 100% !important;      /* Full width only on mobile for easy thumb access */
        flex: 1 1 auto !important;
        height: 48px !important;     /* Slightly taller on mobile for touch accuracy */
        min-height: 48px !important;
        font-size: 1rem !important;
    }
                
    .filter-group input[type="date"] {
        font-size: 0.85rem !important; 
        padding: 0 8px !important;     
    }
    .filter-form-grid {
        display: grid; /* Always grid inside the panel */
        grid-template-columns: 1fr;
    }

    .desktop-actions-only {
        display: none;
    }

    .mobile-actions-only {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .gallery-container {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    #drop-zone-panel {
        width: 90vw;
    }

    .lightbox-nav {
        width: 50px;
        height: 50px;
    }

    #lightbox-prev {
        left: 10px;
    }

    #lightbox-next {
        right: 10px;
    }

    .node-summary-panel {
        width: 95vw;
        max-height: 90vh;
    }

    .summary-node-params li {
        font-size: 0.9rem;
    }
    
    /* --- LIGHTBOX MOBILE OPTIMIZATION --- */
    #lightbox-header {
        padding: 0.25rem 0.5rem !important; /* Reduced lateral padding to save space */
        gap: 2px !important; /* Reduced gap between title and buttons */
    }

    .lb-hide-mobile { display: none !important; }

    #lightbox-title {
        font-size: 0.85rem !important;
        max-width: 90vw !important; /* Allow title to take most of the screen width */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #lightbox-folder-name {
        font-size: 0.75rem !important;
        margin-top: 0 !important;
    }

    #lightbox-toolbar {
        display: flex !important;
        flex-wrap: nowrap !important; /* FORCE NO WRAP to keep X on the same line */
        justify-content: space-between !important; /* Distribute buttons evenly */
        width: 100% !important; /* Utilize full available width */
        padding: 2px !important; /* Reduced container padding */
        gap: 3px !important; /* Tighter gap between buttons */
    }

    #lightbox-toolbar button,
    #lightbox-toolbar a {
        min-width: 32px !important; /* Reduced from 38px to fit all icons */
        height: 34px !important; /* Slightly shorter to maintain proportion */
        padding: 0 4px !important; /* Minimal internal padding */
        font-size: 0.9rem !important; /* Slightly smaller icons */
        flex-shrink: 1 !important; /* Allow buttons to shrink on very small screens */
        border-radius: 6px !important;
    }

    /* Special treatment for the MENU button to fit the text */
    #lightbox-help-btn {
        font-size: 0.75rem !important; /* Smaller font size */
        padding: 0 6px !important; /* Less lateral padding */
        letter-spacing: 0px !important;
    }
    
    #lightbox-toolbar::-webkit-scrollbar {
        display: none; /* Hide scrollbar for Chrome/Safari */
    }

    /* Adjust content area to account for smaller header */
    #lightbox-content {
        padding: 4rem 0.5rem 5rem !important; 
    }
    
}

/* --- CSS RULE: Widen move panel on desktop screens --- */
@media (min-width: 1025px) {
    #drop-zone-panel {
        width: 650px;
        max-width: 90vw;
        /* Adds a limit for very large screens */
    }
}

/* Shortcuts Help Popup */
#shortcuts-help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#shortcuts-help-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.shortcuts-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 800px;           
    max-width: 95vw;
    max-height: 85vh;       
    display: flex;          
    flex-direction: column; 
    overflow: hidden;
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-hover);
    flex-shrink: 0; 
}

.shortcuts-header .close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.5rem;
    transition: color 0.2s;
}
.shortcuts-header .close-btn:hover {
    color: var(--danger-color);
}

/* --- SHORTCUTS HELP LAYOUT --- */
.shortcuts-content {
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    overflow-y: auto;
    align-content: flex-start;
}
.sc-column {
    flex: 1 1 220px;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.sc-header {
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
    padding-bottom: 4px;
    font-size: 0.95rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sc-sub {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: none;
    font-weight: normal;
    margin-top: 2px;
}
.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2px;
}

@media (max-width: 768px) {
    .shortcuts-panel {
        width: 95vw;
    }
    .shortcuts-content {
        grid-template-columns: 1fr;
    }
}

.shortcut-item .key {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 0 var(--border-color);
    font-size: 0.9rem;
}

.shortcut-item .desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* standard UI (Navigating/Selecting from  OS) */
.shortcut-item .key.std {
    background: rgba(0, 123, 255, 0.15); /* Blue Tint */
    border-color: rgba(0, 123, 255, 0.4);
    color: #89CFF0; /* Light Blue */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* --- BATCH RATING MODAL --- */
#batch-rating-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px);
    z-index: 10500; display: none; justify-content: center; align-items: center;
}
#batch-rating-overlay.visible { display: flex; }
.batch-rating-panel {
    background: var(--surface-color); border: 1px solid var(--primary-color);
    border-radius: 16px; padding: 2rem; width: 400px; max-width: 90vw;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8); text-align: center;
    transform: scale(0.9); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#batch-rating-overlay.visible .batch-rating-panel { transform: scale(1); }

.batch-rating-stars {
    display: flex; justify-content: center; gap: 10px; margin: 20px 0; font-size: 3rem;
}
.batch-rating-stars span {
    cursor: pointer; color: rgba(255, 255, 255, 0.15); transition: all 0.2s ease; line-height: 1;
}
.batch-rating-stars span:hover {
    color: rgba(255, 255, 255, 0.5); transform: scale(1.2);
}
.batch-rating-stars span.active {
    color: var(--favorite-color); text-shadow: 0 0 20px rgba(255, 193, 7, 0.6);
}

/* --- SMART DIALOG (Custom Alert/Confirm/Prompt) --- */
#smart-dialog-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7); /* Dark dimming */
    backdrop-filter: blur(8px);      /* Heavy blur behind */
    z-index: 10000; /* Highest priority */
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#smart-dialog-overlay.visible {
    display: flex;
    opacity: 1;
}

.smart-dialog-panel {
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--primary-color); /* Blue accent on top */
    border-radius: 16px;
    padding: 2rem;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Nice bounce effect */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overscroll-behavior: contain !important;
}

#smart-dialog-overlay.visible .smart-dialog-panel {
    transform: scale(1);
}

#sd-title {
    margin: 0;
    font-size: 1.4rem;
    color: white;
    font-weight: 700;
}

#sd-message {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.5;
}

.sd-text-input {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.sd-text-input:focus {
    border-color: var(--primary-color);
    background: rgba(0,0,0,0.5);
}

.sd-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.sd-actions button {
    min-width: 80px;
}

/* --- SMART DIALOG BUTTON FOCUS STATES --- */

.sd-actions button:focus {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    transform: scale(1.08) !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5) !important;
    z-index: 10;
    position: relative;
}

/* General style when any button in the dialog receives keyboard focus */
.sd-actionsxx button:focus {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    transform: scale(1.05) !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4) !important;
    position: relative; 
    /* Ensure the focused button stays on top of neighbors when scaled */
    z-index: 1; 
}

/* Specific focus style for the DELETE/DANGER button */
.sd-actions .btn-reset:focus {
    background-color: #ff4d4d !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.6) !important;
}

/* Specific focus style for the STANDARD CONFIRM button */
.sd-actions .active-blue:focus {
    background-color: #007bff !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.6) !important;
}

/* Specific focus style for the CANCEL button */
.sd-actions button:not(.active-blue):not(.btn-reset):focus {
    background-color: var(--surface-hover) !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2) !important;
}

/* --- LIGHTBOX SHORTCUTS BAR --- */
#lightbox-shortcuts {
    display: none !important; /* TEMPORARILY HIDDEN BY REQUEST */
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    gap: 12px;
    align-items: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 2005;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

#lightbox-shortcuts.ui-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

.kb-group {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem; 
    font-weight: 500;
}

/* Special class to highlight Quick Delete */
.kb-danger {
    color: #ff6b6b;
    font-weight: 700;
}

.kb-key {
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.1) 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 1px 5px;
    min-width: 18px;
    text-align: center;
    font-family: monospace;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 2px 0 rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
    font-size: 0.75rem;
}

.kb-separator {
    width: 1px;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 2px;
}

/* IMPORTANT: Hide on Mobile */
@media (max-width: 1024px) {
    #lightbox-shortcuts { display: none !important; }
}

/* --- LIGHTBOX LOADER --- */
.lightbox-loader {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-bottom-color: var(--primary-color); /* Uses the theme's blue color */
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    /* Perfect centering considering the transformation */
    margin-top: -25px; 
    margin-left: -25px;
    z-index: 15; /* Above the image while loading */
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}        

/* --- GENERATION DATA DASHBOARD --- */
.gen-dashboard {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.gen-section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Prompts */
.gen-prompt-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #eee;
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.gen-prompt-box.positive {
    border-left: 3px solid var(--success-color);
}

.gen-prompt-box.negative {
    border-left: 3px solid var(--danger-color);
    color: #ffcccc;
}

.copy-prompt-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-muted);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.copy-prompt-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Tech Grid - Updated Layout */
.gen-stats-grid {
    display: grid;
    /* Wider columns to accommodate long seeds */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); 
    gap: 10px;
}

.gen-stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    /* Relative positioning needed for absolute elements if any */
    position: relative; 
}

.gen-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    /* Flexbox to align Label text and Copy button */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gen-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    
    /* CRITICAL FIX: Allow long strings (like Seeds) to wrap to the next line */
    white-space: normal; 
    word-break: break-all; 
    line-height: 1.2;
}

.gen-stat-value.seed { color: var(--favorite-color); font-family: monospace; }
.gen-stat-value.model { color: var(--primary-color); word-break: break-word; }

/* Mini Copy Button for Stats (Seed, etc.) */
.stat-copy-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 4px;
    transition: color 0.2s;
}

.stat-copy-btn:hover {
    color: white;
    transform: scale(1.1);
}

/* LoRA Chips */
.gen-lora-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.gen-lora-chip {
    background: rgba(155, 48, 255, 0.15);
    border: 1px solid var(--ai-color);
    color: #f0a0ff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.gen-lora-val {
    background: rgba(0,0,0,0.3);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: white;
}

/* --- INPUT MEDIA IN NODE SUMMARY --- */
.input-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-media-card {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-media-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-size: 0.95rem;
    word-break: break-all;
    text-align: center;
}

.input-media-preview {
    width: 100%;
    height: 300px; 
    object-fit: contain;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Audio player styling specific */
audio.input-media-preview {
    height: 50px;
    margin-top: auto;
    margin-bottom: auto;
}

.input-media-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    margin-top: auto;
}

.input-media-btn {
    flex: 1;
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.input-media-btn:hover {
    background: var(--primary-hover);
    text-decoration: none;
}

.input-media-btn.secondary {
    background: var(--surface-color);
    border-color: var(--border-color);
}
.input-media-btn.secondary:hover {
    background: rgba(255,255,255,0.1);
}

@media (max-width: 768px) {
    .input-media-grid {
        grid-template-columns: 1fr;
    }
    .input-media-preview {
        height: 200px; /* Smaller on mobile */
    }
}

.ai-input-wrapper {
    position: relative;
    width: 100%;
}

#ai-search-clear-text {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

#ai-search-clear-text:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* --- LAYOUT MOBILE HEADER (Filtri + AI) --- */
.mobile-header-row {
    display: none; /* Hidden on desktop */
    gap: 10px;
    margin-bottom: 1rem;
    width: 100%;
}

/* --- STILI AI BANNER (DESKTOP & MOBILE) --- */
.ai-banner {
    background: var(--ai-surface);
    border-bottom: 1px solid var(--ai-color);
    padding: 1rem 2rem;
    /* DESKTOP DEFAULT: Flexbox su una riga */
    display: flex; 
    align-items: center;
    justify-content: space-between;
    color: var(--ai-color);
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 0, 255, 0.2);
    animation: glow 2s infinite alternate;
}

.ai-banner-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    overflow: hidden; /* For desktop */
    white-space: nowrap; /* For desktop */
    text-overflow: ellipsis; /* For desktop */
    margin-right: 15px;
}

.ai-query-part {
    color: white;
    margin-left: 5px;
}

.ai-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* --- LAYOUT MOBILE AI BANNER (GRID) --- */
@media (max-width: 768px) {
    .ai-banner, .global-search-banner {
        padding: 12px;
        /* Switch to Grid for precise positional control */
        display: grid !important; 
        grid-template-columns: 1fr auto; /* Column 1: Label, Column 2: Buttons */
        gap: 10px 0; /* Vertical space between rows */
        height: auto;
    }

    .ai-banner-title {
        /* TRICK: display: contents removes the container div from the layout,
           so its children (span scope and span query) become direct children of the .ai-banner Grid */
        display: contents !important; 
    }

    /* ROW 1, COLUMN 1: Label (e.g. "🧠 Global") */
    .ai-scope-part {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
        font-size: 0.95rem;
        white-space: nowrap;
    }

    /* ROW 1, COLUMN 2: Buttons (Edit/Exit) */
    .ai-banner-actions {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
    }
    
    /* Slightly more compact buttons on mobile */
    .ai-banner-actions button {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    /* ROW 2: User query (Full width) */
    .ai-query-part {
        grid-column: 1 / -1; /* Takes up all columns */
        grid-row: 2;
        margin-left: 0;
        white-space: normal; /* Allows line breaks */
        word-break: break-word;
        background: rgba(0,0,0,0.3); /* Dark background to stand out */
        padding: 8px 10px;
        border-radius: 8px;
        border-left: 3px solid var(--ai-color);
        font-weight: normal;
        font-size: 1rem;
        line-height: 1.4;
    }
}

/* --- CAPTION (Start/Middle/End) --- */
.ai-caption-card {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--ai-color);
    border-radius: 0 8px 8px 0;
    margin-bottom: 15px;
    padding: 0;
    overflow: hidden;
    transition: background 0.3s;
}

.ai-caption-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ai-card-header {
    background: rgba(255, 0, 255, 0.15);
    color: var(--ai-color);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    padding: 5px 10px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-card-body {
    padding: 10px 12px;
    color: #ddd;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Decorative icons for frames */
.ai-card-header::before {
    content: '⏱️';
    font-size: 0.9rem;
}
/* --- MODAL INFO AI --- */
#ai-info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#ai-info-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.ai-info-panel {
    background: #111;
    border: 2px solid var(--ai-color); /* Fuchsia Border */
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.25); /* Glow */
    text-align: center;
    color: #eee;
}

.ai-info-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #888;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.ai-info-close:hover { color: var(--ai-color); }

.ai-hero-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px var(--ai-color));
}

.ai-info-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 0%, var(--ai-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-info-text {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: #ccc;
}

.ai-comparison-box {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
    border-left: 4px solid var(--ai-color);
}

.ai-badge-light { color: var(--success-color); font-weight: bold; }
.ai-badge-full { color: var(--ai-color); font-weight: bold; }

.ai-cta-btn {
    display: inline-block;
    background: linear-gradient(90deg, var(--ai-color) 0%, #a0f 100%);
    color: white;
    text-decoration: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 5px 15px rgba(180, 0, 255, 0.4);
}

.ai-cta-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(180, 0, 255, 0.6);
}

/* ---  MORE MODAL INFO AI --- */
.ai-status-alert {
    background: rgba(255, 50, 50, 0.1);
    border: 1px solid rgba(255, 50, 50, 0.4);
    color: #ffcccc;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    display: inline-block;
    width: 100%;
}

.ai-status-alert code {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    font-family: monospace;
    border: 1px solid rgba(255,255,255,0.1);
}

.ai-steps-list {
    text-align: left;
    margin: 1.5rem 0;
    padding-left: 1.5rem;
    color: #ddd;
}

.ai-steps-list li {
    margin-bottom: 0.8rem;
}

.ai-steps-list strong {
    color: var(--ai-color);
}
/* --- STILI PER IL BLOCCO READ MORE (ACCORDION) --- */
.ai-details {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin: 1.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
    overflow: hidden;
    transition: background 0.3s;
}

.ai-details:hover {
    background: rgba(255, 255, 255, 0.06);
}

.ai-details summary {
    padding: 12px 15px;
    cursor: pointer;
    font-weight: bold;
    color: var(--ai-color);
    list-style: none; /* Hides default triangle */
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

/* Removes default marker on Safari/Chrome */
.ai-details summary::-webkit-details-marker {
    display: none;
}

/* Custom animated arrow */
.ai-details summary::after {
    content: '▼';
    font-size: 0.7rem;
    color: #888;
    transition: transform 0.3s ease;
}

.ai-details[open] summary::after {
    transform: rotate(180deg);
    color: var(--ai-color);
}

.ai-details-content {
    padding: 0 15px 15px 15px;
    color: #ccc;
    font-size: 1.05rem;
    line-height: 1.6;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 5px;
    padding-top: 10px;
}

.ai-details-content em {
    color: #fff;
    font-style: italic;
}

.limit-warning-box {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid var(--favorite-color);
    color: var(--text-muted);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.limit-warning-icon {
    font-size: 1.2rem;
}

/* --- QUICK RESET FILTER ICON --- */
.filter-reset-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10; /* Ensure it stays on top */
}

.filter-reset-icon:hover {
    background: var(--danger-color);
    transform: scale(1.1);
}

/* --- POPOVER FIXED POSITIONING --- */
#options-popover,
#tools-popover,
#auto-refresh-popover {
    display: none;
    position: fixed;
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.9);
    z-index: 10000 !important;
    
    /* RESPONSIVE FIXES */
    width: 260px;          
    max-width: 85vw;       
    white-space: normal;   
    
    backdrop-filter: blur(10px);
    text-align: left;

    max-height: 70vh;  
    overflow-y: auto;  
    overscroll-behavior: contain;
}
#options-popover.visible,
#tools-popover.visible,
#auto-refresh-popover.visible {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Nice bounce effect */
}
/* --- MOBILE OPTIMIZATION FOR OPTIONS MENU --- */
@media (max-width: 768px) {
    #options-popover,
#tools-popover,
#auto-refresh-popover {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) scale(1) !important;
        width: 300px !important;
        max-width: 90vw !important;
        max-height: 80vh !important; /* More vertical space */
        border: 1px solid var(--primary-color) !important;
        box-shadow: 0 0 50px rgba(0,0,0,0.8) !important;
    }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Split button container */
.refresh-group {
    display: inline-flex;
    align-items: center;
    background: var(--workflow-color); /* Green background base */
    border-radius: 8px;
    border: 1px solid var(--workflow-color);
    position: relative; /* Anchor for popover */
}

#refresh-btn {
    background: transparent !important;
    border: none !important;
    color: white !important;
    padding: 0.5rem 0.8rem !important;
    border-radius: 8px 0 0 8px !important;
    margin: 0 !important;
}

#refresh-btn:hover {
    background: rgba(0,0,0,0.1) !important;
}

/* Separator */
.refresh-separator {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.3);
}

#refresh-options-btn {
    background: transparent !important;
    border: none !important;
    color: white !important;
    padding: 0.5rem 0.6rem !important;
    border-radius: 0 8px 8px 0 !important;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#refresh-options-btn:hover {
    background: rgba(0,0,0,0.2) !important;
}

/* --- AUTO-REFRESH ACTIVE INDICATOR --- */
.refresh-group.auto-active {
    /* Keep original border and shadow color for the button group */
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.4);
    border-color: var(--workflow-color);
}

.refresh-group.auto-active::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    /* Only the dot is red */
    background-color: #ff0000; 
    border-radius: 50%;
    box-shadow: 0 0 6px #ff0000;
    z-index: 10;
    /* Animation for pulsing effect */
    animation: pulse-dot-red 2s infinite;
    pointer-events: none;
}

/* Keyframes to make the red dot pulse */
@keyframes pulse-dot-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(255, 0, 0, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

/* ARROW and INPUTS on popover */
.ar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ar-row label { margin: 0; font-size: 0.9rem; cursor: pointer; color: var(--text-color); }
.ar-input { width: 60px; background: var(--glass-bg); border: 1px solid var(--glass-border); color: white; border-radius: 4px; padding: 4px; text-align: center; }

/* OPTIONS MENU STYLES */
.opt-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px; cursor: pointer; border-radius: 6px;
    background: rgba(255,255,255,0.05); border: 1px solid transparent;
    transition: all 0.2s;
}
.opt-item:hover { background: rgba(255,255,255,0.1); border-color: var(--primary-color); }
.opt-item.active { border-left: 3px solid var(--success-color); }
.opt-item.inactive { border-left: 3px solid var(--text-muted); opacity: 0.8; }
.opt-label { font-weight: 600; font-size: 0.9rem; color: var(--text-color); }
.opt-status { font-size: 0.75rem; font-weight: bold; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; }
.opt-status.on { background: var(--success-color); color: white; }
.opt-status.off { background: var(--surface-hover); color: var(--text-muted); border: 1px solid var(--glass-border); }

.opt-shortcut-hint { font-size: 0.7rem; color: var(--text-muted); margin: 10px 0 0 0; text-align: right; }

/* Video Overlay Icon */
.video-play-overlay {
    /* MOBILE DEFAULT: Centered, Big, Pass-through (Visual only) */
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 50px; height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.4rem;
    padding-left: 4px;
    z-index: 12; /* Above duration/badges */
    backdrop-filter: blur(2px);
    pointer-events: none; /* Mobile: Tap goes through to Lightbox */
    transition: all 0.2s;
}

/* DESKTOP OVERRIDE: Corner, Small, Clickable */
@media (min-width: 1025px) {
    .video-play-overlay {
        top: auto; 
        left: 10px; 
        bottom: 10px;
        transform: none; /* Reset center transform */
        
        width: 32px; height: 32px; /* Smaller */
        font-size: 0.9rem;
        padding-left: 2px;
        
        background: rgba(0, 0, 0, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.4);
        
        pointer-events: auto; /* Desktop: Clickable */
        cursor: pointer;
    }

    .video-play-overlay:hover {
        background: var(--primary-color);
        border-color: white;
        transform: scale(1.1);
    }
    
    /* Adjustment for Focus Mode to avoid overlapping the Checkmark (which moves to bottom-left) */
    body.focus-mode .gallery-item.selected .video-play-overlay {
        bottom: 40px; /* Move up slightly if selected in focus mode */
    }
}

@media (max-width: 768px) {
    .opt-shortcut-hint { display: none; }
}

/* --- SIDEBAR FOOTER (Version & Links) --- */
.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0; 
    transition: all 0.3s ease;
}

/* --- GITHUB INFO BADGE --- */
.sidebar-footer-promo {
    position: relative;
    margin-top: auto;
    padding: 10px 5px;
}

.github-promo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
}

.github-promo-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

/* Temporary close button (not persistent) */
.promo-close-x {
    position: absolute;
    top: 4px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    z-index: 5;
    padding: 2px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s;
}

.promo-close-x:hover {
    opacity: 1;
    color: var(--danger-color);
}

/* GitHub Promo Box Style */
.gh-icon {
    width: 28px;
    height: 28px;
    fill: var(--text-muted);
    transition: fill 0.3s;
    flex-shrink: 0;
}

.github-promo-link:hover .gh-icon {
    fill: #fff; /* Bright white on hover */
}

.promo-text {
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--text-muted);
    font-style: italic; /* Persuasive style */
}

.gold-highlight {
    color: var(--favorite-color); /* Gold */
    font-weight: 600;
    font-style: normal; /* Stand out from italic */
}

/* MINIMIZED STATE */
body.sidebar-minimized .brand-info { display: none !important; }
body.sidebar-minimized .sidebar-header { flex-direction: column; gap: 10px; margin-bottom: 0; }

/* When minimized, remove auto margin to center the logo */
body.sidebar-minimized .brand-link { margin-right: 0 !important; justify-content: center; gap: 0 !important; width: 100% !important; }

body.sidebar-minimized .brand-logo { margin: 0 !important; width: 30px; height: 30px; }
body.sidebar-minimized .sidebar-actions { flex-direction: column; width: 100%; }
body.sidebar-minimized #sidebar-expand-btn { display: none !important; }
body.sidebar-minimized #sidebar-minify-btn { width: 100%; border: none; }

/* Minimized Sidebar Handling */
body.sidebar-minimized .sidebar-footer {
    align-items: center;
    padding-top: 10px;
    gap: 10px;
}

body.sidebar-minimized .github-promo-link {
    padding: 10px;
    justify-content: center;
    border-color: transparent;
    background: transparent;
}
body.sidebar-minimized .promo-text {
    display: none; /* Hide text, show only icon */
}
body.sidebar-minimized .github-promo-link:hover {
    background: rgba(255, 255, 255, 0.1);
}
body.sidebar-minimized .github-promo-link:hover .gh-icon {
    fill: var(--favorite-color); /* Gold icon when minimized */
}

/* --- DESKTOP SIDEBAR MINIMIZED MODE --- */
:root {
    --sidebar-min-width: 60px;
}

#sidebar-minify-btn {
    display: flex; /* Flex to center icon */
    justify-content: center;
    width: 32px; /* Fixed width */
}

body.sidebar-minimized .sidebar {
    width: var(--sidebar-min-width);
    min-width: var(--sidebar-min-width);
    padding: 1.5rem 0.5rem; /* Reduced lateral padding */
    overflow: hidden; /* Hides overflowing content */
}

/* Only hide these elements inside the sidebar, not globally */
body.sidebar-minimized .sidebar h1,
body.sidebar-minimized .sidebar .folder-controls,
body.sidebar-minimized .sidebar .folder-tree-container,
body.sidebar-minimized .sidebar #create-folder-btn,
body.sidebar-minimized .sidebar #sidebar-expand-btn {
    display: none !important;
    opacity: 0; 
    transition: opacity 0.2s;
}

body.sidebar-minimized .sidebar-actions {
    flex-direction: column;
    width: 100%;
    align-items: center;
    gap: 0;
}

body.sidebar-minimized #sidebar-minify-btn {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 1.5rem;
}

.nav-btn {
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}
/* --- Highlight the focused button for keyboard navigation --- */
.nav-btn:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
    transform: scale(1.05); /* Slightly enlarge to show it's active */
}
.nav-btn-primary { background: var(--primary-color); color: white; }
.nav-btn-secondary { background: var(--surface-hover); color: var(--text-color); border: 1px solid var(--border-color); }
.nav-btn-cancel { background: transparent; color: var(--text-muted); }

.nav-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }

/* --- AI MANAGER STYLES (Nuovi) --- */
/* Deleted: #ai-manager-btn and hover - Overwritten by "UNIFIED AI BUTTONS" block later */

#ai-manager-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px);
    z-index: 5000; display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
#ai-manager-overlay.visible { opacity: 1; pointer-events: auto; }

.ai-manager-panel {
    background: var(--surface-color); border: 1px solid var(--ai-color); border-radius: 16px;
    width: 800px; max-width: 95vw; 
    max-height: 85vh; 
    display: flex; flex-direction: column;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.15); 
    position: relative;
}

.ai-manager-header {
    padding: 1rem 1.5rem; background: var(--ai-surface); border-bottom: 1px solid var(--ai-color);
    display: flex; justify-content: space-between; align-items: center;
}
.ai-manager-header h2 { margin: 0; color: white; display: flex; align-items: center; gap: 10px; font-size:1.4rem; }
.ai-manager-close { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }

.ai-manager-tabs { display: flex; border-bottom: 1px solid var(--border-color); background: var(--surface-hover); }
.ai-tab-btn {
    flex: 1; padding: 1rem; background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-weight: 600; transition: all 0.2s; border-bottom: 2px solid transparent;
}
.ai-tab-btn.active { color: var(--ai-color); border-bottom-color: var(--ai-color); background: rgba(255,0,255,0.05); }

.ai-manager-content { 
    padding: 1.5rem; 
    overflow-y: auto; 
    flex: 1; 
    min-height: 0; /* Fix Firefox flexbox */
}

#ai-manager-btn-desk {
    height: 42px !important; 
    margin-top: 0 !important;
}

.ai-tab-content { display: none; }
.ai-tab-content.active { display: block; }

.ai-queue-list-container {
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    max-height: 150px;
    overflow-y: auto;
}
.ai-queue-item {
    padding: 6px 10px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex; justify-content: space-between;
}
.ai-queue-item:last-child { border-bottom: none; }
/* AI Priority Item Style */
.ai-queue-item.priority {
    background: rgba(220, 53, 69, 0.15); /* Red tint */
    border-left: 3px solid var(--danger-color);
}
.ai-queue-item.priority span {
    color: #ffcccc;
    font-weight: 600;
}
.ai-status-bar {
    display: flex; gap: 20px; margin-bottom: 20px; background: var(--glass-bg);
    padding: 15px; border-radius: 8px; border: 1px solid var(--glass-border); flex-wrap: wrap;
}
.ai-stat-item { flex: 1; text-align: center; min-width: 120px; }
.ai-stat-val { font-size: 1.2rem; font-weight: bold; color: white; display: block; }
.ai-stat-lbl { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }

.ai-progress-wrapper { margin-bottom: 20px; }
.ai-progress-track { height: 12px; background: #333; border-radius: 6px; overflow: hidden; position: relative; }
.ai-progress-fill { height: 100%; background: var(--ai-gradient); width: 0%; transition: width 0.3s; }
.ai-progress-text { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-top: 5px; }

.ai-controls-row { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 15px; }
.ai-btn-action {
    padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border-color);
    background: var(--surface-hover); color: white; cursor: pointer; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.ai-btn-action:hover { filter: brightness(1.2); }
.ai-btn-pause { border-color: var(--favorite-color); color: var(--favorite-color); }
.ai-btn-danger { border-color: var(--danger-color); color: var(--danger-color); }

.watched-folder-item {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    /* Increased padding for better touch targets on mobile */
    padding: 12px 10px; 
    border-bottom: 1px solid var(--border-color);
}

.watched-folder-path { 
    font-family: monospace; 
    color: var(--text-color);
    /* FIX FOR LONG PATHS ON MOBILE: */
    word-break: break-all; /* Breaks long path strings */
    
    /* PRESERVE SPACES FIX: */
    white-space: pre-wrap;   /* Allows text wrapping AND preserves multiple spaces */
    
    line-height: 1.3;
    margin-right: 10px;    /* Space between text and Stop button */
}
.gpu-warning {
    background: rgba(220, 53, 69, 0.2); border: 1px solid var(--danger-color);
    color: #ffcccc; padding: 10px; border-radius: 6px; margin-bottom: 15px;
    display: none; align-items: center; gap: 10px;
}
.gpu-warning.visible { display: flex; }
.folder-action-btn.ai-index-btn { color: var(--ai-color); font-weight: bold; }

/* --- AI INDEX OPTIONS MODAL --- */
#ai-options-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6); z-index: 6000; display: none;
    justify-content: center; align-items: center; backdrop-filter: blur(3px);
}
#ai-options-modal.visible { display: flex; }

.ai-options-panel {
    background: var(--surface-color); border: 1px solid var(--ai-color);
    border-radius: 12px; padding: 20px; width: 400px; max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.ai-opt-header { font-size: 1.1rem; font-weight: bold; margin-bottom: 15px; color: white; display: flex; gap: 10px; align-items: center; }
.ai-opt-row { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.ai-opt-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: -5px; margin-bottom: 10px; display: block; line-height: 1.3;}
.ai-opt-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.ai-path-preview { font-family: monospace; background: rgba(0,0,0,0.3); padding: 5px; border-radius: 4px; font-size: 0.8rem; margin-bottom: 15px; word-break: break-all; color: var(--ai-color); }

/* --- AI MANAGER SETTINGS IMPROVEMENTS --- */
.ai-settings-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-setting-card {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-setting-card label {
    color: var(--ai-color);
    font-weight: bold;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-setting-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Fix for dark mode dropdowns (especially on mobile) */
.ai-setting-card select {
    background-color: var(--glass-bg);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
}

.ai-setting-card select option {
    background-color: var(--surface-color);
    color: white; /* Ensure text is visible in options */
}

.ai-setting-card input[type="checkbox"] {
    width: 20px; 
    height: 20px; 
    accent-color: var(--ai-color);
}

/* Modal Erase Button */
.nav-btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}
.nav-btn-danger-outline:hover {
    background: var(--danger-color);
    color: white;
}

/* --- FOLDER ACTION MENU (Restyled) --- */
.folder-menu-container {
    position: relative;
    margin-left: auto;
}

.folder-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1.1rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.folder-menu-btn:hover {
    color: var(--text-color);
    background: rgba(255,255,255,0.15);
    transform: scale(1.1);
}

.folder-dropdown {
    display: none;
    position: absolute;
    right: 0;
    
    /* Javascript will decide whether to use "top" (dropdown) or "bottom" (dropup) */
    top: 100%; 
    margin-top: 6px; 
    
    /* High Visibility Style */
    background: #2b2b2b; /* Lighter grey than sidebar to pop out */
    border: 1px solid rgba(255, 255, 255, 0.2); /* Sharper border */
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8); /* Deep shadow for 3D effect */
    
    z-index: 1000; /* Ensure strictly on top */
    min-width: 160px;
    padding: 6px; /* Internal padding for aesthetic */
    flex-direction: column;
    gap: 2px; /* Space between buttons */
}

.folder-dropdown.show {
    display: flex;
    animation: fadeIn 0.2s ease-out; /* Restore neutral animation */
}

.folder-dropdown button {
    background: transparent;
    border: none;
    color: #eeeeee; /* Bright white text */
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px; /* Rounded buttons inside */
    transition: background 0.2s, transform 0.2s;
    font-weight: 500;
}

.folder-dropdown button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px); /* Little visual feedback */
}

/* Specific style for AI Index button inside menu */
.folder-dropdown button[onclick*="indexFolder"] {
    color: var(--ai-color); /* Fuchsia text */
}
.folder-dropdown button[onclick*="indexFolder"]:hover {
    background: rgba(255, 0, 255, 0.15);
}

/* Specific style for Delete button inside menu */
.folder-dropdown button[onclick*="deleteFolder"] {
    color: #ff6b6b; /* Soft Red */
}
.folder-dropdown button[onclick*="deleteFolder"]:hover {
    background: rgba(220, 53, 69, 0.15);
}
.folder-dropdown.is-collection {
    min-width: 230px !important;
}

/* --- MENU BACKDROP (Safe Catcher) --- */
#folder-menu-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999; /* Right below the menu (1000) */
    background: transparent;
}
#folder-menu-backdrop.show {
    display: block;
}

/* --- MOBILE CONTEXT MENU (Bottom Sheet) --- */
@media (max-width: 768px) {
    #folder-menu-backdrop.show {
        background: rgba(0, 0, 0, 0.5); /* Darkens background on mobile */
        backdrop-filter: blur(2px);
    }
    
    .folder-dropdown.show {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 15px !important;
        padding-bottom: max(15px, env(safe-area-inset-bottom)) !important;
        background: #1a1a1a !important;
        border: 1px solid var(--border-color) !important;
        border-bottom: none !important;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.8) !important;
        z-index: 1000 !important;
        animation: slideUpMenu 0.3s cubic-bezier(0.175, 0.885, 0.32, 1) !important;
    }
    
    .folder-dropdown button {
        padding: 16px 12px !important;
        font-size: 1.05rem !important;
    }
}

/* Watched Folder Indicator */
.folder-link.ai-watched::before {
    /* This targets the emoji inside the text if we wrap it, 
       but simpler is to handle it in JS by changing the string */
}

/* --- LIGHTBOX MOBILE FIX --- */
/* Add padding at the bottom to ensure last line is not cut off by borders/screen edge */
#lightbox-ai-text-scroll {
    padding-bottom: 40px !important; 
}

/* --- AI MANAGER TOGGLE BUTTON --- */
#ai-toggle-pause {
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

/* State: Running (Button shows Pause option) */
#ai-toggle-pause.state-running {
    background: var(--surface-hover);
    border-color: var(--favorite-color);
    color: var(--favorite-color);
}

/* State: Paused (Button shows Resume option - GREEN) */
#ai-toggle-pause.state-paused {
    background: var(--success-color); /* Green Background */
    border-color: #1a9c77;
    color: white; /* White text */
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.4);
}

/* Text Color for Status Label */
.ai-stat-val.status-paused {
    color: var(--favorite-color) !important; /* Yellow */
}

/* ========================================= */
/* === UNIFIED AI BUTTONS STYLE (CLEAN) === */
/* ========================================= */

/* Target: AI Manager (Top), AI Search (Desktop & Mobile) */
#ai-manager-btn,
#ai-search-toggle-desktop,
#ai-search-toggle-mobile,
.filter-bar button.ai-btn {
    background: var(--glass-bg) !important;           /* Match Filters Button */
    border: 1px solid var(--glass-border) !important; /* Match Filters Button */
    color: var(--ai-color) !important;                /* Text remains Fuchsia */
    border-radius: 8px !important;
    padding: 0.75rem 1rem !important;                 /* Uniform padding */
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none !important;                      /* Remove old glow */
    text-shadow: none !important;
    
    /* Flex layout for icons */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: auto !important;                          /* Remove fixed height */
    margin-right: 5px;
}

/* Hover State: Standard Surface change + Subtle Fuchsia Border */
#ai-manager-btn:hover,
#ai-search-toggle-desktop:hover,
#ai-search-toggle-mobile:hover,
.filter-bar button.ai-btn:hover {
    background: var(--surface-hover) !important;
    border-color: var(--ai-color) !important;         /* Only border lights up */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
}

/* Active/Pressed State */
#ai-search-toggle-desktop:active,
#ai-search-toggle-mobile:active {
    background: var(--surface-color) !important;
    transform: translateY(0);
}

/* Remove the old specific glow animation from the Manager button if present */
#ai-manager-btn:hover {
    box-shadow: none;
}

@media (max-width: 768px) {
    /* Show header row on mobile */
    .mobile-header-row {
        display: flex; 
    }
    
    #mobile-filter-toggle {
        display: block; /* Make sure it is visible */
        margin-bottom: 0 !important; /* Removes old margin */
        flex-grow: 1; 
        text-align: center;
        width: auto; /* Reset width */
    }

    #ai-search-toggle-desktop {
        display: none !important;
    }
    
    /* Hide the Desktop Toggle */
    #search-toggle-desktop {
        display: none !important;
    }

    #ai-search-toggle-mobile {
        background: var(--glass-bg);
        border: 1px solid var(--ai-color);
        color: white;
        border-radius: 8px;
        padding: 0 1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0; 
        transition: background 0.3s;
    }
    
    #ai-search-toggle-mobile:active {
        background: var(--ai-surface);
    }
}

/* --- LIGHTBOX BOTTOM CONTROLS --- */
#lightbox-bottom-controls {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    z-index: 2010;
    width: 100%;
    pointer-events: none; /* Let clicks pass through empty space */
}

#lightbox-ui-toggle {
    pointer-events: auto; /* Re-enable clicking for the button */
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    border-radius: 50px; /* Pill shape */
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    width: auto; /* Let it grow with text */
    height: auto;
}

#lightbox-ui-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

/* Hidden state for toolbar logic remains same */
#lightbox-toolbar.ui-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}
#lightbox-toolbar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Clean View for Header (No background) */
#lightbox-header.clean-view {
    background: transparent !important;
    backdrop-filter: none !important;
    pointer-events: none;
}
/* Hide text when Clean View (Hidden Toolbar) is active */
#lightbox-header.clean-view #lightbox-title,
#lightbox-header.clean-view #lightbox-folder-name {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Hidden state for toolbar (opacity allows transition, pointer-events prevents clicking) */
#lightbox-toolbar.ui-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

/* Smooth transition for toolbar */
#lightbox-toolbar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- CLEAN VIEW STATE (No Blur/Background) --- */
#lightbox-header.clean-view {
    background: transparent !important;
    backdrop-filter: none !important;
    pointer-events: none; /* Allows clicking through the empty header area */
}

/* Ensure the Toggle Button remains interactive even in clean view */
#lightbox-header.clean-view .lightbox-info-row {
    pointer-events: auto;
}

/* Optional: Hide title in clean view to free up more space, 
   remove this part if you want to keep the title floating */
#lightbox-header.clean-view #lightbox-title,
#lightbox-header.clean-view #lightbox-folder-name {
    text-shadow: 0 0 2px black; /* Add shadow to read text without background */
}

/* --- HIDE AVG TIME STAT (Requested) --- */
.ai-status-bar .ai-stat-item:nth-child(3) {
    display: none !important;
}

/* ========================================================= */
/* === DESKTOP LIGHTBOX DOCKED PANELS (SIDE-BY-SIDE) === */
/* ========================================================= */
@media (min-width: 1025px) {
    /* 1. Make overlays transparent and click-through */
    body.lightbox-open #file-info-overlay,
    body.lightbox-open #node-summary-overlay {
        background: transparent !important;
        backdrop-filter: none !important;
        pointer-events: none; /* Let clicks pass through to lightbox */
    }

    /* 2. Anchor Right Panel (Rating/Comments) */
    body.lightbox-open .file-info-card {
        position: absolute;
        right: 0; top: 0;
        height: 100vh !important; max-height: 100vh !important;
        width: 420px; /* Slightly wider for comfort */
        border-radius: 0;
        border: none; border-left: 1px solid var(--border-color);
        transform: translateX(100%);
        pointer-events: auto; /* Re-enable clicks on the panel itself */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        margin: 0;
        animation: none !important; /* Disable popup bounce */
    }

    /* 3. Anchor Left Panel (Node Summary) */
    body.lightbox-open .node-summary-panel {
        position: absolute;
        left: 0; top: 0;
        height: 100vh !important; max-height: 100vh !important;
        width: 420px;
        border-radius: 0;
        border: none; border-right: 1px solid var(--border-color);
        transform: translateX(-100%);
        pointer-events: auto;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        margin: 0;
    }

    /* Slide them in when active */
    body.lightbox-open #file-info-overlay.visible .file-info-card { transform: translateX(0); }
    body.lightbox-open #node-summary-overlay.visible .node-summary-panel { transform: translateX(0); }

    /* 4. Smoothly squeeze the central content (Header, Image, Controls) */
    #lightbox-content, #lightbox-header, #lightbox-bottom-controls {
        transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    body.lightbox-open.lb-nodes-docked #lightbox-content,
    body.lightbox-open.lb-nodes-docked #lightbox-header,
    body.lightbox-open.lb-nodes-docked #lightbox-bottom-controls { padding-left: 420px; }
    
    body.lightbox-open.lb-info-docked #lightbox-content,
    body.lightbox-open.lb-info-docked #lightbox-header,
    body.lightbox-open.lb-info-docked #lightbox-bottom-controls { padding-right: 420px; }

    /* 5. Keep Navigation Arrows accessible */
    #lightbox-prev, #lightbox-next { transition: left 0.3s, right 0.3s; }
    body.lightbox-open.lb-nodes-docked #lightbox-prev { left: 440px; }
    body.lightbox-open.lb-info-docked #lightbox-next { right: 440px; }
    
    /* 6. Keep Shortcuts Bar Centered */
    body.lightbox-open.lb-nodes-docked.lb-info-docked #lightbox-shortcuts { margin-left: 0; }
    body.lightbox-open.lb-nodes-docked:not(.lb-info-docked) #lightbox-shortcuts { margin-left: 210px; }
    body.lightbox-open.lb-info-docked:not(.lb-nodes-docked) #lightbox-shortcuts { margin-left: -210px; }
}

/* New Styles for Modal Toggle */
#ai-opt-watched-controls {
    display: none;
    background: rgba(255, 193, 7, 0.1); /* Yellow tint */
    border: 1px solid var(--favorite-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

/* --- AI INDEXING DOTS ANIMATION --- */
.ai-working-dots {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    height: 10px;
}

.ai-dot {
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background-color: var(--success-color); /* Green to match Indexing status */
    border-radius: 50%;
    opacity: 0.2;
    animation: dotFade 1.4s infinite ease-in-out both;
}

.ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dot:nth-child(2) { animation-delay: -0.16s; }
.ai-dot:nth-child(3) { animation-delay: 0s; }

@keyframes dotFade {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* --- AI SETTINGS MODERN UI --- */
.ai-options-group {
    margin-bottom: 25px;
}

.ai-group-title {
    color: var(--ai-color);
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-group-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    line-height: 1.4;
}

.ai-radio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

/* Hide the actual radio input */
.ai-radio-input {
    display: none;
}

/* The Visual Card */
.ai-radio-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.ai-radio-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* Selected State */
.ai-radio-input:checked + .ai-radio-card {
    border-color: var(--ai-color);
    background: rgba(255, 0, 255, 0.1);
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.2);
}

.ai-opt-name {
    font-weight: bold;
    color: white;
    font-size: 1rem;
    margin-bottom: 4px;
}

.ai-opt-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Checkmark Icon for selected item */
.ai-check-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    background: var(--ai-color);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: bold;
}

.ai-radio-input:checked + .ai-radio-card .ai-check-icon {
    display: flex;
}

/* --- LIGHTBOX TOGGLE BUTTON POSITIONING --- */

/* 1. Base Style & MOBILE Position (Bottom Center) */
#lightbox-ui-toggle {
    position: fixed;             
    bottom: 60px;                
    left: 50%;                   
    transform: translateX(-50%); 
    z-index: 2020;               
    
    visibility: hidden;
    pointer-events: none;
    opacity: 0;

    /* Visual Style */
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    border-radius: 50px;
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    white-space: nowrap;
}

#lightbox-overlay.visible #lightbox-ui-toggle {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
}

#lightbox-ui-toggle:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: var(--ai-color);
    color: var(--ai-color);
    transform: translateX(-50%) translateY(-2px); 
}

/* Hide the old container */
#lightbox-bottom-controls {
    pointer-events: none;
    height: 0;
    margin: 0;
    padding: 0;
}

/* 2. DESKTOP Override (Top Left Corner) */
@media (min-width: 1025px) {
    #lightbox-ui-toggle {
        top: 30px;       
        left: 30px;      
        bottom: auto;    
        transform: none; 
    }
    
    #lightbox-ui-toggle:hover {
        transform: translateY(-2px); 
    }
}

/* --- NEW GLASS TOOLBAR SYSTEM --- */

/* 1. LAYOUT CONTAINER (Desktop) */
.toolbar-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0.6rem 2rem 1rem 2rem; 
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Pushes elements to the right (e.g. AI Manager) */
.push-right { margin-left: auto; }

/* 2. BASE GLASS BUTTON STYLE (Updated for alignment) */
.glass-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0 1rem; /* Horizontal padding only, height handles vertical */
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    height: 42px; /* Increased slightly and Fixed for perfect alignment */
    line-height: 1; /* Reset line height */
    white-space: nowrap;
    text-decoration: none;
    box-sizing: border-box; /* Includes border in height calculation */
}

.glass-btn:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.glass-btn:active { transform: translateY(0); }

/* Active Styles (when pressed or selected) */
.glass-btn.active-blue {
    background: rgba(50, 150, 255, 0.4); 
    border-color: var(--primary-color);
    color: white;
}
.glass-btn.active-fuxia {
    background: rgba(255, 0, 255, 0.15);
    border-color: var(--ai-color);
    color: var(--ai-color);
}

/* 3. BUTTON GROUPS (Merged buttons: Sort, Refresh) */
.btn-group {
    display: inline-flex;
    border-radius: 8px;
    overflow: hidden; /* Clips internal corners */
    border: 1px solid var(--glass-border); /* Single border around the group */
}

.btn-group .glass-btn {
    border: none; /* Removes individual borders */
    border-radius: 0; /* Removes radius */
    border-right: 1px solid var(--glass-border); /* Separator */
    height: 36px; /* Compensate for group border */
    margin: 0;
}
.btn-group .glass-btn:last-child { border-right: none; }
.btn-group:hover { border-color: var(--text-muted); }

/* 4. REFRESH GROUP SPECIFIC (Red Dot) */
.refresh-group-wrapper {
    position: relative; /* Anchor for the dot */
    display: inline-flex;
}

.refresh-group-wrapper.auto-active::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    background-color: #ff0000;
    border-radius: 50%;
    box-shadow: 0 0 6px #ff0000;
    z-index: 10;
    animation: pulse-dot-red 2s infinite;
    pointer-events: none;
}

/* 5. FILTER BUTTON SPECIFIC (Merged Fix: Style + Alignment) */
.filter-main-btn {
    min-width: 120px; 
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.filter-reset-badge {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    flex-shrink: 0 !important; 
    position: static !important; 
    transform: none !important; 
}
.filter-reset-badge:hover { 
    background: var(--danger-color); 
    color: white; 
}

/* --- FOCUS MODE STYLES --- */

/* Hide UI clutter */
body.focus-mode .item-info,
body.focus-mode .selection-checkmark,
body.focus-mode .file-metadata,
body.focus-mode .file-scanned-time,
body.focus-mode .workflow-badge { 
    display: none !important;
}

/* --- FOCUS MODE FAVORITE INDICATOR --- */
/* Shows a gold star in the bottom-left corner when in Focus Mode */
body.focus-mode .gallery-item:has(.favorite-btn.favorited) .thumbnail-wrapper::after {
    content: '⭐';
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 15;
    font-size: 1.1rem;
    /* High contrast drop shadow to remain visible on any image background */
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 1)) drop-shadow(0 0 2px rgba(0, 0, 0, 1));
    pointer-events: none; /* Ensures the star doesn't block clicks/selection */
    transition: bottom 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* SMART STACKING: If the item is SELECTED, move the star up to make room for the Checkmark */
body.focus-mode .gallery-item.selected:has(.favorite-btn.favorited) .thumbnail-wrapper::after {
    bottom: 42px; /* Positions the star exactly above the selection circle */
}

/* BASE STATE: 100% Scale, 100% Opacity, No filters */
body.focus-mode .gallery-item {
    border-radius: 4px; /* Sharper corners for pro look */
    border: none;
    transition: none; /* Instant feedback, no lag */
    opacity: 1 !important;
    filter: none !important;
    transform: none !important; /* NO SHRINKING */
    overflow: visible !important; /* Allow border to bleed out */
}

/* Hover: Only Z-index change to bring it to top, no movement */
body.focus-mode .gallery-item:hover {
    z-index: 50;
    outline: 1px solid rgba(255,255,255,0.3); /* Subtle hint */
}

/* SELECTED STATE: MASSIVE HIGH-CONTRAST FRAME */
body.focus-mode .gallery-item.selected {
    /* 
       LAYERED SHADOW TRICK FOR THICK BORDERS:
       1. 0px - 4px:  SOLID WHITE (Contrast layer against dark images/bg)
       2. 4px - 10px: SOLID PRIMARY COLOR (The actual selection indicator)
       3. 10px+:      Drop Shadow (Lift effect)
    */
    box-shadow: 
        0 0 0 4px #ffffff, 
        0 0 0 10px #FF00FF,
        0 10px 40px rgba(0,0,0,0.8);
    
    z-index: 100; /* Must be on top of everything to show the border overlap */
    transform: none !important;
}

/* Ensure thumbnail fills the card perfectly */
body.focus-mode .thumbnail-wrapper {
    border-bottom: none;
    height: 100%;
    border-radius: 4px;
}

/* Active Focus Button Style */
/* --- FOCUS MODE BADGES --- */
.focus-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    margin-left: 8px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.focus-badge.on {
    background: var(--success-color);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.focus-badge.off {
    background: rgba(220, 53, 69, 0.2); /* Red tint transparent */
    color: #ff6b6b; /* Soft red text */
    border: 1px solid var(--danger-color);
}

/* Hover effect specific for the button to ensure readability */
#focus-mode-btn:hover .focus-badge.off {
    background: var(--danger-color);
    color: white;
}

/* --- FOCUS MODE CHECKMARK (Bottom-Left) --- */

/* 1. Force visibility ONLY when selected */
body.focus-mode .gallery-item.selected .selection-checkmark {
    display: flex !important;
    
    /* 2. Positioning: Bottom Left */
    left: 8px;
    bottom: 8px;
    right: auto; /* Reset default right position */
    top: auto;
    
    /* 3. Style: White Circle with Fuchsia Icon & Border */
    background-color: #ffffff;
    color: #FF00FF;           /* The Checkmark Color */
    border: 2px solid #FF00FF; /* The Ring Color */
    
    /* 4. Size & Shape */
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: 900; /* Extra Bold Checkmark */
    border-radius: 50%;
    
    /* 5. Polish */
    box-shadow: 0 4px 10px rgba(0,0,0,0.6); /* Drop shadow to pop from image */
    z-index: 101; /* Stay on top of the massive border */
    transform: scale(1);
}

/* Optional: Hover effect on the checkmark itself */
body.focus-mode .gallery-item.selected .selection-checkmark:hover {
    transform: scale(1.1);
    cursor: pointer;
}

/* --- MOBILE LAYOUT OVERRIDES --- */
.mobile-only { display: none !important; }
        
/* Special case for inline-elements (like spans/icons) */
body.dam-mode-active span.dam-only { display: inline !important; }
body.dam-mode-active button.dam-only { display: inline-flex !important; }
body.dam-mode-active div.dam-only { display: block !important; }

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: flex !important; }

    .toolbar-container {
        padding: 0.5rem 1rem;
        gap: 10px;
    }

    /* ROW 1: Mobile Header (Breadcrumbs + AI Icon) */
    .mobile-header-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    /* ROW 2: Big Actions (Filters | AI Search) */
    .mobile-big-actions {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 50% 50% */
        gap: 10px;
        width: 100%;
    }
    .mobile-big-actions .glass-btn {
        width: 100%;
        justify-content: center;
    }

    /* ROW 3: Icon Toolbar (Scrollable or Grid) */
    .mobile-icon-toolbar {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        /* Increased top padding to 8px to allow the red dot to float without being cut */
        padding: 8px 4px 5px 4px; 
        width: 100%;
        justify-content: space-between;
        /* Ensure overflow doesn't clip the shadow/dot */
        overflow-y: visible; 
    }

    /* Square buttons for mobile toolbar */
    .mobile-icon-toolbar .glass-btn, 
    .mobile-icon-toolbar .btn-group .glass-btn {
        padding: 0;
        width: 40px;
        height: 40px;
        font-size: 1.2rem; /* Larger icons */
    }
    
    /* Exception: Refresh group must contain two small buttons */
    /* Exception: Button Groups (Sort/Refresh) need flexibility */
    .mobile-icon-toolbar .btn-group {
        width: auto;
        flex-shrink: 0;
    }
    
    .mobile-icon-toolbar .btn-group .glass-btn {
        /* CHANGED: Removed fixed width (35px) to allow arrows to fit */
        width: auto !important; 
        min-width: 44px !important; /* Minimum touch target size */
        padding: 0 8px !important;  /* Add padding so arrow isn't glued to edge */
        flex-grow: 0 !important;
    }
    
}

/* --- LIGHTBOX HELP OVERLAY --- */
#lightbox-help-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 5000; /* Above Lightbox */
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#lightbox-help-overlay.visible {
    display: flex;
    opacity: 1;
}

/* Ensure keys in help match icon style */
#lightbox-help-overlay .key {
    font-size: 1.2rem;
    min-width: 40px;
    background: rgba(255,255,255,0.05);
}

/* --- FIX MOBILE FOLDER SCROLL --- */
@media (max-width: 1024px) {
    .folder-tree-container {
        /* Limit 40% screen to see the footer */
        max-height: 40vh !important; 
        min-height: 150px !important;
        
        /* enable scroll */
        overflow-y: auto !important; 
        
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        padding: 10px;
        margin-bottom: 20px; 
        
        box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
    }
}
/* Auto-expand AI button on mobile when Filters are hidden */
.mobile-big-actions button:only-child {
    grid-column: 1 / -1; /* Span full width */
}

/* --- COMPARE MODE STYLES --- */
#compare-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #050505;
    z-index: 5000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#compare-overlay.visible { display: flex; }

.compare-header {
    padding: 10px 20px;
    background: rgba(20, 20, 20, 0.9);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    flex-shrink: 0;
}

.compare-stage {
    flex-grow: 1;
    position: relative;
    background-color: #111;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}
.compare-stage:active { cursor: grabbing; }

.cmp-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

.cmp-media-container {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}

.cmp-content {
    max-width: 90%; max-height: 90%;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    will-change: transform; /* Performance for sync zoom */
}

/* The Slider Mechanism */
#cmp-after-wrapper {
    clip-path: inset(0 50% 0 0); /* Dynamic via JS */
    z-index: 10;
}

/* The Handle */
.cmp-handle {
    position: absolute;
    top: 0; bottom: 0; left: 50%;
    width: 4px;
    background: var(--primary-color);
    cursor: col-resize;
    z-index: 20;
    box-shadow: 0 0 10px rgba(0,0,0,0.8);
    transform: translateX(-50%);
    pointer-events: auto;
}

.cmp-handle::after {
    content: '↔';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    background: white;
    border: 4px solid var(--primary-color);
    border-radius: 50%;
    color: var(--primary-color);
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* Data Panel */
.compare-info-panel {
    height: 30%;
    min-height: 40px;
    background: var(--surface-color);
    border-top: 2px solid var(--ai-color);
    display: flex; flex-direction: column;
    transition: height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative; z-index: 30;
}
.compare-info-panel.collapsed { height: 40px; }

.cmp-info-toggle {
    height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    background: rgba(255,255,255,0.05);
    font-size: 0.9rem; color: var(--text-muted); font-weight: bold; gap: 10px;
}
.cmp-info-toggle:hover { color: white; background: rgba(255,255,255,0.1); }

.cmp-table-container { flex-grow: 1; overflow-y: auto; padding: 0 20px 20px 20px; }

.cmp-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; color: #ccc; }
.cmp-table th {
    text-align: left; padding: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    position: sticky; top: 0; background: var(--surface-color);
}
.cmp-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: top; font-family: monospace; word-break: break-all;
}

.cmp-row-diff { background: rgba(255, 193, 7, 0.05); }
.cmp-row-diff td { color: #fff; }
.cmp-row-diff td:first-child { 
    color: var(--favorite-color); font-weight: bold; 
    border-left: 3px solid var(--favorite-color);
}

@media (max-width: 768px) {
    .compare-info-panel { height: 40%; }
    .cmp-table { font-size: 0.8rem; }
    .cmp-handle::after { width: 30px; height: 30px; font-size: 16px; }
    /* Hide the word "Mode" on mobile to save space */
    .cmp-mode-text {
        display: none;
    }
    
    /* Reduce padding in compare header */
    .compare-header {
        padding: 5px 10px;
    }
}

/* Labels over images in Compare Mode */
.cmp-floating-label {
    position: absolute;
    top: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85rem;
    pointer-events: auto;
    cursor: help; /* Indicates clickable info */
    transition: all 0.2s ease;
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 50;
    user-select: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    
    /* Max width constraints */
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmp-floating-label:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.cmp-floating-label:active {
    transform: scale(0.95);
}

/* --- STORYBOARD FULL SCREEN STYLES --- */
#storyboard-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.95); z-index: 3000;
    display: none; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.2s;
}
#storyboard-overlay.visible { display: flex; opacity: 1; }

.sb-panel {
    background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px;
    /* FULL SCREEN GRID as requested */
    width: 98vw; height: 95vh; max-width: none; max-height: none;
    display: flex; flex-direction: column; overflow: hidden;
    transform: scale(0.98); transition: transform 0.2s;
}
#storyboard-overlay.visible .sb-panel { transform: scale(1); }

.sb-header {
    padding: 10px 20px; background: var(--surface-hover); border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.sb-header h3 { margin: 0; font-size: 1.2rem; color: #fff; }

.sb-body {
    padding: 20px; overflow-y: auto; flex-grow: 1; background: #050505;
    display: flex; flex-direction: column; align-items: center;
}

.sb-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 cols */
    gap: 20px; width: 100%; height: 100%;
    /* Auto rows to fit content */
    align-content: start; 
}

.sb-frame {
    background: #000; border: 1px solid #333; border-radius: 8px; overflow: hidden;
    cursor: zoom-in; position: relative; width: 100%; aspect-ratio: 16/9;
    transition: all 0.2s;
}
.sb-frame:hover { border-color: var(--primary-color); transform: scale(1.02); z-index: 5; }
.sb-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }

.sb-footer {
    padding: 8px; text-align: center; border-top: 1px solid var(--border-color);
    color: #777; font-size: 0.8rem; background: var(--surface-hover);
}

#sb-loader { margin-top: 50px; text-align: center; }

/* --- ZOOM OVERLAY STYLES --- */
#sb-zoom-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.95); z-index: 4000; /* Above Storyboard */
    display: none; justify-content: center; align-items: center; cursor: zoom-out;
}
#sb-zoom-img {
    /* Force image to take up space */
    width: auto;
    height: auto;
    min-width: 50vw;  /* Minimum half screen width */
    max-width: 95vw;
    max-height: 95vh;
    
    /* Clean look */
    object-fit: contain;
    box-shadow: 0 0 50px rgba(0,0,0,1);
    border: 2px solid var(--primary-color);
    background: #000;
}

@media (max-width: 768px) {
    .sb-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* --- STORYBOARD ZOOM NAVIGATION --- */
.sb-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4005; /* Must be above the image */
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    user-select: none;
    /* Safe area for mobile touches */
    padding: 0;
    line-height: 1;
}

.sb-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: white;
    transform: translateY(-50%) scale(1.1);
}

.sb-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

#sb-nav-prev { left: 20px; }
#sb-nav-next { right: 20px; }

/* Hide nav buttons on very small screens if image covers them, 
   or adjust position. Here we keep them visible as requested. */
@media (max-width: 768px) {
    .sb-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        background: rgba(0, 0, 0, 0.7); /* Darker for better visibility on mobile */
    }
    #sb-nav-prev { left: 10px; }
    #sb-nav-next { right: 10px; }
}

/* --- ZOOM STATUS BADGE --- */
#sb-zoom-status {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4005;
    
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 6px 16px;
    
    color: #ddd;
    font-family: monospace;
    font-weight: bold;
    font-size: 1rem;
    letter-spacing: 1px;
    pointer-events: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

/* Highlight Styles */
#sb-zoom-status.is-first {
    border-color: var(--success-color);
    color: var(--success-color);
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.3);
}

#sb-zoom-status.is-last {
    border-color: var(--danger-color);
    color: var(--danger-color);
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.3);
}

/* --- ZOOM QUALITY WARNING --- */
#sb-zoom-quality-msg {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4005;
    
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 6px 14px;
    
    color: var(--text-muted); /* Grey text to be subtle */
    font-size: 0.8rem;
    font-weight: 500;
    pointer-events: none;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hide warning on very small screens if needed, or adjust pos */
@media (max-width: 768px) {
    #sb-zoom-quality-msg {
        bottom: 80px; /* Move up to avoid overlapping native home bars on mobile */
        font-size: 0.7rem;
    }
}

/* --- TEMPORARY HIDE COMPARE FEATURE --- */

#compare-selected-btn, /* The Scale Icon in Selection Bar */
#compare-menu-btn,     /* The Menu Item in the dropdown */
#compare-menu-sep      /* The Separator line in the menu */
{ 
    /* display: none !important; */
}

/* --- FORCE HIDE OPTIONS ON MOBILE (Bulletproof) --- */
@media (max-width: 1024px) {
    .opt-desktop-only {
        display: none !important;
    }
    /* Hide the GitHub promo banner ENTIRELY on mobile to save vertical space */
    #github-promo-box {
        display: none !important;
    }
}

/* Logic moved to collections.css */
/* --- SIDEBAR ACCORDION STYLES --- */
.acc-header {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}
.acc-header:hover {
    color: var(--text-color);
}

.acc-arrow {
    display: inline-block;
    margin-right: 6px;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

/* State: Open (Default arrow down) */
.acc-header.open .acc-arrow {
    transform: rotate(0deg); 
}

/* State: Collapsed (Arrow points right) */
.acc-header.collapsed .acc-arrow {
    transform: rotate(-90deg);
}

/* Show strip ONLY when DAM Mode is active */
body.dam-mode-active .status-color-strip {
    display: block;
}

/* Adjustment: move the status badge only if DAM is active */
body.dam-mode-active .gallery-item:has(.status-color-strip) .workflow-badge {
    left: 12px; /* 6px strip + 6px gap */
}

/* --- SIDEBAR SHORTCUT HINT (Keycap Style) --- */
.col-shortcut-hint {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 10px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    /* Subtle 3D effect to look like a key */
    box-shadow: 0 1px 0 rgba(255,255,255,0.05), inset 0 1px 0 rgba(0,0,0,0.2);
    text-transform: uppercase;
}

.col-item:hover .col-shortcut-hint {
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

/* --- SIDEBAR COMPACT TOOLBAR --- */
.sidebar-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: nowrap; /* Force single line */
}

.sidebar-toolbar-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 2px;
    flex-shrink: 0;
}

.search-input-compact {
    flex-grow: 1;
    min-width: 50px;
    height: 28px !important;
    padding: 2px 8px !important;
    font-size: 0.85rem !important;
    background-color: rgba(0, 0, 0, 0.4) !important; 
    color: #ffffff !important; 
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-shadow: none;
}

.search-input-compact:focus {
    background-color: rgba(0, 0, 0, 0.6) !important;
    border-color: var(--primary-color) !important; 
    box-shadow: 0 0 0 1px var(--primary-color) !important; 
    color: #ffffff !important;
}

.search-input-compact::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
    font-style: italic;
}

.sidebar-tool-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border-radius: 6px !important;
    flex-shrink: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-tool-btn:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.sidebar-tool-btn.filter-active {
    background: rgba(0, 123, 255, 0.2);
    border-color: var(--primary-color);
    color: #a8dcff;
}

/* Adjustments for Sort Buttons to be icons too */
.sort-btn-mini {
    font-size: 0.7rem;
    font-weight: bold;
}

/* ============================================================
SIDEBAR & COLLECTIONS SCROLLING: DEFINITIVE RESPONSIVE FIX
============================================================ */

/* 1. DESKTOP BEHAVIOR (Locked at 100vh with internal scroll) */
@media (min-width: 1025px) {
.sidebar {
height: 100vh !important;
max-height: 100vh !important;
display: flex !important;
flex-direction: column !important;
overflow: hidden !important;
position: sticky;
top: 0;
}
}

/* 2. MOBILE BEHAVIOR (Limited height to keep gallery visible) */
@media (max-width: 1024px) {
.sidebar {
height: auto;
max-height: none;
overflow: visible !important;
}

/* CRITICAL: Limit list height on mobile so they DON'T seize the screen */
.folder-tree-container,
#user-collections-list,
.status-scroll-container {
max-height: 30vh !important; /* Limit to 30% of screen height */
overflow-y: auto !important;
border: 1px solid var(--glass-border);
border-radius: 8px;
background: rgba(0, 0, 0, 0.2);
margin-bottom: 10px;
}
}

/* 3. SHARED INTERNAL STRUCTURE */
.collections-section {
display: flex !important;
flex-direction: column !important;
flex: 1;
min-height: 0;
}

#folders-body, 
#user-collections-list-container {
display: flex;
flex-direction: column;
min-height: 0;
max-height: 70vh; /* from here */
}

/* 4. SCROLLABLE AREAS (Capture wheel & touch) */
.folder-tree-container,
#user-collections-list,
.status-scroll-container {
flex: 1 1 auto;
overflow-y: auto !important;
overflow-x: hidden;
overscroll-behavior: contain;
scrollbar-width: thin;
}

/* 5. STATUS SECTION FIX (No overlapping) */
#status-tags-list {
flex: 0 0 auto;
max-height: none;
overflow: visible;
/* Added 25px margin to prevent overlap with Collections header */
margin-bottom: 25px !important; 
padding-bottom: 5px;
}

/* 6. ACCORDION VISIBILITY */
.acc-body.hidden {
display: none !important;
}

/* --- ITEM STYLING (Alignment) --- */
.col-item {
display: flex !important;
align-items: center !important;
justify-content: flex-start !important;
width: 100%;
padding: 10px 8px;
text-decoration: none !important;
cursor: pointer;
box-sizing: border-box;
gap: 10px;
color: var(--text-color) !important;
}

.col-name {
flex: 1;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.collection-count {
flex-shrink: 0;
min-width: 1.5rem;
padding: 1px 6px;
border-radius: 999px;
background: rgba(0, 123, 255, 0.18);
border: 1px solid rgba(137, 207, 240, 0.25);
color: #a8dcff;
font-size: 0.72rem;
font-weight: 600;
font-variant-numeric: tabular-nums;
line-height: 1.35;
text-align: center;
}

.collection-count-descendant {
background: rgba(255, 255, 255, 0.06);
border-color: rgba(255, 255, 255, 0.18);
color: var(--text-muted);
}

/* DAM Mode Visibility */
.dam-only { display: none !important; }
body.dam-mode-active .dam-only { display: block !important; }
body.dam-mode-active div.dam-only { display: flex !important; flex-direction: column; }
body.dam-mode-active button.dam-only.sidebar-tab-btn { display: flex !important; }

/* Status color strip (Thumbnails) */
.status-color-strip {
position: absolute;
top: 0; left: 0; bottom: 0;
width: 6px;
z-index: 20;
box-shadow: 1px 0 4px rgba(0,0,0,0.5);
display: none; /* Controlled by DAM mode class */
}
body.dam-mode-active .status-color-strip { display: block; }

/* ============================================================
RESPONSIVE OVERRIDES (Media Queries)
============================================================ */
@media (max-width: 1024px) {
.sidebar {
height: auto;
overflow: visible;
}

/* Limit height on mobile to prevent infinite scrolling sidebar */
.folder-tree-container,
#user-collections-list {
max-height: 40vh;
}
}

/* --- SIDEBAR TABS (SEGMENTED CONTROL) --- */
.sidebar-tab-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--glass-border);
    gap: 4px;
    flex-shrink: 0; /* Prevent shrinking */
}

.sidebar-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.sidebar-tab-btn span.brand-info {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* On very narrow screens, reduce tab font to fit "Collections" */
@media (max-width: 380px) {
    .sidebar-tab-btn {
        font-size: 0.75rem;
        padding: 8px 2px;
    }
}
.sidebar-tab-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

/* Active State (High Contrast Blue) */
.sidebar-tab-btn.active {
    background: var(--surface-hover); /* Lighter grey/glass */
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Highlight specific tabs with subtle bottom border/glow */
.sidebar-tab-btn[data-tab="status"].active {
    border-bottom: 2px solid var(--workflow-color);
}
.sidebar-tab-btn[data-tab="collections"].active {
    border-bottom: 2px solid var(--favorite-color);
}
.sidebar-tab-btn[data-tab="folders"].active {
    border-bottom: 2px solid var(--primary-color);
}

/* Tab Content Panes */
.tab-content-pane {
    display: none; /* Hidden by default */
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Crucial for nested scrolling */
    overflow: hidden;
}

.tab-content-pane.active {
    display: flex;
    animation: fadeInTab 0.2s ease-out;
}

@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Adjust existing containers to fit new layout */
#folders-body, #user-collections-list-container, #status-tags-list {
    height: 100%;
    padding-bottom: 0;
}

/* Main Wrapper with Tab and Lists */
#wrapper-accordions {
    display: flex;
    flex-direction: column;
    flex: 1;           
    min-height: 0;   
    overflow: hidden;
}

/* --- IMPROVED FILE INFO PANEL (Rating & Comments UX) --- */
#file-info-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 7000;
    display: none; 
    justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s;
}
#file-info-overlay.visible { display: flex; opacity: 1; }

.file-info-card {
    background: #111;
    border: 1px solid var(--primary-color);
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    border-radius: 20px;
    width: 500px; max-width: 95vw;
    height: 80vh; max-height: 700px; /* Fixed height for better scrolling */
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.file-info-header {
    padding: 15px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}

.file-info-header h3 {
    margin: 0; color: white; font-size: 1rem; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Tabs / Switcher */
.fi-mode-switcher {
    display: flex;
    background: #000;
    padding: 4px;
    margin: 15px 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    flex-shrink: 0;
}
.fi-tab {
    flex: 1; padding: 10px; border: none; background: transparent;
    color: var(--text-muted); cursor: pointer; border-radius: 8px;
    font-weight: 600; font-size: 0.85rem; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.fi-tab.active {
    background: var(--primary-color); color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* Scrollable Content */
.file-info-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 20px;
    display: flex; flex-direction: column;
    scrollbar-width: thin;
}

/* Sections Visibility */
.fi-section { display: none; }
.fi-section.active { display: block; }

/* Rating Section Customization */
.rating-row-container {
    background: rgba(255,255,255,0.03);
    padding: 20px; border-radius: 15px; border: 1px solid var(--glass-border);
    margin: 10px 0; text-align: center;
}

/* Sticky Footer for New Messages */
.fi-footer {
    padding: 15px 20px;
    background: #0a0a0a;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#fi-admin-reply {
    width: 100%; min-height: 44px; max-height: 120px;
    background: #000; border: 1px solid #333; color: #fff;
    padding: 12px; border-radius: 10px; font-size: 0.95rem;
    outline: none; transition: border-color 0.2s;
}

/* Message Badges & Audience Dropdown */
.msg-badge {
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: bold; margin-left: 8px; vertical-align: middle; white-space: nowrap;
}
.msg-badge.public { background: rgba(0,255,0,0.1); color: var(--success-color); border: 1px solid rgba(32, 201, 151, 0.4); }
.msg-badge.internal { background: rgba(255,193,7,0.1); color: var(--favorite-color); border: 1px solid rgba(255, 193, 7, 0.4); }
.msg-badge.user { background: rgba(0,123,255,0.1); color: #89CFF0; border: 1px solid rgba(0, 123, 255, 0.4); }

/* Custom Searchable Dropdown for Audience */
.target-select-wrapper { position: relative; width: 100%; flex: 1; }
.target-select-trigger { background: #000; color: #fff; border: 1px solid var(--border-color); border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: border-color 0.2s; }
.target-select-trigger:hover { border-color: var(--primary-color); }
.target-dropdown { display: none; position: absolute; bottom: calc(100% + 5px); left: 0; width: 100%; background: var(--surface-color); border: 1px solid var(--primary-color); border-radius: 8px; box-shadow: 0 -10px 30px rgba(0,0,0,0.8); z-index: 1000; overflow: hidden; flex-direction: column; }
.target-dropdown.show { display: flex; }
.target-search-box { padding: 8px; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.3); }
.target-search-box input { width: 100%; background: #000; border: 1px solid #333; color: white; padding: 8px 10px; border-radius: 4px; outline: none; font-size: 0.85rem; }
.target-search-box input:focus { border-color: var(--primary-color); }
.target-options-list { max-height: 200px; overflow-y: auto; }
.target-opt { padding: 10px 12px; cursor: pointer; font-size: 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.05); color: #ddd; display: flex; align-items: center; gap: 8px; }
.target-opt:hover { background: var(--primary-color); color: white; }

/* Clickable Author Name for Quick Reply */
.reply-author-name { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,0.2); transition: all 0.2s; }
.reply-author-name:hover { text-decoration-color: var(--primary-color); filter: brightness(1.2); }

#fi-admin-reply:focus { border-color: var(--primary-color); }

/* Comments List */
#fi-comments-list {
    display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px;
}

@media (max-width: 768px) {
    .file-info-card { height: 90vh; max-height: none; border-radius: 20px 20px 0 0; align-self: flex-end; }
    
    /* Show text next to icons on mobile */
    .fi-tab span { display: inline !important; } 
    
    /* Slightly smaller font to ensure both buttons fit on narrow screens */
    .fi-tab { 
        font-size: 0.8rem; 
        padding: 10px 4px; 
        gap: 5px;
    }
    
    /* Ensure the count badge doesn't push the layout */
    #fi-comment-count-badge { font-size: 0.7rem; }
}

/* Edit Modal specific styles */
#fi-edit-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(5px);
    z-index: 8000; /* Above everything */
    display: none; 
    justify-content: center; align-items: center;
}
#fi-edit-overlay.visible { display: flex; }

.fi-edit-panel {
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    width: 600px; max-width: 95vw;
    padding: 20px;
    display: flex; flex-direction: column; gap: 15px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.9);
}

/* --- SIDEBAR USER SESSION ROW (Premium Style) --- */
.sidebar-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin: 10px 5px;
    flex-shrink: 0;
}

.user-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3);
}

.user-session-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-left: 10px;
    flex-grow: 1;
}

.user-session-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

.user-session-role {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-session-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.user-session-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.user-session-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: var(--primary-color);
}

.user-session-btn.logout-x {
    color: var(--danger-color);
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1;
}

/* Hide session row if sidebar is minimized */
body.sidebar-minimized .sidebar-user-row {
    display: none !important;
}

/* --- RATING INTERACTIVE STYLES (Added for Index) --- */
.interactive-stars { 
    display: inline-flex; 
    gap: 4px; 
    cursor: pointer; 
    vertical-align: middle;
}
.interactive-stars span { 
    font-size: 1.4rem; 
    color: rgba(255, 255, 255, 0.2); 
    transition: color 0.2s, transform 0.2s; 
    line-height: 1;
}
.interactive-stars span:hover { 
    color: rgba(255, 255, 255, 0.5); 
    transform: scale(1.2);
}
.interactive-stars span.active { 
    color: var(--favorite-color); 
    text-shadow: 0 0 10px rgba(255, 193, 7, 0.4); 
}

.rating-row-container {
    background: var(--surface-hover);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    margin-bottom: 15px;
}

.rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rating-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-reset-rating {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-reset-rating:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* Mobile Optimization for Rating Panel */
@media (max-width: 768px) {
    .rating-row-container {
        padding: 10px;
    }
    .rating-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .rating-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 5px;
        background: rgba(0,0,0,0.2);
        padding: 8px;
        border-radius: 6px;
    }
    .interactive-stars span {
        font-size: 1.6rem; /* Bigger for touch */
        padding: 0 2px;
    }
}

/* FIX TEXTAREA MOBILE and DESKTOP */
#comment-input {
    resize: none;      
    overflow-y: hidden;    
    min-height: 50px;      
    max-height: 150px;     
    height: auto;
    line-height: 1.4;
}

#comment-input:focus {
    overflow-y: auto;
}

/* DAM INFO OVERLAY - ROBUSTO E RESPONSIVE */
#dam-info-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.95); backdrop-filter: blur(12px);
    z-index: 9500; display: none; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s;
}
#dam-info-overlay.visible { display: flex; opacity: 1; }

.dam-info-panel {
    background: #0f0f0f; border: 1px solid #333; border-radius: 24px;
    padding: 40px; width: 800px; max-width: 95vw;
    max-height: 90vh; /* Limite massimo per non sbordare */
    display: flex; flex-direction: column;
    box-shadow: 0 30px 100px rgba(0,0,0,1);
    overflow-y: auto; /* Allows internal scrolling if content exceeds height */
}

@media (max-width: 768px) {
    .dam-info-panel { padding: 20px; border-radius: 16px; max-height: 95vh; }
    .dam-info-grid { grid-template-columns: 1fr !important; gap: 15px !important; }
}

/* DAM Badge Style */
.dam-badge-btn {
    display: inline-flex !important;
    align-items: center;
    background: rgba(155, 48, 255, 0.15) !important; /* Leggermente viola */
    border: 1px solid #9b30ff !important;
    color: #f0a0ff !important;
    padding: 2px 8px !important;
    border-radius: 6px !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    cursor: help !important;
    transition: all 0.25s ease !important;
    text-transform: uppercase;
    margin-left: 8px;
    box-shadow: 0 0 8px rgba(155, 48, 255, 0.2);
}

.dam-badge-btn:hover {
    background: #9b30ff !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(155, 48, 255, 0.4);
    transform: translateY(-1px);
}

#fi-rating-badge {
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    color: var(--favorite-color) !important;
    background: rgba(255, 193, 7, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
}

.folder-dropdown.show {
    pointer-events: auto; 
}
.folder-dropdown:not(.show) {
    pointer-events: none;
}

/* --- MULTI-KEYWORD HINTS & WARNINGS --- */
.filter-hint {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-top: 2px;
    margin-bottom: 6px;
    line-height: 1.3;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
}
.filter-hint code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--primary-color);
}
.filter-warning {
    color: var(--danger-color);
    font-size: 0.75rem;
    margin-top: 4px;
    display: none;
    font-weight: bold;
}

/* --- SORT POPOVER MENUS --- */
.sort-popover {
    display: none; position: fixed; background: var(--surface-color); border: 1px solid var(--border-color);
    border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.8); z-index: 10000;
    padding: 6px; flex-direction: column; gap: 2px; min-width: 210px;
}
.sort-popover.visible { display: flex; animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.sort-popover button {
    background: transparent; border: none; color: white; padding: 12px 15px; text-align: left;
    border-radius: 8px; cursor: pointer; transition: 0.2s; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center;
}
.sort-popover button:hover { background: rgba(255,255,255,0.1); }
.sort-popover button.active { color: var(--primary-color); background: rgba(0,123,255,0.15); font-weight:bold; border: 1px solid rgba(0,123,255,0.3); }

/* --- FOCUS STATUS BAR --- */
#focus-status-bar {
    position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%) translateY(20px);
    /* Sfondo Blu Navy molto più chiaro e contrastato rispetto allo sfondo scuro */
    background: rgba(20, 60, 120, 0.95); 
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    /* Bordi azzurri luminosi */
    border: 1px solid rgba(100, 180, 255, 0.5); 
    border-top: 2px solid #3399ff;
    border-radius: 12px;
    padding: 8px 18px; display: flex; align-items: center; gap: 15px;
    z-index: 900; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #fff; font-size: 0.85rem; 
    box-shadow: 0 15px 50px rgba(0,0,0,0.9), 0 0 20px rgba(0, 123, 255, 0.4);
    white-space: nowrap; max-width: 95vw;
}
#focus-status-bar.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.fsb-item { display: flex; align-items: center; gap: 6px; border-right: 1px solid rgba(255,255,255,0.15); padding-right: 15px; }
.fsb-item:last-child { border-right: none; padding-right: 0; }
/* Nome senza limiti di larghezza per mostrarlo tutto */
.fsb-name { font-weight: bold; color: white; }
.fsb-icon { opacity: 0.7; }
@media (max-width: 1024px) { #focus-status-bar {
    position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%) translateY(20px);
    /* Sfondo Blu Navy molto più chiaro e contrastato rispetto allo sfondo scuro */
    background: rgba(20, 60, 120, 0.95); 
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    /* Bordi azzurri luminosi */
    border: 1px solid rgba(100, 180, 255, 0.5); 
    border-top: 2px solid #3399ff;
    border-radius: 12px;
    padding: 8px 18px; display: flex; align-items: center; gap: 15px;
    z-index: 900; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #fff; font-size: 0.85rem; 
    box-shadow: 0 15px 50px rgba(0,0,0,0.9), 0 0 20px rgba(0, 123, 255, 0.4);
    white-space: nowrap; max-width: 95vw;
} }

/* --- FOCUS STATUS BAR WRAP FIX V4 --- */
#focus-status-bar {
    width: max-content !important; /* STRICT FIX: Stays on one line as long as physically possible */
    max-width: 90vw !important; /* Wraps ONLY when it hits 90% of the screen width */
    flex-wrap: wrap !important;
    justify-content: center !important;
    white-space: normal !important;
    box-sizing: border-box !important;
    gap: 8px 15px !important;
    padding: 10px 18px !important;
}
.fsb-item {
    border-right: none !important;
    padding-right: 0 !important;
    white-space: nowrap !important;
}
.fsb-item:not(:last-child)::after {
    content: "•";
    color: rgba(255, 255, 255, 0.3);
    margin-left: 15px;
}
.fsb-name {
    max-width: 40vw !important; /* Prevents a super-long filename from forcing the wrap alone */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important; /* Required for ellipsis to work correctly inside flex */
}

/* --- MOBILE SELECTION BAR FIX --- */
@media (max-width: 768px) {
    /* Hide the Delete button when 2 items are selected (class dynamically added via JS) */
    #selection-bar.two-selected #delete-selected-btn {
        display: none !important;
    }
    /* Reduce gaps and slightly shrink buttons to ensure everything fits on small phones */
    #selection-bar .sel-bar-actions {
        gap: 2px !important;
    }
    #selection-bar .sel-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1rem !important;
    }
}

/* --- RETURN FOCUS BLINK --- */
.gallery-item.return-focus {
    outline: 6px solid #007bff !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 25px rgba(0, 123, 255, 0.8) !important;
    z-index: 20;
}
.gallery-item.return-focus-blink {
    outline: 6px solid transparent !important;
    outline-offset: 4px !important;
    animation: returnBlinkAnim 0.3s ease-in-out 3 !important;
    z-index: 20;
}
@keyframes returnBlinkAnim {
    0%, 100% { outline-color: transparent !important; box-shadow: none !important; }
    50% { outline-color: #007bff !important; box-shadow: 0 0 25px rgba(0, 123, 255, 0.8) !important; }
}
    50% { outline: 6px solid #007bff !important; outline-offset: 4px !important; box-shadow: 0 0 25px rgba(0, 123, 255, 0.8) !important; }
}


/* --- DOCUMENT / NOTES VISUAL SEPARATION --- */
.gallery-item[data-file-type="document"], .exh-card[data-file-type="document"] {
    grid-column: 1 / -1 !important; 
    display: flex !important;
    flex-direction: row !important;
    min-height: 80px !important;
    height: auto !important;
    background: rgba(0, 123, 255, 0.08) !important;
    border: 1px solid var(--primary-color) !important;
    border-left: 8px solid var(--primary-color) !important;
    align-items: center !important;
    padding: 10px 20px !important;
    order: -1;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
}

.gallery-item[data-file-type="document"] .thumbnail-wrapper,
.exh-card[data-file-type="document"] .exh-thumb-wrap {
    width: 60px !important;
    height: 60px !important;
    min-height: 60px !important;
    background: transparent !important;
    margin-right: 20px;
    border: none !important;
}

.gallery-item[data-file-type="document"] .doc-thumb-preview,
.exh-card[data-file-type="document"] .doc-thumb-preview {
    min-height: 60px !important;
    background: transparent !important;
    border: none !important;
    flex-direction: row;
    gap: 10px;
}

.gallery-item[data-file-type="document"] .doc-icon,
.exh-card[data-file-type="document"] .doc-icon {
    font-size: 3rem;
    margin: 0;
}

.gallery-item[data-file-type="document"] .doc-ext,
.exh-card[data-file-type="document"] .doc-ext {
    display: none;
}

.gallery-item[data-file-type="document"] .item-info,
.exh-card[data-file-type="document"] .exh-info {
    padding: 0 !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100%;
}

.gallery-item[data-file-type="document"] .item-info p,
.exh-card[data-file-type="document"] .exh-name {
    font-size: 1.3rem !important;
    color: var(--primary-color) !important;
    margin-bottom: 0 !important;
}

.gallery-item[data-file-type="document"] .file-metadata,
.exh-card[data-file-type="document"] .exh-meta-row {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    align-items: center !important;
}

/* Fix Document Markdown Spacing */
.theater-document-reader div, #brief-reader-content {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
}

@media (max-width: 768px) {
    .gallery-item[data-file-type="document"], .exh-card[data-file-type="document"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 15px !important;
    }
    .gallery-item[data-file-type="document"] .item-info,
    .exh-card[data-file-type="document"] .exh-info {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
}


/* Document & Note Reader Smooth Scrolling Fix */
.theater-document-reader, #notes-reader-content, #exh-notes-reader-content {
    overflow-y: auto !important;
    pointer-events: auto !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    cursor: auto !important; 
}

/* Dedicated Tab Button Class (Rigid, no-shrink) */
.ntab-btn {
    flex: 0 0 auto !important;
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    height: 40px;
    margin-bottom: 5px;
    white-space: nowrap !important;
}

.ntab-btn:hover {
    background: rgba(255,255,255,0.15);
}

.ntab-btn.active {
    background: var(--favorite-color);
    color: black;
    font-weight: bold;
    border-color: var(--favorite-color);
}

/* --- FULL FILE DETAILS MODAL (Shortcut: I) --- */
#full-file-details-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px);
    z-index: 10005; display: none; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.25s ease;
}
#full-file-details-overlay.visible { display: flex; opacity: 1; pointer-events: auto; }

.full-details-panel {
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-radius: 16px;
    width: 750px; max-width: 95vw;
    height: 85vh; max-height: 850px;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9);
    overflow: hidden;
}

.full-details-header {
    padding: 15px 20px;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.full-details-header h3 { margin: 0; color: white; font-size: 1.2rem; }

.full-details-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex; flex-direction: column; gap: 20px;
    color: #ddd;
    -webkit-overflow-scrolling: touch;
}

/* Top Card (Thumb + Main Info) */
.fd-top-card {
    display: flex; gap: 20px; align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 15px;
}
.fd-thumb-box {
    width: 120px; height: 120px; flex-shrink: 0;
    border-radius: 8px; overflow: hidden; background: #000;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color);
}
.fd-thumb { width: 100%; height: 100%; object-fit: contain; }
.fd-thumb-placeholder { font-size: 3rem; }

.fd-main-meta { display: flex; flex-direction: column; gap: 8px; flex-grow: 1; min-width: 0; }
.fd-title {
    margin: 0; font-size: 1.15rem; color: white; font-weight: bold;
    word-break: break-all; line-height: 1.3;
}
.fd-badges-row { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-badge {
    padding: 3px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.fd-badge.type { background: var(--glass-bg); border: 1px solid var(--glass-border); color: #89CFF0; }
.fd-badge.workflow { background: rgba(40, 167, 69, 0.2); border: 1px solid var(--workflow-color); color: var(--workflow-color); }
.fd-badge.favorite { background: rgba(255, 193, 7, 0.2); border: 1px solid var(--favorite-color); color: var(--favorite-color); }

/* Grid of Cards */
.fd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}
.fd-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px; padding: 10px 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.fd-card-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: bold; }
.fd-card-val { font-size: 0.95rem; color: white; font-weight: 600; word-break: break-all; }

/* Sections */
.fd-section { display: flex; flex-direction: column; gap: 8px; }
.fd-section-title {
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--primary-color); font-weight: 800; border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 4px;
}

/* Stats Row */
.fd-stats-row { display: flex; gap: 12px; flex-wrap: wrap; }
.fd-stat-box {
    background: rgba(0, 0, 0, 0.3); border: 1px solid var(--glass-border);
    border-radius: 8px; padding: 10px 16px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; min-width: 110px;
}
.fd-stat-num { font-size: 1.1rem; font-weight: bold; color: white; }
.fd-stat-lbl { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Path Box & Pills */
.fd-path-box {
    background: rgba(0, 0, 0, 0.4); border: 1px solid var(--glass-border);
    border-radius: 8px; padding: 10px; font-family: monospace; font-size: 0.85rem;
    word-break: break-all; color: var(--success-color); line-height: 1.4;
}
.fd-link-source { margin-top: 8px; color: var(--favorite-color); border-top: 1px solid rgba(255,255,255,0.1); padding-top: 6px; }

.fd-chain-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 6px; }
.fd-pill {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border);
    border-radius: 20px; padding: 4px 10px; font-size: 0.85rem; color: white; font-weight: 500;
}
.fd-pill.folder { border-color: rgba(0, 123, 255, 0.4); background: rgba(0, 123, 255, 0.1); }
.fd-pill.collection { border-color: rgba(255, 193, 7, 0.4); background: rgba(255, 193, 7, 0.1); }
.fd-arrow { color: var(--text-muted); font-size: 0.8rem; }

.fd-collections-box { display: flex; flex-direction: column; gap: 6px; }

.fd-caption-box {
    background: rgba(0,0,0,0.3); border: 1px solid var(--ai-color);
    border-radius: 8px; padding: 12px; font-size: 0.9rem; line-height: 1.5; color: #eee;
}

.fd-genmeta-box {
    background: rgba(0,0,0,0.4); border: 1px solid var(--glass-border);
    border-radius: 8px; padding: 14px; font-family: monospace; font-size: 0.82rem;
    line-height: 1.5; color: #ddd; white-space: pre-wrap; word-break: break-word;
    max-height: 340px; overflow-y: auto;
}
.fd-genmeta-copy {
    align-self: flex-end; background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-muted); border-radius: 6px; padding: 3px 10px; font-size: 0.75rem;
    cursor: pointer;
}
.fd-genmeta-copy:hover { color: white; border-color: var(--primary-color); }

@media (max-width: 768px) {
    .full-details-panel { height: 92vh; border-radius: 16px; }
    .fd-top-card { flex-direction: column; text-align: center; }
    .fd-thumb-box { width: 100%; height: 160px; }
    .fd-badges-row { justify-content: center; }
    .fd-stats-row { justify-content: space-between; }
}


/* --- WORKFLOW FILES AUTOCOMPLETE, DID YOU MEAN & CLUSTERING STYLES --- */
.search-overlay-panel {
    overflow: visible !important;
}

.wf-autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.wf-suggestions-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 520px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface-color, #1a1a1a);
    border: 1px solid var(--primary-color, #007bff);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.9);
    z-index: 100000;
    margin-top: 4px;
    padding: 6px;
}

.wf-suggestion-item {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-color, #eee);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.wf-suggestion-item:last-child {
    border-bottom: none;
}

.wf-suggestion-item:hover {
    background: var(--primary-color, #007bff);
    color: #ffffff;
}

.wf-sug-filename {
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wf-sug-path {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
}

.wf-suggestion-item:hover .wf-sug-path {
    color: rgba(255, 255, 255, 0.8);
}

/* Did You Mean & Cluster Banner */
.did-you-mean-container {
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid var(--favorite-color, #ffc107);
    border-radius: 12px;
    padding: 10px 20px;
    margin: 15px 2rem 0 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease-out;
}

.dym-icon {
    font-size: 1.2rem;
}

.dym-text {
    flex-grow: 1;
}

.dym-text strong {
    color: var(--favorite-color, #ffc107);
    font-family: monospace;
}

.dym-btn {
    height: 32px !important;
    padding: 0 12px !important;
    font-size: 0.8rem !important;
}

.dym-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #aaa);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.dym-close:hover {
    color: var(--danger-color, #dc3545);
}

/* --- CLUSTERING MODAL OVERLAY STYLES (FIXED CENTERING) --- */
#clustering-modal-overlay,
#cluster-prompt-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 9999 !important;
    display: none;
    justify-content: center !important;
    align-items: center !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#clustering-modal-overlay.visible,
#cluster-prompt-modal-overlay.visible {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.clustering-modal-panel {
    background: var(--surface-color, #1a1a1a) !important;
    border: 1px solid var(--ai-color, #ff00ff) !important;
    border-radius: 16px !important;
    width: 480px !important;
    max-width: 90vw !important;
    box-shadow: 0 0 40px rgba(255, 0, 255, 0.25) !important;
    padding: 0 !important;
    overflow: hidden !important;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

#clustering-modal-overlay.visible .clustering-modal-panel {
    transform: scale(1);
}

.cluster-badge-top-flush {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 12px 12px 0 0 !important;
    padding: 4px 10px !important;
    margin: 0 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
    z-index: 12 !important;
}

.cluster-mode-active .workflow-badge {
    display: none !important;
}

.list-view-active .gallery-item.cluster-item-active {
    border-left: 6px solid var(--cluster-color, var(--ai-color, #ff00ff)) !important;
    box-shadow: inset 4px 0 8px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .did-you-mean-container {
        margin: 10px 1rem 0 1rem;
        flex-wrap: wrap;
        padding: 10px;
    }
    .dym-text {
        width: 100%;
    }
    .wf-suggestions-dropdown {
        max-width: calc(100vw - 40px);
    }
}

/* Notification Container High Z-Index */
#notification-container {
    z-index: 100000 !important;
}

/* Clickable Workflow Badge Hover Effect in Details Modal */
.fd-badge.workflow {
    background: rgba(40, 167, 69, 0.2) !important;
    border: 1px solid var(--workflow-color) !important;
    color: var(--workflow-color) !important;
    transition: all 0.2s ease !important;
}
.fd-badge.workflow:hover {
    background: var(--workflow-color) !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
}

/* Cluster Sub-Badges */
.cluster-sub-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: bold;
    margin-left: 4px;
    border: 1px solid rgba(255,255,255,0.3);
    cursor: pointer;
    transition: transform 0.2s;
}
.cluster-sub-badge:hover {
    transform: scale(1.1);
}

/* Full Details Tabs */
.fd-tab-bar {
    display: flex;
    gap: 8px;
    background: rgba(0,0,0,0.4);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--glass-border, #333);
    margin-bottom: 15px;
    flex-shrink: 0;
}
.fd-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted, #aaa);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.fd-tab-btn.active {
    background: var(--surface-hover, #222);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.fd-tab-pane {
    display: none;
    flex-direction: column;
    gap: 15px;
}
.fd-tab-pane.active {
    display: flex;
}

/* Generation metadata inspector */
#generation-metadata-toggle { position: fixed; bottom: 12px; right: 16px; z-index: 2010; padding: 8px 12px; border: 1px solid var(--border-color, #444); border-radius: 8px; background: var(--surface-color, #25262b); color: var(--text-color, #ddd); cursor: pointer; }
#generation-metadata-toggle[aria-pressed="true"] { color: var(--primary-color, #69baff); }
#generation-metadata-panel { position: fixed; z-index: 2011; box-sizing: border-box; max-height: calc(100dvh - 160px); overflow: auto; overscroll-behavior: contain; padding: 16px; border: 1px solid var(--border-color, #444); border-radius: 12px; background: var(--surface-color, #25262b); color: var(--text-color, #ddd); box-shadow: 0 8px 30px #0006; font-size: 13px; }
#generation-metadata-panel[hidden], #generation-metadata-toggle[hidden] { display: none; }
#generation-metadata-panel header { display: flex; align-items: center; gap: 10px; }
#generation-metadata-panel header strong { flex: 1; font-size: 17px; }
#generation-metadata-panel button { border: 0; background: transparent; color: var(--primary-color, #69baff); cursor: pointer; padding: 4px; font: inherit; }
#generation-metadata-panel button:disabled { opacity: .4; cursor: default; }
#generation-metadata-panel button:focus-visible { outline: 2px solid var(--primary-color, #69baff); }
#generation-metadata-name { margin: 8px 0; overflow-wrap: anywhere; color: var(--text-muted, #aaa); }
#generation-metadata-panel section { border-top: 1px solid var(--border-color, #444); margin-top: 12px; padding-top: 12px; }
#generation-metadata-panel h3 { font-size: 14px; margin: 0 0 8px; display: flex; align-items: center; justify-content: space-between; }
#generation-metadata-panel p { margin: 0; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.gm-collapsed { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.gm-resource { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.gm-resource > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.gm-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-badge { display: inline-block; background: #3198d822; color: var(--primary-color, #69baff); border-radius: 4px; padding: 3px 6px; font-size: 11px; overflow-wrap: anywhere; }
#generation-metadata-panel.gm-bottom { max-height: 32dvh; }
body.gm-grid-docked { padding-bottom: var(--gm-dock-height, 280px); }
body.gm-grid-docked .gallery-item { scroll-margin-bottom: var(--gm-dock-height, 280px); }
body.gm-grid-docked #generation-metadata-toggle { bottom: calc(var(--gm-dock-height, 280px) + 4px); }
@media (max-width: 600px) { #generation-metadata-panel { max-height: 55dvh; } }

.gm-pin-controls { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
#generation-metadata-panel .gm-pin-controls button { border: 1px solid var(--border-color, #444); border-radius: 5px; padding: 4px 8px; }
#generation-metadata-pin-status { color: var(--text-muted, #aaa); font-size: 12px; }
#generation-metadata-panel [hidden] { display: none !important; }
body.lightbox-open #generation-metadata-toggle { display: none; }
