:root {
    color-scheme: dark;
    --bg: #0f0e0c;
    --bg-elevated: #1a1816;
    --surface: #1e1c19;
    --surface-hover: #26241f;
    --border: #33302b;
    --border-hover: #4d4942;
    --border-hairline: rgba(255, 255, 255, 0.06);
    --inset-hi: rgba(255, 255, 255, 0.04);
    --inset-lo: rgba(255, 255, 255, 0.03);
    --well-shadow: rgba(0, 0, 0, 0.28);
    --grid-line: rgba(255, 255, 255, 0.015);
    --text: #f5f4f0;
    --text-dim: #a8a39a;
    --text-faint: #6b665e;

    --gold: #c9a84c;
    --gold-soft: #e0c77a;
    --gold-dark: #b8922e;
    --gold-text: #201a0d;

    --accent: var(--gold);
    --accent-soft: rgba(201, 168, 76, 0.12);
    --accent-2: #7aa0c8;
    --accent-text: var(--gold-soft);
    --accent-grad: linear-gradient(180deg, #e0c77a 0%, #c9a84c 100%);

    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --danger: #dc2626;
    --danger-soft: rgba(192, 57, 43, 0.14);
    --danger-text: #f0938a;

    --radius-lg: 1rem;
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-full: 999px;

    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    --ease-pop: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-fast: cubic-bezier(0.55, 0, 1, 0.45);

    --ring: 0 0 0 1px var(--border), 0 0 0 3px var(--bg-elevated), 0 0 0 4px var(--border);
    --ring-hover: 0 0 0 1px var(--border-hover), 0 0 0 3px var(--surface), 0 0 0 4px var(--border-hover);
    --shadow: 0 0 0 1px var(--border), 0 0 0 4px var(--bg-elevated), 0 0 0 5px var(--border), 0 24px 70px rgba(0, 0, 0, 0.55);

    --font-display: 'Cinzel Decorative', 'Cinzel', serif;
    --font-heading: 'Cinzel', Georgia, serif;
    --font-body: 'Raleway', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #faf9f7;
    --bg-elevated: #f5f4f0;
    --surface: #ffffff;
    --surface-hover: #eeece8;
    --border: #d8d5cf;
    --border-hover: #a8a39a;
    --border-hairline: rgba(0, 0, 0, 0.06);
    --inset-hi: rgba(255, 255, 255, 0.8);
    --inset-lo: rgba(0, 0, 0, 0.04);
    --well-shadow: rgba(28, 26, 23, 0.09);
    --grid-line: rgba(28, 26, 23, 0.025);
    --text: #1c1a17;
    --text-dim: #4d4942;
    --text-faint: #8a857c;

    --gold-text: #201a0d;
    --accent-2: #3d6a94;
    --accent-text: #8b6914;
    --danger-text: #b91c1c;
}

.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after {
    transition-property: background, background-color, border-color, box-shadow, color !important;
    transition-duration: 0.3s !important;
    transition-timing-function: ease !important;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    overflow-x: clip;
}

body {
    background-image:
        radial-gradient(circle at 20% 0%, rgba(201, 168, 76, 0.05), transparent 45%),
        repeating-linear-gradient(0deg, transparent, transparent 119px, var(--grid-line) 119px, var(--grid-line) 120px),
        repeating-linear-gradient(90deg, transparent, transparent 199px, var(--grid-line) 199px, var(--grid-line) 200px);
    background-attachment: fixed;
}

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

a {
    color: var(--accent-2);
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius-lg);
    padding: 14px 22px;
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring), 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

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

.brand-mark {
    position: relative;
    font-size: 18px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-grad);
    color: var(--gold-text);
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0 0 1px var(--gold-dark), 0 2px 10px rgba(201, 168, 76, 0.25);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 19px;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text);
}

.brand-text p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--text-faint);
}

.brand-text p a {
    color: var(--text-faint);
    text-decoration: underline;
}

.brand-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success, #4caf7d);
    box-shadow: 0 0 0 3px rgba(76, 175, 125, 0.18);
    flex-shrink: 0;
    animation: status-pulse 2.4s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(224, 90, 90, 0.18);
    animation: none;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.cabinet-header-plans {
    margin-left: auto;
}

.voices-header {
    margin-bottom: 20px;
}

/* Custom searchable select (trigger + dropdown), ported from the heroic-cms
   .c-select pattern — same structure, our own dark stone/gold tokens. */
.hs-select {
    position: relative;
    z-index: 20;
}

.hs-select.is-open {
    z-index: 50;
}

.hs-select__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border: none;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    padding: 10px 40px 10px 10px;
    position: relative;
    transition: box-shadow 0.2s ease;
}

.hs-select__trigger:hover {
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring-hover);
}

.hs-select.is-open .hs-select__trigger {
    box-shadow: inset 0 1px 0 var(--inset-hi), 0 0 0 1px var(--gold-dark), 0 0 0 3px var(--accent-soft);
}

.hs-select__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--accent-grad);
    color: var(--gold-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
}

.hs-select__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hs-select__arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-faint);
    transition: transform 0.2s ease, color 0.2s ease;
}

.hs-select.is-open .hs-select__arrow {
    transform: translateY(-50%) rotate(180deg);
    color: var(--gold);
}

.hs-select__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    /* No transition here on purpose: closing must be instant (no fade-out),
       otherwise two selects can both render fully visible for a moment
       mid-transition when the user switches between them quickly. */
}

.hs-select.is-open .hs-select__dropdown {
    opacity: 1;
    visibility: visible;
    max-height: 320px;
    overflow-y: auto;
    transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.hs-select__search {
    width: 100%;
    margin-bottom: 6px;
    padding: 9px 10px;
    font-size: 12.5px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--text);
    border: none;
    position: sticky;
    top: 0;
}

.hs-select__option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-dim);
    font-size: 12.5px;
    transition: background 0.12s ease, color 0.12s ease;
}

.hs-select__option:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.hs-select__option.is-selected {
    background: var(--accent-soft);
    color: var(--gold);
}

.hs-select__option.is-selected:after {
    content: '';
    margin-left: auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    flex-shrink: 0;
}

.hs-select__option-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--bg-elevated);
    box-shadow: 0 0 0 1px var(--border);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
}

.hs-select__option-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.hs-select__option-name {
    font-family: var(--font-heading);
    font-size: 12.5px;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hs-select__option-meta {
    font-size: 10.5px;
    color: var(--text-faint);
}

.hs-select__preview-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--bg-elevated);
    box-shadow: 0 0 0 1px var(--border);
    color: var(--text-dim);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.hs-select__preview-btn:hover {
    color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold-dark);
}

.hs-select__preview-btn.is-playing {
    background: var(--accent-grad);
    color: var(--gold-text);
    box-shadow: none;
}

.hs-select__empty {
    padding: 14px;
    text-align: center;
    color: var(--text-faint);
    font-size: 12px;
}

/* Compact filter chips (language/gender/category), same trigger+dropdown
   mechanics as .hs-select but sized to sit inline in a wrapping row. */
.hs-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.hs-select--chip {
    flex-shrink: 0;
    z-index: 15;
}

.hs-select__trigger--chip {
    width: auto;
    padding: 7px 30px 7px 12px;
    font-size: 11.5px;
    border-radius: var(--radius-full);
}

.hs-select__trigger--chip .hs-select__arrow {
    right: 10px;
    font-size: 9px;
}

.hs-select--chip .hs-select__dropdown {
    left: 0;
    right: auto;
    min-width: 170px;
}

.hs-select--chip.is-open .hs-select__dropdown {
    max-height: 220px;
    overflow-y: auto;
}

.hs-filter-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.hs-select__count {
    padding: 2px 6px 6px;
    font-size: 10.5px;
    color: var(--text-faint);
}

.account-box {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-left: auto;
}

.key-field {
    display: flex;
    align-items: center;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius-sm);
    padding: 0 5px 0 14px;
    box-shadow: var(--ring);
}

.key-field:focus-within {
    box-shadow: var(--ring-hover), 0 0 0 3px var(--accent-soft);
}

.key-field input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    box-shadow: none;
    color: var(--text);
    font-size: 13px;
    padding: 11px 0;
    font-family: var(--font-mono);
}

.key-field input::placeholder {
    color: var(--text-faint);
    font-family: inherit;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 14px;
    padding: 9px;
    border-radius: var(--radius-sm);
    line-height: 1;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.icon-btn-bordered {
    background: var(--surface);
    box-shadow: var(--ring);
}

.nav-util-wrap {
    position: relative;
}

.nav-util-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--surface);
    border: none;
    color: var(--text-dim);
    font-family: var(--font-heading);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 9px 14px;
    border-radius: var(--radius-full);
    box-shadow: var(--ring);
    cursor: pointer;
    transition: box-shadow 0.15s ease, color 0.15s ease;
}

.nav-util-btn:hover {
    color: var(--text);
    box-shadow: var(--ring-hover);
}

.nav-util-btn i {
    font-size: 11px;
    color: var(--text-faint);
}

.nav-util-caret {
    font-size: 9px !important;
}

.nav-util-btn-icon {
    position: relative;
    padding: 9px 12px;
}

.nav-bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-util-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px;
    z-index: 200;
    animation: pop-in 0.2s var(--ease-pop);
}

.nav-util-section-label {
    font-family: var(--font-heading);
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 6px 8px 4px;
}

.nav-util-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 2px;
}

.nav-util-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
}

.nav-util-option:hover {
    background: var(--surface-hover);
}

.nav-util-option:disabled {
    cursor: default;
    color: var(--text-dim);
}

.nav-util-option.active {
    color: var(--gold);
}

.nav-util-option i {
    font-size: 12px;
    color: var(--text-faint);
}

.plans-wrap {
    position: relative;
}

.plans-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-width: 80vw;
    max-height: 60vh;
    overflow-y: auto;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    z-index: 200;
    animation: pop-in 0.2s var(--ease-pop);
}

.plans-popover h4 {
    font-family: var(--font-heading);
    margin: 0 0 10px;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.plans-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.plan-item {
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    box-shadow: var(--ring);
}

.plan-item-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    margin-bottom: 4px;
}

.plan-item-head strong {
    font-family: var(--font-heading);
    font-size: 12.5px;
}

.plan-item-head span {
    font-family: var(--font-mono);
    color: var(--accent-2);
    font-weight: 600;
    white-space: nowrap;
}

.plan-item-meta {
    font-size: 11px;
    color: var(--text-faint);
    line-height: 1.4;
}

.free-badge {
    display: inline-block;
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gold-text);
    background: var(--accent-grad);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    margin-left: 6px;
    vertical-align: middle;
}

.balance-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, var(--surface), var(--bg-elevated));
    border-radius: var(--radius-full);
    padding: 8px 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--ring);
}

.balance-chip .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.balance-chip.low .dot {
    background: var(--warning);
    box-shadow: 0 0 0 3px var(--warning-soft);
}

.free-credits-chip {
    color: var(--accent-text);
    cursor: pointer;
    font-family: var(--font-heading);
}

.free-credits-chip:hover {
    background: var(--surface-hover);
    box-shadow: var(--ring-hover);
    transform: translateY(-1px);
}

.free-credits-chip .edit-glyph {
    font-size: 10px;
    color: var(--text-faint);
}

.profile-block {
    position: relative;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 9px;
    background: linear-gradient(135deg, var(--surface), var(--bg-elevated));
    border: none;
    border-radius: var(--radius-full);
    padding: 5px 12px 5px 5px;
    box-shadow: var(--ring);
    cursor: pointer;
}

.profile-trigger:hover {
    box-shadow: var(--ring-hover);
}

.profile-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-grad);
    color: var(--gold-text);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 13px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.profile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    text-align: left;
}

.profile-name {
    font-family: var(--font-heading);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
}

.profile-email {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-faint);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-caret {
    font-size: 10px;
    color: var(--text-faint);
}

.profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 20;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
}

.profile-menu-item:hover {
    background: var(--surface-hover);
    color: var(--danger-text);
}

.key-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
}

.key-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
    flex-shrink: 0;
}

.key-status.set .key-status-dot {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.key-hint {
    font-size: 12.5px;
    color: var(--text-faint);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    box-shadow: var(--ring);
    padding: 10px 14px;
    margin: 0 0 20px;
    line-height: 1.5;
}

.key-hint code {
    font-family: var(--font-mono);
    background: var(--surface);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 12px;
}

.layout {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 22px;
    align-items: start;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
}

.main-nav {
    display: flex;
    gap: 2px;
}

.main-nav-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-heading);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 10px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}

.main-nav-btn::after {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 2px;
    height: 2px;
    border-radius: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transition: transform 0.15s ease;
}

.main-nav-btn i {
    font-size: 13px;
    color: var(--text-faint);
}

.main-nav-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.main-nav-btn.active {
    color: var(--gold);
    background: var(--surface-hover);
}

.main-nav-btn.active::after {
    transform: scaleX(1);
}

.main-nav-btn.active i {
    color: var(--gold);
}

/* Project tab strip — Generator-view-only workspace switcher. Pill shape
   (not .main-nav-btn's underline) since the list is variable-length and
   horizontally scrollable rather than a fixed 2-3 item set. */
.project-tabs {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
}

.project-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--text-dim);
    font-family: var(--font-heading);
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 8px 7px 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.project-tab:hover {
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-hover);
}

.project-tab.active {
    background: var(--accent-grad);
    color: var(--gold-text);
    box-shadow: none;
}

.project-tab-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-tab-name-input {
    max-width: 160px;
    background: none;
    border: none;
    outline: none;
    color: inherit;
    font: inherit;
    padding: 0;
}

.project-tab-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 11px;
}

.project-tab-menu-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.15);
}

.project-tab-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s ease, color 0.15s ease;
}

.project-tab-add:hover {
    color: var(--gold);
    box-shadow: inset 0 0 0 1px var(--gold-dark);
}

.project-tabs.locked .project-tab:not(.active),
.project-tabs.locked .project-tab-add {
    opacity: 0.4;
    pointer-events: none;
}

.project-menu-popover {
    position: absolute;
    min-width: 160px;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow);
    z-index: 300;
    animation: pop-in 0.15s var(--ease-pop);
}

.cabinet-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 920px;
}

.cabinet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}

.cabinet-card {
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: inset 0 1px 0 var(--inset-hi), 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.35s var(--ease-pop), box-shadow 0.35s ease;
    animation: cabinet-card-rise 0.5s var(--ease-pop) both;
}

.cabinet-card:hover {
    transform: translateY(-3px);
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring-hover), 0 12px 30px rgba(0, 0, 0, 0.3);
}

.cabinet-card:nth-child(1) { animation-delay: 0.05s; }
.cabinet-card:nth-child(2) { animation-delay: 0.1s; }
.cabinet-card:nth-child(3) { animation-delay: 0.15s; }
.cabinet-card:nth-child(4) { animation-delay: 0.2s; }

@keyframes cabinet-card-rise {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cabinet-card-head {
    display: flex;
    align-items: center;
    gap: 9px;
}

.cabinet-card-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface-hover);
    color: var(--gold);
    font-size: 13px;
    box-shadow: inset 0 0 0 1px var(--border);
    flex-shrink: 0;
    overflow: hidden;
}

.cabinet-card-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.12) 50%, transparent 60%);
    animation: cabinet-icon-shimmer 3.5s ease infinite;
}

.cabinet-card-icon i {
    position: relative;
    z-index: 1;
}

@keyframes cabinet-icon-shimmer {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.cabinet-card-label {
    font-family: var(--font-heading);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.cabinet-card-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.cabinet-card-value--text {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.cabinet-card .field-hint {
    margin: 0;
}

.cabinet-card .key-field {
    margin: 2px 0;
}

.cabinet-card .balance-chip {
    align-self: flex-start;
}

.cabinet-card .btn {
    margin-top: auto;
}

.panel {
    position: relative;
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: inset 0 1px 0 var(--inset-hi), 0 2px 10px rgba(0, 0, 0, 0.3);
}

.control-panel {
    position: sticky;
    top: 20px;
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 15px;
    margin: 0 0 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.field {
    margin-bottom: 18px;
}

.field:last-of-type {
    margin-bottom: 0;
}

.field > label {
    display: block;
    font-family: var(--font-heading);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.field-hint-inline {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text-faint);
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-faint);
    font-size: 12px;
    cursor: pointer;
    vertical-align: middle;
}

.help-icon:hover, .help-icon:focus-visible {
    color: var(--accent-2);
}

.help-popover {
    position: absolute;
    width: 280px;
    max-width: calc(100vw - 24px);
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 12px 14px;
    z-index: 300;
    animation: pop-in 0.15s var(--ease-pop);
}

.help-popover p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-dim);
}

.field-hint {
    font-size: 11.5px;
    color: var(--text-faint);
    margin: 6px 2px 0;
    line-height: 1.4;
}

.chain-mode-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    font-family: var(--font-body);
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.45;
    cursor: pointer;
}

.chain-mode-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    margin-top: 1px;
    flex-shrink: 0;
    cursor: pointer;
}

.field-error {
    font-size: 12.5px;
    color: var(--danger);
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px rgba(192, 57, 43, 0.35);
    padding: 8px 12px;
    margin: 10px 0 0;
}

.field-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    gap: 10px;
}

#promptCount {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
}

.link-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 11.5px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.link-btn:hover {
    color: var(--accent-2);
}

.bulk-wrap {
    margin-top: 10px;
}

#bulkCount {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent-2);
    font-weight: 600;
    white-space: nowrap;
    margin-left: auto;
}

.bulk-separator-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.bulk-separator-row label {
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
}

.bulk-separator-row select, .bulk-separator-row input[type="text"] {
    width: auto;
    flex: 1;
    min-width: 90px;
    font-size: 12px;
    padding: 6px 8px;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%238a857c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
    background-repeat: no-repeat, no-repeat;
    background-position: right 10px center, 0 0;
    background-size: 14px, 100% 100%;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    padding: 10px 32px 10px 12px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    box-shadow: var(--ring);
}

select:focus {
    box-shadow: var(--ring-hover), 0 0 0 3px var(--accent-soft);
}

select option {
    background: var(--bg-elevated);
    color: var(--text);
}

.generate-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.generate-actions .btn-generate {
    flex: 1;
}

.count-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.count-row .field-hint {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.count-row .stepper {
    flex-shrink: 0;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

:where(textarea, input[type="text"], input[type="password"], input[type="email"]) {
    width: 100%;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    padding: 12px 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    box-shadow: inset 0 1px 3px var(--well-shadow), var(--ring);
}

:where(textarea, input[type="text"], input[type="password"], input[type="email"]):focus {
    box-shadow: inset 0 1px 2px var(--well-shadow), var(--ring-hover), 0 0 0 3px var(--accent-soft);
}

textarea::placeholder, input::placeholder {
    color: var(--text-faint);
}

.model-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.model-skeleton {
    height: 76px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 37%, var(--surface) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s infinite;
}

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

.model-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring);
    transition: transform var(--transition-base);
}

.model-card:hover {
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring-hover), 0 2px 12px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.model-card.selected {
    background: linear-gradient(180deg, var(--accent-soft), transparent 60%), linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    box-shadow: inset 0 1px 0 var(--inset-hi), 0 0 0 1px var(--accent), 0 0 0 3px var(--bg-elevated), 0 0 0 4px var(--accent);
}

.model-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.model-card .mc-name {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.model-card .mc-meta {
    font-size: 11px;
    color: var(--text-faint);
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.model-card .mc-maker {
    color: var(--text-faint);
}

.model-card .mc-price {
    font-family: var(--font-mono);
    color: var(--accent-2);
    font-weight: 600;
}

.health-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.health-normal {
    background: var(--success);
}

.health-slow {
    background: var(--warning);
}

.health-very_slow, .health-unavailable {
    background: var(--danger);
}

.health-no_data {
    background: var(--text-faint);
}

.segmented {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 3px;
    box-shadow: inset 0 1px 3px var(--well-shadow), inset 0 0 0 1px var(--border);
}

/* .field:last-of-type zeroes out margin-bottom on the field wrapping this
   (it's the last .field in the VoiceGen control panel before the Generate
   button) — put the gap on the control itself instead so it isn't lost. */
#vgPresetSegmented {
    margin-bottom: 0.5rem;
}

.seg-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 7px 8px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.seg-btn:hover {
    color: var(--text);
}

.seg-btn.active {
    background: linear-gradient(180deg, var(--surface-hover), var(--surface));
    color: var(--text);
    box-shadow: 0 0 0 1px var(--border-hover), 0 1px 3px var(--well-shadow);
}

.seg-btn small {
    font-family: var(--font-mono);
    color: var(--text-faint);
    font-weight: 400;
}

.seg-btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 3px;
    width: 100px;
    box-shadow: inset 0 1px 3px var(--well-shadow), inset 0 0 0 1px var(--border);
}

.step-btn {
    width: 28px;
    height: 28px;
    background: var(--surface-hover);
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    line-height: 1;
}

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

.step-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent-text);
}

#countValue, #durationValue {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13.5px;
    min-width: 16px;
    text-align: center;
}

.drop-zone {
    border: 1.5px dashed var(--border-hover);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    background: var(--surface);
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-zone p {
    margin: 0 0 10px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.drop-zone-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.ref-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ref-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--ring);
}

.ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ref-thumb .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ref-thumb .role-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 8.5px;
    text-align: center;
    padding: 1px 0;
}

.cost-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-dim);
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 14px;
    box-shadow: var(--ring);
}

.cost-row strong {
    font-family: var(--font-mono);
    color: var(--accent-text);
    font-size: 14.5px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 10px 16px;
    cursor: pointer;
    transition: transform var(--transition-fast), opacity var(--transition-base);
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    position: relative;
    overflow: hidden;
    background: var(--accent-grad);
    color: var(--gold-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0 0 1px var(--gold-dark), 0 2px 10px rgba(201, 168, 76, 0.2);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.btn-primary:hover:not(:disabled)::before {
    left: 120%;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0 0 1px var(--gold-dark), 0 4px 18px rgba(201, 168, 76, 0.35);
}

.btn-primary:active:not(:disabled) {
    filter: brightness(0.97);
    box-shadow: inset 0 1px 4px var(--well-shadow), 0 0 0 1px var(--gold-dark);
}

.btn-secondary {
    background: linear-gradient(180deg, var(--surface-hover) 0%, var(--surface) 100%);
    color: var(--text-dim);
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring);
}

.btn-secondary:hover:not(:disabled) {
    color: var(--text);
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring-hover), 0 4px 14px rgba(0, 0, 0, 0.25);
}

.btn-secondary:active:not(:disabled) {
    box-shadow: inset 0 1px 3px var(--well-shadow), var(--ring);
}

.btn-ghost {
    background: none;
    color: var(--text-faint);
    font-family: var(--font-body);
    font-weight: 500;
    letter-spacing: normal;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text);
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
}

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

.btn-generate {
    width: 100%;
    padding: 13px;
    font-size: 14px;
}

.spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.25);
    border-top-color: var(--gold-text);
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

.spinner.dark {
    border-color: var(--border);
    border-top-color: var(--accent);
}

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

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

.results-header .panel-title {
    margin: 0;
    display: flex;
    align-items: center;
}

.results-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.queue-panel.hidden {
    display: none;
}

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

.queue-header-actions .job-cost {
    white-space: nowrap;
}

.queue-header-actions strong {
    font-family: var(--font-mono);
    color: var(--accent-text);
    font-size: 13px;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    box-shadow: var(--ring);
    animation: pop-in 0.2s var(--ease-pop);
}

.queue-item-model {
    font-family: var(--font-heading);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--accent-2);
    background: rgba(122, 160, 200, 0.12);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.queue-item-prompt {
    flex: 1;
    font-size: 12.5px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-item-cost {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-faint);
    white-space: nowrap;
}

.queue-errors-box {
    margin-top: 12px;
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px rgba(192, 57, 43, 0.3);
    padding: 10px 12px;
}

.queue-errors-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    color: var(--danger);
    margin-bottom: 6px;
}

.queue-error-item {
    font-size: 11.5px;
    color: var(--text-dim);
    padding: 4px 0;
    border-top: 1px solid rgba(192, 57, 43, 0.2);
}

.queue-error-item:first-child {
    border-top: none;
}

.job-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.empty-state {
    position: relative;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}

.empty-icon {
    position: relative;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 78px;
    height: 78px;
    margin: 0 auto 16px;
    color: var(--text-faint);
}

.empty-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    animation: ring-pulse 3s ease-in-out infinite;
}

@keyframes ring-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.08);
        opacity: 0.5;
    }
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-family: var(--font-mono);
    background: var(--accent-soft);
    color: var(--accent-text);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
}

.job-card {
    position: relative;
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: inset 0 1px 0 var(--inset-hi), var(--ring);
    /* With hundreds of cards in a long history, skip layout/paint for ones far
       off-screen — the intrinsic size is just a placeholder guess so scrolling
       doesn't jump once the browser measures the real height. */
    content-visibility: auto;
    contain-intrinsic-size: 0 320px;
}

.job-card.card-enter {
    animation: card-in 0.4s var(--ease-pop);
}

.job-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.job-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.job-card-title .job-model {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13.5px;
    letter-spacing: 0.01em;
}

.job-card-title .job-time {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-faint);
}

.redo-tag {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--gold);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 9px 3px 8px;
    border-radius: var(--radius-full);
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
    flex-shrink: 0;
}

.status-queued {
    background: var(--warning-soft);
    color: var(--warning);
}

.status-processing {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.status-processing::before {
    animation: dot-pulse 1.4s ease-in-out infinite;
}

.status-succeeded {
    background: var(--success-soft);
    color: var(--success);
}

.status-failed {
    background: var(--danger-soft);
    color: var(--danger-text);
}

.status-canceled {
    background: var(--border);
    color: var(--text-faint);
}

.job-prompt {
    font-size: 13px;
    color: var(--text-dim);
    margin: 0 0 10px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}

.job-prompt.expanded {
    -webkit-line-clamp: unset;
}

.job-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12.5px;
    color: var(--text-dim);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: inset 0 0 0 1px var(--border);
}

.jobs-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
}

.job-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 420px));
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border);
}

.gallery-item img {
    width: 100%;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    display: block;
    background: var(--bg);
    transition: transform 0.25s ease;
}

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

.gallery-item-actions {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

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

.gallery-icon-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(10, 10, 8, 0.75);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.gallery-icon-btn:hover {
    background: var(--gold-dark);
}

.job-error-box {
    font-size: 12.5px;
    color: var(--danger-text);
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px rgba(192, 57, 43, 0.3);
    padding: 10px 12px;
    line-height: 1.5;
}

.job-error-box .retry-tag {
    font-weight: 700;
}

.job-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.job-cost {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
}

.job-actions {
    display: flex;
    gap: 6px;
}

.gallery-item video {
    width: 100%;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    display: block;
    background: var(--bg);
}

.video-play-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(10, 10, 8, 0.65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.glightbox-container .goverlay {
    background: rgba(10, 9, 7, 0.92);
}

.glightbox-container .gslide-media {
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

.glightbox-container .gslide-image img {
    border-radius: var(--radius);
}

.glightbox-container .gslide-video {
    background: var(--bg);
    border-radius: var(--radius);
}

.glightbox-container .gslide-description {
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
}

.glightbox-container .gslide-title {
    font-family: var(--font-heading);
    color: var(--text);
    letter-spacing: 0.02em;
}

.glightbox-container .gdesc-inner {
    color: var(--text-dim);
}

.glightbox-container .gclose,
.glightbox-container .gnext,
.glightbox-container .gprev {
    background: var(--surface);
    box-shadow: var(--ring);
    border-radius: 50%;
    opacity: 1;
    fill: var(--text);
    color: var(--text);
}

.glightbox-container .gclose:hover,
.glightbox-container .gnext:hover,
.glightbox-container .gprev:hover {
    box-shadow: var(--ring-hover);
    background: var(--surface-hover);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 7, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.modal.hidden {
    display: none;
}

.modal-card {
    background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg) 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    width: 380px;
    max-width: 90vw;
    box-shadow: var(--shadow);
    animation: modal-pop 0.35s var(--ease-pop);
}

.modal-card h3 {
    font-family: var(--font-heading);
    margin: 0 0 12px;
    font-size: 14.5px;
    letter-spacing: 0.02em;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.auth-card {
    width: 400px;
}

.auth-card .brand {
    justify-content: center;
    text-align: center;
    flex-direction: column;
    margin-bottom: 18px;
}

.auth-card .segmented {
    margin-bottom: 18px;
}

.auth-card .btn-generate {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.toasts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1002;
    max-width: 340px;
}

.toast {
    position: relative;
    background: linear-gradient(170deg, var(--surface) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius-sm);
    padding: 11px 14px 11px 18px;
    font-size: 12.5px;
    box-shadow: var(--shadow);
    animation: slide-in 0.3s var(--ease-pop);
    overflow: hidden;
}

.toast::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.toast.error::after {
    background: var(--danger);
}

.toast.success::after {
    background: var(--success);
}

.toast.leaving {
    animation: slide-out 0.25s var(--ease-in-fast) forwards;
}

@keyframes slide-in {
    from {
        transform: translateX(24px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes slide-out {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateX(28px) scale(0.94);
        opacity: 0;
    }
}

#queueRunBtn.running {
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.1) 75%, transparent 75%, transparent);
    background-size: 24px 24px;
    animation: stripes 1s linear infinite;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}


@keyframes dot-pulse {
    0%, 100% {
        opacity: 0.85;
        box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4);
    }
    50% {
        opacity: 0.5;
        box-shadow: 0 0 0 4px rgba(201, 168, 76, 0);
    }
}

@keyframes stripes {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 24px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

.hidden {
    display: none !important;
}

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

    .control-panel {
        position: static;
    }
}

@media (max-width: 520px) {
    .app {
        padding: 14px 12px 40px;
    }

    .model-grid {
        grid-template-columns: 1fr;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .count-row {
        flex-wrap: wrap;
    }
}
