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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    color: #4a5568;
    margin-bottom: 10px;
}

.header h1 i {
    color: #667eea;
    margin-right: 15px;
}

.header p {
    font-size: 1.2rem;
    color: #718096;
}

.scraper-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.input-group input {
    flex: 1;
    min-width: 300px;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group input[type="number"] {
    flex: 0 0 150px;
    min-width: 150px;
}

button {
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
}

.quick-examples {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-examples span {
    font-weight: 600;
    color: #4a5568;
}

.example-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
    color: #2d3748;
}

.loading-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.results-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.results-header h2 {
    color: #4a5568;
    font-size: 1.8rem;
}

.results-actions {
    display: flex;
    gap: 15px;
}

.advanced-controls {
    margin-bottom: 30px;
    padding: 25px;
    background: #f7fafc;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.search-section {
    margin-bottom: 20px;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 0 15px;
    transition: all 0.3s ease;
}

.search-bar:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-bar i {
    color: #a0aec0;
    margin-right: 10px;
}

.search-bar input {
    flex: 1;
    border: none;
    padding: 12px 0;
    font-size: 1rem;
    background: transparent;
}

.search-bar input:focus {
    outline: none;
}

.search-bar button {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.search-bar button:hover {
    background: #f7fafc;
    color: #4a5568;
    transform: none;
    box-shadow: none;
}

.sorting-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sorting-section label {
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}

.sorting-section select {
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    min-width: 200px;
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group label {
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
    min-width: 80px;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.filter-group input[type="number"] {
    width: 80px;
}

.selection-controls {
    margin-bottom: 20px;
}

.selection-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.selection-group label {
    font-weight: 600;
    color: #4a5568;
    margin-right: 10px;
}

.selection-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.selection-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.stats-panel {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: #f7fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #4a5568;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 500;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 10px;
}

.image-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.image-card.selected {
    border: 3px solid #48bb78;
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.2);
}

.image-preview {
    width: 100%;
    height: 180px;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0aec0;
    flex-shrink: 0;
}

.image-info {
    padding: 6px 8px;
    font-size: 0.85rem;
}

.image-format {
    display: inline-block;
    padding: 3px 8px;
    background: #667eea;
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.image-url {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
    line-height: 1.3;
}

.selection-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #48bb78;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-card.selected .selection-indicator {
    opacity: 1;
}

.download-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.download-progress h3 {
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    width: 0%;
    transition: width 0.3s ease;
}

.download-complete {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.success-message i {
    font-size: 4rem;
    color: #48bb78;
    margin-bottom: 20px;
}

.success-message h3 {
    color: #4a5568;
    font-size: 2rem;
    margin-bottom: 15px;
}

.footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group input {
        min-width: 100%;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .results-actions {
        justify-content: center;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}

/* Scrollbar styling */
.image-grid::-webkit-scrollbar {
    width: 8px;
}

.image-grid::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 4px;
}

.image-grid::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.image-card .image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-card:hover .image-overlay {
    opacity: 1;
}

.lightbox-btn {
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid white;
    padding: 10px 20px;
    cursor: pointer;
}

.lightbox-modal {
    display: none; 
    position: fixed; 
    z-index: 1; 
    padding-top: 100px; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgb(0,0,0); 
    background-color: rgba(0,0,0,0.9);
}

.lightbox-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
}

#lightboxCaption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    height: 150px;
}

.lightbox-content, #lightboxCaption {
    animation-name: zoom;
    animation-duration: 0.6s;
}

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

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Toasts */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 100000; display: grid; gap: 8px; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; min-width: 220px; animation: fadeIn 0.2s ease; }
.toast.success { border-color: #16a34a; }
.toast.error { border-color: #dc2626; }

/* Lightbox Modal Styles */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    position: relative;
    background: var(--surface);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.2s ease;
    color: #4a5568;
    font-size: 1.2rem;
}

.lightbox-close:hover {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    transform: rotate(90deg) scale(1.1);
    box-shadow: none;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10001;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4a5568;
    font-size: 1.5rem;
    pointer-events: all;
}

.nav-btn:hover {
    background: rgba(102, 126, 234, 0.9);
    color: white;
    transform: scale(1.1);
    box-shadow: none;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.lightbox-image-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    min-height: 400px;
    max-height: 70vh;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0;
}

.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #718096;
}

.lightbox-loading .loading-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 15px;
}

.lightbox-info {
    padding: 14px;
    background: var(--surface);
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.lightbox-details {
    flex: 1;
}

.lightbox-details h3 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.lightbox-details p {
    margin-bottom: 8px;
    color: #718096;
    font-size: 0.95rem;
}

.lightbox-details strong {
    color: #4a5568;
    min-width: 100px;
    display: inline-block;
}

.lightbox-details a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.lightbox-details a:hover {
    text-decoration: underline;
}

.lightbox-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.lightbox-actions button {
    width: 100%;
    justify-content: center;
}

/* Enhanced mobile responsiveness for lightbox */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        flex-direction: column;
    }
    
    .lightbox-info {
        flex-direction: column;
        gap: 20px;
    }
    
    .lightbox-actions {
        min-width: auto;
    }
    
    .advanced-controls {
        padding: 15px;
    }
    
    .filter-controls {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .selection-group {
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .sorting-section {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .sorting-section select {
        min-width: auto;
    }
}

/* Lightbox fit-to-viewport overrides */
#lightboxModal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 10000; display: none; align-items: center; justify-content: center; padding: 24px; }
#lightboxImage { max-width: 96vw; max-height: 92vh; width: auto; height: auto; object-fit: contain; border-radius: 2px; box-shadow: 0 16px 48px rgba(0,0,0,0.5); }
#lightboxCaption { color: #e5e7eb; margin-top: 10px; text-align: center; max-width: 96vw; word-break: break-word; }
#lightboxModal .lightbox-close { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,0.9); color: #111827; width: 40px; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* Minimal layout for new sidebar/main structure */
.main-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 320px;
    background: rgba(255,255,255,0.95);
    padding: 20px;
    border-right: 1px solid #e2e8f0;
}

.sidebar.collapsed {
    width: 60px;
    overflow: hidden;
}

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

.toggle-sidebar-btn {
    background: none;
    color: #4a5568;
    padding: 8px;
    border-radius: 8px;
}

.main-content {
    flex: 1;
    padding: 20px;
}

.control-group {
    margin-bottom: 16px;
}

.filter-options {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.initial-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    opacity: 0.9;
    min-height: 200px;
}

/* Minimal theme overrides (content-first) */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-contrast: #ffffff;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(0,0,0,0.05);
}
/* System dark preference only applies when no explicit theme is set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0b0f14;
        --surface: #121821;
        --text: #e5e7eb;
        --muted: #9aa4b2;
        --border: #263243;
        --primary: #3b82f6;
        --primary-contrast: #0b0f14;
        --shadow: 0 1px 2px rgba(0,0,0,0.4);
    }
}
:root[data-theme="dark"] {
    --bg: #0b0f14;
    --surface: #121821;
    --text: #e5e7eb;
    --muted: #9aa4b2;
    --border: #263243;
    --primary: #3b82f6;
    --primary-contrast: #0b0f14;
    --shadow: 0 1px 2px rgba(0,0,0,0.4);
}
:root[data-theme="light"] {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-contrast: #ffffff;
    --shadow: 0 1px 2px rgba(0,0,0,0.05);
}

body {
    background: var(--bg) !important;
    color: var(--text);
}

.container { max-width: 1040px; margin: 0 auto; padding: 8px 12px; }

.topbar { position: sticky; top: 0; z-index: 1000; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar .brand { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.topbar-actions { display: flex; gap: 6px; align-items: center; }

.toolbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.toolrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

input[type="url"], input[type="number"], input[type="text"], select {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    padding: 6px 8px;
}

button { border-radius: var(--radius); }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(0,0,0,0.03); }
.btn-primary { background: var(--primary) !important; color: var(--primary-contrast) !important; border: 1px solid var(--primary); }
.btn-primary:hover { filter: brightness(0.95); box-shadow: var(--shadow); transform: none; }
.btn-secondary { background: transparent !important; color: var(--text) !important; border: 1px solid var(--border) !important; }
.btn-secondary:hover { background: rgba(0,0,0,0.03); box-shadow: none; transform: none; }

.results-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.results-header h2 { color: var(--text); }
.small-stats { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 8px; }
.stat-value { color: var(--text); font-weight: 600; }
.stat-label { color: var(--muted); margin-left: 6px; font-size: 0.8rem; }

.image-grid { border-top: 1px solid var(--border); padding-top: 12px; gap: 16px; }
.image-card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; }
.image-card:hover { box-shadow: var(--shadow); transform: none; }
.image-card.selected { border: 2px solid var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.selection-indicator { background: var(--surface); color: var(--primary); }
.image-format { background: rgba(37, 99, 235, 0.1); color: var(--primary); }

/* Skeletons */
.skeleton-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.skeleton-thumb { height: 180px; background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.08) 37%, rgba(0,0,0,0.05) 63%); background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-lines { padding: 12px; display: grid; gap: 8px; }
.skeleton-line { height: 10px; background: rgba(0,0,0,0.06); border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }

.loading-section, .download-section, .download-complete { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.progress-bar { background: var(--border); }
.progress-fill { background: var(--primary); }

 .sticky-actions { display: none; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.sticky-actions.show { display: block; }
.sticky-actions-inner { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }

/* Fullscreen gallery height, container-centered width, and configurable thumbnails */
html, body { height: 100%; }
/* Use height-based calculation instead of grid to avoid extra siblings affecting layout */
body { min-height: 100%; }

/* Defaults (overridable via classes/variables) */
:root { --thumb-ratio: 4 / 3; --thumb-min: 200px; --thumb-gap: 12px; }

/* Presets you can toggle by adding a class on <body> */
body.ratio-1-1 { --thumb-ratio: 1 / 1; }
body.ratio-4-3 { --thumb-ratio: 4 / 3; }
body.ratio-3-2 { --thumb-ratio: 3 / 2; }

body.grid-tight { --thumb-min: 180px; --thumb-gap: 8px; }
body.grid-cozy { --thumb-min: 220px; --thumb-gap: 12px; }
body.grid-comfy { --thumb-min: 260px; --thumb-gap: 16px; }

.main { display: flex; flex-direction: column; min-height: 0; }

/* Container-centered by default; page scroll only (no inner scroll) */
.results-section { display: block; }
/* Optional full-bleed mode if you add class="full-bleed" on .results-section */
.results-section.full-bleed { width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); border-radius: 0; }

/* Let the page scroll; no overflow on the grid */
.image-grid { grid-template-columns: repeat(auto-fill, minmax(var(--thumb-min, 220px), 1fr)); gap: var(--thumb-gap, 12px); padding: 12px; max-height: none !important; overflow: visible !important; }

.image-preview { aspect-ratio: var(--thumb-ratio, 1 / 1); height: auto; background: var(--surface); }
.image-preview img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }

/* Match skeleton thumbnails to current ratio */
.skeleton-thumb { aspect-ratio: var(--thumb-ratio, 1 / 1); height: auto; }

@media (max-width: 768px) {
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
