/* ============================================================================
   GRAVITY Studio — Design System
   Freepik-inspired dark UI with CSS Custom Properties
   ============================================================================ */

/* 1. Design Tokens
   ============================================================================ */
:root {
    /* Backgrounds — pure black base */
    --bg-app: #000000;
    --bg-sidebar: #0a0a0a;
    --bg-panel: #0f0f0f;
    --bg-surface: #161616;
    --bg-input: #1a1a1a;
    --bg-hover: #222222;
    --bg-elevated: #2a2a2a;

    /* Text hierarchy */
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-dim: #444444;

    /* Accent — Lemon */
    --accent: #ccff00;
    --accent-hover: #d4ff33;
    --accent-subtle: rgba(204, 255, 0, 0.10);
    --accent-glow: rgba(204, 255, 0, 0.20);

    /* Semantic colors */
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #64b5f6;
    --purple: rgba(156, 39, 176, 0.9);
    --teal: rgba(0, 150, 136, 0.9);
    --gold: #f5a623;

    /* Borders */
    --border: #222222;
    --border-hover: #333333;
    --border-focus: var(--accent);
    --border-subtle: rgba(255, 255, 255, 0.06);

    /* Radii — minimal, sharp */
    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Layout */
    --header-height: 52px;
    --subheader-height: 44px;
    --panel-width: 420px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --font-size-xs: 10px;
    --font-size-sm: 12px;
    --font-size-md: 14px;
    --font-size-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-overlay: 0 12px 48px rgba(0, 0, 0, 0.8);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
}

/* Slim scrollbars (Freepik style) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* 3. Layout
   ============================================================================ */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* -- Header -- */
.header {
    height: var(--header-height);
    min-height: var(--header-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-logo img {
    height: 22px;
}

.header-logo span {
    font-size: var(--font-size-md);
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.nav-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-link.active svg {
    opacity: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-credits {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--warning);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.header-version {
    font-size: var(--font-size-xs);
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* -- Gallery Toolbar (inside gallery panel) -- */
.gallery-toolbar {
    height: var(--subheader-height);
    min-height: var(--subheader-height);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 var(--space-5);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* -- Main area -- */
.main {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-width: 0;
}

/* -- Control Panel -- */
.control-panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: var(--space-6);
    overflow-y: auto;
}

/* -- Gallery Panel -- */
.gallery-panel {
    flex: 1;
    background: var(--bg-app);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.gallery-panel .gallery-grid-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow-y: auto;
}

.gallery-panel .gallery-grid {
    padding: var(--space-5);
}

/* 4. Typography
   ============================================================================ */
.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

label, .label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.text-mono {
    font-family: var(--font-mono);
}

.text-muted {
    color: var(--text-muted);
}

.text-accent {
    color: var(--accent);
}

.hint-text {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: calc(-1 * var(--space-2));
    margin-bottom: var(--space-5);
}

/* 5. Form Controls
   ============================================================================ */
.form-group {
    margin-bottom: var(--space-6);
    position: relative;
}

.form-row {
    display: flex;
    gap: var(--space-4);
    width: 100%;
}

.form-row > * {
    flex: 1;
    min-width: 0;
}

select,
input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: var(--space-3);
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
    outline: none;
}

select:hover,
input[type="text"]:hover,
input[type="number"]:hover,
textarea:hover {
    border-color: var(--border-hover);
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    border-color: var(--border-focus);
    background-color: var(--bg-surface);
}

select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

/* Sliders */
.slider-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
}

input[type="range"] {
    flex-grow: 1;
    width: 100%;
    min-width: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.val-display {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    min-width: 40px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

/* Color mapping */
.color-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.color-item {
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: var(--space-3);
    align-items: center;
}

.color-box {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.color-item input {
    padding: var(--space-2) var(--space-3);
    font-size: 13px;
}

/* Thumbnails */
.thumbnail-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.thumbnail {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: #000;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    opacity: 0.7;
    transition: opacity var(--transition-fast), border-color var(--transition-fast);
    cursor: pointer;
}

.thumbnail:hover {
    opacity: 1;
    border-color: var(--border-hover);
}

.thumbnail-large {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: contain;
    border-radius: var(--radius-md);
    border: 1px solid var(--accent);
    margin-bottom: var(--space-4);
}

.version-info {
    font-family: var(--font-mono);
    font-size: 11px;
    margin-top: var(--space-1);
    color: var(--accent);
}

/* 6. Buttons
   ============================================================================ */
.btn-generate {
    background: var(--accent);
    color: #000000;
    border: none;
    padding: var(--space-4);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    width: 100%;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-top: var(--space-3);
    position: relative;
    overflow: hidden;
}

.btn-generate:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

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

.btn-generate .cost-display {
    font-size: 11px;
    font-weight: normal;
    opacity: 0.6;
    margin-top: var(--space-1);
    display: block;
    font-family: var(--font-mono);
    color: #000000;
}

/* 7. Cards & Gallery
   ============================================================================ */
.gallery-controls {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.filter-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    margin-right: var(--space-1);
}

.gallery-count {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-5);
}

.gallery-item {
    background: var(--bg-surface);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    display: flex;
    flex-direction: column;
}

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

.gallery-item img,
.gallery-item video {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-item-desc {
    padding: var(--space-3);
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: flex;
    flex-direction: column;
}

.gallery-item-desc .filename {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-item-desc .param-info {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Overlay buttons */
.gallery-overlay-btns {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    opacity: 0;
    transform: translateY(-5px);
    transition: all var(--transition-normal);
    z-index: 10;
}

.gallery-item:hover .gallery-overlay-btns {
    opacity: 1;
    transform: translateY(0);
}

.btn-overlay {
    background: rgba(30, 30, 30, 0.92);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-overlay:hover {
    transform: scale(1.05);
}

.btn-overlay.btn-reuse { background: rgba(204, 255, 0, 0.9); color: #000; }
.btn-overlay.btn-reuse:hover { background: var(--accent); }
.btn-overlay.btn-video { background: var(--purple); }
.btn-overlay.btn-video:hover { background: rgba(186, 69, 206, 0.95); }
.btn-overlay.btn-upscale { background: var(--teal); }
.btn-overlay.btn-upscale:hover { background: rgba(30, 180, 166, 0.95); }
.btn-overlay.btn-busy { opacity: 0.5; cursor: wait; pointer-events: none; }

/* Type Badge */
.type-badge {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    padding: 3px 8px;
    font-size: 9px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 10;
    pointer-events: none;
}

.badge-video { background: var(--purple); color: #fff; }
.badge-upscale2x { background: var(--teal); color: #fff; }
.badge-upscale4x { background: rgba(0, 120, 106, 0.95); color: #fff; }
.badge-upscale8x { background: rgba(0, 90, 76, 0.95); color: #fff; }

/* Filter pills */
.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 3px 10px;
    font-size: var(--font-size-xs);
    border-radius: var(--radius-full);
    cursor: pointer;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.filter-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.star-filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 3px 10px;
    font-size: var(--font-size-xs);
    border-radius: var(--radius-full);
    cursor: pointer;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.star-filter-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.star-filter-btn.active {
    background: rgba(245, 166, 35, 0.15);
    border-color: var(--gold);
    color: var(--gold);
}

/* Zoom control */
.zoom-control {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.zoom-control input[type="range"] {
    width: 100px;
    cursor: pointer;
}

/* 8. Modal
   ============================================================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    padding: 40px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    align-items: center;
}

.modal-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    object-fit: contain;
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-modal {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: var(--space-3) var(--space-6);
    font-size: 13px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.btn-modal:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-modal.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #000000;
}

.btn-modal.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #000000;
}

.btn-modal.btn-video-action {
    background: var(--purple);
    border-color: var(--purple);
}

.btn-modal.btn-upscale-action {
    background: var(--teal);
    border-color: var(--teal);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    background: none;
    border: none;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: 1;
}

.modal-close:hover {
    color: white;
    background: var(--bg-hover);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 20, 20, 0.9);
    color: white;
    border: 1px solid var(--border);
    padding: var(--space-5) var(--space-4);
    cursor: pointer;
    font-size: 24px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-nav:hover {
    background: rgba(40, 40, 40, 0.9);
    border-color: var(--border-hover);
}

.modal-prev { left: 20px; }
.modal-next { right: 20px; }

.modal-filename {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    margin-top: var(--space-3);
}

.modal-json {
    color: #bbb;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    overflow-wrap: break-word;
    text-align: left;
    line-height: 1.5;
    max-width: 800px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
}

/* Model comparison popup */
.model-popup-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
}

.model-popup-overlay.active {
    display: flex;
}

.model-popup-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
    box-shadow: var(--shadow-overlay);
    width: 90vw;
    max-width: 820px;
    max-height: 80vh;
    overflow-y: auto;
}

.model-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
}

.model-popup-title {
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.model-popup-close {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 24px;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    background: none;
    border: none;
    line-height: 1;
}

.model-popup-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.model-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.6;
}

.model-table th {
    padding: var(--space-2) var(--space-1);
    color: var(--text-muted);
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.model-table td {
    padding: var(--space-2) var(--space-1);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.model-table .model-name {
    color: var(--info);
    font-weight: 600;
}

.model-table .price-low { color: var(--success); }
.model-table .price-mid { color: var(--warning); }
.model-table .price-high { color: var(--error); }

.model-table-footer {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
    font-size: var(--font-size-xs);
    color: var(--text-dim);
    line-height: 1.6;
}

/* 9. Job Queue Popup
   ============================================================================ */
.status-pill {
    display: none;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: 600;
    transition: all var(--transition-fast);
    user-select: none;
    color: var(--text-secondary);
}

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

.status-pill.active {
    display: flex;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.status-dot.running {
    background: #ffeb3b;
    animation: pulse 1.5s infinite;
}

.status-dot.has-errors {
    background: var(--error);
    animation: pulse 1.5s infinite;
}

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

.job-popup {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + 8px);
    right: 12px;
    width: 560px;
    max-height: 70vh;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    flex-direction: column;
    overflow: hidden;
}

.job-popup.open {
    display: flex;
}

.job-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.job-popup-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
}

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

.popup-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--space-1) var(--space-3);
    font-size: 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.popup-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 0 var(--space-1);
    line-height: 1;
    transition: color var(--transition-fast);
}

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

.job-popup-body {
    overflow-y: auto;
    flex: 1;
}

.job-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.job-table th {
    background: var(--bg-input);
    color: var(--text-muted);
    padding: var(--space-2) var(--space-3);
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: var(--font-size-xs);
    position: sticky;
    top: 0;
    z-index: 5;
}

.job-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.job-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Status badges */
.s-badge {
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.s-pending { background: #333; color: #999; }
.s-uploading { background: #1a3a5c; color: var(--info); }
.s-submitted { background: #1a3a5c; color: var(--info); }
.s-polling { background: #2d3a18; color: #aed581; }
.s-downloading { background: #2d3a18; color: #aed581; }
.s-completed { background: #1b3a1b; color: #66bb6a; }
.s-failed { background: #3a1b1b; color: #ef5350; }

.retry-btn {
    background: var(--warning);
    color: #000;
    border: none;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-weight: 700;
    font-size: var(--font-size-xs);
    transition: background var(--transition-fast);
}

.retry-btn:hover {
    background: #e68a00;
}

.log-section {
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-3);
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-dim);
    white-space: pre-wrap;
}

.empty-state {
    padding: var(--space-8);
    text-align: center;
    color: var(--text-dim);
    font-size: var(--font-size-sm);
}

/* 10. Star Rating
   ============================================================================ */
.star-rating {
    display: flex;
    gap: 2px;
    padding: var(--space-2) 0 var(--space-1) 0;
}

.star-rating .star {
    cursor: pointer;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.15);
    transition: color var(--transition-fast);
    user-select: none;
    line-height: 1;
    padding: 2px;
}

.star-rating .star.active {
    color: var(--gold);
    text-shadow: 0 0 4px rgba(245, 166, 35, 0.4);
}

.star-rating .star:hover,
.star-rating .star.hover-preview {
    color: #f5c842;
    text-shadow: 0 0 6px rgba(245, 200, 66, 0.5);
}

/* 11. Utilities
   ============================================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Info button (model comparison) */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border-hover);
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    font-family: serif;
    font-style: italic;
    line-height: 1;
    transition: all var(--transition-fast);
    background: none;
}

.info-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Disabled nav links */
.nav-link:disabled,
.nav-link[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.nav-link:disabled:hover,
.nav-link[disabled]:hover {
    background: none;
    color: var(--text-secondary);
}

/* 12. Theme Switcher
   ============================================================================ */
.theme-switcher {
    display: flex;
    align-items: center;
}

.theme-dots {
    display: flex;
    gap: var(--space-2);
}

.theme-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.theme-dot:hover {
    transform: scale(1.15);
}

.theme-dot.active {
    border-color: var(--text-primary);
}

.theme-dot .theme-label {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.theme-dot:hover .theme-label {
    opacity: 1;
}

/* 13. Theme: Glass — backdrop blur for panels
   ============================================================================ */
.theme-glass .header {
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.theme-glass .gallery-toolbar {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.theme-glass .control-panel {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.theme-glass .gallery-item {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.theme-glass .job-popup {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.theme-glass .modal {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.theme-glass select,
.theme-glass input[type="text"],
.theme-glass input[type="number"],
.theme-glass textarea {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
