:root {
    --bg-main: #060608;
    --bg-dark-glass: rgba(12, 12, 16, 0.65);
    --bg-panel-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 100%);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent: #e2e8f0; /* Silver/Platinum */
    --accent-hover: #ffffff;
    --brand: #e2e8f0; /* Silver alignment */
    --bevel-light: rgba(255, 255, 255, 0.25);
    --bevel-dark: rgba(0, 0, 0, 0.7);
    --glass-blur: blur(32px) saturate(220%);
    --transition: cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy tactile feel */
}

body {
    background-image: url('assets/dark_geometric_glass_background.png');
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    color: var(--text-primary);
    margin: 0;
}

/* Brand font — Agbalumo everywhere. !important wins over all component rules. */
* {
    font-family: 'Agbalumo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif !important;
}

/* ===== Tailwind-Independent Fallbacks ===== */
/* These ensure the site renders correctly even if the Tailwind CDN fails */

/* Screen-reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Logo sizing — constrain to reasonable size */
.sidebar header img {
    display: block;
    margin: 0 auto 1rem;
    max-height: 8rem;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

/* ===== SVG Icon Sizing (Tailwind w-X h-X fallback) ===== */
/* All SVGs inside the sidebar, buttons, and search use Tailwind for sizing.
   Without Tailwind they balloon to 300px+. Constrain them globally. */
.sidebar svg,
.genui-search-container svg,
.reset-btn svg,
#admin-login-btn svg {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* Search magnifying glass icon */
.genui-search-container .pointer-events-none svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Voice status overlay — must never block taps on filters beneath */
#voice-status {
    pointer-events: none;
}

/* ===== Search Input ===== */
.genui-search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.genui-search-container > div {
    position: relative;
    display: flex;
    align-items: center;
}

.genui-search-container .pointer-events-none {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    padding-left: 0.75rem;
    display: flex;
    align-items: center;
    pointer-events: none;
}

#ai-search {
    width: 100%;
    background: rgba(17, 18, 20, 0.8);
    border: 1px solid #2d3135;
    color: white;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#ai-search:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
}

#ai-search::placeholder {
    color: #6b7280;
}

/* ===== Filter Button Bar (Reset + Admin Gear) ===== */
.sidebar > div:last-child {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.reset-btn {
    flex: 1;
}

/* Admin gear button — prevent oversizing */
#admin-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid #2d3135;
    color: #9ca3af;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    min-width: 42px;
    max-width: 42px;
}

#admin-login-btn:hover {
    color: var(--brand);
    border-color: rgba(226, 232, 240, 0.4);
    background: #1a1c1e;
}

/* ===== Mobile-Specific Optimizations ===== */
@media (max-width: 600px) {
    .sidebar header img {
        max-height: 5rem;
    }
    
    .sidebar-tagline {
        font-size: 0.72rem;
    }

    .filter-group h3 {
        font-size: 0.7rem;
    }
    
    .custom-radio {
        font-size: 0.82rem;
        margin-bottom: 8px;
        padding-left: 26px;
    }
    
    .radiomark {
        height: 15px;
        width: 15px;
    }
    
    .radiomark:after {
        top: 2px;
        left: 2px;
        width: 7px;
        height: 7px;
    }

    .gallery-header h2 {
        font-size: 1.5rem;
    }
    
    .gallery-area {
        padding: 1rem;
    }
    
    .gallery-grid {
        gap: 1rem;
    }
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar & Glassmorphism 2.0 */
.sidebar {
    width: 340px;
    background: var(--bg-dark-glass);
    background-image: var(--bg-panel-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--bevel-light);
    box-shadow: inset -1px 0 0 var(--bevel-dark), 5px 0 30px rgba(0,0,0,0.6);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 20;
}

.sidebar header { margin-bottom: 2rem; }
.sidebar h1 { font-size: 2rem; font-weight: 300; letter-spacing: 2px; text-transform: uppercase; }

/* Tagline styling */
.sidebar-tagline {
    color: var(--accent);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 300;
    letter-spacing: 0.5px;
    line-height: 1.5;
    margin-top: 0.5rem;
    opacity: 0.85;
}

.filters { flex: 1; }
.filter-group { margin-bottom: 1.8rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 1.2rem; }
.filter-group:last-child { border-bottom: none; }
.filter-group h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.8rem;
}

/* Custom Radio Buttons — now <button> elements for guaranteed iOS tap reliability.
   <button> is natively interactive so iOS Safari always fires click without
   any cursor/tabindex workarounds. Reset default button chrome here. */
.custom-radio {
    display: block;
    position: relative;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    outline: none;
    padding-left: 30px;
    margin-bottom: 10px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    /* Only transition color — 'transition:all' can block taps on some mobile browsers */
    transition: color 0.3s ease;
    -webkit-tap-highlight-color: rgba(226, 232, 240, 0.15);
    touch-action: manipulation;
    /* Ensure label is always tappable */
    -webkit-user-select: none;
    user-select: none;
}

/* Hover effects only on devices with a mouse — prevents tap-shift on mobile */
@media (hover: hover) and (pointer: fine) {
    .custom-radio:hover { color: var(--accent); transform: translateX(4px); }
    .custom-radio:active { transform: translateX(2px) scale(0.97); }
}
/* No hidden inputs — filters are pure divs with data-* attributes.
   This eliminates ALL mobile tap issues caused by Tailwind Preflight
   applying appearance:none to invisible checkboxes. */

.radiomark {
    position: absolute;
    top: 2px;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: transparent;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s var(--transition);
    /* Decorative only — let all touches fall through to the <button> */
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .custom-radio:hover .radiomark { border-color: var(--accent); }
}

/* Active state driven by JS .active class — no checkbox dependency */
.custom-radio.active { color: var(--accent); }

.custom-radio.active .radiomark {
    border-color: var(--accent);
    background: transparent;
}

.radiomark:after {
    content: "";
    position: absolute;
    display: none;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px rgba(203, 213, 225, 0.5);
}

.custom-radio.active .radiomark:after { display: block; }

.reset-btn {
    margin-top: 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--bevel-light);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    padding: 0.75rem 0;
    width: 100%;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s var(--transition), box-shadow 0.2s var(--transition), background-color 0.2s ease, color 0.2s ease;
    letter-spacing: 0.5px;
    box-shadow: inset 1px 1px 1px rgba(255,255,255,0.15), 0 4px 10px rgba(0,0,0,0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.reset-btn:hover { 
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05)); 
    border-color: var(--accent); 
    color: var(--accent); 
    box-shadow: inset 1px 1px 2px rgba(255,255,255,0.2), 0 6px 15px rgba(0,0,0,0.5);
    transform: translateY(-2px);
}
.reset-btn:active {
    transform: translateY(1px) scale(0.96);
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.5), 0 2px 5px rgba(0,0,0,0.3);
}

/* Main Gallery Area */
.gallery-area { flex: 1; padding: 2.5rem; max-width: 1600px; margin: 0 auto; }
.gallery-header { margin-bottom: 3rem; display: flex; justify-content: space-between; align-items: flex-end; }
.gallery-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 400;
    font-style: italic;
    background: linear-gradient(135deg, #ffffff 0%, #9ca3af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.results-count {
    color: var(--accent);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 300;
    opacity: 0.7;
}

/* Uniform Grid Setup (Dealer Style) */
.gallery-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
}

@media (max-width: 1100px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* Bento Span Utilities */
@media (min-width: 640px) {
    .bento-col-2 { grid-column: span 2; }
    .bento-row-2 { grid-row: span 2; }
}

/* Lightbox GlightBox Customization */
.gslide-desc {
    background: rgba(0,0,0,0.85) !important;
    text-align: center !important;
    backdrop-filter: blur(10px) !important;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; padding: 1.5rem; border-right: none; border-bottom: 1px solid var(--bevel-light); display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; overflow-y: visible; }
    .sidebar header { grid-column: 1 / -1; margin-bottom: 0; text-align: center; }
    .filters { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
    .filter-group { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
    .reset-btn { grid-column: 1 / -1; max-width: 300px; margin: 1rem auto 0; }
    .gallery-area { padding: 1.5rem; }
    .gallery-header h2 { font-size: 2rem; }
}

@media (max-width: 600px) {
    .filters { grid-template-columns: 1fr; }
    .gallery-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

/* Edit Feature Styling — compact button in corner */
.edit-item-btn {
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.3s ease;
}

.gallery-item:hover .edit-item-btn {
    opacity: 1;
    transform: translateY(0);
}

/* Custom Select Dropdowns in Modal */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select option {
    background-color: #1a1c1e;
    color: #ffffff;
    padding: 10px;
}

/* Gallery Item — beveled card with floating caption */
.gallery-item {
    width: 100%;
    height: auto;
    margin-bottom: 0 !important;
    position: relative;
    border-radius: 1.2rem;
    display: flex;
    flex-direction: column;
}

.gallery-item a {
    display: block;
    width: 100%;
    /* Use auto height so the anchor sizes to its image content, not 100% of parent */
    height: auto;
    transition: transform 0.4s var(--transition), box-shadow 0.4s var(--transition), border-color 0.4s ease;
    background: var(--bg-panel-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    border-right: 1px solid rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid rgba(0, 0, 0, 0.6);
    border-radius: 1.2rem;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.15),
        inset -2px -2px 6px rgba(0, 0, 0, 0.4),
        8px 8px 24px rgba(0, 0, 0, 0.5);
    overflow: hidden; /* Ensure image respects border radius */
}

/* ===== Gallery Image Fallbacks (Tailwind-independent) ===== */
/* These ensure images display correctly even without Tailwind CDN */
.gallery-item img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 3 / 4;
}

.gallery-item a:hover {
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.2),
        inset -2px -2px 8px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(226, 232, 240, 0.12),
        0 0 40px rgba(226, 232, 240, 0.06),
        12px 12px 30px rgba(0, 0, 0, 0.6);
    transform: translateY(-4px) scale(1.015);
    border-color: rgba(226, 232, 240, 0.5);
}

/* --- Floating Caption (appears below card on hover) --- */
.gallery-item .floating-caption {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(-8px);
    transition: opacity 0.35s ease, max-height 0.4s ease, transform 0.35s ease, padding 0.35s ease;
    padding: 0 0.75rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.01) 100%);
    border-radius: 0 0 1rem 1rem;
    border: 1px solid transparent;
    border-top: none;
}

.gallery-item:hover .floating-caption {
    opacity: 1;
    max-height: 120px;
    transform: translateY(0);
    padding: 0.75rem;
    border-color: rgba(226, 232, 240, 0.15);
}

.floating-caption h3 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 0.4rem 0;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floating-caption .caption-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.floating-caption .caption-tag {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border-radius: 4px;
    white-space: nowrap;
}

.floating-caption .caption-tag.premium {
    background: rgba(226, 232, 240, 0.12);
    color: var(--brand);
    border: 1px solid rgba(226, 232, 240, 0.2);
}

/* ===== Tailwind Utility Fallbacks for Gallery Cards ===== */
/* Positioning & display utilities used in JS-generated gallery HTML */
.gallery-item .relative { position: relative; }
.gallery-item .absolute { position: absolute; }
.gallery-item .block { display: block; }
.gallery-item .flex { display: flex; }
.gallery-item .inline { display: inline; }
.gallery-item .hidden { display: none !important; }

/* Z-index layers */
.gallery-item .z-20 { z-index: 20; }

/* Spacing & sizing used by edit/select buttons */
.gallery-item .top-3 { top: 0.75rem; }
.gallery-item .left-3 { left: 0.75rem; }
.gallery-item .right-3 { right: 0.75rem; }
.gallery-item .bottom-12 { bottom: 3rem; }
.gallery-item .px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.gallery-item .py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.gallery-item .gap-1\.5 { gap: 0.375rem; }
.gallery-item .rounded-lg { border-radius: 0.5rem; }
.gallery-item .rounded-2xl { border-radius: 1rem; }
.gallery-item .overflow-hidden { overflow: hidden; }
.gallery-item .items-center { align-items: center; }
.gallery-item .justify-center { justify-content: center; }
.gallery-item .text-xs { font-size: 0.75rem; line-height: 1rem; }
.gallery-item .text-white { color: #ffffff; }
.gallery-item .outline-none { outline: none; }

/* Checkbox sizing */
.gallery-item .w-6 { width: 1.5rem; }
.gallery-item .h-6 { height: 1.5rem; }
.gallery-item .w-4 { width: 1rem; }
.gallery-item .h-4 { height: 1rem; }
.gallery-item .w-3\.5 { width: 0.875rem; }
.gallery-item .h-3\.5 { height: 0.875rem; }
.gallery-item .w-3 { width: 0.75rem; }
.gallery-item .h-3 { height: 0.75rem; }

/* Hover group interaction — edit btn visibility */
.gallery-item .group-hover\:opacity-100 { opacity: 0; }
.gallery-item:hover .group-hover\:opacity-100 { opacity: 1; }

/* Transition utilities */
.gallery-item .transition-all { transition: all 0.3s ease; }
.gallery-item .transition-transform { transition: transform 0.3s ease; }
.gallery-item .transition-colors { transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease; }

/* Background utilities for buttons */
.gallery-item .bg-black\/60 { background: rgba(0, 0, 0, 0.6); }
.gallery-item .bg-black\/40 { background: rgba(0, 0, 0, 0.4); }
.gallery-item .backdrop-blur-sm { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.gallery-item .border-white\/20 { border: 1px solid rgba(255, 255, 255, 0.2); }
.gallery-item .border-white\/70 { border-color: rgba(255, 255, 255, 0.7); }
.gallery-item .cursor-pointer { cursor: pointer; }

/* Missing animation fix */
.gallery-item.animate-in { opacity: 1; transform: scale(1); }

/* ================================================================
   MOBILE UX AUDIT PATCHES — April 2026
   Covers: touch targets, responsive fixes, accessibility,
   mobile captions, tap feedback, compositing performance
   ================================================================ */

/* --- PATCH 1: Touch Target Sizing (44px minimum) --- */

/* Filter buttons — enforce minimum 44px tap zone without breaking the
   absolute-positioned radiomark layout. Keep display:block (set on the
   base rule) and grow the tap zone via vertical padding only; min-height
   acts as a floor. display:flex here caused the radiomark to detach from
   the label text because .radiomark is position:absolute. */
.custom-radio {
    min-height: 44px;
    padding-top: 11px;
    padding-bottom: 11px;
}

/* Keep the radiomark vertically centered regardless of button height */
.radiomark {
    top: 50%;
    transform: translateY(-50%);
}

/* Admin gear button — expand to meet 44px minimum */
#admin-login-btn {
    min-width: 44px;
    max-width: 44px;
    min-height: 44px;
}

/* Modal action buttons — enforce 44px minimum */
#edit-form button,
#admin-login-form button,
#bulk-edit-form button {
    min-height: 44px;
}

/* Bulk select checkbox — expand tap zone with padding */
.bulk-select-checkbox {
    padding: 10px;
    margin: -10px;
}

/* --- PATCH 2: Mobile Tap Feedback (coarse pointer devices) --- */

/* Filter buttons — active flash for touch devices */
@media (pointer: coarse) {
    .custom-radio:active {
        background: rgba(226, 232, 240, 0.08);
        border-radius: 8px;
        transition: background 0.1s ease;
    }

    .custom-radio.active {
        background: rgba(226, 232, 240, 0.06);
        border-radius: 8px;
    }

    /* Stronger active state indicator — add left accent bar */
    .custom-radio.active::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 60%;
        background: var(--accent);
        border-radius: 2px;
    }

    /* Gallery cards — show edit button always on touch */
    .edit-item-btn {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }

    /* Gallery cards — tap scale feedback */
    .gallery-item a:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }

    /* Reset button tap feedback */
    .reset-btn:active {
        background: rgba(255, 255, 255, 0.15) !important;
    }
}

/* --- PATCH 3: Mobile Floating Captions (touch-to-reveal) --- */

/* On touch devices, show captions always (no hover needed) */
@media (pointer: coarse) {
    .gallery-item .floating-caption {
        opacity: 1;
        max-height: 120px;
        transform: translateY(0);
        padding: 0.75rem;
        border-color: rgba(226, 232, 240, 0.15);
    }
}

/* --- PATCH 4: Responsive Fixes for 375px / Small Phones --- */

@media (max-width: 479px) {
    /* Tighter gallery padding */
    .gallery-area {
        padding: 0.75rem;
    }

    .gallery-header {
        margin-bottom: 1.5rem;
    }

    .gallery-header h2 {
        font-size: 1.25rem;
    }

    .gallery-grid {
        gap: 0.75rem;
    }

    /* Sidebar — reduce padding */
    .sidebar {
        padding: 1rem;
    }

    /* Radiomark — enlarge on small phones for visibility */
    .radiomark {
        height: 20px;
        width: 20px;
    }

    .radiomark:after {
        top: 4px;
        left: 4px;
        width: 8px;
        height: 8px;
    }

    /* Filter group headers */
    .filter-group h3 {
        font-size: 0.68rem;
    }

    /* Modal — add margin so it doesn't touch screen edges */
    #edit-modal > div,
    #admin-login-modal > div,
    #bulk-edit-modal > div {
        margin: 0 12px;
        max-width: calc(100vw - 24px);
    }
}

/* Bulk edit bar — responsive padding on small screens */
@media (max-width: 640px) {
    #bulk-edit-bar {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #bulk-edit-bar > div {
        width: 100%;
        justify-content: center;
    }

    #bulk-edit-bar > div:first-child {
        text-align: center;
    }
}

/* --- PATCH 5: Safe Area Insets (iPhone notch / home indicator) --- */

#bulk-edit-bar {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* Ensure modals respect notch on landscape */
#edit-modal,
#admin-login-modal,
#bulk-edit-modal {
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* --- PATCH 6: Filter Active State — Stronger Visibility --- */

/* Add checkmark icon to active state (CSS-only, no color dependency) */
.custom-radio.active .radiomark {
    border-color: var(--accent);
    background: var(--accent);
}

.custom-radio.active .radiomark:after {
    /* Override circle with a checkmark shape */
    display: block;
    width: 5px;
    height: 10px;
    border: solid #060608;
    border-width: 0 2px 2px 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    transform: rotate(45deg);
    top: 1px;
    left: 5px;
}

/* --- PATCH 7: Accessibility — Results Count Live Region --- */
/* (Applied via HTML patch below — this ensures proper styling) */
.results-count[aria-live] {
    /* Visual styling stays the same; aria-live is functional only */
}

/* --- PATCH 8: Compositing Performance — Reduce Backdrop Blur on Mobile --- */
@media (pointer: coarse) {
    .gallery-item a {
        /* Reduce heavy blur on mobile to improve scroll performance */
        backdrop-filter: blur(12px) saturate(160%);
        -webkit-backdrop-filter: blur(12px) saturate(160%);
    }

    /* Use will-change sparingly for the sidebar (it persists on screen) */
    .sidebar {
        will-change: auto;
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }
}

/* ================================================================
   AI PHOTO SORT — Admin Ingestion Tab Styles
   ================================================================ */

/* --- Admin Tabs --- */
.admin-tabs {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-tab {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-tab:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-tab:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.03);
}

.admin-tab.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.admin-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

/* Tab content area */
.admin-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
}

.admin-tab-content.active {
    display: flex;
}

/* Header actions (exit + close) */
.ai-sort-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.exit-admin-btn {
    padding: 0.4rem 0.8rem;
    background: none;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: rgba(239, 68, 68, 0.7);
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exit-admin-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

/* --- Gallery Tools Panel --- */
.gallery-tools-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0;
}

.tools-info-card {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.06) 0%, rgba(52, 211, 153, 0.01) 100%);
    border: 1px solid rgba(52, 211, 153, 0.15);
    border-radius: 0.75rem;
    align-items: flex-start;
}

.tools-info-icon {
    width: 2rem;
    height: 2rem;
    color: #34d399;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.tools-info-card h3 {
    font-size: 0.95rem;
    color: #fff;
    font-weight: 500;
    margin: 0 0 0.35rem 0;
}

.tools-info-card p {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.6;
    margin: 0;
}

.tools-stats {
    display: flex;
    gap: 1rem;
}

.tools-stat {
    flex: 1;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.75rem;
    text-align: center;
}

.tools-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 300;
    color: var(--accent);
    line-height: 1.2;
}

.tools-stat-label {
    display: block;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.25rem;
}

/* --- Full-Screen AI Sort Modal --- */
.ai-sort-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    z-index: 55;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.ai-sort-modal.active {
    display: flex;
    opacity: 1;
}

.ai-sort-inner {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
    overscroll-behavior: contain;      /* prevents scroll from leaking to body behind modal */
}

.ai-sort-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.ai-sort-header h2 {
    font-size: 1.75rem;
    font-weight: 400;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-sort-header h2 .ai-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.ai-sort-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0.5rem;
    line-height: 1;
}

.ai-sort-close:hover { color: #fff; }

/* --- Glassmorphic Drop Zone --- */
.drop-zone {
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 1.25rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-shrink: 0;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 1.35rem;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0), rgba(52, 211, 153, 0));
    z-index: -1;
    transition: background 0.3s ease;
    opacity: 0;
}

.drop-zone:hover {
    border-color: rgba(52, 211, 153, 0.3);
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.drop-zone.drag-over {
    border-color: #34d399;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.1) 0%, rgba(52, 211, 153, 0.03) 100%);
    transform: scale(1.01);
    box-shadow: 0 0 40px rgba(52, 211, 153, 0.1), inset 0 0 40px rgba(52, 211, 153, 0.03);
}

.drop-zone.drag-over::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.15), rgba(52, 211, 153, 0.05));
}

.drop-zone-icon {
    width: 3rem;
    height: 3rem;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.3s ease, transform 0.3s ease;
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
    color: #34d399;
    transform: translateY(-4px);
}

.drop-zone-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.95rem;
    font-weight: 400;
}

.drop-zone-text strong {
    color: rgba(255, 255, 255, 0.75);
}

.drop-zone-subtext {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
}

.drop-zone input[type="file"] {
    display: none;
}

/* --- Processing Overlay --- */
.processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 8, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 1.25rem;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    z-index: 10;
}

.processing-overlay.active {
    display: flex;
}

.processing-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #34d399;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-text {
    color: #34d399;
    font-size: 0.9rem;
    font-weight: 500;
}

.processing-progress {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

/* --- Progress Bar --- */
.ai-progress-bar {
    width: 100%;
    max-width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.ai-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #34d399, #10b981);
    border-radius: 4px;
    width: 0%;
    transition: width 0.4s ease;
}

/* --- Review Grid (Pending Photos) --- */
.pending-section {
    flex: none;
    display: none;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    overflow: visible;
}

.pending-section.active {
    display: flex;
}

.pending-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.pending-header h3 {
    font-size: 1.1rem;
    color: #fff;
    font-weight: 400;
}

.pending-count {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.pending-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    overflow: visible;
    padding-bottom: 1rem;
}

/* --- Pending Card (Individual Photo Review) --- */
.pending-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
    will-change: transform;
}

.pending-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.pending-card-img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    background: #000;
    display: block;
}

.pending-card-body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pending-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pending-card-filename {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

/* --- Confidence Badges --- */
.confidence-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.confidence-high {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.confidence-medium {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.confidence-low {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* --- Tag Selects in Pending Cards --- */
.pending-tag-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pending-tag-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pending-tag-label {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    width: 70px;
    flex-shrink: 0;
}

.pending-tag-select {
    flex: 1;
    background: rgba(17, 18, 20, 0.8);
    border: 1px solid rgba(45, 49, 53, 0.8);
    color: #e5e7eb;
    border-radius: 6px;
    padding: 0.3rem 1.5rem 0.3rem 0.4rem;
    font-size: 0.72rem;
    outline: none;
    transition: border-color 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 0.7em;
}

.pending-tag-select:focus {
    border-color: var(--brand);
}

/* --- Reasoning Tooltip --- */
.reasoning-toggle {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.2rem 0;
    text-align: left;
    transition: color 0.2s ease;
}

.reasoning-toggle:hover { color: rgba(255, 255, 255, 0.6); }

.reasoning-text {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    line-height: 1.5;
    margin-top: 0.25rem;
    display: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.35rem;
}

.reasoning-text.active { display: block; }

/* --- Pending Card Actions --- */
.pending-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.pending-remove-btn {
    background: none;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: rgba(239, 68, 68, 0.7);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.pending-remove-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* --- Duplicate Badge --- */
.duplicate-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.5rem;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

/* --- Action Bar (Finalize / Discard) --- */
.ai-sort-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
    flex-shrink: 0;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-sort-actions button {
    padding: 0.65rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.ai-discard-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
}

.ai-discard-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.ai-finalize-btn {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: #34d399;
}

.ai-finalize-btn:hover {
    background: #34d399;
    color: #000;
}

.ai-finalize-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Mobile Responsive (Android-first ≤ 640px) --- */
@media (max-width: 640px) {

    /* Inner panel — tighter padding, no side margins */
    .ai-sort-inner {
        padding: 0.75rem 0.875rem;
    }

    /* ── Header: stack tabs above exit/close row ────────────── */
    .ai-sort-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.625rem;
        margin-bottom: 0.875rem;
    }

    /* Tabs: fill full width, equal columns, allow text wrap */
    .admin-tabs {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .admin-tab {
        padding: 0.55rem 0.25rem;
        font-size: 0.7rem;
        justify-content: center;
        text-align: center;
        white-space: normal;       /* allow wrapping on tiny screens */
        line-height: 1.2;
        gap: 0.25rem;
    }

    /* Gemini badge — hide on mobile to save space */
    .admin-tab .ai-badge {
        display: none;
    }

    /* Exit + close: right-aligned row below tabs */
    .ai-sort-header-actions {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .exit-admin-btn {
        padding: 0.45rem 0.875rem;
        font-size: 0.72rem;
        min-height: 36px;
    }

    /* ✕ close button — bigger touch target */
    .ai-sort-close {
        font-size: 1.75rem;
        padding: 0.25rem 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ── Drop zone — comfortable tap target ─────────────────── */
    .drop-zone {
        padding: 1.75rem 1rem;
        min-height: 140px;
    }

    .drop-zone-icon {
        width: 36px;
        height: 36px;
    }

    .drop-zone-text {
        font-size: 0.875rem;
    }

    .drop-zone-subtext {
        font-size: 0.7rem;
    }

    .pending-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    /* Card image — let the contain logic work */
    .pending-card-img {
        max-height: 250px;
    }

    /* Card body — more breathing room between rows */
    .pending-card-body {
        padding: 0.875rem;
        gap: 0.625rem;
    }

    /* Tag selects — larger font + taller for easy touch */
    .pending-tag-select {
        font-size: 0.8rem;
        padding: 0.45rem 1.75rem 0.45rem 0.5rem;
        min-height: 36px;
    }

    .pending-tag-label {
        font-size: 0.65rem;
        width: 58px;
    }

    /* Remove button — full width, taller */
    .pending-remove-btn {
        padding: 0.55rem;
        font-size: 0.72rem;
        min-height: 40px;
    }

    /* ── Action bar — stacked, full-width buttons ───────────── */
    .ai-sort-actions {
        flex-direction: column-reverse; /* Finalize on top (primary action) */
        gap: 0.625rem;
        margin-top: 0.875rem;
        padding-top: 0.875rem;
    }

    .ai-sort-actions button {
        width: 100%;
        padding: 0.875rem;
        font-size: 0.9rem;
        min-height: 52px;           /* large thumb target */
    }

    /* Pending header */
    .pending-header h3 {
        font-size: 0.95rem;
    }

    .pending-count {
        font-size: 0.72rem;
    }
}

/* --- PATCH 9: prefers-reduced-motion Safety Net --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
