* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure inline SVG icons inside interactive controls inherit the theme highlight color */
button svg,
.mode-icon svg,
.enhanced-action-btn svg,
.action-btn svg,
.modal-btn svg,
.batch-icon svg,
.btn-icon svg {
    color: var(--highlight-end, #0f77bd);
}

/* Use currentColor for strokes by default; fills are controlled per-icon via inline attributes */
svg {
    stroke: currentColor;
}

/* SVG rendering normalization for consistent icon appearance */
svg {
    vector-effect: non-scaling-stroke;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Suppress transitions/animations during initial app state restoration to avoid
   flicker of toggles and controls. This class is removed by JS as soon as
   initialization finishes. */
.no-transitions-on-init * {
    transition: none !important;
    animation: none !important;
}

/* Legacy gallery CSS neutralized: replaced by unified `.image-viewer` styles above.
   Keeping these commented out to avoid accidental conflicts; remove if safe.

   (Original gallery rules were here but have been neutralized.) */

/* Footer compact styles */
.modal-footer.compact {
    padding: 10px 12px;
    background: rgba(0,0,0,0.18);
    border-radius: 8px;
    width: 100%;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

/* Simple lightbox styles (minimal, centered single-image view) */
.simple-lightbox .modal-content {
    max-width: 1100px;
    width: calc(100% - 48px);
    padding: 12px;
    border-radius: 10px;
    background: rgba(10, 14, 17, 0.9);
}
.simple-lightbox .modal-header { position: relative; z-index: 5; }
.simple-lightbox .modal-header h3 { display: none; } /* hide overlapping label */
.simple-lightbox .modal-close { position: absolute; right: 14px; top: 10px; z-index: 10; }
/* Remove any stray top border/line that could run through the image */
.simple-lightbox .modal-header, .simple-lightbox .modal-content { border-top: none; }
.simple-lightbox .lightbox-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.simple-lightbox .lightbox-image-wrap {
    max-width: 100%;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.simple-lightbox .lightbox-image-wrap img {
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 8px;
}
.lightbox-nav {
    background: rgba(0,0,0,0.45);
    border: none;
    color: #fff;
    font-size: 28px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lightbox-nav:hover { background: rgba(0,0,0,0.6); }
.simple-lightbox .modal-overlay { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* Ensure modal footer buttons wrap instead of overflowing */
.simple-lightbox .modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.simple-lightbox .modal-actions .modal-btn { min-width: 88px; }

/* Fullscreen adjustments: allow the modal to expand while keeping content centered */
:-webkit-full-screen .simple-lightbox .modal-content,
:fullscreen .simple-lightbox .modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.simple-lightbox .modal-content { font-family: inherit; }
.simple-lightbox .modal-prompt { font-size: 14px; color: #ddd; }
.simple-lightbox .modal-image-info { color: #b7dff2; font-size: 13px; }

/* When a lightbox is active, ensure the page doesn't scroll and hides the vertical scrollbar leak */
.image-modal-active { overflow: hidden; height: 100%; }

/* Unified Image Viewer styles */
.image-viewer .viewer-content { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; color: #eee; }
.image-viewer .viewer-header { display:flex; align-items:center; justify-content:space-between; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.image-viewer .viewer-title { font-weight:600; font-size:16px; color:#fff; }
.image-viewer .modal-close { background: transparent; border: 1px solid rgba(255,255,255,0.06); color: #fff; padding:6px 10px; border-radius:8px; }

.image-viewer .viewer-body { display:flex; align-items:center; gap:12px; padding: 18px 12px; }
.image-viewer .viewer-main { flex:1 1 auto; display:flex; align-items:center; justify-content:center; }
.image-viewer .viewer-image { max-width:100%; max-height:72vh; object-fit:contain; border-radius:8px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }
.image-viewer .viewer-nav { background: rgba(0,0,0,0.45); border: none; color:#fff; width:44px; height:44px; border-radius:8px; display:inline-flex; align-items:center; justify-content:center; }

.image-viewer .viewer-thumbs { display:flex; gap:8px; padding: 8px 12px 18px 12px; overflow:auto; justify-content:center; }
.image-viewer .viewer-thumb { background:transparent; border:none; padding:2px; border-radius:6px; }
.image-viewer .viewer-thumb img { width:96px; height:64px; object-fit:cover; border-radius:6px; display:block; }
.image-viewer .viewer-thumb.active img { outline:3px solid rgba(59,130,246,0.9); box-shadow:0 6px 18px rgba(0,0,0,0.5); }

.image-viewer .viewer-footer { display:flex; align-items:center; gap:12px; padding: 12px; border-top:1px solid rgba(255,255,255,0.03); }
.image-viewer .viewer-prompt { flex:1 1 60%; font-size:14px; color:#cfeefd; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.image-viewer .viewer-info { color:#9fdaf4; font-size:13px; }
.image-viewer .viewer-actions { display:flex; gap:8px; }
.image-viewer .modal-btn { padding:8px 12px; border-radius:8px; font-size:14px; }
.image-viewer .modal-btn.primary { background: var(--highlight-gradient); color:#fff; border:none; }
.image-viewer .modal-btn.secondary { background: rgba(255,255,255,0.06); color:#fff; border:1px solid rgba(255,255,255,0.06); }

/* Responsive adjustments to keep buttons visible on narrow viewports */
@media (max-width: 720px) {
    .image-viewer .viewer-thumb img { width:72px; height:48px; }
    .image-viewer .viewer-body { padding: 12px; }
    .image-viewer .viewer-footer { flex-direction:column; align-items:stretch; gap:8px; }
    .image-viewer .viewer-prompt { white-space:normal; }
}

/* Ensure header controls remain visible on small screens. Allow wrapping and reduce gaps. */
@media (max-width: 480px) {
    .app-header .header-controls {
        gap: 6px;
        padding-right: 8px;
        flex-wrap: wrap;
        align-items: center;
    }
    .app-header .header-controls .primary-btn,
    .app-header .header-controls .mode-toggle-btn {
        padding: 0 8px !important;
        font-size: 0.75rem !important;
    }
    .app-header .header-controls #appVersion {
        order: 99;
        width: 100%;
        text-align: right;
        opacity: 0.9;
        padding-top: 4px;
    }
}

/* App version badge in header */
.app-version {
    font-size: 12px;
    color: var(--text-secondary, #9fb2c6);
    margin-left: 10px;
    padding: 0 6px;
    border-radius: 0;
    background: transparent;
    border: none;
    align-self: center;
}

/* Overlay version badge */
.overlay-version-badge {
    display: inline-block;
    font-size: 12px;
    color: var(--text-secondary, #9fb2c6);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.04);
    padding: 6px 8px;
    border-radius: 8px;
}
.simple-lightbox :fullscreen .lightbox-image-wrap img,
.simple-lightbox :-webkit-full-screen .lightbox-image-wrap img {
    max-height: 100vh;
    max-width: 100vw;
}

.modal-prompt .clamped-prompt {
    display: inline-block;
    max-width: 55vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}
.modal-header h3 { margin: 0; font-size: 1.1em; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.modal-prompt { max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-image-info { color: #9fdaf4; font-size: 0.9em; }

/* LLM spinner + status shown in simple mode when enhancing prompt */
.llm-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--muted-color, #444);
    margin-top: 8px;
    padding-left: 12px;
    position: relative;
    min-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.llm-status:not([style*="display: none"]) {
    opacity: 1;
    transform: translateY(0);
}

/* Toast container + toast styles (stacked toasts) */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
}
.toast {
    min-width: 220px;
}
.confirm-message { 
    color: #e6eef6; 
    font-size: 15px; 
    line-height: 1.4;
    text-align: left;
    margin-bottom: 16px;
}

.confirm-actions { 
    display: flex; 
    gap: 10px; 
    justify-content: flex-end;
    align-items: center;
}

.confirm-actions .modal-btn { 
    min-width: 96px; 
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
}

.confirm-box {
    text-align: left;
}
.llm-spinner {
     /* Default highlight values. Keep the dark stop slightly lighter than pure black so
         gradients remain visible when user picks a hue. The JS will override these via
         --highlight-color / --highlight-hue when the user customizes the theme. */
     --highlight-color: #0f77bd;
     --highlight-start: #111417; /* slightly lifted from #0a0a0a to preserve subtle gradient */
     --highlight-end: #0f77bd;
     --highlight-gradient: linear-gradient(135deg, var(--highlight-start), var(--highlight-end));
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: var(--accent-color, #1a73e8);
    border-radius: 50%;
    animation: llm-spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes llm-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive adjustments for mobile / small screens */
@media (max-width: 700px) {
    .image-modal .modal-content,
    .image-modal .modal-content.gallery-content {
        width: 95vw;
        max-width: 95vw;
        padding: 12px;
        border-radius: 10px;
        max-height: 90vh;
        overflow: auto;
    }

    /* Stack gallery layout vertically for narrow screens */
    .gallery-container {
        flex-direction: column;
        gap: 12px;
    }

    .gallery-main {
        flex: 1 1 100%;
        width: 100%;
    }

    /* Mobile: keep thumbnails horizontal and touch friendly */
    .gallery-thumbnails {
        width: 100%;
        order: 2;
        display: flex;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding: 8px 0;
    }

    .gallery-thumb {
        flex: 0 0 auto;
        width: 96px;
        height: 64px;
        border-radius: 8px;
        object-fit: cover;
    }

    /* Make modal footer buttons stack and touch-friendly */
    .modal-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .modal-actions {
        display: flex;
        gap: 10px;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .modal-actions .modal-btn {
        flex: 1 1 48%;
        min-height: 44px;
        padding: 10px 12px;
    }

    /* Make single-image modal image nicely responsive */
    .modal-image-container .modal-image,
    .gallery-main .modal-image {
        width: 100%;
        height: auto;
        max-height: 60vh;
        object-fit: contain;
        border-radius: 8px;
    }

    /* Compact header for mobile */
    .app-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .app-header h1 {
        font-size: 1.6rem;
        line-height: 1.2;
    }

    .app-logo {
        width: 34px;
        height: 34px;
    }

    .mode-toggle-btn {
        padding: 8px 10px;
    }

    /* Slightly reduce gallery item min-height on very small screens to fit viewports */
    .simple-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .simple-gallery-item {
        min-height: 380px;
    }
}


/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

::-webkit-scrollbar-corner {
    background: rgba(255, 255, 255, 0.05);
}

/* Firefox Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

/* Icon System */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
}

.icon svg, .icon img {
    width: 100%;
    height: 100%;
    display: block;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    margin-right: 8px;
}

.btn-icon svg, .btn-icon img {
    width: 100%;
    height: 100%;
}

.mode-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1em;
    height: 1.1em;
    margin-right: 6px;
}

.mode-icon svg, .mode-icon img {
    width: 100%;
    height: 100%;
}

/* Preview and Gallery Icons */
.preview-btn, .gallery-btn, .seed-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 8px;
}

.preview-btn svg, .preview-btn img, .gallery-btn svg, .gallery-btn img, .seed-btn svg, .seed-btn img {
    width: 20px;
    height: 20px;
}

/* Gallery button hover effects */
.gallery-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    transform: scale(1.05);
}

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
}

.empty-icon svg, .empty-icon img {
    width: 100%;
    height: 100%;
}

.placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
}

.placeholder-icon svg, .placeholder-icon img {
    width: 100%;
    height: 100%;
}

/* Smart thumbnail grid for gallery items (1-9 images) */
.smart-thumb-grid {
    display: grid;
    gap: 6px;
    width: 100%;
    height: 300px;
    align-items: stretch;
}
.smart-thumb-grid[data-rows="1"] { grid-template-rows: 1fr; }
.smart-thumb-grid[data-rows="2"] { grid-template-rows: 1fr 1fr; }
.smart-thumb-grid[data-rows="3"] { grid-template-rows: 1fr 1fr 1fr; }
.smart-thumb-grid[data-cols="1"] { grid-template-columns: 1fr; }
.smart-thumb-grid[data-cols="2"] { grid-template-columns: 1fr 1fr; }
.smart-thumb-grid[data-cols="3"] { grid-template-columns: 1fr 1fr 1fr; }
.smart-thumb-grid[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
.grid-thumb {
    overflow: hidden;
    position: relative;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.1));
}
.grid-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 220ms var(--ease-out-quart), filter 220ms var(--ease-out-quart);
}
.grid-thumb:hover img { transform: scale(1.03); filter: brightness(1.02); }
.grid-thumb.placeholder { display:flex; align-items:center; justify-content:center; color:var(--text-muted); font-weight:600; }
.grid-placeholder { font-size:1.1rem; opacity:0.85; }

/* Ensure gallery item click area (the wrapper) changes cursor and provides subtle hover */
.simple-gallery-item, .enhanced-gallery-item, .enhanced-item { cursor: pointer; transition: transform 220ms var(--ease-out-quart); }
.simple-gallery-item:hover, .enhanced-gallery-item:hover { transform: translateY(-4px); }

:root {
    /* Primary colors now derive from the user-configurable highlight so accents match */
    --primary-blue: var(--highlight-start, #00d4ff);
    --primary-green: var(--highlight-end, #006eff);
    --primary: var(--highlight-end, #00d4ff);
    --primary-hover: rgba(0,0,0,0.12);
    --primary-dim: rgba(0, 0, 0, 0.06);
    --dark-bg: #0a0a0a;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-color: #ffffff;
    --text-muted: #888888;
    --accent-gradient: var(--highlight-gradient);
    /* User-configurable highlight gradient (defaults) */
    --highlight-start: #363636; /* slightly lifted from pure black to keep gradient visible */
    --highlight-end: #0f77bd;
    --highlight-gradient: linear-gradient(135deg, var(--highlight-start), var(--highlight-end));
    --success: #00ff88;
    --warning: #ffaa00;
    --error: #ff4444;
    --muted: #555555;
    
    /* Enhanced Glass Morphism */
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
    --glass-shadow-active: 0 4px 16px rgba(0, 0, 0, 0.2);
    
    /* Enhanced Typography */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Animation Easings */
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
    --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--dark-bg);
    background-image: 
    radial-gradient(circle at 20% 80%, rgba(0,0,0,0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 110, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(0, 255, 136, 0.03) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    font-weight: var(--font-weight-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;    
}

.app-container {
    width: 100%;
    margin: 0 auto;
    padding: 0px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 8px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border-radius: 0;
    height: 44px;
    box-sizing: border-box;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 28px;
}

.mode-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    height: 28px;
    background: transparent;
    border:none;
    /* background: rgba(255, 255, 255, 0.05); */
    /* border: 1px solid rgba(255, 255, 255, 0.1); */
    /* border-radius: 6px; */
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.mode-toggle-btn:hover {
    /* Keep hover subtle to avoid layout shifts */
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.95);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff, #0f77bd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    line-height: 1.2;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}
.app-logo img {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-tagline {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.app-logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}



.mode-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-text {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff, #0f77bd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Force the app logo to render without border, background, shadow or blur chrome.
   The SVG itself contains the visual; UI should not add framing around it. */
.app-header .app-logo,
.app-header .app-logo img,
.app-header .app-logo svg {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    padding: 0 !important;
}

.app-logo {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.app-logo:hover {
    transform: scale(1.05);
}

.app-logo svg, .app-logo img {
    width: 32px;
    height: 32px;
    transition: filter 0.3s ease;
}

.app-logo:hover svg, .app-logo:hover img {
    filter: brightness(1.1);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.connection-status:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-icon {
    display: flex;
    align-items: center;
    position: relative;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.status-icon svg {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.status-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid var(--background);
    transition: all 0.3s ease;
}

.settings-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.settings-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

/* Failed job styling */
.enhanced-gallery-item.failed,
.enhanced-gallery-item.error {
    border: 1px solid rgba(255, 68, 68, 0.3);
    background: rgba(255, 68, 68, 0.05);
}

.enhanced-item-status.failed,
.enhanced-item-status.error {
    color: #ff4444;
}

.remove-btn {
    background: rgba(255, 68, 68, 0.2) !important;
    color: #ff4444 !important;
}

.remove-btn:hover {
    background: rgba(255, 68, 68, 0.3) !important;
    color: #ff6666 !important;
}

.retry-btn {
    background: rgba(255, 170, 0, 0.2) !important;
    color: #ffaa00 !important;
}

.retry-btn:hover {
    background: rgba(255, 170, 0, 0.3) !important;
    color: #ffcc33 !important;
}

/* Theme icon switching */
.theme-moon {
    display: none;
}

[data-theme="dark"] .theme-sun {
    display: none;
}

[data-theme="dark"] .theme-moon {
    display: block;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.server-status .status-text {
    font-weight: 500;
    color: var(--text-color);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

.status-indicator.connected {
    background: var(--success);
    animation: none;
}

.status-indicator.error {
    background: var(--error);
    animation: pulse 1s infinite;
}

/* Connection Configuration Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.modal.show,
.modal[style*="flex"] {
    display: flex;
}

.connection-modal {
    max-width: 800px;
    width: 90vw;
    background: rgba(26, 32, 44, 0.95);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Ensure modal content doesn't overflow the viewport and allow internal scrolling */
.connection-modal {
    position: relative;
    max-height: calc(100vh - 60px);
    /* Allow shadows and controls to extend slightly; body will scroll instead of clipping footer */
    overflow: visible;
}

.server-config {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.server-config h3 {
    margin: 0 0 15px 0;
    color: var(--primary);
    font-size: 18px;
}

.server-fields {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 15px;
    align-items: end;
}

/* Ollama parameters grid for better organization */
.ollama-params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    grid-column: 1 / -1;
    margin-top: 15px;
}

.ollama-params-grid .form-group {
    margin-bottom: 0;
}

/* Full width for model and system instruction */
.ollama-full-width {
    grid-column: 1 / -1;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .connection-modal {
        max-width: 95vw;
        width: 95vw;
    }
    
    .ollama-params-grid {
        grid-template-columns: 1fr;
    }
    
    .server-fields {
        grid-template-columns: 1fr;
    }
}

.connection-test {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.test-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.test-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.test-btn:disabled {
    background: var(--muted);
    cursor: not-allowed;
    transform: none;
}

.test-result {
    font-size: 14px;
    font-weight: 500;
}

.test-result.success {
    color: var(--success);
}

.test-result.error {
    color: var(--error);
}

/* Modal Structure */
.modal-header {
    padding: 25px 25px 20px 25px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: 70vh;
}

/* Make modal footer sticky so buttons are always visible and not overlapped by body content */
.connection-modal .modal-footer,
.modal-content .modal-footer {
    position: sticky;
    bottom: 0;
    /* Match the modal background so buttons are crisp and not visually doubled */
    background: rgba(26, 32, 44, 0.95);
    z-index: 60; /* above modal body content */
}

.modal-footer {
    padding: 20px 25px 25px 25px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 60px;
}

/* Settings modal footer specifically */
.modal-content .modal-footer {
    padding: 20px 25px 25px 25px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    flex-wrap: nowrap;
    min-height: 60px;
}

.primary-btn, .secondary-btn {
    padding: 4px 16px;
    height: 28px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    outline: none;
}

.primary-btn {
    background: linear-gradient(135deg, #0f77bd, #1a8cd6);
    color: white;
    box-shadow: 0 1px 3px rgba(15, 119, 189, 0.2);
}

.primary-btn:hover {
    background: linear-gradient(135deg, #0d6ba8, #1680c4);
    box-shadow: 0 2px 6px rgba(15, 119, 189, 0.3);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.app-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Simple Layout */
.simple-layout {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 30px;
    align-items: start;
}

.simple-form-container {
    /* background: var(--glass-bg); */
    border-right: 1px solid var(--glass-border);
    border-radius: 0px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 30px;
}

.simple-gallery-container {
    background: transparent; /* flat */
    border: none;
    border-radius: 0;
    padding: 8px; /* reduced padding */
    min-height: 500px;
}

.simple-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px; /* tighter grid */
    height: 100%;
}

/* Polished gallery cards: consistent sizing, aligned footers, and smooth hover */
.simple-gallery-item {
    display: flex;
    flex-direction: column;
    background: transparent; /* flat item */
    border: none;
    border-radius: 0;
    overflow: visible;
    /* Reserve consistent vertical space so generating placeholders and completed items don't jump */
    min-height: 420px;
    transition: transform 180ms var(--ease-out-quart);
}

/* Card header badge and action overlay */
.simple-image-container .image-badge {
    position: absolute;
    left: 12px;
    top: 12px;
    background: rgba(0,0,0,0.45);
    color: #e6f5ff;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}
.image-actions {
    position: absolute;
    right: 10px;
    top: 10px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 180ms ease, transform 180ms ease;
}
.simple-gallery-item.completed:hover .image-actions {
    opacity: 1;
    transform: translateY(-2px);
}

/* Loading spinner and empty state centering */
.empty-state { display:flex; align-items:center; justify-content:center; flex-direction:column; padding: 40px; color: var(--text-muted); }
.empty-icon { margin-bottom: 12px; }

/* Slightly stronger shadow on hover for completed items */
.simple-gallery-item.completed:hover { box-shadow: var(--glass-shadow-hover); }

/* Small responsive tweaks: reduce min-height on narrow viewports */
@media (max-width: 720px) {
    .simple-gallery { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .simple-gallery-item { min-height: 360px; }
    .simple-image-container { min-height: 260px; }
}

/* Ensure the image area reserves space and preserves aspect ratio to avoid layout shift */
.simple-image-container {
    aspect-ratio: 16 / 10;
    min-height: 260px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
}

.simple-controls {
    margin: 20px 0;
}

/* Batch Presets */
.batch-explanation {
    font-size: 0.9em;
    color: #666;
    margin: 0.5rem 0 1rem 0;
    line-height: 1.4;
}

.batch-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 10px;
}

.batch-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--text-color);
    min-height: 120px;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.batch-preset:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-dim);
    transform: translateY(-2px);
}

.batch-preset.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(0,0,0,0.26);
}

.batch-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.batch-icon svg, .batch-icon img {
    width: 100%;
    height: 100%;
}

.batch-number {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3px;
    line-height: 1;
    flex-shrink: 0;
}

.batch-label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
    line-height: 1;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.batch-time {
    font-size: 10px;
    opacity: 0.6;
    line-height: 1;
    flex-shrink: 0;
}

.batch-hint {
    font-size: 12px;
    opacity: 0.7;
    font-weight: normal;
    margin-left: 8px;
}

/* Compact shape selector for simple mode */
.shape-selector-compact {
    margin: 1rem 0;
}

.shape-icons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.shape-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-width: 42px;
    min-height: 42px;
}

.shape-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-dim);
    transform: translateY(-2px);
}

.shape-icon-btn.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(0,0,0,0.26);
}

.shape-icon-btn .shape-icon {
    width: 24px;
    height: 18px;
    border: 2px solid var(--primary);
    border-radius: 3px;
    background: var(--primary-dim);
    opacity: 0.8;
    position: relative;
    margin: 0;
}

.shape-icon-btn .shape-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background: var(--primary);
    border-radius: 1px;
    opacity: 0.6;
}

.shape-icon-btn .square-icon {
    width: 18px;
    height: 18px;
}

.shape-icon-btn .portrait-icon {
    width: 15px;
    height: 21px;
}

.shape-icon-btn .landscape-icon {
    width: 27px;
    height: 15px;
}

.shape-icon-btn .tall-icon {
    width: 12px;
    height: 24px;
}

.shape-icon-btn .wide-icon {
    width: 30px;
    height: 12px;
}

.shape-selection-info {
    text-align: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.selected-shape-name {
    font-weight: 600;
    color: var(--primary);
    font-size: 16px;
    margin-bottom: 4px;
}

.selected-shape-description {
    font-size: 0.85em;
    opacity: 0.8;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Advanced mode shape selector adaptations */
.shape-selector-compact.advanced-mode {
    margin: 0.5rem 0;
}

.shape-selector-compact.advanced-mode .shape-icons {
    gap: 6px;
    margin-bottom: 8px;
}

.shape-selector-compact.advanced-mode .shape-icon-btn {
    padding: 6px;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.shape-selector-compact.advanced-mode .shape-label {
    font-size: 0.75em;
    margin-top: 4px;
    opacity: 0.8;
    white-space: nowrap;
}

.shape-selector-compact.advanced-mode .shape-icon-btn.active .shape-label {
    opacity: 1;
    color: var(--primary);
    font-weight: 500;
}

/* Advanced size controls */
.advanced-size-controls {
    margin-top: 12px;
}

.advanced-size-controls .size-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.advanced-size-controls .size-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
}

.advanced-size-controls .size-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-dim);
}

.advanced-size-controls .size-btn.active {
    background: var(--accent-gradient);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0,0,0,0.18);
}

.advanced-size-controls .size-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.advanced-size-controls .size-icon svg, .advanced-size-controls .size-icon img {
    width: 20px;
    height: 20px;
    color: var(--primary);
    opacity: 0.8;
    transition: all 0.3s ease;
}

.advanced-size-controls .size-btn.active .size-icon svg, .advanced-size-controls .size-btn.active .size-icon img {
    opacity: 1;
    color: var(--primary);
}

.advanced-size-controls .size-label {
    font-size: 0.85em;
    opacity: 0.9;
}

.advanced-size-controls .size-btn.active .size-label {
    opacity: 1;
    font-weight: 500;
}

.advanced-size-controls .dimensions-display {
    text-align: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    margin-bottom: 8px;
}

.advanced-size-controls .dimensions-display span {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1em;
}

.advanced-size-controls .dimensions-display small {
    display: block;
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 2px;
}

/* Upscale preview */
.upscale-preview {
    margin-top: 8px;
}

.dimensions-preview {
    text-align: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid var(--glass-border);
}

.dimensions-preview span {
    font-weight: 600;
    color: var(--primary);
    font-size: 1em;
}

.dimensions-preview small {
    display: block;
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 2px;
}

.generate-btn.large {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    color: var(--text-secondary);
    height: 100%;
    min-height: 200px;
    padding-top: 40px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.empty-state p {
    max-width: 280px;
    min-width: 220px;
    border-radius: 8px;
    padding: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* Keep items a consistent taller height to avoid layout shift between generating/completed */
    min-height: 420px;
}

/* Only apply hover effects to completed items to prevent flashing during loading */
.simple-gallery-item.completed:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.22);
}

/* Ensure generating items use the same baseline look (no jump) */
.simple-gallery-item.generating,
.simple-gallery-item.pending,
.simple-gallery-item.queued {
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    border-color: rgba(255,255,255,0.06);
}

/* Disable hover effects for loading/generating items */
.simple-gallery-item.generating,
.simple-gallery-item.waiting {
    cursor: default;
}

.simple-image-container {
    position: relative;
    width: 100%;
    flex: 1;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Increase image container height to match the desired larger card size and keep consistent */
    min-height: 300px;
}

.simple-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Item info area: stick to bottom, keep text readable and neatly spaced */
.simple-item-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px 18px 16px;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.02));
}
.simple-status-row { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.simple-prompt { flex: 1 1 auto; font-size: 0.95rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.simple-prompt-original { color: #e6f5ff; font-weight: 600; }
.simple-prompt-enhanced { color: #cfeefd; font-size: 0.9rem; opacity: 0.95; }

/* Progress bar and status polishing */
.progress-bar { height: 10px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--highlight-end); width: 0%; transition: width 240ms var(--ease-out-quart); }

/* Header control fixes: keep status block compact and aligned */
.header-controls {
    display: flex;
    gap: 14px;
    align-items: center;
}
.connection-status { display:flex; gap:10px; align-items:center; }
.server-status { display:flex; gap:8px; align-items:center; }
.status-indicator { width:10px; height:10px; border-radius:50%; background: rgba(255,255,255,0.06); box-shadow: 0 0 0 4px rgba(0,0,0,0.12) inset; }
.status-indicator.online { background: var(--success); box-shadow: none; }
.status-text { font-size: 0.9rem; color: var(--text-secondary); }

/* Thumbnail Grid Styles */
.thumbnail-grid {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    gap: 2px;
    cursor: pointer;
}

.thumb-grid-1 {
    grid-template-columns: 1fr;
}

.thumb-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.thumb-grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.thumb-grid-dynamic {
    display: grid;
    gap: 4px;
    width: 100%;
    height: 100%;
    /* Grid columns and rows set dynamically via inline styles */
}

.thumb-grid-3-dynamic {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
}

.thumb-grid-6 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.thumb-grid-9 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

.thumb-item {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-item.pending {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.2em;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.thumb-placeholder::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2L13.09 8.26L22 9L13.09 9.74L12 16L10.91 9.74L2 9L10.91 8.26L12 2Z' stroke='%23ffffff20' stroke-width='2' fill='none'/%3E%3C/svg%3E") center/24px 24px no-repeat;
    opacity: 0.3;
}

.thumb-progress {
    position: absolute;
    bottom: 2px;
    left: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.7em;
    text-align: center;
    font-weight: bold;
}

/* Enhanced thumbnail grid container */
.thumbnail-grid-container {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Horizontal thumbnail row (used by createThumbnailGrid) */
.thumbnail-row {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: stretch;
    overflow-x: auto;
    /* prevent vertical scrollbars from appearing due to rounding/layout */
    overflow-y: hidden;
}

/* Thin overlay scrollbar for thumbnail rows (modern browsers) */
.thumbnail-row::-webkit-scrollbar { height: 8px; }
.thumbnail-row::-webkit-scrollbar-track { background: transparent; }
.thumbnail-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 6px; }
.thumbnail-row { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.06) transparent; }

.thumbnail-row .thumb-item {
    flex: 0 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,0.02);
}

.thumb-label {
    margin-top: 6px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Default highlight swatch (overridden by header-specific rules) */
.highlight-swatch {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    display: inline-block;
}
.highlight-swatch:focus {
    outline: 2px solid var(--highlight-start);
    outline-offset: 1px;
}

/* Thumb overflow badge (e.g. +3) */
.thumb-overflow {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 6px 8px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9em;
    box-shadow: 0 6px 18px rgba(0,0,0,0.36);
}

/* Enhanced thumbnail progress indicators */
.thumb-item.generating .thumb-placeholder {
    /* Use highlight gradient for generating placeholders */
    background: var(--highlight-gradient);
    position: relative;
    overflow: hidden;
}

.thumb-item.generating .thumb-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 1.5s infinite;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.thumb-check {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.thumb-number {
    font-size: 0.8em;
    font-weight: bold;
    color: var(--text-secondary);
}

/* Error state for failed images */
.thumb-item.image-error {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.thumb-item.image-error::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' stroke='%23ffffff40' stroke-width='2' fill='none'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5' stroke='%23ffffff40' stroke-width='1' fill='none'/%3E%3Cpath d='M21 15l-5-5L5 21' stroke='%23ffffff40' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/32px 32px no-repeat;
    opacity: 0.4;
}

/* Overall Progress Container */
.overall-progress-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
}

.overall-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.overall-progress-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.overall-stats {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 0.9rem;
}

.overall-stats .progress-count {
    color: var(--primary);
    font-weight: 600;
}

.overall-stats .progress-percentage {
    color: var(--primary-green);
    font-weight: 600;
    font-size: 1.1em;
}

.overall-stats .active-jobs {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.overall-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

    .overall-progress-fill {
    height: 100%;
    background: var(--highlight-gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Enhanced Progress Container */
.progress-container {
    margin-top: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.progress-stats {
    display: flex;
    gap: 10px;
    align-items: center;
}

.progress-timing {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.85em;
}

.elapsed-time {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Simple Mode Progress Bars */
.progress-bar-container {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar-container .progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.04);
}

    .progress-bar-container .progress-bar-fill {
    height: 100%;
    background: var(--highlight-gradient);
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.progress-bar-container .elapsed-time {
    font-size: 0.75em;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 40px;
}

.progress-bar-container .progress-status-mini {
    font-size: 0.7em;
    color: var(--primary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.progress-bar-container .completion-info {
    font-size: 0.75em;
    color: var(--success);
    font-weight: 500;
}

.progress-bar-container.completed .progress-bar-fill {
    background: linear-gradient(135deg, var(--success), var(--highlight-end));
}

/* New Progress Section Styling */
.progress-section {
    margin-top: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(15, 18, 22, 0.8), rgba(15, 18, 22, 0.4));
    border-radius: 10px;
    border: 1px solid rgba(55, 65, 81, 0.3);
    backdrop-filter: blur(5px);
}

.progress-section.completed {
    background: linear-gradient(135deg, rgba(22, 101, 52, 0.15), rgba(22, 101, 52, 0.05));
    border-color: rgba(34, 197, 94, 0.3);
}

.progress-section .progress-bar-container {
    margin-top: 0;
    display: block;
}

.progress-section .progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(55, 65, 81, 0.4);
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid rgba(75, 85, 99, 0.2);
    overflow: hidden;
}

.progress-section .progress-bar-fill {
    height: 100%;
    background: var(--highlight-gradient);
    border-radius: 6px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 12px rgba(0,0,0,0.24);
    position: relative;
}

.progress-section .progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

/* Use highlight-end for active thumbnail outlines */
.image-viewer .viewer-thumb.active img {
    outline: 3px solid var(--highlight-end);
    box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}

/* Make primary buttons use the highlight gradient */
.image-viewer .modal-btn.primary,
.modal-btn.primary {
    background: var(--highlight-gradient) !important;
    color: #fff;
    border: none;
}

/* Improve swatch visibility */
.highlight-swatch {
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-section.completed .progress-bar-fill {
    background: linear-gradient(90deg, var(--success), var(--highlight-end));
    box-shadow: 0 0 12px rgba(0,0,0,0.2);
}

.progress-section.completed .progress-bar-fill::after {
    display: none;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #9ca3af;
}

.progress-info .elapsed-time {
    font-weight: 500;
    color: var(--highlight-end);
}

.progress-info .progress-status {
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}

.completion-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.completed-count {
    color: #22c55e;
    font-weight: 500;
    font-size: 13px;
}

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-indicator.generating {
    color: var(--highlight-end);
    animation: pulse 2s infinite;
}

.status-indicator.completed {
    color: var(--success);
}

.status-indicator.error {
    color: #ef4444;
}

.status-indicator.queued,
.status-indicator.pending {
    color: #f59e0b;
    animation: pulse 2s infinite;
}

.status-icon {
    width: 16px;
    height: 16px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Action Buttons */
.image-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.simple-gallery-item:hover .image-actions {
    opacity: 1;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
}

.action-btn svg, .action-btn img {
    width: 14px;
    height: 14px;
}

/* Ensure inlined icon images are visible on dark backgrounds */
.action-btn img, .action-btn svg {
    filter: brightness(200%) contrast(120%);
}

/* Provide a subtle stroke/background for monochrome SVG icons that might be dark */
.action-btn svg { 
    stroke: #fff; 
    fill: none;
}

.action-btn.regenerate-btn:hover {
    background: rgba(255,255,255,0.04);
    color: var(--highlight-end);
}

.action-btn.download-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.action-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Simple Gallery Item Layout */
.simple-status-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.simple-prompt {
    flex: 1;
    margin-left: 4px;
}

.simple-image-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

/* Polished completed info */
.simple-completed-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, rgba(0,0,0,0.6), rgba(0,0,0,0.4));
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--success);
    font-weight: 600;
}
.simple-completed-info .completed-label {
    font-size: 0.9em;
}
.simple-completed-info .completed-timestamp {
    font-size: 0.85em;
    color: #c8ffd6;
}

.completion-time {
    color: #6b7280;
    font-size: 10px;
    opacity: 0.6;
    font-weight: 400;
}

/* Queue Item Styling */
.active-item-content,
.queue-item-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.active-item-prompt,
.queue-item-prompt {
    flex: 1;
    font-size: 13px;
    color: #e5e7eb;
    line-height: 1.4;
}

.queue-item-details {
    flex: 1;
}

.queue-item-params {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.active-item,
.queue-item {
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(55, 65, 81, 0.3);
}

.active-item.generating {
    border-color: rgba(0,0,0,0.12);
    background: rgba(255,255,255,0.02);
}

.active-item.completed {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.05);
}

/* Beautiful Clean Placeholders */
.simple-placeholder {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1f2937, #111827);
    position: relative;
    overflow: hidden;
}

.simple-placeholder.generating {
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

.simple-placeholder.error {
    background: linear-gradient(135deg, #450a0a, #7f1d1d);
}

.generating-spinner {
    width: 40px;
    height: 40px;
    position: relative;
}

.spinner-ring {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255,255,255,0.06);
    border-top: 3px solid var(--highlight-end);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error-icon {
    width: 32px;
    height: 32px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}

.placeholder-shimmer {
    width: 80%;
    height: 80%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    border-radius: 4px;
    animation: shimmer 2s infinite;
}

.queue-item.pending {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.05);
}

.progress-status {
    color: var(--highlight-end);
    font-size: 0.8em;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--highlight-gradient);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-count {
    color: var(--highlight-end);
    font-weight: 600;
    font-size: 0.9em;
}

.progress-percent {
    color: var(--success);
    font-weight: 600;
    font-size: 0.9em;
}

.thumb-label {
    position: absolute;
    bottom: 1px;
    left: 1px;
    right: 1px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.6em;
    text-align: center;
    padding: 1px;
    border-radius: 2px;
}

/* Simple inline progress bar that actually works */
.simple-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin: 4px 0;
}

.simple-progress-fill {
    height: 100%;
    background: var(--highlight-gradient);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-info {
    padding: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    margin: 4px 0;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.progress-timing {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8em;
    color: #ccc;
    margin-top: 4px;
}

/* Progress bar styles */
.progress-container {
    margin-top: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(45deg, var(--primary-blue), var(--secondary-purple));
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

/* No shimmer animation - show static progress bars only */
.simple-gallery-item.generating .progress-fill::after {
    display: none;
}

/* No shimmer for completed jobs */
.simple-gallery-item.completed .progress-fill::after {
    display: none;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7em;
    color: white;
}

.progress-count {
    font-weight: bold;
}

.progress-percent {
    color: var(--primary-blue);
    font-weight: bold;
}

.progress-status {
    font-size: 0.6em;
    color: var(--text-secondary);
}

/* Animations */
@keyframes thumbFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Status indicators */
.status-generating {
    color: var(--primary-blue);
    animation: pulse 2s infinite;
}

.status-queued {
    color: #ffc107;
}

.status-pending {
    color: var(--text-secondary);
}

.status-completed {
    color: #28a745;
}

.status-error {
    color: #dc3545;
}

.status-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.status-check {
    color: #28a745;
    font-weight: bold;
    font-size: 14px;
}

.status-error {
    color: #dc3545;
    font-weight: bold;
    font-size: 16px;
}

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

.status-processing {
    color: var(--primary-blue);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.thumb-overflow {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 4px;
}

.simple-placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.simple-item-info {
    text-align: center;
    flex-shrink: 0;
}

.simple-prompt {
    color: var(--text-primary);
    font-size: 0.8rem;
    margin-bottom: 6px;
    line-height: 1.2;
    font-weight: 500;
}

.simple-status {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
}

.simple-status.generating {
    background: rgba(255, 170, 0, 0.2);
    color: var(--warning);
}

.simple-status.completed {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.simple-status.error {
    background: rgba(255, 68, 68, 0.2);
    color: var(--error);
}

.enhancement-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px 0;
}

.enhancement-toggle input[type="checkbox"] {
    display: none;
}

.enhancement-toggle .toggle-slider {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.enhancement-toggle .toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.enhancement-toggle input[type="checkbox"]:checked + .toggle-slider {
    background: var(--accent-gradient);
}

.enhancement-toggle input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.enhancement-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.enhancement-label strong {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.enhancement-label small {
    color: rgba(255, 255, 255, 0.7);
    display: block;
    margin-top: 2px;
}

/* Batch image handling */
.batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 5px;
    width: 100%;
    height: 100%;
}

.batch-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

/* Only apply hover scale to completed batch images */
.batch-image.completed:hover {
    transform: scale(1.05);
}

/* Disable hover for generating/waiting batch images */
.batch-image.generating,
.batch-image.waiting {
    cursor: default;
}

.batch-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    background: linear-gradient(45deg, var(--primary-blue), var(--secondary-purple));
    color: white;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.75em;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Batch controls */
.batch-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 8px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-item:hover .batch-controls {
    opacity: 1;
}

.batch-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.7em;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    text-align: center;
}

.batch-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-blue);
    transform: translateY(-1px);
}

/* Image count displays */
.simple-image-count {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-top: 4px;
}

.thumb-count {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.7em;
    font-weight: bold;
}

/* Image action buttons */
.image-actions {
    position: absolute;
    bottom: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    /* Allow clicks to pass through container; only buttons should receive pointer events */
    pointer-events: none;
}

.simple-image-container:hover .image-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    /* Buttons must accept pointer events despite the container being pointer-events:none */
    pointer-events: auto;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.regenerate-btn:hover {
    background: rgba(34, 197, 94, 0.8);
}

.download-btn:hover {
    background: rgba(59, 130, 246, 0.8);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Enhancement options */
.enhancement-options {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s, max-height 0.3s;
    overflow: hidden;
}

.enhancement-options.hidden {
    opacity: 0.5;
    max-height: 0;
    padding: 0 15px;
    margin-top: 0;
}

/* When enhancement options are rendered inside the advanced duplicate box, flatten their appearance
   so the UI doesn't become nested boxes inside boxes. The advanced container handles the card visuals. */
.advanced-settings .enhancement-options {
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 8px;
}

/* Prompt display styles */
.simple-prompt-original {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin-bottom: 3px;
}

.simple-prompt-enhanced {
    color: rgba(139, 195, 74, 0.8);
    font-size: 0.85em;
    font-style: italic;
    margin-top: 3px;
    border-left: 2px solid rgba(139, 195, 74, 0.3);
    padding-left: 8px;
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: rgba(26, 32, 44, 0.95);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    max-width: 90vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Auth modal specific tweaks */
.modal-content.auth-modal,
.auth-modal .modal-content {
    max-width: 760px;
    width: calc(100% - 64px);
    padding: 0;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.auth-tab {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
}

.auth-tab.active {
    background: var(--highlight-gradient);
    color: #fff;
    border-color: rgba(255,255,255,0.06);
}

.auth-form {
    padding: 18px 24px 28px 24px;
    display: block;
}

.auth-form .form-group { margin-bottom: 12px; }
.auth-form label { display:block; margin-bottom:6px; color: var(--text-secondary); font-size:0.95rem; }
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    color: var(--text-primary);
    font-size: 14px;
}

.auth-form .primary-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 15px;
}

/* small helper for inline error messages inside the modal */
.auth-error {
    color: var(--error);
    font-size: 13px;
    margin-top: 8px;
}

/* ensure modal header close icon sits correctly */
.modal-header #closeAuthModal, .modal-header .modal-close {
    font-size: 22px;
    width: 36px;
    height: 36px;
}

/* FULLSCREEN AUTH OVERLAY */
.auth-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none; /* toggled to flex by JS */
    align-items: stretch;
    justify-content: center;
    z-index: 20000;
    background: linear-gradient(120deg, #0f1a2b 0%, #1a2c4a 50%, #0a0e14 100%);
    animation: overlay-bg-animate 2.8s cubic-bezier(.2,.9,.2,1) forwards;
}

.auth-overlay.show {
    display: flex;
}

@keyframes overlay-bg-animate {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}
.auth-overlay .overlay-inner {
    display: grid;
    grid-template-columns: 1fr 420px;
    width: min(1100px, 96%);
    height: min(720px, 92%);
    margin: auto;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
.auth-overlay .branding {
    background: linear-gradient(180deg, rgba(20,24,28,0.6), rgba(6,10,16,0.8));
    padding: 36px;
    display:flex;
    flex-direction:column;
    gap:18px;
    color: #fff;
}
.auth-overlay .branding .brand-logo {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    display:flex;
    align-items:center;
    justify-content:center;
    /* flatten visual style to match rest of UI */
    box-shadow: none;
    transform: none;
    animation: none;
}
.auth-overlay.show .branding .brand-logo {
    animation: logo-pulse 1.2s cubic-bezier(.2,.9,.2,1) 1;
}
@keyframes logo-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(15,119,189,0.18); }
    40% { transform: scale(1.08); box-shadow: 0 12px 30px 0 rgba(15,119,189,0.22); }
    60% { transform: scale(1.04); box-shadow: 0 8px 18px 0 rgba(15,119,189,0.16); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(15,119,189,0.18); }
}
.auth-overlay .branding h2 { font-size: 28px; margin-top: 8px; }
.auth-overlay .branding p { color: rgba(255,255,255,0.8); line-height:1.4; }
.auth-overlay .primary-btn,
.auth-overlay .secondary-btn {
    transition: transform 120ms cubic-bezier(.2,.9,.2,1);
}
.auth-overlay .primary-btn:active,
.auth-overlay .secondary-btn:active {
    transform: translateY(0);
}
.auth-overlay :focus {
    outline: 3px solid #3b82f6;
    outline-offset: 3px;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.18);
}
.auth-overlay .form-pane { background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)); padding: 28px; display:flex; flex-direction:column; gap:12px; }
.auth-overlay .form-pane .close-btn { align-self:flex-end; background: transparent; border: none; color: #fff; font-size: 22px; cursor:pointer; }
.auth-overlay .form-pane .form-inner { overflow:auto; padding-right:8px; }
.auth-overlay .form-pane .small-muted { color: rgba(255,255,255,0.6); font-size:13px; }

/* Overlay entrance/exit animation */
.auth-overlay { opacity: 0; transition: opacity 220ms ease; }
.auth-overlay.show { opacity: 1; }
.auth-overlay .overlay-inner { transform: translateY(8px); transition: transform 260ms cubic-bezier(.2,.9,.2,1), box-shadow 260ms; }
.auth-overlay.show .overlay-inner { transform: translateY(0); }

/* Button loading state: show spinner and visually indicate disabled */
.primary-btn.loading, .secondary-btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}
.primary-btn.loading::after, .secondary-btn.loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12);
    border-top-color: rgba(255,255,255,0.92);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* Branding pulse to add life when overlay opens */
.auth-overlay .branding .brand-logo {
    transition: none;
}
.auth-overlay.show .branding .brand-logo {
    transform: none;
}

/* Visible focus outlines within overlay for accessibility */
.auth-overlay :focus {
    outline: 3px solid rgba(59,130,246,0.18);
    outline-offset: 3px;
}

/* Subtle button hover micro-interaction */
.auth-overlay .primary-btn:hover { transform: translateY(-2px); transition: transform 160ms ease; }
.auth-overlay .primary-btn { transition: transform 160ms ease, box-shadow 160ms ease; }

/* Disabled control click helper */
.disabled-click-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    z-index: 30000;
    display: none;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.disabled-click-hint.show { display: block; }

/* Make overlay responsive */
@media (max-width: 900px) {
    .auth-overlay .overlay-inner { grid-template-columns: 1fr; height: 86vh; }
    .auth-overlay .branding { display:none; }
}

/* Default modal header (used by small dialog modals such as connection/settings) */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3em;
}

/* Generic .modal-close (small icon-style) kept for compatibility but many modals
   use this class for footer buttons too. We'll scope the large, absolute icon
   style to the full-screen image modal below and provide a footer override so
   connection/settings footer buttons keep the normal button appearance. */
.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

/* Footer-specific override: when a close control appears inside a modal footer
   (e.g. the 'Cancel' button in the connection modal) we want it to look like
   a normal footer button, not the circular header icon. This rule ensures
   footer close buttons inherit the footer/button styles and are not clipped. */
.modal-footer .modal-close,
.connection-modal .modal-footer .modal-close {
    width: auto !important;
    height: auto !important;
    padding: 12px 24px !important;
    border-radius: 10px !important;
    background: unset !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    color: inherit !important;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-image-container {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    max-height: calc(100vh - 200px);
    overflow: hidden;
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Image preview modal footer */
.image-modal .modal-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-prompt {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 15px;
    line-height: 1.4;
}

.modal-prompt strong {
    color: white;
}

.modal-image-info {
    margin: 10px 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.image-dimensions {
    font-family: monospace;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.modal-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.modal-btn.danger {
    background: rgba(220, 53, 69, 0.8);
    color: white;
    border: 1px solid rgba(220, 53, 69, 0.6);
}

.modal-btn.danger:hover {
    background: rgba(220, 53, 69, 1);
    border-color: rgba(220, 53, 69, 0.8);
    transform: translateY(-1px);
}

/* Multiple images indicator */
.multiple-images-indicator {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 0.75em;
    backdrop-filter: blur(5px);
}

.multiple-images-indicator span {
    font-weight: bold;
    display: block;
}

.multiple-images-indicator small {
    opacity: 0.8;
    font-size: 0.9em;
}

/* True full-screen overlays - no modals, identical experience for single and gallery */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

.image-modal .modal-overlay {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
}

.image-modal .modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    max-width: none;
    max-height: none;
}

/* Image-modal specific header & close icon are intentionally scoped to .image-modal
   so they don't leak into smaller dialog modals like the connection/settings modal. */
.image-modal .modal-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    pointer-events: none;
}

.image-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.image-modal .modal-close {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    pointer-events: auto;
    transition: background 0.2s;
}

.image-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.gallery-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: relative;
}

.gallery-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 100%;
    padding: 80px 20px 120px;
    box-sizing: border-box;
}

.gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.gallery-slide.active {
    display: flex;
}

.gallery-slide img {
    max-width: 90vw;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 20px 24px;
    font-size: 28px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    z-index: 10001;
    font-weight: bold;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav.prev {
    left: 40px;
}

.gallery-nav.next {
    right: 40px;
}

.gallery-thumbnails {
    position: absolute;
    /* sit above the footer so thumbnails never overlap action buttons */
    bottom: calc(20px + 84px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    max-width: 88vw;
    min-height: calc(var(--thumb-size, 80px) + 12px);
    overflow-x: auto;
    z-index: 10001;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.gallery-thumb {
    --thumb-size: 80px;
    width: var(--thumb-size);
    height: calc(var(--thumb-size) * 0.75);
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.72;
    transition: transform 160ms var(--ease-out-quart), opacity 160ms;
    border: 2px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.45);
    background-clip: padding-box;
}

.gallery-thumb:hover {
    opacity: 1;
    transform: translateY(-3px) scale(1.04);
}

.gallery-thumb.active {
    opacity: 1;
    border-color: #667eea;
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 10px 30px rgba(102,126,234,0.12);
}

.modal-footer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    color: white;
}

.modal-prompt {
    margin-bottom: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.modal-image-info {
    margin-bottom: 16px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.modal-btn.primary {
    background: #667eea;
    border-color: #667eea;
}

.modal-btn.danger {
    background: rgba(220, 53, 69, 0.8);
    border-color: rgba(220, 53, 69, 0.8);
}

.power-user-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0px;
    height: calc(100vh - 44px);
    padding: 0px;
    box-sizing: border-box;
    overflow: visible;
}

.left-panel, .center-panel, .right-panel {
    
    border-right: 1px solid var(--glass-border);
    border-radius: 0px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--glass-shadow);
    transition: all 0.3s var(--ease-out-quart);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.left-panel:hover, .center-panel:hover, .right-panel:hover {
    box-shadow: var(--glass-shadow-hover);
    border-color: rgba(255, 255, 255, 0.25);
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-bottom: 18px; /* give room at bottom so inserted blocks don't collide */
}

.center-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding:5px;
    overflow: visible;
}

/* Extra top padding for right panel to prevent button cut-off */
.power-user-layout .right-panel {
    /* padding-top: 24px; */
    overflow: visible;
}

/* Simplify form styling in Advanced mode */
.power-user-layout .form-container {
    background: none;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
}

.power-user-layout .control-section {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 24px;
}

.power-user-layout .control-section h3 {
    border-bottom: none;
    margin-bottom: 16px;
    padding-bottom: 0;
}

/* Hide center panel in Advanced mode for 2-column layout */
.power-user-layout .center-panel {
    display: none;
}

/* Enhanced Layout Styles */
.preview-section.main-focus {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.preview-container.expanded {
    flex: 1;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.2) 100%);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    margin: 0;
}

.preview-container.expanded .preview-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.preview-container.expanded .preview-placeholder h3 {
    font-size: 1.6rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 600;
}

.preview-container.expanded .preview-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    opacity: 0.6;
}

/* Queue Status Bar */
.queue-status-bar {
    background: linear-gradient(135deg, rgba(0,0,0,0.06), rgba(0,0,0,0.02));
    border: 1px solid rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

/* Hide queue in advanced mode */
.power-user-layout .queue-status-bar {
    display: none;
}

.power-user-layout #queueBtn {
    display: none;
}

/* Make generate button full width when queue is hidden */
.power-user-layout .generation-actions {
    display: block;
}

.power-user-layout .generate-btn.primary {
    width: 100%;
    flex: none;
}

.queue-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-indicator-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.queue-count-badge {
    background: var(--highlight-gradient);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 16px;
    min-width: 32px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.queue-label-main {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.queue-actions-main {
    display: flex;
    gap: 12px;
}

.queue-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.queue-action-btn.primary {
    background: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border-color: rgba(255,255,255,0.04);
    color: var(--text-primary);
}

.queue-action-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border-color: rgba(255,255,255,0.06);
    transform: translateY(-1px);
}

.queue-action-btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.queue-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gallery-section.full-height {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.gallery-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.enhanced-gallery.expanded-sidebar {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 0;
}

/* Responsive Design for New Layout */
@media (max-width: 1600px) {
    .power-user-layout {
        grid-template-columns: 360px 1fr 380px;
        gap: 28px;
    }
}

@media (max-width: 1400px) {
    .power-user-layout {
        grid-template-columns: 340px 1fr 360px;
        gap: 24px;
    }
}

@media (max-width: 1200px) {
    .power-user-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        gap: 20px;
        height: auto;
        min-height: 100vh;
        padding: 16px;
    }
    
    .left-panel, .center-panel, .right-panel {
        height: auto;
        max-height: none;
        padding: 24px;
    }
    
    .left-panel {
        order: 1;
        max-height: 600px;
        overflow-y: auto;
    }
    
    .center-panel {
        order: 2;
        min-height: 500px;
    }
    
    .right-panel {
        order: 3;
        max-height: 700px;
    }
    
    .preview-container.expanded {
        height: 500px;
        min-height: 500px;
    }
    
    .gallery-section.full-height {
        height: auto;
        max-height: 600px;
    }
    
    .enhanced-gallery.expanded-sidebar {
        max-height: 500px;
    }
}

@media (max-width: 768px) {
    .power-user-layout {
        padding: 12px;
        gap: 16px;
    }
    
    .left-panel, .center-panel, .right-panel {
        padding: 20px;
        border-radius: 16px;
    }
    
    .preview-container.expanded {
        height: 400px;
        min-height: 400px;
    }
    
    .control-section {
        padding: 20px;
        margin-bottom: 16px;
    }
}

.queue-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-count-mini {
    background: var(--accent-gradient);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.queue-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.queue-mini-actions {
    display: flex;
    gap: 6px;
}

.queue-mini-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.queue-mini-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.queue-mini-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Control Sections */
.control-section {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 24px;
}

.control-section h3 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: none;
}

/* Add subtle separator after each section except the last */
.control-section:not(:last-child)::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    margin-top: 8px;
}

/* Generation Mode Selector */
.mode-selector {
    display: flex;
    gap: 5px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 5px;
}

.mode-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.22);
}

.mode-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Parameter Controls */
.parameter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.param-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.param-input {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.param-input input[type="number"] {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 14px;
}

.param-slider {
    display: flex;
    align-items: center;
}

/* Advanced duplicate container styles when moved into the left panel */
#advancedSettingsDup {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255,255,255,0.02);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.03);
    margin-bottom: 12px;
    max-height: 380px;
    overflow: auto;
}

@media (min-width: 1400px) {
    #advancedSettingsDup {
        max-height: 520px;
    }
}

/* Ensure form controls inside the advanced duplicate stretch to available width */
#advancedSettingsDup select,
#advancedSettingsDup input,
#advancedSettingsDup textarea {
    width: 100%;
    box-sizing: border-box;
}

#advEnhancementOptions {
    margin-top: 8px;
}

.slider {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.22);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Aspect Ratio Presets */
.aspect-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.aspect-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 60px;
}

.aspect-btn .aspect-ratio {
    font-size: 0.8rem;
    font-weight: 600;
}

.aspect-btn .aspect-label {
    font-size: 0.65rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aspect-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

.aspect-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Enhanced Image Controls */
.aspect-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.size-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.size-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.size-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

.size-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.dimensions-display {
    text-align: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--accent-color);
    font-weight: 500;
}

.size-warning {
    text-align: center;
    margin-top: 6px;
}

.size-warning small {
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Refiner, Upscaler, and Post-processing Controls */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    position: relative;
    width: 18px;
    height: 18px;
    appearance: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--accent-gradient);
    border-color: transparent;
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.checkbox-label:hover input[type="checkbox"]:not(:checked) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.refiner-settings,
.upscaler-settings {
    margin-top: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

/* Seed Control */
.seed-control {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Add extra top spacing to separate Seed from inserted advanced blocks */
.form-group + .form-group .seed-control,
.form-group .seed-control {
    margin-top: 8px;
}

.seed-control input {
    flex: 1;
    min-width: 0;
}

.seed-btn {
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    flex-shrink: 0;
    min-width: 32px;
    text-align: center;
}

.seed-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Generation Actions */
.generation-actions {
    display: flex;
    gap: 10px;
}

.generate-btn.primary {
    flex: 2;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-weight: 600;
}

.generate-btn.secondary {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-icon {
    margin-right: 8px;
}

/* Preview Section */
.preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.preview-header h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.preview-controls {
    display: flex;
    gap: 8px;
}

.preview-btn {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.preview-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Gallery Section */
.gallery-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: visible;
}

/* In advanced mode, gallery takes full height since no queue */
.power-user-layout .gallery-section {
    height: 100%;
    overflow: visible;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}

/* Simplified header for advanced mode - remove box styling */
.power-user-layout .gallery-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    margin-bottom: 16px;
    background: none;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
}

.gallery-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery-header h3::before {
    content: '🎨';
    font-size: 1.2rem;
    opacity: 0.8;
}

/* Modern title styling for advanced mode */
.power-user-layout .gallery-header h3 {
    font-size: 1.2rem;
    color: var(--highlight-end);
    text-align: left;
}

.gallery-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Horizontal layout for advanced mode */
.power-user-layout .gallery-controls {
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    overflow-y: auto;
    flex: 1;
}

/* Compact thumbnails for advanced mode - similar to simple mode */
.power-user-layout .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Only apply hover effects to completed items */
.gallery-item.completed:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.32);
    transform: scale(1.05);
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fallback for broken/missing images */
.gallery-thumb:not(:has(img)), 
.gallery-thumb:has(img[src=""]), 
.gallery-thumb:has(img:not([src])),
.gallery-thumb:has(img[src*="undefined"]) {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
}

.gallery-thumb:not(:has(img))::before, 
.gallery-thumb:has(img[src=""])::before, 
.gallery-thumb:has(img:not([src]))::before,
.gallery-thumb:has(img[src*="undefined"])::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' stroke='%23ffffff40' stroke-width='2' fill='none'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5' stroke='%23ffffff40' stroke-width='1' fill='none'/%3E%3Cpath d='M21 15l-5-5L5 21' stroke='%23ffffff40' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/32px 32px no-repeat;
    opacity: 0.4;
}

/* Enhanced Gallery for Advanced Mode */
.enhanced-gallery {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    padding: 4px;
}

/* In power-user layout, enhanced gallery should fill all available space */
.power-user-layout .enhanced-gallery {
    height: 100%;
    max-height: none;
}

.enhanced-gallery-item {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s ease;
    position: relative;
    margin-bottom: 8px;
}

.enhanced-gallery-item:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
    border-color: var(--highlight-end);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.enhanced-gallery-item.generating {
    border-color: var(--highlight-end);
    background: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
}

.enhanced-gallery-item.completed {
    border-color: rgba(0, 255, 136, 0.3);
}

.enhanced-gallery-item.error {
    border-color: rgba(255, 68, 68, 0.5);
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.1), rgba(255, 68, 68, 0.05));
}

.enhanced-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.enhanced-item-info {
    flex: 1;
    min-width: 0;
}

.enhanced-item-prompt {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.enhanced-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.enhanced-item-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.enhanced-item-status.generating {
    color: var(--highlight-end);
}

.enhanced-item-status.completed {
    color: var(--success);
}

.enhanced-item-status.error {
    color: #ff4444;
}

.enhanced-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.enhanced-gallery-item:hover .enhanced-item-actions {
    opacity: 1;
}

.enhanced-action-btn {
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.enhanced-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Specific hover styles for delete buttons */
.enhanced-action-btn[title="Delete"]:hover,
.action-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
}

.enhanced-item-content {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.enhanced-item-preview {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    position: relative;
}

.enhanced-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.enhanced-item-preview img:hover {
    transform: scale(1.02);
}

.enhanced-item-details {
    flex: 1;
    min-width: 0;
}

.enhanced-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.enhanced-progress-fill {
    height: 100%;
    background: var(--highlight-gradient);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.enhanced-item-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.enhanced-grid-thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.enhanced-grid-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.enhanced-grid-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: bold;
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.status-indicator.generating {
    background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    color: var(--highlight-end);
}

.status-indicator.completed {
    background: rgba(0,0,0,0.06);
    color: var(--success);
}

.status-indicator.error {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
}

/* Selection mode */
.enhanced-gallery.selection-mode .enhanced-gallery-item {
    cursor: pointer;
}

.enhanced-gallery.selection-mode .enhanced-gallery-item::before {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.enhanced-gallery.selection-mode .enhanced-gallery-item.selected::before {
    background: var(--highlight-gradient);
    border-color: var(--highlight-end);
}

.enhanced-gallery.selection-mode .enhanced-gallery-item.selected::after {
    content: '✓';
    position: absolute;
    top: 14px;
    right: 16px;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 3;
}

.item-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.thumb-overlay {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 0 8px 0 8px;
    padding: 4px;
}

.thumb-status {
    font-size: 0.8rem;
}

.thumb-status.completed {
    color: var(--success);
}

.thumb-status.generating {
    color: var(--warning);
    animation: pulse 2s infinite;
}

.thumb-status.error {
    color: var(--error);
}

/* Queue Section */
.queue-section, .active-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px; /* Ensure minimum height */
}

.queue-header, .active-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.queue-status, .active-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.queue-count, .active-count {
    background: var(--accent-gradient);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.queue-label, .active-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.queue-explanation {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 10px;
}

.queue-explanation p {
    margin: 2px 0;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.queue-explanation strong {
    color: var(--primary-green);
}

.queue-list, .active-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1; /* Take up available height */
    overflow-y: auto;
    margin-bottom: 10px;
    min-height: 200px; /* Minimum height */
}

.queue-empty, .active-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 15px 10px;
}

.queue-empty small {
    display: block;
    margin-top: 5px;
    font-size: 0.7rem;
    opacity: 0.8;
}

.queue-actions {
    display: flex;
    gap: 8px;
}

.queue-action-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.queue-action-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.queue-action-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.queue-action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.28), 0 6px 18px color-mix(in srgb, var(--highlight-end) 14%, transparent);
}

.queue-item, .active-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.8rem;
}

.queue-item-prompt, .active-item-prompt {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.queue-item-details, .active-item-status {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.active-item.generating {
    border-color: var(--warning);
    background: rgba(255, 170, 0, 0.1);
}

.active-item.completed {
    border-color: var(--success);
    background: rgba(0, 255, 136, 0.1);
}

/* Compact styles for less cluttered right panel */
.compact .queue-header h3,
.compact .active-header h3 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    padding-bottom: 4px;
}

.compact .queue-list,
.compact .active-list {
    max-height: 80px;
    margin-bottom: 8px;
}

.compact .queue-empty,
.compact .active-empty {
    padding: 10px 5px;
    font-size: 0.75rem;
}

.compact .queue-actions {
    gap: 4px;
}

.compact .queue-action-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.compact .queue-item,
.compact .active-item {
    padding: 6px;
    font-size: 0.75rem;
}

.compact .queue-item-prompt,
.compact .active-item-prompt {
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.compact .queue-item-details,
.compact .active-item-status {
    font-size: 0.65rem;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .simple-layout {
        grid-template-columns: 400px 1fr;
    }
}

@media (max-width: 1200px) {
    .power-user-layout {
        grid-template-columns: 340px 1fr 280px;
        gap: 20px;
    }
    
    .simple-layout {
        grid-template-columns: 350px 1fr;
        gap: 20px;
    }

    .simple-form-container {
        min-width: 300px;
    }
}

@media (max-width: 1024px) {
    .power-user-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .left-panel, .center-panel, .right-panel {
        max-height: none;
    }
    
    .center-panel {
        order: 1;
    }
    
    .left-panel {
        order: 2;
    }
    
    .right-panel {
        order: 3;
    }
    
    .simple-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 10px;
    }
}

/* Settings Section */
.settings-section {
    flex: 1;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-controls {
    display: flex;
    gap: 8px;
}

.settings-btn {
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.setting-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.setting-toggle input[type="checkbox"]:checked + .toggle-slider {
    background: var(--accent-gradient);
}

.setting-toggle input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.setting-label {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.settings-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.settings-action-btn.secondary {
    background: rgba(255, 68, 68, 0.1);
    border-color: rgba(255, 68, 68, 0.3);
    color: var(--error);
}

.settings-action-btn.secondary:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: var(--error);
}

.settings-action-btn .icon {
    width: 16px;
    height: 16px;
}

/* Compact settings for smaller panels */
.compact .settings-header h3 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    padding-bottom: 4px;
}

.compact .settings-panel {
    gap: 10px;
}

.compact .setting-group {
    gap: 6px;
}

.compact .setting-label {
    font-size: 0.8rem;
}

.compact .settings-action-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.compact .settings-action-btn .icon {
    width: 14px;
    height: 14px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .power-user-layout {
        grid-template-columns: 340px 1fr 280px;
        gap: 20px;
    }
}

@media (max-width: 1024px) {
    .power-user-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .left-panel, .center-panel, .right-panel {
        max-height: none;
    }
    
    .center-panel {
        order: 1;
    }
    
    .left-panel {
        order: 2;
    }
    
    .right-panel {
        order: 3;
    }
}

.form-container, .gallery-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 30px;
}

.generate-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 18px;
}

label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input, select, textarea {
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s var(--ease-out-quart);
    font-family: inherit;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

input:hover, select:hover, textarea:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 20px color-mix(in srgb, var(--highlight-end) 26%, transparent), 0 0 12px rgba(0,0,0,0.18);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Fix dropdown option visibility */
select option {
    background: var(--dark-bg);
    color: var(--text-primary);
    padding: 8px 12px;
}

/* Webkit-based browsers (Chrome, Safari, etc.) */
select option:checked {
    background: var(--primary-blue);
    color: var(--dark-bg);
}

/* Firefox */
@-moz-document url-prefix() {
    select option {
        background: #1a1a1a;
        color: #ffffff;
    }
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Advanced Mode Specific Improvements */
.power-user-layout textarea {
    min-height: 70px;
    line-height: 1.4;
}

.power-user-layout .prompt-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.power-user-layout .control-section {
    border-radius: 12px;
}

.advanced-toggle {
    margin: 10px 0;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-blue);
}

.toggle-btn .arrow {
    transition: transform 0.3s ease;
}

.toggle-btn.active .arrow {
    transform: rotate(180deg);
}

.advanced-settings {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    /* Ensure the advanced duplicate block behaves like a contained card */
    width: 100%;
    box-sizing: border-box;
    background: var(--panel-background, rgba(255,255,255,0.02));
    border-radius: 10px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,0.03);
    margin-bottom: 12px;
}

.advanced-settings.show {
    max-height: 500px;
    margin-top: 20px;
}

.advanced-settings > .form-group,
.advanced-settings > .form-row {
    margin-bottom: 12px;
}

/* Make selects and inputs inside the advanced duplicate stretch to the panel width */
.advanced-settings select,
.advanced-settings input,
.advanced-settings textarea {
    width: 100%;
    box-sizing: border-box;
}

/* Small spacing tweak for the enhancement options area */
#advEnhancementOptions, .enhancement-options {
    margin-top: 8px;
}

.generate-btn {
    padding: 15px 30px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all 0.3s var(--ease-out-quart);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.28), 0 6px 24px color-mix(in srgb, var(--highlight-end) 14%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.generate-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

/* Use highlight color for icons within primary action buttons so they pick up the user's selected hue */
.generate-btn .btn-icon { color: var(--highlight-end); }

/* Ensure preview placeholder and simple-mode badges inherit the highlight color when appropriate */
.empty-icon, .simple-mode-badge, .viewer-thumb.active img { color: var(--highlight-end); }

.generate-btn .btn-icon svg, .generate-btn .btn-icon img {
    width: 100%;
    height: 100%;
    display: block;
}

/* Status indicator colors (moved from inline styles) */
.status-indicator.generating { color: #f3c623; }
.status-indicator.queued, .status-indicator.pending { color: #9aa0a6; }
.status-indicator.completed { color: #34d399; }
.status-indicator.error { color: #fb7185; }

/* Small status-icon variant (12px) */
.status-icon-small { width: 12px; height: 12px; display: inline-block; vertical-align: middle; }

.generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    /* sheen slightly tinted by the highlight color for better visual integration */
    background: linear-gradient(90deg, transparent, color-mix(in srgb, white 40%, var(--highlight-color) 8%), transparent);
    transition: left 0.5s var(--ease-out-quart);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.36), 0 10px 40px color-mix(in srgb, var(--highlight-end) 22%, transparent);
}

.generate-btn:hover::before {
    left: 100%;
}

.generate-btn:active {
    transform: translateY(0);
    box-shadow: var(--glass-shadow-active);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.generate-btn:disabled::before {
    display: none;
}

.generate-btn .btn-loading {
    display: none;
}

.generate-btn.loading .btn-text {
    display: none;
}

.generate-btn.loading .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.generate-btn.loading .btn-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.gallery-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.queue-info {
    padding: 5px 12px;
    /* highlight-aware translucent background */
    background: color-mix(in srgb, var(--highlight-end) 12%, transparent);
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--highlight-end);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.gallery::-webkit-scrollbar {
    width: 8px;
}

.gallery::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.gallery::-webkit-scrollbar-thumb {
    background: var(--accent-gradient);
    border-radius: 10px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px 16px;
    color: var(--text-secondary);
}

.gallery-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 15px;
    transition: all 0.3s ease;
}

/* Only apply hover effects to completed gallery items */
.gallery-item.completed:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-blue);
}

/* Disable hover effects for generating items */
.gallery-item.generating,
.gallery-item.waiting,
.gallery-item.queued,
.gallery-item.pending {
    cursor: default;
}

/* Completely disable all hover effects for non-completed items */
.simple-gallery-item:not(.completed):hover,
.gallery-item:not(.completed):hover,
.batch-image:not(.completed):hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Disable transitions for non-completed items to prevent flashing */
.simple-gallery-item:not(.completed),
.gallery-item:not(.completed),
.batch-image:not(.completed) {
    transition: none !important;
}

/* Nuclear option: Disable ALL hover effects on elements that don't have 'completed' class */
.simple-gallery-item:not(.completed),
.simple-gallery-item:not(.completed):hover,
.gallery-item:not(.completed),
.gallery-item:not(.completed):hover,
.batch-image:not(.completed),
.batch-image:not(.completed):hover {
    transform: none !important;
    box-shadow: none !important;
    border-color: inherit !important;
    background: inherit !important;
    opacity: 1 !important;
}

.gallery-item.generating {
    /* Removed border-color to keep consistent with base gallery-item */
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.3);
}

.gallery-item.error {
    border-color: var(--error);
}

.item-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.item-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.item-prompt {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.item-status.generating {
    color: var(--warning);
}

.item-status.completed {
    color: var(--success);
}

.item-status.error {
    color: var(--error);
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Glass morphism enhancements */
.form-container::before,
.gallery-container::before,
.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
}

.form-container,
.gallery-container,
.app-header {
    position: relative;
}

/* Responsive design */
@media (max-width: 768px) {
    .app-container {
        padding: 0px;
    }
    
    .simple-layout {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .app-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}

/* ============ PRODUCTION POLISH & ACCESSIBILITY ============ */

/* Screen Reader Only Content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced Focus Indicators for Accessibility */
button:focus-visible, 
.btn:focus-visible, 
input:focus-visible, 
select:focus-visible, 
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 8px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .glass-panel,
    .main-container,
    .control-panel {
        backdrop-filter: none;
        background: rgba(0, 0, 0, 0.9);
        border: 2px solid var(--text);
    }
    
    button, .btn {
        border: 2px solid var(--text);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .generate-btn.loading .btn-loading::after {
        animation: none;
        border: 2px solid var(--primary);
        border-radius: 50%;
    }
}

/* Print Styles */
@media print {
    .control-panel,
    .connection-panel,
    .modal-backdrop,
    button,
    .btn {
        display: none !important;
    }
    
    .main-container {
        background: white;
        color: black;
        box-shadow: none;
        backdrop-filter: none;
    }
    
    .gallery-item img {
        break-inside: avoid;
    }
}

/* Reduced border-radius overrides for less rounded appearance */
.control-section, .param-group, .form-group, .gallery-item, 
.queue-item, .image-actions, .preview-container, .modal-content,
.generate-btn, .btn, button, input, select, textarea {
    border-radius: 8px !important;
}

.enhancement-toggle .toggle-slider {
    border-radius: 12px !important;
}

.enhancement-toggle .toggle-slider::before {
    border-radius: 50% !important;
}

.aspect-btn {
    border-radius: 6px !important;
}

.status-indicator {
    border-radius: 50% !important;
}

/* ===== VISIONCRAFT BACKGROUND GENERATION ===== */

.visioncraft-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    pointer-events: none;
    transition: opacity 3s ease-in-out;
}

/* Enhanced glassmorphism with background */
body:has(.visioncraft-background) .generate-form,
body:has(.visioncraft-background) .queue-panel,
body:has(.visioncraft-background) .modal-content,
body:has(.visioncraft-background) .image-viewer {
    backdrop-filter: blur(20px) saturate(1.8);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Darker glass effect in dark mode */
@media (prefers-color-scheme: dark) {
    body:has(.visioncraft-background) .generate-form,
    body:has(.visioncraft-background) .queue-panel,
    body:has(.visioncraft-background) .modal-content,
    body:has(.visioncraft-background) .image-viewer {
        background: rgba(0, 0, 0, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.6),
            inset 0 1px 0 rgba(255, 255, 255, 0.05);
    }
}

/* Subtle shimmer animation on glass panels when background is active */
body:has(.visioncraft-background) .generate-form::before,
body:has(.visioncraft-background) .queue-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    animation: shimmer 6s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes shimmer {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}


/* ==========================
   Header Minimal Overrides
   Purpose: ensure a thin, consistent, no-flicker header
   Scope: only inside .app-header so wider UI remains unchanged
   ========================== */
.app-header {
    position: sticky; /* stay visible */
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999; /* ensure header sits above content */
    min-height: 44px;
    padding: 6px 12px;
    box-sizing: border-box;
    height: auto; /* allow natural height when controls wrap */
    background: rgba(0,0,0,0.24);
}

.app-header .app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.app-header .app-logo img,
.app-header .app-logo svg {
    display: block;
}

/* Make the logo container compact in the header */
.app-header .app-logo {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: none !important;
    background: transparent !important;
}

.app-header .brand-text h1 {
    margin: 0;
    font-size: 14px;
    line-height: 1;
    font-weight: 600;
}

.app-header .brand-text .brand-tagline {
    font-size: 11px;
    line-height: 1;
    opacity: 0.7;
}

/* HEADER CONTROL OVERRIDES - Force exact alignment */
.app-header .header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    flex-wrap: wrap; /* allow controls to wrap when space is limited */
}

/* ALL header controls MUST have exact same dimensions */
.app-header .header-controls .mode-toggle-btn,
.app-header .header-controls .primary-btn,
.app-header .header-controls .secondary-btn,
.app-header .header-controls .user-badge,
.app-header .header-controls .icon-btn {
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    vertical-align: middle !important;
    margin: 0 !important;
    margin-right: 10px !important;
    padding: 0 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Color swatch - special case, keeps its own background */
.app-header .header-controls .highlight-swatch {
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    vertical-align: middle !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    cursor: pointer !important;
    /* DO NOT override background - let JS set the color */
}

/* Text-containing buttons - add padding back */
.app-header .header-controls .mode-toggle-btn,
.app-header .header-controls .primary-btn,
.app-header .header-controls .secondary-btn,
.app-header .header-controls .user-badge {
    padding: 0 10px !important;
}

/* Buttons with gaps between text/icons */
.app-header .header-controls .mode-toggle-btn {
    gap: 6px !important;
}

/* Primary button background override */
.app-header .header-controls .primary-btn {
    background: linear-gradient(135deg, #0f77bd, #1a8cd6) !important;
    color: white !important;
}

/* User badge background */
.app-header .header-controls .user-badge {
    background: rgba(255,255,255,0.08) !important;
}

/* Icon-only buttons */
.app-header .header-controls .icon-btn {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
}

/* Flatten auth tabs to match app style */
.auth-tabs { background: transparent; padding: 10px 16px; gap: 6px; }
.auth-tab {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: none;
}
.auth-tab.active {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.18);
}

/* Anonymous feature hint chip */
.auth-note {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.auth-note svg { opacity: 0.8; }

/* Header control hover effects - Override all global hover styles */
.app-header .header-controls .mode-toggle-btn:hover,
.app-header .header-controls .primary-btn:hover,
.app-header .header-controls .secondary-btn:hover,
.app-header .header-controls .icon-btn:hover {
    background: rgba(255,255,255,0.06) !important;
    transform: none !important;
    box-shadow: none !important;
    transition: background-color 0.15s ease !important;
}

.app-header .header-controls .primary-btn:hover {
    background: linear-gradient(135deg, #0d6ba8, #1680c4) !important;
}

.app-header .header-controls .highlight-swatch:hover {
    background: var(--highlight-start) !important;
    transform: none !important;
}

/* Disabled mode toggle for anonymous users */
.app-header .header-controls .mode-toggle-btn.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: auto !important;
}

.app-header .header-controls .mode-toggle-btn.disabled:hover {
    background: transparent !important;
}

/* Mode button icon specifics */
.app-header .header-controls .mode-icon {
    width: 14px !important;
    height: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 0 !important;
}

.app-header .header-controls .mode-toggle-btn,
.app-header .header-controls .primary-btn,
.app-header .header-controls .secondary-btn,
.app-header .header-controls .user-badge,
.app-header .header-controls .icon-btn {
    height: 28px !important;
    min-height: 28px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    flex-shrink: 1 !important; /* allow shrinking/wrapping */
    vertical-align: middle !important;
    margin: 0 !important;
    margin-right: 8px !important;
    padding: 6px 8px !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    background: transparent !important;
}
