:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --primary-color: #2563eb;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

.app-container {
    display: flex;
    height: calc(100vh - 56px);
    /* Subtract nav bar height */
}

/* ========================================
   GLOBAL NAVIGATION BAR
   ======================================== */
.global-nav {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.nav-tab {
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    height: 56px;
    box-sizing: border-box;
}

.nav-tab:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* Full-width layout when sidebar is hidden */
.main-content.full-width {
    max-width: 100%;
}

.main-content.full-width .content-body {
    padding: 2rem 3rem;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar.hidden {
    display: none;
}

.sidebar .logo {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar .logo a {
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-color);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-item-header {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--text-color);
    user-select: none;
    transition: background-color 0.1s;
}

.nav-item-header:hover {
    background-color: #f3f4f6;
}

.nav-item-header .arrow {
    margin-right: 0.5rem;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.nav-item-children {
    display: none;
    background-color: #f9fafb;
}

.nav-child {
    display: block;
    padding: 0.5rem 1.5rem 0.5rem 2.5rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-child:hover {
    color: var(--primary-color);
    background-color: #eff6ff;
}

.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.status-dot.present {
    background-color: #10b981;
}

.status-dot.absent {
    background-color: #d1d5db;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

/* Breadcrumb Navigation Row - scrolls with page */
.breadcrumb-nav-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0 0.75rem 0;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.breadcrumb-nav-row a {
    text-decoration: none;
    color: var(--primary-color);
}

/* Sticky Mode Controls Bar - 3 column layout */
.mode-controls-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
    background: transparent;
}

.mode-controls-spacer {
    grid-column: 1;
}

.mode-toggle {
    grid-column: 2;
    justify-self: center;
    position: relative;
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-btn:hover {
    color: #334155;
}

.mode-btn.active {
    background: white;
    color: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hero {
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    margin-top: 0;
    font-weight: 700;
}

.theme-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.theme-header h1 {
    margin: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 20px;
    /* Standard pill shape */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    font-size: 13px;
    height: 36px;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-outline-primary {
    background: white;
    border-color: #d2e3fc;
    color: #1a73e8;
}

.btn-outline-primary:hover {
    background: #e8f0fe;
    border-color: #1a73e8;
}

.btn-outline-warning {
    background: white;
    border-color: #feefc3;
    color: #ea8600;
}

.btn-outline-warning:hover {
    background: #fef7e0;
    border-color: #ea8600;
}

.btn-outline-danger {
    background: white;
    border-color: #fad2cf;
    color: #c5221f;
}

.btn-outline-danger:hover {
    background: #fce8e6;
    border-color: #c5221f;
}

.btn-outline-success {
    background: white;
    border-color: #ceead6;
    color: #137333;
}

.btn-outline-success:hover {
    background: #e6f4ea;
    border-color: #137333;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Grid System */
.filter-section {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f8f9fa;
    padding: 4px 12px 4px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    height: 36px;
}

/* Sidebar Specific Filter Styles */
.sidebar-search {
    padding: 15px 15px 15px;
    position: relative;
    /* For autocomplete positioning */
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.sidebar-search input:focus {
    border-color: var(--primary-color);
}

.sidebar-search-results {
    background: #f9fafb;
    /* border-bottom: 1px solid var(--border-color); */
    flex: 1;
    overflow-y: auto;
}

.search-header {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.close-search {
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
}

.search-result-item {
    padding: 0.5rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.search-result-category {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.search-output .nav-child {
    padding: 0;
}

.sidebar-filter-wrapper {
    padding: 0.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.filter-controls.sidebar-mode {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
    justify-content: flex-start;
    padding: 8px 12px;
    border-radius: 8px;
    height: auto;
}

.filter-controls.sidebar-mode .filter-label {
    font-size: 13px;
    margin-left: auto;
    /* Push label to right if needed, or keep close */
    margin-left: 0;
    flex: 1;
}

.filter-label {
    font-size: 13px;
    color: #5f6368;
    font-weight: 600;
}

/* Toggle Switch Styling */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.card-icon {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.card-content h3 {
    margin: 0;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge.empty {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge.images {
    background-color: #dcfce7;
    color: #166534;
}

/* Upload & Gallery */
.upload-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    border: 2px dashed var(--border-color);
    margin-bottom: 2rem;
    text-align: center;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.gallery-item {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.gallery-item img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    /* Fix truncation */
    background-color: #f9fafb;
    /* Light gray background for transparent images */
    display: block;
    cursor: zoom-in;
    transition: transform 0.2s;
}

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

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 100001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.lightbox.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    animation: zoomIn 0.2s ease-out;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: var(--primary-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
    }

    to {
        transform: scale(1);
    }
}

.image-name {
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress Bar */
.progress-container {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.progress-bar-wrapper {
    background: #e5e7eb;
    border-radius: 10px;
    height: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

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

#split-status-text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Active link highlight */
.nav-child.active-link {
    background-color: var(--primary-color);
    color: white !important;
    font-weight: 600;
    border-radius: 6px;
    /* Use box-shadow inset instead of margin to avoid layout shift */
    box-shadow: inset 0 0 0 2px var(--primary-color), 0 2px 4px rgba(37, 99, 235, 0.2);
}

.nav-child.active-link:hover {
    background-color: var(--primary-color);
    color: white !important;
    opacity: 0.9;
}

/* Recent Themes Section */
.recent-section {
    margin-bottom: 2.5rem;
}

.recent-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    margin-top: 0;
    font-weight: 700;
}

/* Wrapper for generating placeholders - uses contents to not occupy grid cell when empty */
#generating-placeholders {
    display: contents;
}

.recent-scroll-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    padding-bottom: 1rem;
    overflow: visible;
    transition: max-height 0.4s ease-in-out, clip-path 0.4s ease-in-out;
}

.recent-scroll-container.expanded {
    max-height: 2000px;
    /* Remove clip-path when expanded */
    clip-path: none;
}

.recent-actions {
    display: flex;
    justify-content: center;
    margin-top: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.btn-toggle-recent {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.recent-time {
    display: block;
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 2px;
}

.btn-toggle-recent:hover {
    background: #f3f4f6;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* View All Card */
.view-all-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed var(--border-color);
    cursor: pointer;
    justify-content: center;
    min-height: 120px;
}

.view-all-card:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    transform: scale(1.02);
}

.view-all-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.view-all-icon {
    font-size: 2rem;
}

.view-all-text {
    font-weight: 600;
    color: var(--text-color);
}

.view-all-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 10px;
    border-radius: 12px;
}

/* Recent Modal */
.recent-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.recent-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.recent-modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.recent-modal-overlay.active .recent-modal-content {
    transform: scale(1);
}

.recent-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.recent-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.recent-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.recent-modal-close:hover {
    color: var(--danger-color);
}

.recent-modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    display: grid;
    /* Force 2-3 large cards per row */
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.recent-modal-card {
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    /* Enforce minimum size */
    min-width: 300px;
}

.recent-modal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.recent-modal-card img {
    width: 100%;
    height: auto;
    display: block;
    /* Ensure image fills card width */
    min-width: 100%;
}

.recent-modal-info {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-modal-info .name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-modal-info .category {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recent-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    /* Ensure z-index handling for children */
    position: relative;
    z-index: 1;
    /* Fix height for grid calculation */
    box-sizing: border-box;
    height: 100%;
}

.recent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
    /* Raise stacking context on hover so zoom appears above all other cards */
    z-index: 100;
}

.recent-icon {
    font-size: 1.5rem;
    background: #f3f4f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recent-info {
    display: flex;
    flex-direction: column;
}

.recent-theme-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.recent-category-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Recent Image Styles */
.recent-image-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: visible;
    /* CORE FIX: Allowed overflow for zoomed image */
    flex-shrink: 0;
}

.recent-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.recent-image-zoom {
    display: none;
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translate(10px, -50%);
    /* Larger size to show full main image */
    width: 320px;
    max-width: 90vw;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    background: white;
    border: 3px solid white;
    pointer-events: none;
    overflow: hidden;
}

.recent-image-zoom img {
    width: 100%;
    height: auto;
    display: block;
    /* Ensure full image is shown */
    object-fit: contain;
}

.recent-image-wrapper:hover .recent-image-zoom {
    display: block;
}

/* Image Grid Layout - Simple hover overlay design */
.groups-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, 390px);
    gap: 1.5rem;
    justify-content: center;
}

/* Image Card - Simple image with hover overlay (same size as puzzle grid) */
.image-card {
    position: relative;
    width: 390px;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Highlight animation for images navigated from Explore */
.image-card.highlight-pulse {
    animation: highlightPulse 2.5s ease-out;
}

@keyframes highlightPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    }

    15% {
        transform: scale(1.02);
        box-shadow: 0 0 0 20px rgba(37, 99, 235, 0.3);
    }

    30% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0.5);
    }

    50% {
        box-shadow: 0 0 0 25px rgba(37, 99, 235, 0.2);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(37, 99, 235, 0.3);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

/* Back to Explore floating button */
.back-to-explore-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    transform: translateY(-10px);
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    z-index: 100;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.back-to-explore-btn.visible {
    transform: translateY(0);
    opacity: 1;
}

.back-to-explore-btn.dismissing {
    transform: translateY(-10px);
    opacity: 0;
}

.back-to-explore-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.back-to-explore-btn .back-icon {
    font-size: 16px;
}

.back-to-explore-btn .back-text {
    white-space: nowrap;
}

.image-card .main-image {
    width: 100%;
    display: block;
    border-radius: 12px;
}

/* Hover Overlay */
.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.25s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    border-radius: 12px;
    pointer-events: none;
    /* Allow clicks to pass through to image */
}

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

/* Overlay Action Buttons */
.overlay-actions {
    display: flex;
    gap: 10px;
    pointer-events: auto;
    /* Re-enable clicks on buttons */
}

.overlay-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.overlay-btn:hover {
    transform: scale(1.1);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.overlay-btn.danger:hover {
    background: #fee2e2;
}

/* ============================================================
   PUZZLE MODE - In-place Grid Editing
   ============================================================ */

/* Puzzle grid overlay on each image */
.puzzle-grid-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
}

.puzzle-grid-overlay .puzzle-tile {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-size: 400% 400%;
    cursor: grab;
    transition: box-shadow 0.15s ease;
}

.puzzle-grid-overlay .puzzle-tile:hover {
    transform: scale(1.02);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
    z-index: 10;
}

.puzzle-grid-overlay .puzzle-tile.selected {
    box-shadow: 0 0 0 3px #3b82f6, 0 0 20px rgba(59, 130, 246, 0.5);
    z-index: 20;
}

/* Modified tile indicator - green dot */
.puzzle-grid-overlay .puzzle-tile.modified::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.puzzle-grid-overlay .puzzle-tile {
    position: relative;
}

/* Swap animation for inline puzzle */
.puzzle-grid-overlay .puzzle-tile.restoring {
    z-index: 100;
    animation: inlineSwapMove 0.35s ease-in-out forwards;
}

@keyframes inlineSwapMove {
    0% {
        transform: translate(var(--move-x), var(--move-y));
    }

    50% {
        transform: translate(calc(var(--move-x) * 0.5), calc(var(--move-y) * 0.5)) scale(1.08);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* Puzzle controls bar - for mode toggle area */
.puzzle-controls {
    display: none;
    gap: 8px;
    align-items: center;
    margin-left: 12px;
}

body.puzzle-mode .puzzle-controls {
    display: flex;
}

/* Puzzle controls panel - coordinated expand/collapse animations */
/* Puzzle controls panel - coordinated expand/collapse animations */
.puzzle-controls-panel {
    display: flex;
    visibility: hidden;
    position: absolute;
    left: 100%;
    top: 0;
    gap: 8px;
    align-items: center;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    padding-left: 8px;
    /* Collapse: wait for buttons to animate out first */
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.35s,
        opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0.35s,
        visibility 0s linear 0.7s;
}

.puzzle-ctrl-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    transform: scale(0);
    opacity: 0;
}

.puzzle-ctrl-btn svg {
    width: 16px;
    height: 16px;
}

/* Expand: Elastic bounce - total ~0.5s */
body.puzzle-mode .puzzle-ctrl-btn:nth-child(1) {
    animation: btnGrowIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.1s forwards;
}

body.puzzle-mode .puzzle-ctrl-btn:nth-child(2) {
    animation: btnGrowIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.15s forwards;
}

body.puzzle-mode .puzzle-ctrl-btn:nth-child(3) {
    animation: btnGrowIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s forwards;
}

/* Collapse: Smooth and fast - total ~0.5s */
body:not(.puzzle-mode) .puzzle-ctrl-btn:nth-child(3) {
    animation: btnShrinkOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0s forwards;
}

body:not(.puzzle-mode) .puzzle-ctrl-btn:nth-child(2) {
    animation: btnShrinkOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.05s forwards;
}

body:not(.puzzle-mode) .puzzle-ctrl-btn:nth-child(1) {
    animation: btnShrinkOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s forwards;
}

@keyframes btnGrowIn {
    0% {
        transform: scale(0) translateX(-10px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateX(0);
        opacity: 1;
    }
}

@keyframes btnShrinkOut {
    0% {
        transform: scale(1) translateX(0);
        opacity: 1;
    }

    100% {
        transform: scale(0.3) translateX(-10px);
        opacity: 0;
    }
}

.puzzle-ctrl-btn:hover {
    background: #f0f7ff;
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.puzzle-ctrl-btn.primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    color: white;
}

.puzzle-ctrl-btn.primary:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Save Button States */
.puzzle-ctrl-btn.loading {
    cursor: not-allowed;
    opacity: 0.8;
}

.puzzle-ctrl-btn.loading .btn-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.puzzle-ctrl-btn.success {
    background: #10b981 !important;
    /* Emerald 500 */
    border-color: #10b981 !important;
    transform: scale(1.1);
}

.puzzle-ctrl-btn.error {
    background: #ef4444 !important;
    /* Red 500 */
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* ============================================================
   PUZZLE MODE STATE - Applied via body.puzzle-mode
   ============================================================ */

/* Hide browse-only elements in puzzle mode */
body.puzzle-mode .browse-only {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Show puzzle-only elements in puzzle mode */
body.puzzle-mode .puzzle-only {
    opacity: 1;
    pointer-events: auto;
}

body.puzzle-mode .puzzle-grid-overlay {
    opacity: 1;
    pointer-events: auto;
    /* Removed background: white to prevent flash */
}

/* Keep main image visible behind puzzle grid for seamless transition */
body.puzzle-mode .main-image {
    opacity: 1;
}

/* Change cursor and disable hover effects in puzzle mode */
body.puzzle-mode .image-card {
    cursor: default;
}

body.puzzle-mode .image-card:hover {
    transform: none;
    box-shadow: none;
}

body.puzzle-mode .puzzle-controls-panel {
    visibility: visible;
    max-width: 200px;
    opacity: 1;
    /* Expand: bouncy and inviting */
    transition: max-width 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.05s,
        visibility 0s linear 0s;
}

/* Dim generation section in puzzle mode */
body.puzzle-mode .actions-footer {
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Split count badge */
.split-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #1a73e8 0%, #4285f4 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================================
   SPLIT RESULTS MODAL
   ============================================================ */
.split-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.split-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.split-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.split-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: splitModalSlideIn 0.3s ease-out;
}

@keyframes splitModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.split-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
}

.split-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.split-modal-count {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.split-modal-header .modal-close {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: none;
    background: #e5e7eb;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.split-modal-header .modal-close:hover {
    background: #d1d5db;
}

.split-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    align-content: start;
}

.split-modal-body .gallery-item {
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.split-modal-body .gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.split-modal-body .gallery-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.split-modal-body .image-name {
    padding: 8px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Material Progress Indicators */
.progress-container {
    margin-top: 1.5rem;
}

.progress-bar-wrapper {
    background-color: #e8f0fe;
    height: 4px;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    background-color: var(--primary-blue);
    height: 100%;
    transition: width 0.4s ease;
}

.progress-container p {
    font-size: 12px;
    color: #5f6368;
    margin-top: 8px;
    font-weight: 500;
}

/* Enterprise Drop Zone (MS Fluent Style) */
.upload-section {
    max-width: 600px;
    /* Slightly wider for better presentation */
    margin: 3rem 0;
}

.upload-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #202124;
    margin-bottom: 1.5rem;
}

.drop-zone {
    border: 2px dashed #dadce0;
    border-radius: 12px;
    background-color: #f8f9fa;
    padding: 2.5rem 1.5rem !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.drop-zone:hover {
    border-color: var(--primary-blue);
    background-color: rgba(26, 115, 232, 0.02);
}

.drop-zone.drag-over {
    border-color: var(--primary-blue);
    background-color: rgba(26, 115, 232, 0.05);
    transform: scale(1.01);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    font-size: 32px;
    background: #e8f0fe;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--primary-blue);
    transition: transform 0.3s;
}

.drop-zone:hover .upload-icon {
    transform: translateY(-5px);
}

.upload-text p {
    font-size: 16px;
    font-weight: 500;
    color: #3c4043;
    margin: 0;
}

.drop-zone .sub-text {
    font-size: 13px;
    color: #70757a;
    display: block;
    margin-top: 4px;
}

/* ============================================================
   ACTION CARDS (inside .groups-container grid)
   ============================================================ */

/* Action card - matches .image-card dimensions */
.action-card {
    position: relative;
    width: 390px;
    height: 390px;
    border-radius: 12px;
    overflow: hidden;
    box-sizing: border-box;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s ease;
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.action-card-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    box-sizing: border-box;
}

/* Generation section styling inside action card */
.action-card .generation-section {
    background: linear-gradient(135deg, #fff 0%, #f0f7ff 100%);
    border: 2px dashed #dbeafe;
    border-radius: 12px;
}

/* Upload section styling inside action card */
.action-card .upload-section {
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    max-width: none;
    width: 100%;
    height: 100%;
    margin: 0;
}

.action-card .generation-section h3,
.action-card .upload-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: var(--text-color);
    letter-spacing: -0.02em;
}

/* Elegant dropdown styling */
.action-card .generation-controls {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-card .generation-controls select {
    width: 100%;
    font-size: 14px;
    padding: 10px 36px 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.action-card .generation-controls select:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.action-card .generation-controls select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.action-card .btn-large {
    height: 46px;
    padding: 0 24px;
    font-size: 15px;
    font-weight: 600;
    width: 100%;
    max-width: 300px;
    margin-top: 6px;
}

.action-card .hint-text {
    font-size: 12px;
    margin-top: 1rem;
    color: #9ca3af;
}

/* Drop zone adjustments for action card */
.action-card .drop-zone {
    padding: 1.5rem 1rem !important;
    border: none;
    background: transparent;
    height: auto;
}

.action-card .upload-icon {
    font-size: 36px;
    width: 72px;
    height: 72px;
}

.action-card .upload-text p {
    font-size: 16px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.action-card .drop-zone .sub-text {
    font-size: 13px;
    color: #9ca3af;
}

/* Hide action cards in puzzle mode */
body.puzzle-mode .action-card {
    opacity: 0.3;
    pointer-events: none;
}

/* Smooth shifting animation when new images are inserted */
.action-card.shifting {
    animation: cardShift 0.5s ease-out;
}

@keyframes cardShift {
    0% {
        transform: translateX(0);
    }

    30% {
        transform: translateX(10px);
    }

    100% {
        transform: translateX(0);
    }
}

/* ============================================================
   ENTERPRISE TAGGING SYSTEM (Google Material 3 + MS Fluent)
   ============================================================ */

.tags-component {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 20px 0;
    position: relative;
    --primary-blue: #1a73e8;
    --bg-gray: #f1f3f4;
    --text-gray: #3c4043;
    --border-gray: #dadce0;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Base Chip: Strict Material Design 3 Specs */
.chip {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    background-color: var(--chip-bg, var(--bg-gray));
    color: var(--chip-text, var(--text-gray));
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    /* M3 style is more rectangular with soft corners, or pill */
    border: 1px solid var(--chip-border, transparent);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
    user-select: none;
    box-sizing: border-box;
    animation: chipPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes chipPop {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chip:hover {
    background-color: var(--chip-hover-bg, #e8eaed);
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
    transform: translateY(-1px);
}

/* Centered Add Button: Circular & Precise */
.chip-add {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    background-color: white !important;
    border: 1px solid var(--border-gray) !important;
    color: var(--primary-blue) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.chip-add:hover {
    background-color: rgba(26, 115, 232, 0.04) !important;
    border-color: var(--primary-blue) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    transform: rotate(90deg);
}

.chip-add .icon {
    font-size: 20px;
    line-height: 1;
    margin-top: -1px;
    /* Optical centering */
    display: block;
}

.chip-add .label {
    display: none;
    /* Icon only for centering precision */
}

/* Remove Icon */
.chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 8px;
    margin-right: -4px;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: currentColor;
    opacity: 0.54;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
}

.chip-remove:hover {
    background-color: rgba(0, 0, 0, 0.1);
    opacity: 1;
}

/* Microsoft Fluent Popover / Suggestions */
.tag-popover {
    position: absolute;
    top: 40px;
    left: 0;
    z-index: 1000;
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideDown 0.2s cubic-bezier(0, 0, 0, 1);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tag-input {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--primary-blue);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    background: white;
}

.tag-suggestions {
    max-height: 240px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.suggestion-header {
    font-size: 11px;
    font-weight: 700;
    color: #5f6368;
    padding: 8px 12px 4px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-gray);
    border-radius: 4px;
    transition: background-color 0.1s;
    gap: 10px;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: rgba(0, 0, 0, 0.05);
}

.suggestion-item.selected {
    border-left: 2px solid var(--primary-blue);
    padding-left: 10px;
}

.suggestion-item .icon {
    font-size: 16px;
    opacity: 0.7;
}

.suggestion-item.disabled {
    color: #80868b;
    cursor: default;
}

/* Color Palette: Google Theme */
.chip:nth-child(4n+1) {
    --chip-bg: #e8f0fe;
    --chip-text: #1967d2;
    --chip-border: #d2e3fc;
    --chip-hover-bg: #d2e3fc;
}

.chip:nth-child(4n+2) {
    --chip-bg: #e6f4ea;
    --chip-text: #137333;
    --chip-border: #ceead6;
    --chip-hover-bg: #ceead6;
}

.chip:nth-child(4n+3) {
    --chip-bg: #fce8e6;
    --chip-text: #c5221f;
    --chip-border: #fad2cf;
    --chip-hover-bg: #fad2cf;
}

.chip:nth-child(4n) {
    --chip-bg: #fef7e0;
    --chip-text: #ea8600;
    --chip-border: #feefc3;
    --chip-hover-bg: #feefc3;
}

.status-msg {
    margin-top: 1rem;
    font-size: 14px;
    font-weight: 500;
    color: #5f6368;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-msg.success {
    color: #137333;
}

.status-msg.error {
    color: #c5221f;
}

.simple-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 1rem;
    opacity: 0.6;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between !important;
    padding: 0.75rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.vault-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.vault-btn:hover {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.vault-btn .icon {
    font-size: 16px;
}

.image-group {
    transition: opacity 0.2s ease-in-out;
}

/* Sleek Progress Bar */
.progress-container {
    margin-top: 1rem;
    display: none;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.sleek-progress {
    width: 100%;
    height: 4px;
    /* Material standard is usually 4px for linear indicators */
    background: #e2e7ec;
    /* Neutral track color */
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    /* No shadows for flat design */
}

.sleek-bar {
    height: 100%;
    width: 0%;
    background: #1a73e8;
    /* Google Blue 600 */
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Shimmer Effect */
.sleek-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 50%,
            rgba(255, 255, 255, 0) 100%);
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}

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

.progress-text {
    font-size: 11px;
    color: #444746;
    /* Material Grey 700 */
    margin-top: 6px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-align: right;
    display: block;
    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
}

/* Staggered Animation for New Images */
@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.new-item-anim {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Stagger delays handled in JS or via nth-child loops if needed */

/* Fix for Layout Jumping: Absolute Positioning */
.group-controls {
    position: relative;
    /* Anchor point */
}

/* Override previous static positioning for progress */
.progress-container {
    position: absolute;
    bottom: -32px;
    /* Position below the action row */
    left: 0;
    right: 0;
    margin-top: 0 !important;
    padding-top: 8px;
    /* Buffer */
    z-index: 5;
    /* Ensure it floats above potential overlaps */
}

/* Ensure there's space reserved at bottom of heather so it doesn't overlap sub-gallery if too tight */
.group-header {
    padding-bottom: 2rem !important;
    /* Add breathing room for the absolute bar */
}

/* Optimized Control Layout: Stable Toolbar */
.controls-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Center vertically for clean alignment */
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 0.5rem;
    /* Space before tags */
}

/* Title Styling in new layout */
.controls-top-row h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #202124;
    word-break: break-word;
    /* Better than break-all for readability */
    line-height: 1.4;
    flex-grow: 1;
    /* Allow title to take space */
    margin-right: auto;
}

/* Ensure actions don't shrink */
.action-row {
    flex-shrink: 0;
    margin-left: auto;
}

/* Adjust tag component to sit nicely below */
.tags-component {
    margin: 0 !important;
    /* Remove old margins, let Flexbox gap handle it */
    width: 100%;
}

/* ============================================================
   1688 UPLOAD HELPER - PREMIUM MODAL UI
   ============================================================ */

/* FAB Trigger Button */
.fab-1688 {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.4);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-1688:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.5);
}

.fab-1688:active {
    transform: scale(0.95);
}

/* Ensure image-group is positioned for FAB */
.image-group {
    position: relative;
}

/* Modal Overlay */
.modal-1688 {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.modal-1688.open {
    display: flex;
}

.modal-1688-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Modal Content */
.modal-1688-content {
    position: relative;
    width: 90%;
    max-width: 1100px;
    /* Optimized for large screens */
    max-height: 88vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Header */
.modal-1688-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #fff9f5 0%, #fff 100%);
}

.modal-1688-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-1688-header .modal-icon {
    font-size: 28px;
}

.modal-1688-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #202124;
}

.modal-theme-badge {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #eee;
    color: #333;
    transform: rotate(90deg);
}

/* Modal Cards */
.modal-card {
    margin: 20px 24px;
    padding: 20px;
    background: #fafbfc;
    border-radius: 16px;
    border: 1px solid #f0f0f0;
}

.modal-card .card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.modal-card .card-icon {
    font-size: 20px;
}

.modal-card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex-grow: 1;
}

/* Title Row V2 */
.title-row-v2 {
    display: flex;
    gap: 10px;
    align-items: center;
}

.title-input-v2 {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 15px;
    background: white;
    color: #333;
    transition: border-color 0.2s;
}

.title-input-v2:focus {
    outline: none;
    border-color: #ff6b35;
}

.title-input-v2::placeholder {
    color: #aaa;
}

/* 1688 Buttons */
.btn-1688 {
    height: 44px;
    padding: 0 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-1688.primary {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
}

.btn-1688.primary:hover {
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
    transform: translateY(-1px);
}

.btn-1688.secondary {
    background: #f0f0f0;
    color: #555;
}

.btn-1688.secondary:hover {
    background: #e5e5e5;
}

/* Batch Generate Button */
.btn-batch {
    height: 36px;
    padding: 0 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.2s;
}

.btn-batch:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-batch:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Slots Grid V2 - Horizontal Layout */
.slots-grid-v2 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding-bottom: 40px;
    /* Space for history thumbnails */
}

@media (max-width: 700px) {
    .slots-grid-v2 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .slots-grid-v2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Slot V2 */
.slot-v2 {
    position: relative;
    aspect-ratio: 1;
    background: white;
    border-radius: 14px;
    border: 2px dashed #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
    /* Allow history to show */
}

.slot-v2:hover {
    border-color: #ff6b35;
    border-style: solid;
    background: #fff9f5;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.15);
    /* Removed transform to prevent layout shift */
}

.slot-v2.slot-white {
    background: linear-gradient(135deg, #f8f8f8 0%, #fff 100%);
}

.slot-v2.slot-white:hover {
    border-color: #1a73e8;
    background: #f0f7ff;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.15);
}

.slot-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
    overflow: hidden;
    /* Keep image contained */
    border-radius: 12px;
}

.slot-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    transition: none;
    /* No in-place scaling */
}

.slot-placeholder-icon {
    font-size: 32px;
    opacity: 0.4;
}

.slot-label-v2 {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: #888;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
    z-index: 5;
}

/* Refresh Button - ALWAYS VISIBLE on hover, high z-index */
.slot-refresh {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
    /* HIGH z-index to stay above everything */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.slot-v2:hover .slot-refresh {
    opacity: 1;
    transform: scale(1);
}

.slot-refresh:hover {
    background: #ff6b35;
    color: white;
    transform: scale(1.15) rotate(180deg);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

/* Slot History Thumbnails */
.slot-history {
    position: absolute;
    bottom: -32px;
    left: 0;
    width: 100%;
    height: 28px;
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 0 4px;
    pointer-events: auto;
    z-index: 5;
}

.history-thumb {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

.history-thumb:hover {
    border-color: #ff6b35;
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.3);
}

/* Autocomplete Dropdown */
.search-autocomplete {
    position: absolute;
    top: calc(100% + 4px);
    left: 15px;
    right: 15px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 4px 0;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* Stack vertically */
    align-items: flex-start;
    /* Align left */
    gap: 2px;
    /* Small gap between title and category */
    transition: all 0.2s;
    border-bottom: 1px solid transparent;
}

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

.autocomplete-item:hover,
.autocomplete-item.selected {
    background-color: #f3f4f6;
}

.autocomplete-theme {
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item:hover .autocomplete-theme,
.autocomplete-item.selected .autocomplete-theme {
    color: var(--primary-color);
}

.autocomplete-category {
    color: #9ca3af;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    /* Removed pill style for cleaner 2-line look */
    background: transparent;
    padding: 0;
}

/* Autocomplete scrollbar styling */
.search-autocomplete::-webkit-scrollbar {
    width: 4px;
}

.search-autocomplete::-webkit-scrollbar-track {
    background: transparent;
}

.search-autocomplete::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.search-autocomplete::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* ===== HOVER ZOOM: Fixed Preview at Top-Right ===== */
/* Shows a larger preview in a fixed position, NOT covering the slot */
.slot-v2 .zoom-preview {
    display: none;
    position: fixed;
    top: 100px;
    right: 40px;
    width: 600px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    pointer-events: none;
    overflow: hidden;
}

.slot-v2:hover .zoom-preview {
    display: block;
}

.slot-v2 .zoom-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Global Slot Zoom Preview - Fixed position at top-right */
/* Responsive: adapts to screen size to avoid blocking slots */
.slot-zoom-preview {
    position: fixed;
    top: 80px;
    right: 30px;
    width: 650px;
    height: 650px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.35);
    z-index: 2000;
    pointer-events: none;
    overflow: hidden;
    border: 3px solid #ff6b35;
}

.slot-zoom-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f8f8f8;
}

/* Medium screens: reduce preview size */
@media (max-width: 1400px) {
    .slot-zoom-preview {
        width: 450px;
        height: 450px;
        top: 100px;
        right: 20px;
    }

    .slot-v2 .zoom-preview {
        width: 450px;
        height: 450px;
    }
}

/* Small screens: further reduce and reposition to bottom-right */
@media (max-width: 1000px) {
    .slot-zoom-preview {
        width: 300px;
        height: 300px;
        top: auto;
        bottom: 20px;
        right: 20px;
    }

    .slot-v2 .zoom-preview {
        width: 300px;
        height: 300px;
        top: auto;
        bottom: 80px;
        right: 20px;
    }
}

/* Slot Loading State */
.slot-v2.loading {
    pointer-events: none;
}

/* Loading Overlay - Visible feedback during generation */
.slot-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 12px;
    z-index: 50;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 13px;
    font-weight: 600;
    color: #ff6b35;
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Modal Footer */
.modal-1688-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: center;
    border-top: 1px solid #f0f0f0;
    background: #fafbfc;
}

.btn-export {
    height: 48px;
    padding: 0 32px;
    background: linear-gradient(135deg, #34c759 0%, #2fb350 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s;
}

.btn-export:hover {
    box-shadow: 0 6px 20px rgba(52, 199, 89, 0.4);
    transform: translateY(-2px);
}

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

/* Scrollable content area if needed */
.modal-1688-content {
    overflow-y: auto;
}

/* ================== PUZZLE MODE CSS ================== */

/* Entry Button */
.theme-actions-bar {
    margin-bottom: 2rem;
}

.btn-puzzle-mode {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #8e2de2, #4a00e0);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 0, 224, 0.3);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn-puzzle-mode:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(74, 0, 224, 0.4);
}

/* Modal Backdrop */
.puzzle-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.puzzle-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

/* Modal Content */
.puzzle-modal-content {
    position: relative;
    width: 95vw;
    height: 90vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Header */
.puzzle-header {
    flex: 0 0 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.puzzle-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.puzzle-icon {
    font-size: 24px;
}

.puzzle-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.puzzle-theme-badge {
    background: #e0e7ff;
    color: #4338ca;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.puzzle-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.puzzle-btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.puzzle-btn.primary {
    background: #3b82f6;
    color: white;
}

.puzzle-btn.primary:hover {
    background: #2563eb;
}

.puzzle-btn.secondary {
    background: white;
    border-color: #cbd5e1;
    color: #475569;
}

.puzzle-btn.secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

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

.puzzle-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    margin-left: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s;
}

.puzzle-close:hover {
    background: #f1f5f9;
    color: #ef4444;
}

/* Main Area */
.puzzle-main {
    flex: 1;
    background: #eef2f6;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    /* Only horizontal scroll for layouts */
    padding: 40px;
    display: flex;
    align-items: center;
    /* Center vertically */
}

/* Container for multiple grids */
.puzzle-grids-container {
    display: flex;
    flex-wrap: wrap;
    /* Enable wrapping */
    gap: 30px;
    margin: 0 auto;
    padding: 0 40px;
    /* Cleaned up duplicate properties */
}

.puzzle-grid-wrapper {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.puzzle-grid-header {
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    background: rgba(255, 255, 255, 0.8);
    padding: 6px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
}

.puzzle-origin-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #e2e8f0;
}

/* The 4x4 Grid */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    /* Remove grid lines */
    /* Reduced size by ~50% (was 500px) -> Scaled up to 1.5x */
    width: 390px;
    height: 390px;
    background: #fff;
    padding: 4px;
    border-radius: 4px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15);
    /* Removed background-color: #333; */
}

.puzzle-tile {
    width: 100%;
    height: 100%;
    /* Depends on grid sizing */
    position: relative;
    cursor: grab;
    overflow: hidden;
    background: #f1f5f9;
}

.puzzle-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    /* Crucial for clean dragging */
}

/* Dragging States */
.puzzle-tile.dragging {
    opacity: 0.4;
    cursor: grabbing;
    /* border: 2px dashed #3b82f6; */
}

.puzzle-tile.over {
    /* Target highlight */
    outline: 3px solid #f59e0b;
    /* Amber highlight */
    z-index: 10;
    transform: scale(1.05);
    transition: transform 0.1s;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.puzzle-tile.selected {
    outline: 3px solid #3b82f6;
    /* Blue highlight */
    z-index: 10;
    transform: scale(0.95);
    box-shadow: inset 0 0 0 2px white;
}

/* Modified Tile Indicator */
.puzzle-tile.modified::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #10b981;
    /* Green dot */
    border-radius: 50%;
    border: 1px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Restoring Animation */
.puzzle-tile.restoring {
    z-index: 100;
    animation: restoreMove 0.4s ease-in-out forwards;
}

@keyframes restoreMove {
    0% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(var(--move-x), var(--move-y)) scale(1.1);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    }

    100% {
        transform: translate(var(--move-x), var(--move-y));
    }
}

/* Footer Instructions */
.puzzle-footer {
    flex: 0 0 50px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.puzzle-hint {
    color: #64748b;
    font-size: 13px;
    margin: 0;
}

/* Loading/Empty States */
.puzzle-loading,
.puzzle-empty {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #64748b;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Puzzle Preview Button - Subtle icon */
.puzzle-preview-btn {
    margin-top: 4px;
    padding: 2px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
}

.puzzle-preview-btn:hover {
    opacity: 1;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* Puzzle Lightbox */
.puzzle-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.puzzle-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.puzzle-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

/* Comparison layout - side by side */
.puzzle-lightbox-content.puzzle-comparison {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.puzzle-compare-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.puzzle-compare-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
}

.puzzle-compare-item img {
    max-width: 40vw;
    max-height: 70vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.puzzle-lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.puzzle-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.puzzle-lightbox-close:hover {
    background: #ef4444;
    transform: scale(1.1);
}

/* Large Screen Optimization for 1688 Modal */
@media (min-width: 1600px) {
    .modal-1688-content {
        max-width: 1400px;
    }
}

/* Archive Vault Styles (Matching Image Card) */
.image-group {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 390px;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    /* Ensure it behaves like a card */
    display: flex;
    flex-direction: column;
}

.image-group:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.image-group .main-image {
    width: 100%;
    height: auto;
    display: block;
    /* Aspect ratio fix if needed, but auto height is usually fine for these */
}

.group-header {
    padding: 0;
}

.group-controls {
    padding: 1rem;
}

/* ================== PUZZLE COMPARISON MODAL (Lightroom Style) ================== */

/* Comparison Backdrop */
.puzzle-compare-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4000;
    justify-content: center;
    align-items: center;
    background: #0b0b0b;
    /* Deep black/grey */
}

.puzzle-compare-modal.open {
    display: flex;
}

.puzzle-compare-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    /* Show clickable cursor */
}

/* Modal Content - Full Screen Workspace */
.puzzle-compare-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 4001;
    background: transparent;
    pointer-events: none;
    /* Allow clicks to pass through to backdrop */
}

/* Close Button - Minimalist */
.puzzle-compare-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #999;
    border-radius: 50%;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5000;
    pointer-events: auto;
    /* Re-enable clicks for close button */
}

.puzzle-compare-close:hover {
    color: white;
}

/* Main Body - Split View */
.puzzle-compare-body {
    flex: 1;
    display: flex;
    gap: 4px;
    /* Tiny gap line */
    padding: 0;
    justify-content: stretch;
    align-items: stretch;
    pointer-events: none;
    /* Pass clicks through */
}

.compare-pane {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0b0b0b;
    overflow: hidden;
    pointer-events: none;
    /* Pass clicks through */
}

/* Overlay Labels instead of headers */
.compare-label {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.5);
    color: #e0e0e0;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.compare-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    /* Breathe space */
    pointer-events: auto;
    /* Re-enable clicks for images */
}

.compare-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
    /* Subtle outline */
}

/* Re-use grid styles inside comparison */
.compare-image-container .puzzle-grid {
    box-shadow: none;
    width: auto !important;
    height: auto !important;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    /* Ensure grid scales properly */
}

/* Footer - Minimal Info */
.puzzle-compare-footer {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: #666;
    pointer-events: none;
    font-size: 12px;
}

/* Responsive Stack */
@media (max-width: 768px) {
    .puzzle-compare-body {
        flex-direction: column;
    }

    .compare-pane {
        border-bottom: 1px solid #222;
    }

    .compare-image-container {
        padding: 10px;
    }
}

/* ================== PUZZLE MAGNIFYING GLASS BUTTON ================== */
.puzzle-compare-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 18px;
    /* 1/4 area approx of 32px would be ~16px, letting it be 18px for usability */
    height: 18px;
    background: rgba(255, 255, 255, 0.85);
    /* Slightly less opaque */
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    /* Smaller icon */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    z-index: 50;
    /* Above tiles */
    opacity: 0.6;
    /* Unobtrusive by default */
}

.puzzle-compare-btn:hover {
    transform: scale(1.1);
    background: white;
    opacity: 1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ================== PENDING LIST FEATURE ================== */

/* Pending Button Badge */
.pending-list-btn {
    position: relative;
}

.pending-count-badge {
    display: none;
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Add to Pending Button Style */
.add-to-pending-btn.active {
    background: #10b981 !important;
    color: white !important;
}

.add-to-pending-btn.active svg {
    stroke: white;
}

.add-to-pending-btn.added {
    animation: pendingPulse 0.3s ease;
}

.add-to-pending-btn.removed {
    animation: pendingShake 0.3s ease;
}

@keyframes pendingPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
        background: #10b981;
    }

    100% {
        transform: scale(1);
    }
}

@keyframes pendingShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

/* Pending List Modal */
.pending-list-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
}

.pending-list-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.pending-list-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.pending-list-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pending-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.pending-list-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pending-list-header .modal-icon {
    font-size: 1.5rem;
}

.pending-list-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.pending-list-header .modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.pending-list-header .modal-close:hover {
    color: #374151;
}

.pending-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    min-height: 200px;
}

/* Empty State */
.pending-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6b7280;
    text-align: center;
}

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

.pending-empty p {
    margin: 0;
    font-size: 1rem;
}

.pending-empty .hint {
    margin-top: 8px;
    font-size: 0.875rem;
    color: #9ca3af;
}

/* Pending Groups */
.pending-group {
    margin-bottom: 20px;
}

.pending-group:last-child {
    margin-bottom: 0;
}

.pending-group-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.group-category {
    color: #9ca3af;
}

.group-separator {
    color: #d1d5db;
}

.group-theme {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
}

.group-theme:hover {
    text-decoration: underline;
}

.pending-group-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

/* Pending Item */
.pending-item {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.2s;
}

.pending-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.pending-item-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 6px;
    background: white;
    margin-bottom: 8px;
}

.pending-item-name {
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pending-item-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.pending-item:hover .pending-item-remove {
    opacity: 1;
}

.pending-item-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.pending-list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: #f9fafb;
    border-radius: 0 0 16px 16px;
}

.pending-list-count {
    font-size: 0.875rem;
    color: #6b7280;
}

.pending-list-footer .btn-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: #6b7280;
    font-size: 0.875rem;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.pending-list-footer .btn-secondary:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ================== PENDING LIST CARD STYLES (Browse-like) ================== */

.pending-item-card {
    position: relative;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.pending-item-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

/* Pending Page Badge - Shows theme/category on image cards */
.pending-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    z-index: 10;
}

.image-card:hover .pending-badge {
    opacity: 1;
    transform: translateY(0);
}

.pending-badge .badge-category {
    color: #a5b4fc;
}

.pending-badge .badge-sep {
    color: #6b7280;
}

.pending-badge .badge-theme {
    color: #fbbf24;
    font-weight: 600;
}

.pending-card-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #f9fafb;
    display: block;
}

.pending-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 24px;
    /* Leave space for filename */
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pending-item-card:hover .pending-card-overlay {
    opacity: 1;
}

.pending-card-overlay .overlay-actions {
    display: flex;
    gap: 8px;
}

.pending-card-overlay .overlay-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pending-card-overlay .overlay-btn:hover {
    transform: scale(1.1);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pending-card-overlay .overlay-btn.danger {
    background: rgba(254, 226, 226, 0.95);
    color: #dc2626;
}

.pending-card-overlay .overlay-btn.danger:hover {
    background: #fecaca;
}

.pending-card-overlay .overlay-btn svg {
    width: 18px;
    height: 18px;
}

.pending-card-name {
    display: block;
    padding: 8px 10px;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    background: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ================== PENDING PAGE FULL VIEW ================== */

.pending-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.pending-page-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pending-page-title .page-icon {
    font-size: 1.75rem;
}

.pending-page-title h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.pending-page-count {
    background: #f3f4f6;
    color: #6b7280;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.pending-page-actions .btn {
    font-size: 0.875rem;
}

/* Empty State */
.pending-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.pending-empty-state .empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.pending-empty-state p {
    margin: 0;
    color: #6b7280;
    font-size: 1rem;
}

.pending-empty-state .hint {
    margin-top: 8px;
    font-size: 0.875rem;
    color: #9ca3af;
}

/* Theme Sections */
.pending-theme-section {
    margin-bottom: 2.5rem;
}

.pending-theme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.pending-theme-link {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.pending-theme-link:hover {
    opacity: 0.8;
}

.pending-theme-link .theme-category {
    color: #9ca3af;
}

.pending-theme-link .theme-separator {
    color: #d1d5db;
}

.pending-theme-link .theme-name {
    color: var(--primary-color);
    font-weight: 600;
}

.pending-theme-header .theme-count {
    font-size: 0.875rem;
    color: #9ca3af;
}

/* Images Grid - reuse groups-container style */
.pending-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

/* Pending Image Card - reuse image-card styling */
.pending-image-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.pending-image-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.pending-image-card .main-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #f9fafb;
    display: block;
    cursor: zoom-in;
}

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

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

/* Loading state */
.pending-loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* ================== MINIMAL LANGUAGE SWITCH ================== */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    user-select: none;
    margin-right: 12px;
    font-size: 13px;
    font-weight: 500;
}

.lang-option {
    padding: 4px 8px;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
}

.lang-option::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: all 0.2s ease;
    transform: translateX(-50%);
}

.lang-option:hover {
    color: var(--text-color);
}

.lang-option.active {
    color: var(--primary-color);
    font-weight: 600;
}

.lang-option.active::after {
    width: 100%;
}

.lang-divider {
    color: var(--border-color);
    font-weight: 300;
}

/* Remove the old slider - no longer needed */
.lang-slider {
    display: none;
}

/* Make sure nav-right items are aligned */
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Settings Button */
.settings-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: #888;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.settings-btn svg {
    width: 18px;
    height: 18px;
}

/* Settings Section */
.settings-section {
    margin-bottom: 20px;
}

.settings-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Generic Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal .modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal .modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    line-height: 1;
    padding: 0;
}

.modal .modal-close:hover {
    color: var(--text-color);
}

.modal .modal-body {
    padding: 20px;
}

.modal .modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Sidebar Navigation Header Fix */
.nav-header {
    flex: 1;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.nav-header .label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 4px;
}

/* ========================================
   FILTER TOAST NOTIFICATION
   ======================================== */
.filter-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1100;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 14px;
}

.filter-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.filter-toast .toast-icon {
    font-size: 18px;
}

.filter-toast .toast-text {
    font-weight: 500;
}

/* ========================================
   BATCH GENERATION - INLINE PANEL + TOAST
   ======================================== */

/* Recent Section Header with Actions */
.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.recent-header h2 {
    margin: 0;
}

.recent-actions-inline {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Inline Button - Minimal Outline Style */
.batch-gen-btn-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.batch-gen-btn-inline:hover {
    background: var(--primary-color);
    color: white;
}

.batch-gen-btn-inline svg {
    width: 14px;
    height: 14px;
}

/* Dropdown Panel */
.batch-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
    min-width: 280px;
}

.batch-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.batch-panel-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.batch-label {
    font-size: 13px;
    color: var(--text-muted);
}

.batch-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    cursor: pointer;
    min-width: 60px;
}

.batch-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.batch-go-btn {
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.batch-go-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* Toast Notification */
.batch-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    min-width: 300px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.batch-toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.batch-toast.complete {
    border-left: 4px solid #10b981;
}

.batch-toast-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.batch-toast-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--primary-color);
}

.batch-toast-icon .spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.batch-toast-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

.batch-toast-progress {
    font-size: 12px;
    color: var(--text-muted);
}

.batch-toast-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.batch-toast-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}