/* ==========================================================================
   Evarni Image Engine - Design System & Stylesheet
   ========================================================================== */

:root {
    --bg-base: #090d16;
    --bg-surface: #0f172a;
    --bg-surface-elevated: #1e293b;
    --bg-surface-hover: #27354f;
    --bg-input: #0b1120;
    
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-medium: rgba(255, 255, 255, 0.12);
    --border-focus: #38bdf8;
    
    --primary: #0284c7;
    --primary-light: #38bdf8;
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    --accent-purple: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 25px -5px rgba(56, 189, 248, 0.3);
    
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.app-wrapper {
    max-width: 1560px;
    margin: 0 auto;
    padding: 16px 24px 60px;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */

.navbar {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 12px;
    z-index: 100;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

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

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.logo-sparkle {
    font-size: 1.35rem;
    color: white;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.version-chip {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 2px 8px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 9999px;
    letter-spacing: 0.05em;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav-center {
    display: flex;
    align-items: center;
}

.preset-badge-group {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 4px 10px;
    gap: 8px;
}

.preset-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preset-select {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    padding-right: 6px;
}

.preset-select option {
    background: var(--bg-surface);
    color: var(--text-main);
}

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

.nav-chip-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-chip-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--primary-light);
}

.system-status-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    color: #34d399;
}

.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   Upload Dropzone
   ========================================================================== */

.upload-container {
    margin-bottom: 24px;
}

.dropzone-card {
    position: relative;
    border: 2px dashed var(--border-medium);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.6) 100%);
    border-radius: var(--radius-xl);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropzone-card:hover, .dropzone-card.drag-over {
    border-color: var(--primary-light);
    background: linear-gradient(180deg, rgba(2, 132, 199, 0.08) 0%, rgba(15, 23, 42, 0.8) 100%);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.dropzone-body {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
    margin-bottom: 4px;
    transition: transform 0.3s ease;
}

.dropzone-card:hover .upload-icon-wrap {
    transform: translateY(-4px) scale(1.08);
}

.upload-svg {
    width: 28px;
    height: 28px;
}

.dropzone-text h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.dropzone-text p {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 600px;
}

.dropzone-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

.format-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
}

.pill-max {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--primary-light);
}

.file-input-hidden {
    display: none;
}

/* ==========================================================================
   Queue Card & Telemetry
   ========================================================================== */

.queue-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 16px;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s ease;
}

.queue-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 12px;
}

.queue-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pulse-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: pulseGlow 1.5s infinite;
}

.queue-title-wrap h3 {
    font-size: 1rem;
    font-weight: 700;
}

.queue-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.worker-selector-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.worker-select {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.progress-track {
    height: 8px;
    background: var(--bg-input);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 14px;
    border: 1px solid var(--border-subtle);
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.queue-telemetry {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    background: var(--bg-input);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.telemetry-item {
    display: flex;
    flex-direction: column;
}

.telemetry-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.telemetry-val {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
}

/* ==========================================================================
   Toolbar Section
   ========================================================================== */

.toolbar-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px 18px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 7px 12px;
    gap: 8px;
    transition: border-color 0.2s ease;
}

.search-input-wrap:focus-within {
    border-color: var(--border-focus);
}

.search-svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.875rem;
    outline: none;
    min-width: 240px;
}

.search-clear-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
}

.filter-group {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-btn.active {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.filter-count {
    font-size: 0.6875rem;
    padding: 1px 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    user-select: none;
}

.btn-gradient {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.btn-gradient:hover {
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.45);
    transform: translateY(-1px);
}

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

.btn-primary:hover {
    background: #0369a1;
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-medium);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger-ghost {
    background: transparent;
    color: #f87171;
}

.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.15);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

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

.badge {
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.badge-primary {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

/* ==========================================================================
   Product Gallery Grid & Cards
   ========================================================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.product-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.product-card:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: var(--shadow-md);
}

.product-card.selected {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px var(--primary-light), var(--shadow-md);
}

.card-checkbox {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.card-preview-wrap {
    aspect-ratio: 1;
    position: relative;
    background: #ffffff;
    /* Transparent grid pattern */
    background-image: linear-gradient(45deg, #f1f5f9 25%, transparent 25%), 
                      linear-gradient(-45deg, #f1f5f9 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #f1f5f9 75%), 
                      linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-preview-wrap:hover .card-img {
    transform: scale(1.06);
}

.card-top-badges {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.status-chip {
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    backdrop-filter: blur(8px);
}

.status-chip.approved {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-chip.review {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-chip.rejected {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.score-chip {
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-main);
    border: 1px solid var(--border-medium);
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.card-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-sku-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.card-sku-name:hover {
    color: var(--primary-light);
}

.card-compression-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.size-flow {
    color: var(--text-muted);
    font-size: 0.6875rem;
}

.size-flow strong {
    color: var(--text-main);
}

.compression-pill-badge {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
}

.card-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timing-badge {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary-light);
}

.card-variants-pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.var-pill {
    font-size: 0.625rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-dim);
}

.card-action-bar {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

/* Empty State */
.empty-state-card {
    grid-column: 1 / -1;
    text-align: center;
    padding: 70px 20px;
    background: var(--bg-surface);
    border: 1px dashed var(--border-medium);
    border-radius: var(--radius-xl);
}

.empty-icon-glow {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-state-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
    max-width: 500px;
    margin: 0 auto;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Modals & Split Comparison Inspector
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-window {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 1280px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-window.modal-sm {
    max-width: 680px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-subtle);
}

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

.modal-header-left h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.timing-chip {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: rgba(56, 189, 248, 0.12);
    color: var(--primary-light);
    padding: 3px 8px;
    border-radius: 9999px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
}

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

.modal-layout {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 24px;
    padding: 24px;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .modal-layout {
        grid-template-columns: 1fr;
    }
}

/* Modal Viewport & Comparison Stage */
.modal-viewport {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.viewport-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.layer-tabs {
    display: flex;
    background: var(--bg-input);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    gap: 2px;
}

.layer-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.layer-tab.active {
    background: var(--primary);
    color: white;
}

.zoom-controls {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 2px 6px;
    gap: 6px;
}

.zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 2px 6px;
}

.zoom-level {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #ffffff;
    background-image: linear-gradient(45deg, #f1f5f9 25%, transparent 25%), 
                      linear-gradient(-45deg, #f1f5f9 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #f1f5f9 75%), 
                      linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.comparison-stage {
    position: relative;
    width: 100%;
    height: 100%;
}

.comp-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
}

#compOverlay {
    clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.split-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #38bdf8;
    cursor: ew-resize;
    z-index: 20;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

.split-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background: #0284c7;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.625rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    user-select: none;
}

.slider-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Floating Compression Widget (Reference Screenshot Match)
   ========================================================================== */

.floating-compress-widget {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideUp 0.3s ease;
}

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

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

.compress-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.compress-badge-live {
    font-size: 0.6875rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 2px 8px;
    border-radius: 9999px;
    font-family: var(--font-mono);
}

.compress-select-row {
    width: 100%;
}

.compress-variant-select {
    width: 100%;
    background: #090d16;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.compress-rows-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 6px 12px;
}

.compress-row.compressed-row {
    background: rgba(2, 132, 199, 0.15);
    border-color: rgba(56, 189, 248, 0.35);
}

.compress-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row-arrow {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.compress-size-info {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.compress-size-val {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-main);
}

.compress-size-val.highlight {
    color: #38bdf8;
}

.compress-file-name, .compress-format-tag {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.compress-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reduction-tag {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
}

.reduction-tag.zero {
    color: var(--text-dim);
}

.reduction-tag.savings {
    color: #34d399;
}

.btn-download-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-download-icon.primary {
    background: #0284c7;
    color: white;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.5);
}

.btn-download-icon:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* Modal Sidebar */
.modal-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
}

.panel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-card-header h3 {
    font-size: 0.9375rem;
    font-weight: 700;
}

.panel-badge {
    font-size: 0.6875rem;
    color: #34d399;
    font-weight: 700;
}

.scorecard-body {
    display: flex;
    align-items: center;
    gap: 16px;
}

.score-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--success-bg);
    border: 3px solid var(--success);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.score-number {
    font-size: 1.35rem;
    font-weight: 800;
    color: #34d399;
    line-height: 1;
}

.score-total {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex: 1;
}

.metric-box {
    background: var(--bg-input);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
}

.metric-title {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.metric-data {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Timing & Waterfall Breakdown */
.timing-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
}

.timing-duration {
    font-family: var(--font-mono);
    font-weight: 700;
}

.timing-duration.highlight {
    color: #38bdf8;
}

.timing-duration.highlight-cyan {
    color: #34d399;
}

.stage-waterfall {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 10px;
}

.stage-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.stage-label {
    width: 140px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 9999px;
    overflow: hidden;
}

.stage-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
}

.stage-ms {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    width: 45px;
    text-align: right;
    color: var(--text-main);
}

/* Variants Table */
.variants-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.variant-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-input);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.variant-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.var-filename {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
}

.var-size-tag {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--primary-light);
    background: rgba(56, 189, 248, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
}

.var-savings-tag {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
}

.modal-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

/* ==========================================================================
   Storage Modal Styles
   ========================================================================== */

.modal-body-padded {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.storage-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 14px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-val {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 4px;
}

.storage-info-box {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.path-code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--primary-light);
}

.cleanup-actions-section h4 {
    font-size: 0.9375rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.cleanup-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.cleanup-btn-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-left: 4px solid var(--primary-light);
    color: var(--text-main);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

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

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

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
    .app-wrapper {
        padding: 10px 14px 40px;
    }
    
    .nav-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-actions {
        justify-content: space-between;
    }
    
    .toolbar-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left, .toolbar-right {
        width: 100%;
        justify-content: stretch;
    }
    
    .search-input-wrap {
        width: 100%;
    }
    
    .search-input {
        min-width: 120px;
        width: 100%;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }
}


/* ==========================================================================
   Advanced Studio Modes, Skeletons & Mask Editor Styles
   ========================================================================== */

/* Shimmer Skeleton & Card Loader */
.card-preview-wrap {
    position: relative;
    overflow: hidden;
    background: #090d16;
}

.skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.02) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.card-img.loaded + .skeleton-shimmer {
    opacity: 0;
    visibility: hidden;
}

.card-img {
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
}

.card-img.loaded {
    opacity: 1;
}

/* UI Mode Switcher */
.ui-mode-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 4px;
}

.mode-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-tab:hover {
    color: var(--text-main);
}

.mode-tab.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

/* View Mode Selector (1:1 Cutout vs Studio Canvas) */
.view-mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 4px;
}

.view-mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-mode-btn.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Studio Customizer Swatches */
.restyle-controls-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

.restyle-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.restyle-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.swatches-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.swatch-btn {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.swatch-btn:hover {
    border-color: var(--primary-light);
}

.swatch-btn.active {
    border-color: var(--primary-light);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Interactive Mask Editor Modal */
.modal-editor-window {
    max-width: 1100px;
    width: 95vw;
    height: 88vh;
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-light);
}

.tool-range {
    width: 100px;
    accent-color: var(--primary-light);
    cursor: pointer;
}

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

.editor-canvas-stage {
    flex: 1;
    position: relative;
    background: #090d16;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
                      linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
                      linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
}

#maskEditorCanvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    cursor: crosshair;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Processing Mode Selector (Resize Only vs Remove Background)
   ========================================================================== */

.proc-mode-selector {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.85);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    gap: 6px;
    margin: 8px 0 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.proc-mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.proc-mode-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.proc-mode-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.proc-mode-btn .mode-icon {
    font-size: 1rem;
}

