/* Visual Search Application Styles - eSmart Design System */
@import url('./tokens.css');

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--text-high);
    background: var(--bg-app);
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Body acts as the old .view wrapper — flex column, full viewport */
body.page-adaptive {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

/* === Focus States === */
:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-app), 0 0 0 4px var(--primary);
}

/* Ensure touch targets for interactive elements */
a, button, [role="button"], input, select, textarea {
    touch-action: manipulation;
}

/* === Views === */
.view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.view.hidden {
    display: none;
}

/* === Appbar (shared styles in shared/css/components/appbar.css) === */

/* Adjust main-layout for fixed headers (global nav + secondary appbar) */
.main-layout {
    margin-top: calc(56px + var(--appbar-height)); /* Global nav + secondary appbar */
}

/* === Home Content === */
.home-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2xl);
    padding-top: calc(56px + var(--space-2xl)); /* Account for global navbar */
}

.home-content > .site-footer {
    margin-left: calc(-1 * var(--space-2xl));
    margin-right: calc(-1 * var(--space-2xl));
    margin-bottom: calc(-1 * var(--space-2xl));
}

.home-header {
    margin-bottom: var(--space-xl);
}

.home-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-high);
}

/* === Main Layout (Project View) === */
.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 48px;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .class-list {
    display: none;
}

/* Sidebar collapse toggle button */
.sidebar-collapse-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    color: var(--text-subtle);
    cursor: pointer;
    display: none; /* Hidden by default, shown only on tablet */
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.sidebar-collapse-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-high);
    border-color: var(--primary);
}

.sidebar.collapsed .sidebar-collapse-toggle {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

.sidebar.collapsed .sidebar-collapse-toggle svg {
    transform: rotate(180deg);
}

.sidebar-header {
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-divider);
}

.sidebar-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--text-high);
}

.class-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

/* === Datasets Sidebar Section === */
.sidebar-section {
    padding: var(--space-md);
    padding-bottom: 0;
}

.sidebar-header-collapsible {
    cursor: pointer;
    user-select: none;
    border-bottom: none;
    padding: 0;
    margin-bottom: var(--space-sm);
}

.sidebar-header-collapsible:hover {
    color: var(--text-high);
}

.section-collapse-btn {
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-subtle);
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-collapse-btn:hover {
    color: var(--text-high);
}

.sidebar-section.collapsed .section-collapse-btn {
    transform: rotate(-90deg);
}

.sidebar-section.collapsed .dataset-list {
    display: none;
}

.sidebar-section.collapsed .sidebar-divider {
    margin-top: var(--space-sm);
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border-divider);
    margin: var(--space-md) 0 0 0;
}

.dataset-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* Hidden gallery items (dataset filter) */
.gallery-item.dataset-hidden {
    display: none !important;
}

.dataset-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
}

.dataset-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.dataset-label {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.dataset-name {
    color: var(--text-high);
}

.dataset-count {
    color: var(--text-low);
    font-size: var(--font-size-xs);
}

/* === Attach Dataset Modal === */
.attach-dataset-list {
    max-height: 300px;
    overflow-y: auto;
}

.attach-dataset-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.attach-dataset-item:hover {
    background: var(--bg-hover);
}

.attach-dataset-item label {
    flex: 1;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}

.attach-dataset-item .dataset-meta {
    color: var(--text-low);
    font-size: var(--font-size-sm);
}

.attach-progress {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-divider);
}

.attach-progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

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

.attach-progress-text {
    font-size: var(--font-size-sm);
    color: var(--text-medium);
    margin-top: var(--space-xs);
    text-align: center;
}

.attach-progress-note {
    font-size: 0.7rem;
    color: var(--text-low);
    margin-top: var(--space-xs);
    text-align: center;
    opacity: 0.8;
}

/* === Upload Dataset Picker Modal === */
.upload-dataset-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.upload-dataset-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.upload-dataset-item:hover {
    background: var(--bg-hover);
}

.upload-dataset-item input[type="radio"] {
    accent-color: var(--primary);
}

.upload-dataset-name {
    flex: 1;
    font-weight: var(--font-weight-medium);
}

.upload-dataset-count {
    color: var(--text-low);
    font-size: var(--font-size-sm);
}

/* === Class Card === */
.class-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-divider);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.class-card:hover {
    border-color: var(--glass-border);
}

.class-card-header {
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.class-card-header:hover {
    background: var(--bg-hover);
}

.class-card-name {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.class-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}

.class-card-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.class-edit-btn {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
    opacity: 0;
}

.class-card-header:hover .class-edit-btn,
.class-edit-btn:focus-visible {
    opacity: 1;
}

@media (hover: none) {
    .class-edit-btn {
        opacity: 1;
    }
}

.class-edit-btn:hover {
    color: var(--text-high);
    background: var(--bg-hover);
}

.class-delete-btn {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), opacity var(--transition-fast);
    opacity: 0;
}

.class-card-header:hover .class-delete-btn,
.class-delete-btn:focus-visible {
    opacity: 1;
}

@media (hover: none) {
    .class-delete-btn {
        opacity: 1;
    }
}

.class-delete-btn:hover {
    color: var(--error, #ef4444);
}

.dataset-detach-btn {
    display: none;
    padding: 2px;
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.dataset-item:hover .dataset-detach-btn {
    display: flex;
}

.dataset-detach-btn:hover {
    color: var(--error, #ef4444);
}

.class-card-count {
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    background: var(--bg-panel);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.class-card-count .pending-delta {
    color: var(--warning);
    font-weight: var(--font-weight-semibold);
}

.class-card.has-pending {
    border-color: var(--warning);
    border-style: dashed;
}

.class-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: var(--space-sm);
    padding-top: 0;
}

.class-example-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.class-example-thumb:hover {
    border-color: var(--border-selected);
    transform: scale(1.05);
}

.class-example-thumb.pending-add {
    border-style: dashed;
    border-color: var(--warning);
}

/* === Gallery Container === */
.gallery-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-pane);
}

/* === Toolbar === */
.toolbar {
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-sm);
    background: var(--bg-surface-1);
    border-bottom: 1px solid var(--border-card);
    min-height: var(--appbar-height);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.toolbar-left {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.toolbar-right {
    flex: 0 0 auto;
}

/* Toolbar button sizing consistency */
.toolbar .btn {
    flex-shrink: 0;
}

.toolbar .btn-sm {
    padding: 6px 16px;
    font-size: 13px;
    line-height: 1.5;
    min-height: 34px;
}


/* Bootstrap form-select styling for toolbar */
.toolbar .form-select {
    background-color: var(--bg-input);
    border-color: var(--border-input);
    color: var(--text-high);
    font-size: 13px;
    padding: 6px 32px 6px 12px;
    min-width: 140px;
}

.toolbar .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

.toolbar .form-select-sm {
    padding-top: 4px;
    padding-bottom: 4px;
}

/* Toolbar upload drop zone */
.toolbar-upload-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: var(--bg-input);
    border: 2px dashed var(--border-input);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 140px;
    height: 40px;
}

.toolbar-upload-drop:hover {
    border-color: var(--primary);
    background: rgba(57, 151, 151, 0.1);
}

.toolbar-upload-drop.drag-over {
    border-color: var(--primary);
    border-style: solid;
    background: rgba(57, 151, 151, 0.15);
}

.upload-drop-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-subtle);
    font-size: 13px;
}

.upload-drop-prompt svg {
    flex-shrink: 0;
    color: var(--text-subtle);
}

.toolbar-upload-drop:hover .upload-drop-prompt,
.toolbar-upload-drop:hover .upload-drop-prompt svg {
    color: var(--primary-light);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-divider);
    margin: 0 var(--space-sm);
}

.image-count {
    font-size: var(--font-size-sm);
    color: var(--text-subtle);
}

/* Info icon for image count (mobile only) */
.image-count-icon {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-subtle);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.image-count-icon:hover {
    background: var(--bg-hover);
    color: var(--text-high);
    border-color: var(--primary);
}

/* Help button (replay tour) */
.tour-help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-subtle);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.tour-help-btn:hover {
    color: var(--text-high);
    border-color: var(--primary);
}

.image-quota {
    font-size: var(--font-size-sm);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    margin-left: 8px;
}

.image-quota.quota-ok {
    color: var(--color-success);
    background: rgba(34, 197, 94, 0.1);
}

.image-quota.quota-warning {
    color: var(--color-warning);
    background: rgba(234, 179, 8, 0.15);
}

.image-quota.quota-critical {
    color: var(--color-error);
    background: rgba(239, 68, 68, 0.15);
}

.image-quota.quota-full {
    color: var(--color-error);
    background: rgba(239, 68, 68, 0.2);
    font-weight: 600;
}

/* === Gallery === */
.gallery {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-lg);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumbnail-size), 1fr));
    gap: var(--space-md);
    align-content: start;
}

/* === Load More === */
.load-more-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: var(--space-xl) 0;
}

.load-more-btn {
    min-width: 200px;
}

/* === Gallery Item === */
.gallery-item {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-card);
    overflow: clip;
    width: 100%;
    /* Square ratio via ::before spacer (cross-browser, avoids padding-bottom grid bug in Firefox) */
    transition: transform var(--transition-fast),
                border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.gallery-item:hover {
    transform: scale(1.01);
    border-color: rgba(57, 151, 151, 0.25);
    box-shadow: var(--shadow-lg);
}

.gallery-item.assigned {
    border-color: var(--teal-600);
    box-shadow: inset 0 0 0 1px var(--teal-600);
}

.gallery-item.pending {
    border-style: dashed;
    border-color: var(--warning);
}

.gallery-item.pending.assigned {
    border-color: var(--warning);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.gallery-item::before {
    content: '';
    display: block;
    aspect-ratio: 1;
}

.gallery-item-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Score badge (floating top-right) */
.gallery-item-score {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    z-index: 4;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    font-variant-numeric: tabular-nums;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-high  { background: var(--score-high-bg);  color: var(--score-high); }
.score-medium { background: var(--score-medium-bg); color: var(--score-medium); }
.score-low   { background: var(--score-low-bg);   color: var(--score-low); }

/* Action tray (always visible at bottom) */
.gallery-item-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    padding: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    z-index: 5;
}

.gallery-item-actions-name {
    margin-left: auto;
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

/* Quick assign buttons - styles in shared/css/components/buttons.css */

/* Predicted class badge (top prediction for this image) */
.predicted-class-badge {
    position: absolute;
    bottom: var(--space-sm);
    right: var(--space-sm);
    padding: 2px var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    border: none;
    border-radius: var(--radius-full);
    background-color: var(--badge-color);
    color: #fff;
    z-index: 10;
    cursor: default;
    box-shadow: var(--shadow-sm);
    max-width: calc(100% - var(--space-lg));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.predicted-class-badge::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.predicted-class-badge:hover::after {
    opacity: 1;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-primary {
    background: var(--primary-dark);
    color: var(--text-high);
    border-color: var(--primary-dark);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-input);
    color: var(--text-medium);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-high);
}

/* Button utilities (ghost, danger, sizes, icon-only) - styles in shared/css/components/buttons.css */

/* === Form Controls === */
.control-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs);
    background: var(--bg-surface-0);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    min-width: 0;
    flex: 0 1 auto;
}

.control-label {
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
    line-height: 1;
}

/* Sort dropdown max width */
#rank-class-select {
    max-width: 160px;
}

/* Confidence filter */
#confidence-filter-group {
    align-items: center;
}

/* === Range Slider (Dual-thumb) === */
.range-slider-container {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
    flex: 1 1 auto;
}

.range-slider-track {
    position: relative;
    width: 120px;
    min-width: 60px;
    flex-shrink: 1;
    height: 4px;
    background: var(--bg-panel);
    border-radius: var(--radius-full);
}

.range-slider-fill {
    position: absolute;
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    pointer-events: none;
}

.range-slider-track input[type="range"] {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0;
}

.range-slider-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: var(--radius-full);
    cursor: pointer;
    pointer-events: auto;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    z-index: 2;
}

.range-slider-track input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.range-slider-track input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    pointer-events: auto;
}

.range-slider-track input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

/* Ensure max slider thumb is on top when values are close */
.range-slider-track input#confidence-max {
    z-index: 1;
}

#confidence-range-label {
    font-size: var(--font-size-xs);
    color: var(--text-medium);
    white-space: nowrap;
    min-width: 70px;
    display: none; /* Hidden, replaced by number inputs */
}

/* Confidence number inputs */
.range-slider-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    color: var(--text-medium);
}

.range-slider-inputs input[type="number"] {
    width: 48px;
    padding: 2px 4px;
    text-align: center;
    font-size: var(--font-size-xs);
}

.range-slider-inputs input[type="number"]::-webkit-inner-spin-button,
.range-slider-inputs input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.range-slider-inputs input[type="number"] {
    -moz-appearance: textfield;
}

/* Name filter input */
#name-filter-input {
    width: 90px;
    font-size: var(--font-size-xs);
}

/* === Drop Zone === */
.drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(57, 151, 151, 0.1);
    border: 3px dashed var(--primary);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.drop-zone.active {
    display: flex;
}

.drop-zone-content {
    text-align: center;
    color: var(--text-high);
}

.drop-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-lg);
    color: var(--primary);
}

.drop-text {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-medium);
}

/* === Upload Progress === */
.upload-progress {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    padding: var(--space-md) var(--space-xl);
    min-width: 300px;
    box-shadow: var(--shadow-xl);
    display: none;
    z-index: 1000;
}

.upload-progress.active {
    display: block;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.progress-text {
    font-size: var(--font-size-sm);
    color: var(--text-medium);
}

.progress-percent {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--primary-light);
}

.progress-track {
    height: 4px;
    background: var(--bg-panel);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary-light));
    width: 0%;
    transition: width var(--transition-normal);
}

.progress-detail {
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    margin-top: var(--space-sm);
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* === Utility Classes === */
.text-subtle { color: var(--text-subtle); }
.text-medium { color: var(--text-medium); }
.text-high { color: var(--text-high); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none !important; }

/* === Project Type Selection === */
.modal-wide {
    min-width: min(600px, 95vw);
}

.project-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.project-type-card {
    background: var(--bg-card);
    border: 2px solid var(--border-divider);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    cursor: pointer;
    transition: border-color var(--transition-fast),
                transform var(--transition-fast),
                box-shadow var(--transition-fast);
}

.project-type-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.project-type-card.selected {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.project-type-card.locked {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.project-type-card.locked:hover {
    transform: none;
    border-color: var(--border-divider);
    box-shadow: none;
}

.premium-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    color: #fff;
    text-align: center;
    padding: var(--space-md);
}

.project-type-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-subtle);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
}

.project-type-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary-light);
}

.project-type-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-sm);
}

.project-type-desc {
    font-size: var(--font-size-sm);
    color: var(--text-subtle);
    margin-bottom: var(--space-md);
}

.project-type-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.project-type-features li {
    font-size: var(--font-size-xs);
    color: var(--text-medium);
    padding: var(--space-xs) 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.project-type-features li::before {
    content: "✓";
    color: var(--success);
    font-weight: var(--font-weight-semibold);
}

/* === Project Type Badge === */
.project-type-badge {
    font-size: var(--font-size-xs);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text-subtle);
    margin-left: var(--space-sm);
}

.project-type-badge.binary {
    background: var(--primary-subtle);
    color: var(--primary-light);
}

.project-type-badge.fast {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.project-type-badge.accurate {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

/* === Binary Mode Panels === */
.binary-panels {
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    padding: var(--space-md) var(--space-lg);
    flex-shrink: 0;
}

.binary-panels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.binary-panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-divider);
    padding: var(--space-md);
    min-height: 100px;
}

.binary-panel.positive-panel {
    border-left: 3px solid var(--score-high);
    background: var(--bg-card);
}

.binary-panel.negative-panel {
    border-left: 3px solid var(--score-low);
    background: var(--bg-card);
}

.binary-panel-header {
    margin-bottom: var(--space-sm);
}

.binary-panel-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.binary-panel-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
}

.binary-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}

.binary-dot.positive { background: var(--success); }
.binary-dot.negative { background: var(--error); }

.binary-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 50px;
    max-height: 120px;
    overflow-y: auto;
    align-items: flex-start;
    align-content: flex-start;
}

.binary-empty-text {
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    font-style: italic;
}

.binary-example-thumb {
    position: relative;
    width: 50px;
    height: 50px;
}

.binary-example-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

.binary-example-thumb:hover img {
    border-color: var(--border-selected);
}

.binary-example-thumb.pending img {
    border-style: dashed;
    border-color: var(--warning);
}

.binary-example-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-full);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    color: var(--text-subtle);
}

.binary-example-thumb:hover .binary-example-remove {
    display: flex;
}

.binary-example-remove:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.binary-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Binary mode gallery buttons */
.binary-assign-buttons {
    display: flex;
    gap: 4px;
}

.binary-assign-btn {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: var(--font-weight-semibold);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0.9;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.binary-assign-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

.binary-assign-btn.positive {
    background: var(--success);
    color: white;
}

.binary-assign-btn.negative {
    background: var(--error);
    color: white;
}

.binary-assign-btn.active {
    box-shadow: 0 0 0 2px white;
}

/* === Instruction Modal === */
.instruction-content {
    line-height: 1.6;
}

.instruction-content p {
    margin-bottom: var(--space-md);
}

.instruction-steps {
    margin: var(--space-lg) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.instruction-step {
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--primary-subtle);
    color: var(--primary-light);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.instruction-step div p {
    margin: var(--space-xs) 0 0 0;
    font-size: var(--font-size-sm);
    color: var(--text-subtle);
}

.instruction-tip {
    background: var(--bg-panel);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary);
    margin-top: var(--space-lg);
}

.key-hint {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-sm);
    padding: 0 6px;
    font-family: monospace;
    font-size: var(--font-size-sm);
}

/* === Assignment flash animation === */
@keyframes assignFlash {
    0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
    100% { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
}

.quick-assign-btn.just-assigned {
    animation: assignFlash 0.3s ease-out;
}

/* === Gallery shimmer skeleton === */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.gallery-item-image:not([src]),
.gallery-item-image[src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="] {
    background: linear-gradient(90deg, var(--bg-surface-2) 0%, var(--bg-surface-3) 50%, var(--bg-surface-2) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
    background: var(--border-section);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-disabled);
}

/* === Form Styles === */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-sm);
    color: var(--text-high);
}

.form-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-high);
    font-size: var(--font-size-md);
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.form-input::placeholder {
    color: var(--text-disabled);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    margin-top: var(--space-xs);
}

.form-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--error);
    font-size: var(--font-size-sm);
    margin-top: var(--space-md);
}


/* === Demo Models Section === */
.demo-section {
    margin-top: 48px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.home-subtitle {
    font-size: 1.25rem;
    color: var(--text-subtle);
    margin: 32px 0 16px;
    font-weight: var(--font-weight-medium);
}

.demo-badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
}

/* === Sidebar Toggle (mobile) === */
.sidebar-toggle {
    display: none;
    min-width: 44px;
    min-height: 44px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === Desktop (1024px+) === */
@media (min-width: 1025px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* === Tablet (768px - 1024px) === */
@media (max-width: 1024px) {
    /* Use collapse approach on tablets */
    .sidebar-collapse-toggle {
        display: flex;
    }

    .sidebar-toggle {
        display: none;
    }

    .binary-panels-grid {
        gap: var(--space-md);
    }

    .toolbar {
        gap: var(--space-sm);
    }

    .range-slider-container {
        min-width: 160px;
    }
}

/* === Small screens (below 768px) - use overlay approach === */
@media (max-width: 767px) {
    .sidebar-collapse-toggle {
        display: none;
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        width: var(--sidebar-width);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .main-layout {
        margin-left: 0;
    }
}

/* === Mobile (640px - 768px) === */
@media (max-width: 768px) {
    .home-content {
        padding: var(--space-lg);
        padding-top: calc(56px + var(--space-lg));
    }

    .home-content > .site-footer {
        margin-left: calc(-1 * var(--space-lg));
        margin-right: calc(-1 * var(--space-lg));
        margin-bottom: calc(-1 * var(--space-lg));
    }

    .binary-panels-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .binary-panel {
        min-height: 80px;
    }

    .toolbar {
        padding: var(--space-sm) var(--space-md);
    }

    .toolbar-divider {
        display: none;
    }

    .gallery {
        padding: var(--space-md);
        gap: var(--space-sm);
    }

    /* Touch targets - styles in shared/css/components/buttons.css */

    .binary-assign-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .project-type-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: var(--space-lg);
        margin: var(--space-md);
    }

    .modal-wide {
        min-width: calc(100vw - 2 * var(--space-md));
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        top: auto;
        bottom: var(--space-xl);
    }

    .toast {
        width: 100%;
    }
}

/* === Small Mobile (480px and below) === */
@media (max-width: 480px) {
    :root {
        --sidebar-width: 100vw;
    }

    .home-content {
        padding: var(--space-md);
        padding-top: calc(56px + var(--space-md));
    }

    .home-content > .site-footer {
        margin-left: calc(-1 * var(--space-md));
        margin-right: calc(-1 * var(--space-md));
        margin-bottom: calc(-1 * var(--space-md));
    }

    .home-title {
        font-size: var(--font-size-xl);
    }

    #test-in-zoo-btn {
        display: none !important;
    }

    /* Mobile toolbar: compact single row */
    .toolbar {
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px var(--space-sm);
        min-height: 40px;
    }

    .toolbar-left,
    .toolbar-right {
        flex-wrap: nowrap;
        gap: 6px;
    }

    .toolbar-upload-drop {
        min-width: 160px;
        padding: 6px 12px;
        height: 36px;
    }

    .upload-drop-prompt span {
        font-size: 12px;
    }

    .control-group {
        flex: 0 0 auto;
        min-width: 0;
    }

    .control-label {
        display: none;
    }

    /* Compact sort dropdown */
    #rank-class-select {
        min-width: 90px;
        max-width: 100px;
        padding: 4px 24px 4px 8px;
        font-size: 12px;
    }

    .range-slider-container {
        min-width: 100px;
    }

    .range-slider-track {
        width: 80px;
    }

    #confidence-range-label {
        min-width: 55px;
        font-size: 10px;
    }

    /* Hide image count text on mobile, show info icon instead */
    .image-count {
        display: none;
    }

    .image-count-icon {
        display: flex;
    }

    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-item-actions {
        padding: var(--space-xs);
    }

    .binary-example-thumb {
        width: 40px;
        height: 40px;
    }

    .instruction-step {
        flex-direction: column;
        gap: var(--space-sm);
    }

    /* Class examples mobile adjustments */
    .class-examples {
        gap: 3px;
    }

    .class-example-thumb {
        width: 32px;
        height: 32px;
    }

    /* Sidebar toggle visible on phone */
    .sidebar-toggle {
        display: flex;
        min-width: 44px;
        min-height: 44px;
    }

    /* Class card adjustments */
    .class-card-header {
        padding: var(--space-xs) var(--space-sm);
    }

    .class-card-name {
        font-size: var(--font-size-xs);
    }
}

/* === Portrait Phone Support === */
@media (max-width: 767px) and (orientation: portrait) {
    .main-layout {
        flex-direction: column;
    }

    /* In portrait, sidebar becomes a compact horizontal strip matching toolbar height */
    .sidebar {
        position: relative !important;
        width: 100% !important;
        height: 40px;
        max-height: 40px;
        min-height: 40px;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        transform: none !important;
        flex-direction: row;
        align-items: center;
        padding: 0 var(--space-sm);
    }

    .sidebar-header {
        padding: 0;
        padding-right: 8px;
        border-bottom: none;
        flex-shrink: 0;
        gap: 6px;
    }

    .sidebar-title {
        font-size: var(--font-size-sm);
    }

    #add-class-btn {
        padding: 4px 8px;
        font-size: 11px;
        min-height: 26px;
    }

    .class-list {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px;
        padding: 0;
        flex: 1;
        align-items: center;
    }

    .class-card {
        flex-shrink: 0;
        width: auto;
        min-width: 70px;
        max-width: 100px;
        min-height: auto;
        margin-bottom: 0;
        background: var(--bg-input);
        border-radius: var(--radius-sm);
    }

    .class-card-header {
        padding: 4px 8px;
    }

    .class-card-name {
        font-size: 11px;
        gap: 4px;
    }

    .class-dot {
        width: 8px;
        height: 8px;
    }

    .class-card-count {
        font-size: 10px;
        padding: 1px 4px;
    }

    .class-examples {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .sidebar-toggle,
    .sidebar-collapse-toggle {
        display: none !important;
    }

    /* Toolbar also 40px to match */
    .toolbar {
        height: 40px;
        min-height: 40px;
    }

    /* Ensure modals appear above sidebar in portrait */
    .modal-overlay {
        z-index: 1100 !important;
    }
}


/* ==========================================
   Image Lightbox
   ========================================== */

#image-lightbox-modal .modal-dialog {
    max-width: 90vw;
    width: 90vw;
    margin: 1rem auto;
}

#image-lightbox-modal .modal-content {
    background: var(--bg-app);
    border: 1px solid var(--border-divider);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 60px rgba(57, 151, 151, 0.15);
    overflow: hidden;
}

#image-lightbox-modal .modal-header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-divider);
    padding: var(--space-md) var(--space-lg);
}

#image-lightbox-modal .modal-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    color: var(--text-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#image-lightbox-modal .modal-body {
    height: 80vh;
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    background: linear-gradient(180deg, var(--bg-pane) 0%, var(--bg-app) 100%);
}

.lightbox-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    border-radius: var(--radius-lg);
    background: var(--bg-app);
    overflow: hidden;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    transition: transform var(--transition-normal);
}

/* Score badge - glassmorphism style */
.lightbox-score {
    position: absolute;
    top: var(--space-lg);
    left: var(--space-lg);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-lg);
    border: none;
    box-shadow: var(--shadow-md);
    z-index: 5;
}

.lightbox-score.score-high {
    background: var(--score-high);
    color: white;
}

.lightbox-score.score-medium {
    background: var(--warning);
    color: var(--text-inverse);
}

.lightbox-score.score-low {
    background: var(--score-low);
    color: white;
}

/* Predicted class badge */
.lightbox-predicted {
    position: absolute;
    bottom: var(--space-lg);
    right: var(--space-lg);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-md);
    background: var(--badge-color, var(--primary));
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
    z-index: 5;
}

/* Class assignment buttons */
.lightbox-buttons {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    padding-top: var(--space-lg);
    flex-wrap: wrap;
}

.lightbox-class-btn {
    position: relative;
    min-width: 120px;
    padding: var(--space-sm) var(--space-xl);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-md);
    letter-spacing: 0.3px;
    border-radius: var(--radius-md);
    border: 1.5px solid rgba(255,255,255,0.12);
    cursor: pointer;
    transition: opacity var(--transition-fast),
                transform var(--transition-fast),
                box-shadow var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.lightbox-class-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.25);
}

.lightbox-class-btn.active {
    border-color: var(--text-high);
    box-shadow: 0 0 0 1px var(--text-high),
                0 4px 12px rgba(0,0,0,0.4);
}

/* Keyboard shortcut hints on lightbox buttons */
.lightbox-class-btn::after {
    content: attr(data-key);
    position: absolute;
    top: -8px;
    right: -6px;
    font-size: 10px;
    background: var(--bg-app);
    color: var(--text-subtle);
    border-radius: var(--radius-md);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-divider);
}

.lightbox-class-btn.just-assigned {
    animation: assignFlash 0.3s ease-out;
}

/* Navigation buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-high);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.lightbox-nav:hover {
    background: var(--bg-selected);
    border-color: var(--border-selected);
    color: white;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(-50%) scale(1.1);
}

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

.lightbox-nav-prev {
    left: var(--space-lg);
}

.lightbox-nav-next {
    right: var(--space-lg);
}

/* Binary mode buttons */
.lightbox-buttons .btn-success {
    background: var(--success);
    border: none;
    box-shadow: var(--shadow-sm);
}

.lightbox-buttons .btn-success:hover {
    background: #16a34a;
    box-shadow: var(--shadow-md);
}

.lightbox-buttons .btn-danger {
    background: var(--error);
    border: none;
    box-shadow: var(--shadow-sm);
}

.lightbox-buttons .btn-danger:hover {
    background: #dc2626;
    box-shadow: var(--shadow-md);
}

/* Lightbox mobile */
@media (max-width: 767px) {
    #image-lightbox-modal .modal-dialog {
        max-width: 100vw;
        width: 100vw;
        margin: 0;
    }

    #image-lightbox-modal .modal-content {
        border-radius: 0;
        height: 100vh;
        height: 100dvh;
    }

    #image-lightbox-modal .modal-body {
        height: auto;
        flex: 1;
        padding: var(--space-sm);
    }

    .lightbox-buttons {
        gap: var(--space-sm);
        padding-top: var(--space-sm);
    }

    .lightbox-class-btn {
        min-width: 0;
        flex: 1 1 auto;
        padding: var(--space-xs) var(--space-md);
        font-size: var(--font-size-sm);
    }

    /* Hide keyboard shortcut hints on touch */
    .lightbox-class-btn::after {
        display: none;
    }

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

    .lightbox-predicted {
        font-size: var(--font-size-sm);
        padding: var(--space-xs) var(--space-md);
    }
}

/* Make gallery items clickable */
.gallery-item {
    cursor: pointer;
}

/* === Upload Queue - styles in shared/css/components/upload.css === */

/* Status icons - augment shared/css/components/loading.css */
.status-icon {
    font-size: 18px;
    font-weight: bold;
}

.status-icon.pending {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-medium);
    opacity: 0.5;
}

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

/* Alias for .esm-spinner - prefer .esm-spinner in new code */
.spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: esm-spin 0.8s linear infinite;
}

/* === Driver.js Tour — Dark Theme Overrides === */
.driver-popover.esm-tour-popover {
    background: var(--bg-surface-3) !important;
    border: 1px solid var(--border-section) !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    color: var(--text-high);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    isolation: isolate;
    transform: translateZ(0);
}

.driver-popover.esm-tour-popover * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.driver-popover.esm-tour-popover .driver-popover-title {
    color: var(--text-high);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.driver-popover.esm-tour-popover .driver-popover-description {
    color: var(--text-medium);
    font-size: var(--font-size-md);
    line-height: 1.5;
}

.driver-popover.esm-tour-popover .driver-popover-progress-text {
    color: var(--text-subtle);
    font-size: var(--font-size-xs);
}

.driver-popover.esm-tour-popover .driver-popover-prev-btn {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-section);
    color: var(--text-medium);
    border-radius: var(--radius-md);
}

.driver-popover.esm-tour-popover .driver-popover-prev-btn:hover {
    background: var(--bg-hover);
    color: var(--text-high);
}

.driver-popover.esm-tour-popover .driver-popover-next-btn,
.driver-popover.esm-tour-popover .driver-popover-done-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
}

.driver-popover.esm-tour-popover .driver-popover-next-btn:hover,
.driver-popover.esm-tour-popover .driver-popover-done-btn:hover {
    background: var(--primary-hover);
}

.driver-popover.esm-tour-popover .driver-popover-close-btn {
    color: var(--text-subtle);
}

.driver-popover.esm-tour-popover .driver-popover-close-btn,
.driver-popover.esm-tour-popover .driver-popover-close-btn:focus,
.driver-popover.esm-tour-popover .driver-popover-close-btn:focus-visible {
    box-shadow: none !important;
    outline: none !important;
}

.driver-popover.esm-tour-popover .driver-popover-close-btn:hover {
    color: var(--text-high);
}

/* Arrow: use border-section color so it's visible against the dark overlay */
.driver-popover.esm-tour-popover .driver-popover-arrow {
    border: 5px solid var(--border-section) !important;
}

.driver-popover.esm-tour-popover .driver-popover-arrow-side-left {
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-top-color: transparent !important;
}

.driver-popover.esm-tour-popover .driver-popover-arrow-side-right {
    border-left-color: transparent !important;
    border-bottom-color: transparent !important;
    border-top-color: transparent !important;
}

.driver-popover.esm-tour-popover .driver-popover-arrow-side-top {
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-left-color: transparent !important;
}

.driver-popover.esm-tour-popover .driver-popover-arrow-side-bottom {
    border-left-color: transparent !important;
    border-top-color: transparent !important;
    border-right-color: transparent !important;
}

/* === Missing Embeddings Banner === */
.missing-embeddings-banner {
    background: rgba(245, 158, 11, 0.1);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    padding: var(--space-sm) var(--space-lg);
    flex-shrink: 0;
}

.meb-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: var(--warning);
    font-size: var(--font-size-sm);
}

.meb-content span {
    flex: 1;
    color: var(--text-medium);
}

.meb-content strong {
    color: var(--warning);
}

.meb-extract-btn {
    flex-shrink: 0;
    padding: 3px 10px;
    font-size: var(--font-size-xs);
    min-height: auto;
}

.meb-progress {
    margin-top: var(--space-sm);
}

.meb-progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}

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

.meb-progress-text {
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    margin-top: var(--space-xs);
    display: block;
}
