/* ═══════════════════════════════════════════════════
   AIHUB — Brand Design System (Premium Dark Mode)
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Instrument+Sans:wght@400;500;600;700&family=Sora:wght@500;600;700&display=swap');

:root {
    /* Base Neutral Palette */
    --bg-base:           #080a0f;
    --bg-surface:        #11151d;
    --bg-surface-hover:  #181e28;
    --border-subtle:     rgba(255, 255, 255, 0.08);
    --border-strong:     rgba(255, 255, 255, 0.15);
    
    /* Text Colors */
    --text-primary:      #f5f7fb;
    --text-secondary:    #9aa4b2;
    --text-muted:        #8490a0;

    /* Accent Palette */
    --brand-accent:      #4266af;
    --brand-accent-strong:#365895;
    --brand-accent-rgb:  66, 102, 175;
    --brand-red:         #e11d48;
    --brand-muted:       #7f98c9;
    --brand-green:       #22c55e;
    --brand-amber:       #f59e0b;
    --brand-purple:      #8b5cf6;
    --brand-purple-fill: #6d28d9;
    --status-success-text:#4ade80;
    --status-warning-text:#fbbf24;
    --status-danger-text: #fb7185;
    --status-purple-text: #a78bfa;
    --status-code-text:   #f472b6;
    --status-neutral-text:#cbd5e1;
    --on-success:         #07150d;
    --text-on-dark-muted: #aab4c2;
    
    /* Layout & Styling Tokens */
    --sidebar-width:     380px;
    --topbar-height:     102px;
    --radius-sm:         6px;
    --radius-md:         10px;
    --radius-lg:         16px;
    --radius-xl:         24px;

    /* Theme Specific Components */
    --card-shadow:        0 4px 24px rgba(0,0,0,0.2);
    --card-shadow-hover:  0 8px 32px rgba(0,0,0,0.35);
    --btn-shadow:         0 2px 8px rgba(255,255,255,0.1);
    --btn-shadow-hover:   0 4px 12px rgba(255,255,255,0.15);
    --btn-outline-hover:  rgba(255,255,255,0.05);
    --btn-dark-brand-bg:  rgba(255,255,255,0.06);
    --btn-secondary-bg:   rgba(255,255,255,0.1);
    --btn-secondary-hover:rgba(255,255,255,0.15);
    --btn-brand-hover-bg: #e2e8f0;
    --input-bg:           rgba(0,0,0,0.3);
    --input-bg-focus:     rgba(0,0,0,0.5);
    --input-focus-shadow: 0 0 0 3px rgba(255,255,255,0.05);
    --upload-zone-bg:     rgba(0,0,0,0.2);
    --chat-bubble-other-bg: var(--bg-surface-hover);
    --sidebar-active-bg:  rgba(66, 102, 175, 0.16);
    --topbar-bg:          #11151d;
    --bs-badge-color:     #ffffff;
}

[data-theme="light"] {
    --bg-base: #f5f7fb;
    --bg-surface: #ffffff;
    --bg-surface-hover: #edf0f5;
    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;
    --text-primary: #11151d;
    --text-secondary: #596474;
    --text-muted: #5f6978;
    --brand-accent: #4266af;
    --brand-accent-strong: #365895;
    --brand-accent-rgb: 66, 102, 175;
    --brand-red: #dc2626;
    --brand-green: #16a34a;
    --brand-amber: #d97706;
    --brand-purple: #7c3aed;
    --brand-muted: #365895;
    --brand-purple-fill: #6d28d9;
    --status-success-text: #166534;
    --status-warning-text: #92400e;
    --status-danger-text: #991b1b;
    --status-purple-text: #5b21b6;
    --status-code-text: #9d174d;
    --status-neutral-text: #334155;
    --on-success: #07150d;
    --text-on-dark-muted: #aab4c2;
    --card-shadow: 0 4px 20px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.02);
    --card-shadow-hover: 0 10px 30px rgba(15, 23, 42, 0.08);
    --btn-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    --btn-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08);
    --btn-outline-hover: rgba(15, 23, 42, 0.04);
    --btn-dark-brand-bg: #f1f5f9;
    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-hover: #cbd5e1;
    --btn-brand-hover-bg: #1e293b;
    --input-bg: #ffffff;
    --input-bg-focus: #ffffff;
    --input-focus-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    --upload-zone-bg: #f8fafc;
    --chat-bubble-other-bg: #f1f5f9;
    --sidebar-active-bg: rgba(66, 102, 175, 0.09);
    --topbar-bg: #ffffff;
    --bs-badge-color: var(--text-primary);
}

/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* ── App Shell ─────────────────────────────────── */
.app-body {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overscroll-behavior: contain;
}

.sidebar-header {
    padding: 24px 24px 20px;
    text-align: center;
}

.sidebar-logo-link { display: inline-block; }

.sidebar-logo {
    max-width: 160px;
    max-height: 60px;
    object-fit: contain;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 16px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 20px 12px 6px;
    display: block;
    border-top: 1px solid var(--border-subtle);
    margin: 8px 0 0;
}

.sidebar-nav-item { margin: 4px 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--brand-muted);
    box-shadow: inset 3px 0 0 var(--brand-accent);
}

.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.sidebar-icon { 
    font-size: 1.1rem; 
    width: 24px; 
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.sidebar-link:hover .sidebar-icon { color: var(--text-primary); }
.sidebar-link.active .sidebar-icon { color: var(--brand-muted); }

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-user-name {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 12px;
}

.btn-logout {
    background: var(--btn-dark-brand-bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* ── Mobile Topbar ─────────────────────────────── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
    gap: 14px;
    z-index: 1100;
}

.topbar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
}

.topbar-toggle:focus-visible {
    outline: 3px solid rgba(var(--brand-accent-rgb), 0.35);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.topbar-logo {
    height: 32px;
    object-fit: contain;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    width: 100%;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.sidebar-overlay.active { display: block; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px)); }
    body.sidebar-open { overflow: hidden; }
}

@media (min-width: 992px) {
    .topbar { display: none !important; }
    .main-content { margin-left: var(--sidebar-width); }
}

/* ── Main Content ──────────────────────────────── */
.main-content {
    flex: 1;
    min-height: 100vh;
    min-height: 100dvh;
}

.content-wrapper {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── Page Headers ──────────────────────────────── */
.page-header {
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    margin: 8px 0 0;
    font-size: 1rem;
}

/* ── Cards ─────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    color: var(--text-primary);
}

.card-header {
    background: transparent;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    padding: 20px 24px;
    font-weight: 600;
    font-size: 1.1rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

/* ── Overrides for Bootstrap Modals ── */
.modal-content {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-subtle);
}

.modal-footer {
    border-top: 1px solid var(--border-subtle);
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}
[data-theme="light"] .btn-close {
    filter: none !important;
}

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--border-strong);
}
a > .stat-card:hover, a:has(.stat-card) .stat-card:hover {
    border-color: var(--brand-accent);
    box-shadow: 0 8px 32px rgba(59,130,246,0.15);
}

.stat-card .stat-number {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Buttons ───────────────────────────────────── */
.btn-brand {
    background: var(--text-primary);
    border: 1px solid var(--text-primary);
    color: var(--bg-base);
    font-weight: 500;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: var(--btn-shadow);
}

.btn-brand:hover {
    background: var(--btn-brand-hover-bg);
    color: var(--bg-base);
    transform: translateY(-1px);
    box-shadow: var(--btn-shadow-hover);
}

.btn-brand-outline {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    font-weight: 500;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.btn-brand-outline:hover {
    background: var(--btn-outline-hover);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* C-3 Fix: Define .btn-dark-brand (previously missing) */
.btn-dark-brand {
    background: var(--btn-dark-brand-bg);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    font-weight: 500;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-dark-brand:hover {
    background: var(--btn-secondary-bg);
    border-color: var(--text-primary);
    color: var(--text-primary);
    text-decoration: none;
}

/* Pagination page number button hover (used in _Pagination.cshtml) */
.pagination-page-btn:hover {
    border-color: var(--brand-accent) !important;
    color: var(--text-primary) !important;
    text-decoration: none;
}

.btn-outline-primary {
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-outline-primary:hover {
    background: var(--btn-outline-hover);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-strong);
}
.btn-outline-secondary:hover {
    background: var(--btn-outline-hover);
    color: var(--text-primary);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    border: none;
}
.btn-secondary:hover {
    background: var(--btn-secondary-hover);
    color: var(--text-primary);
}

/* ── Forms ─────────────────────────────────────── */
.form-control, .form-select {
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background: var(--input-bg-focus);
    border-color: var(--text-secondary);
    box-shadow: var(--input-focus-shadow);
    color: var(--text-primary);
}

.btn-outline-danger {
    color: var(--status-danger-text);
    border-color: var(--status-danger-text);
}
.btn-outline-warning,
.btn-outline-warning.text-warning {
    color: var(--status-warning-text) !important;
    border-color: var(--status-warning-text);
}

.nav-link { color: var(--brand-muted); }
.nav-link:hover,
.nav-link:focus { color: var(--text-primary); }

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.form-text {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ── Tables ────────────────────────────────────── */
.table {
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--text-primary) !important;
    --bs-table-border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

.table > :not(caption) > * > * {
    background-color: transparent !important;
    color: inherit;
    border-bottom-color: var(--border-subtle) !important;
    box-shadow: none !important;
}

.table thead th {
    color: var(--text-muted) !important;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle) !important;
    padding: 16px;
}

.table tbody td {
    border-bottom: 1px solid var(--border-subtle) !important;
    padding: 16px;
    vertical-align: middle;
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--bg-surface-hover) !important;
    color: var(--text-primary) !important;
}

/* ── Badges ────────────────────────────────────── */
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Premium styling for standard status badge classes */
.text-bg-primary {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: var(--brand-muted) !important;
    border: 1px solid rgba(59, 130, 246, 0.25) !important;
}
.text-bg-secondary {
    background-color: var(--btn-secondary-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-subtle) !important;
}
.text-bg-success {
    background-color: rgba(34, 197, 94, 0.15) !important;
    color: var(--status-success-text) !important;
    border: 1px solid rgba(34, 197, 94, 0.25) !important;
}
.text-bg-danger {
    background-color: rgba(225, 29, 72, 0.15) !important;
    color: var(--status-danger-text) !important;
    border: 1px solid rgba(225, 29, 72, 0.25) !important;
}
.text-bg-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: var(--status-warning-text) !important;
    border: 1px solid rgba(245, 158, 11, 0.25) !important;
}
.text-bg-info {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: var(--brand-muted) !important;
    border: 1px solid rgba(59, 130, 246, 0.25) !important;
}

/* Light mode badge overrides to ensure readability and correct specificity */
[data-theme="light"] .badge {
    --bs-badge-color: var(--text-primary);
}

/* Light mode overrides for neutral badges with no background color helper classes */
[data-theme="light"] .badge:not(.bg-primary):not(.bg-secondary):not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info):not(.bg-light):not(.bg-dark):not(.bg-brand):not(.text-bg-primary):not(.text-bg-secondary):not(.text-bg-success):not(.text-bg-danger):not(.text-bg-warning):not(.text-bg-info):not(.text-bg-light):not(.text-bg-dark):not(.text-bg-brand):not([class*="text-"]) {
    background-color: rgba(15, 23, 42, 0.08);
}

/* Solid badge fills need explicit on-colors; translucent badges use semantic text tokens below. */
.badge.bg-primary,
.badge.bg-danger,
.badge.bg-dark,
.badge.bg-brand {
    --bs-badge-color: #ffffff;
}
.badge.bg-success,
.badge.bg-warning {
    color: var(--on-success) !important;
    --bs-badge-color: #000000;
}

.badge.bg-primary[class*="bg-opacity-"],
.badge.bg-info[class*="bg-opacity-"],
.badge.bg-brand[class*="bg-opacity-"] {
    color: var(--brand-muted) !important;
}
.badge.bg-success[class*="bg-opacity-"] {
    color: var(--status-success-text) !important;
}
.badge.bg-warning[class*="bg-opacity-"] {
    color: var(--status-warning-text) !important;
}
.badge.bg-danger[class*="bg-opacity-"] {
    color: var(--status-danger-text) !important;
}
.badge.bg-secondary[class*="bg-opacity-"] {
    color: var(--status-neutral-text) !important;
}

/* ── Asset Library: clickable content-tag chips ──────────────────
   Fully token-driven so contrast holds in both themes. Deliberately
   NOT a .badge and uses no inline brand var, so the white-text badge
   rule above never applies. Follows the sidebar/kind-chip "active"
   idiom: accent text on an accent tint (high contrast in light AND
   dark); the filtered tag reads as active via a stronger tint, a
   solid accent border, and heavier weight — never white-on-blue. */
.asset-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    background: rgba(var(--brand-accent-rgb), 0.12);
    color: var(--brand-muted);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.22);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.asset-tag-chip:hover {
    background: rgba(var(--brand-accent-rgb), 0.22);
    border-color: var(--brand-accent);
    color: var(--brand-muted);
}
.asset-tag-chip.active,
.asset-tag-chip.active:hover {
    background: rgba(var(--brand-accent-rgb), 0.16);
    border-color: var(--brand-accent);
    color: var(--brand-muted);
    font-weight: 700;
}

/* ── Dashboard launcher tiles — quiet by default, brand-accent on hover/focus ── */
.tool-tile { transition: border-color 0.15s ease, transform 0.15s ease; }
.tool-tile:hover,
.tool-tile:focus-visible {
    border-color: var(--brand-accent);
    transform: translateY(-2px);
}

/* ── Create-form "more options" disclosure toggle — chevron flips when open ── */
.form-more-chevron { transition: transform 0.15s ease; }
.form-more-toggle[aria-expanded="true"] .form-more-chevron { transform: rotate(180deg); }

/* ── Loading Spinner ───────────────────────────── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(8px);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.loading-overlay.active { display: flex; }

.loading-spinner {
    width: 52px;
    height: 52px;
    border: 3px solid rgba(59, 130, 246, 0.15);
    border-top-color: var(--brand-accent);
    border-right-color: rgba(59, 130, 246, 0.5);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
    margin-bottom: 24px;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton Loader ───────────────────────────── */
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton-loader {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 2.5s infinite linear;
    border-radius: var(--radius-md);
    width: 100%;
    height: 100%;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-strong);
    color: var(--text-muted);
}

/* ── Utilities ─────────────────────────────────── */
.text-brand {
    color: var(--text-primary) !important;
}
.text-muted    { color: var(--text-muted) !important; }
.text-primary  { color: var(--text-primary) !important; }
.text-secondary{ color: var(--text-secondary) !important; }
.text-success  { color: var(--status-success-text) !important; }
.text-warning  { color: var(--status-warning-text) !important; }
.text-danger   { color: var(--status-danger-text) !important; }
.text-info     { color: var(--brand-muted) !important; }
.bg-brand {
    background-color: rgba(var(--brand-accent-rgb), var(--bs-bg-opacity, 1)) !important;
}

code { color: var(--status-code-text); }

/* AI Output Adjustments for Dark Mode */
.ai-output-text {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--brand-accent); /* H-8 Fix: was var(--text-primary) */
    border-radius: var(--radius-md);
    padding: 20px;
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
}

/* ── Reusable Component Standard (Antigravity Inspired) ──────────────── */

/* Selection Cards & Chips */
.selection-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); 
    gap: 12px; 
}
.selection-btn { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s ease; background: transparent; color: var(--text-secondary);
}
.selection-btn:hover { 
    border-color: var(--brand-accent); 
    background: rgba(var(--brand-accent-rgb), 0.04); 
    color: var(--text-primary);
}
.selection-btn.selected { 
    border-color: var(--brand-accent); 
    background: rgba(var(--brand-accent-rgb), 0.08); 
    color: var(--brand-muted);
}
.selection-btn .sel-icon { font-size: 1.6rem; color: inherit; }
.selection-btn .sel-name { font-size: 0.85rem; font-weight: 500; }

.selection-chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.selection-chip { 
    padding: 6px 16px; border: 1px solid var(--border-subtle); border-radius: 24px;
    font-size: 0.85rem; cursor: pointer; transition: all 0.2s ease; color: var(--text-secondary);
}
.selection-chip:hover { 
    border-color: var(--brand-accent); 
    color: var(--text-primary);
}
.selection-chip.selected { 
    border-color: var(--brand-accent); 
    background: rgba(var(--brand-accent-rgb), 0.08); 
    color: var(--brand-muted);
    font-weight: 500; 
}

/* Upload Zone */
.upload-zone { 
    border: 1px dashed var(--border-strong); border-radius: var(--radius-md); padding: 32px 20px; text-align: center;
    cursor: pointer; transition: all 0.2s ease; background: var(--upload-zone-bg);
}
.upload-zone:hover, .upload-zone.dragover { 
    border-color: var(--brand-accent); 
    background: rgba(var(--brand-accent-rgb), 0.02);
}
.upload-zone:focus-visible {
    outline: 3px solid rgba(var(--brand-accent-rgb), 0.35);
    outline-offset: 3px;
    border-color: var(--brand-accent);
}
.upload-zone input[type=file] { display: none; }
.upload-zone .uz-icon { color: var(--text-muted); margin-bottom: 12px; }
.upload-zone .uz-text { font-size: 0.9rem; color: var(--text-secondary); }
.upload-zone .uz-filename { font-size: 0.85rem; color: var(--brand-muted); margin-top: 8px; font-weight: 500; }

/* Feature specific cards (Booth, Social, etc) */
.create-card { 
    background: var(--bg-surface); border: 1px solid var(--border-subtle); 
    border-radius: var(--radius-lg); padding: 32px; margin-bottom: 24px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.section-label { 
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; 
    color: var(--text-muted); margin-bottom: 16px; border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

/* ── Login Page ────────────────────────────────── */
.login-body {
    background: var(--bg-base);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
    padding: 16px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo img {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

/* ── H-11: Dark Mode Alert Overrides ────────────── */
.alert-success {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-left: 4px solid var(--brand-green);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

.alert-danger {
    background: rgba(225, 29, 72, 0.08);
    border: 1px solid rgba(225, 29, 72, 0.25);
    border-left: 4px solid var(--brand-red);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-left: 4px solid var(--brand-amber);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

.alert-info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-left: 4px solid var(--brand-accent);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

/* ── C-5: Chat Bubble Classes ───────────────────── */
.chat-bubble-mine {
    background: var(--brand-accent);
    color: #fff;
    border-radius: 14px;
    border-bottom-right-radius: 3px;
    padding: 12px 16px;
}
.chat-bubble-other {
    background: var(--chat-bubble-other-bg);
    color: var(--text-primary);
    border-radius: 14px;
    border-bottom-left-radius: 3px;
    border: 1px solid var(--border-subtle);
    padding: 12px 16px;
}

/* ── L-5: Focus-Visible Keyboard Navigation ─────── */
:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 3px;
    border-radius: 4px;
}
.btn-brand:focus-visible,
.btn-brand-outline:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-rgb), 0.35);
    outline: none;
}

/* ── L-6: Form Validation Error Color ──────────── */
.field-validation-error {
    color: var(--status-danger-text) !important;
    font-size: 0.82rem;
    margin-top: 4px;
    display: block;
}
.input-validation-error {
    border-color: var(--brand-red) !important;
}
.input-validation-error:focus {
    box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.25) !important;
}

/* ── H-10: Full-width content wrapper for wide layouts ── */
.content-wrapper--full {
    max-width: none;
}

/* ── H-6: Campaign Details responsive height ────── */
@media (max-width: 991.98px) {
    #chatStream {
        min-height: 400px;
        max-height: 60vh;
    }
}

/* ── L-1: Responsive content wrapper padding ────── */
@media (max-width: 767.98px) {
    .content-wrapper { padding: 20px 16px; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
    .content-wrapper { padding: 32px 24px; }
}

/* ── M-1: Page header responsive typography ─────── */
.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}
@media (min-width: 992px) {
    .page-header h1 { font-size: 2.25rem; }
}

/* ── M-8: Consistent form label color ───────────── */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ── H-4: Sidebar section separator ─────────────── */
.sidebar-section-label:first-of-type {
    border-top: none;
    margin-top: 0;
}

/* ── Logo Library Picker ── */
.logo-grid-item {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
}
.logo-grid-item:hover {
    background: var(--bg-surface-hover);
    border-color: var(--brand-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--brand-accent-rgb), 0.15);
}
.logo-grid-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(225, 29, 72, 0.15);
    color: var(--status-danger-text);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, background 0.2s;
    z-index: 10;
}
.logo-grid-item:hover .logo-grid-delete {
    opacity: 1;
}
.logo-grid-delete:hover {
    background: var(--brand-red);
    color: #fff;
}

/* ── Toast Notification System ── */
#toast-container {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom, 0px));
    right: max(24px, env(safe-area-inset-right, 0px));
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 350px;
    width: calc(100% - 48px);
}

/* Keep the Dashboard's Ask AI controls on the light-theme component palette. */
[data-theme="light"] #askAiForm .form-control {
    background: var(--input-bg);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
[data-theme="light"] .ask-example.btn-dark-brand {
    background: var(--btn-dark-brand-bg);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.toast-notification {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow-hover);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: all 0.3s ease;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* -- Dashboard: Pick Up Where You Left Off cards -------------------------- */
.resume-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    color: var(--text-primary);
}
.resume-card:hover {
    border-color: var(--brand-accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    color: var(--text-primary);
}
.resume-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--bg-surface-hover);
}
.resume-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.resume-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.resume-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.04em;
    backdrop-filter: blur(4px);
}
.resume-body {
    padding: 10px 12px;
}
.resume-label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
}
.resume-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Campaign asset thumbnail picker (_CampaignAssetPicker) */
.cap-grid { max-height: 220px; overflow-y: auto; }
.cap-card {
    cursor: pointer; width: 96px; padding: 6px;
    border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    background: var(--bg-surface-hover); text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.cap-card:hover { border-color: var(--border-strong); }
.cap-card.cap-selected { border-color: var(--brand-accent); box-shadow: 0 0 0 1px var(--brand-accent); }
.cap-card img { width: 100%; height: 54px; object-fit: contain; border-radius: var(--radius-sm); background: var(--bg-base); }
.cap-card .cap-name { font-size: 0.7rem; color: var(--text-secondary); width: 100%; }
.cap-card .cap-type { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.cap-card .cap-none-icon {
    width: 100%; height: 54px; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); background: var(--bg-base); border-radius: var(--radius-sm);
}
.cap-none .cap-name { color: var(--text-muted); }

/* Dropdown menus (shared _ImageActionBar "More" overflow, and any other Bootstrap dropdown) */
.dropdown-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    padding: 6px;
    min-width: 12rem;
}
.dropdown-item {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem; font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.dropdown-item:hover, .dropdown-item:focus {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}
.dropdown-item.text-danger { color: var(--status-danger-text); }
.dropdown-item.text-danger:hover, .dropdown-item.text-danger:focus {
    background: rgba(225, 29, 72, 0.1); color: var(--status-danger-text);
}
.dropdown-item.saved { color: var(--status-success-text); }
.dropdown-item [data-lucide] { flex-shrink: 0; }
/* Forms wrapping a dropdown-item (e.g. Share to campaign) shouldn't add their own inset */
.dropdown-menu form { margin: 0; }
.dropdown-menu form .dropdown-item { width: 100%; text-align: left; }
.dropdown-divider { border-top-color: var(--border-subtle); margin: 6px 4px; }

/* ── Global sidebar "Generating…" tray (genTray.js) ───────────────────────── */
.gen-tray-li { list-style: none; }
.gen-tray {
    margin: 6px 10px 10px;
    padding: 8px;
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}
.gen-tray-header {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 2px 4px 6px;
}
.gen-tray-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    transition: background-color 0.15s ease;
}
.gen-tray-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.gen-tray-ico {
    width: 22px; height: 22px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--brand-muted);
}
.gen-tray-item--ready .gen-tray-ico { color: var(--status-success-text); }
.gen-tray-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gen-tray-label {
    font-size: 0.75rem; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gen-tray-sub { font-size: 0.64rem; color: var(--brand-muted); font-weight: 500; }
.gen-tray-item--ready .gen-tray-sub { color: var(--status-success-text); }
.gen-tray-spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.25);
    border-top-color: var(--brand-accent);
    animation: gen-tray-spin 0.7s linear infinite;
}
@keyframes gen-tray-spin { to { transform: rotate(360deg); } }
.gen-tray-dismiss {
    flex-shrink: 0; border: 0; background: transparent;
    color: var(--text-muted); font-size: 1.1rem; line-height: 1;
    padding: 0 4px; cursor: pointer; border-radius: var(--radius-sm);
}
.gen-tray-dismiss:hover { color: var(--text-primary); }
.gen-tray-flip { animation: gen-tray-flash 1.2s ease; }
@keyframes gen-tray-flash {
    0% { background: rgba(34, 197, 94, 0.22); }
    100% { background: transparent; }
}

/* -- Presentation Studio workbench -------------------------------------- */
.presentation-workbench {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.presentation-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.presentation-topbar h1 {
    font-size: 1.75rem;
    line-height: 1.15;
}

.deck-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.deck-step {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    background: var(--bg-surface);
}

.deck-step span {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    font-weight: 700;
}

.deck-step strong {
    font-size: 0.82rem;
}

.deck-step--active {
    color: var(--text-primary);
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.14);
}

.deck-step--active span,
.deck-step--done span {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    color: #fff;
}

.deck-step--done {
    color: var(--text-secondary);
}

.outline-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.outline-main,
.outline-next .card,
.slide-rail,
.deck-preview-panel,
.slide-inspector {
    min-width: 0;
}

.outline-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.outline-head h2,
.finish-panel h3,
.outline-next h3 {
    font-size: 1.05rem;
    margin: 0 0 4px;
}

.outline-head p,
.outline-next p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.outline-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.outline-card {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
}

.outline-card__number {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand-accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
}

.outline-card__body {
    min-width: 0;
}

.outline-title {
    flex: 1 1 280px;
}

.outline-layout {
    flex: 0 1 210px;
}

.outline-card__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.outline-next {
    position: sticky;
    top: 84px;
}

.deck-editor-grid {
    display: grid;
    grid-template-columns: 260px minmax(420px, 1fr) 360px;
    gap: 14px;
    align-items: start;
}

.slide-rail,
.slide-inspector,
.finish-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
}

.slide-rail,
.slide-inspector {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 104px);
    overflow: auto;
}

.slide-rail__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.slide-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
}

.slide-nav-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    width: 100%;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    padding: 9px;
    text-align: left;
}

.slide-nav-card:hover,
.slide-nav-card.active {
    background: var(--bg-surface-hover);
    border-color: var(--border-subtle);
}

.slide-nav-card.active {
    border-color: var(--brand-accent);
}

.slide-nav-card__num {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand-accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
}

.slide-nav-card__meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.slide-nav-card__meta strong,
.slide-nav-card__meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slide-nav-card__meta strong {
    font-size: 0.83rem;
}

.slide-nav-card__meta small {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.slide-nav-card__ok {
    width: 14px;
    height: 14px;
    color: var(--status-success-text);
    margin-left: auto;
    flex-shrink: 0;
}

.deck-preview-panel {
    position: sticky;
    top: 84px;
}

.preview-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.preview-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.design-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 54px 54px;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.design-strip .form-control-color {
    width: 100%;
}

.inspector-card {
    display: none;
    padding: 14px;
}

.inspector-card.active {
    display: block;
}

.inspector-card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.inspector-card__head h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
}

.inspector-section {
    padding: 12px 0;
    border-top: 1px solid var(--border-subtle);
}

.inspector-section summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 600;
}

.slide-img-thumb {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.slide-img-thumb img {
    height: 46px;
    width: 64px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.visual-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 10px;
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-sm);
}

.slide-images {
    position: relative;
}

.slide-images.is-busy {
    min-height: 72px;
}

.slide-image-busy {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 600;
}

.inspector-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.finish-panel {
    margin: 12px;
    padding: 12px;
}

.finish-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 1200px) {
    .deck-editor-grid {
        grid-template-columns: 220px minmax(360px, 1fr);
    }
    .slide-inspector {
        grid-column: 1 / -1;
        position: static;
        max-height: none;
    }
}

@media (max-width: 900px) {
    .deck-steps,
    .outline-workspace,
    .deck-editor-grid {
        grid-template-columns: 1fr;
    }
    .outline-next,
    .slide-rail,
    .deck-preview-panel {
        position: static;
        max-height: none;
    }
    .slide-nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    html:focus-within { scroll-behavior: auto; }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================================================
   Fekra Production Desk shell
   ================================================================ */
.app-body {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
}

h1, h2, h3, .page-header h1 {
    font-family: 'Sora', 'Instrument Sans', sans-serif;
    letter-spacing: -0.025em;
}

h1.compact-ui-heading {
    font-family: inherit;
    letter-spacing: normal;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 1600;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    background: var(--text-primary);
    color: var(--bg-base);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-150%);
}

.skip-link:focus {
    color: var(--bg-base);
    transform: translateY(0);
}

.production-header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1100;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-subtle);
}

.production-header__bar {
    position: relative;
    height: 70px;
    display: flex;
    align-items: center;
    gap: clamp(20px, 2.5vw, 42px);
    padding: 0 clamp(20px, 3vw, 48px);
}

.production-logo-link {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 112px;
    text-decoration: none;
}

.production-logo {
    width: auto;
    max-width: 132px;
    height: 34px;
    object-fit: contain;
    object-position: left center;
}

.production-primary {
    align-self: stretch;
    display: flex;
    align-items: stretch;
    gap: 3px;
}

.production-primary__link {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 2px 13px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.production-primary__link::after {
    content: '';
    position: absolute;
    right: 13px;
    bottom: 0;
    left: 13px;
    height: 2px;
    background: var(--brand-accent);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 160ms ease;
}

.production-primary__link:hover,
.production-primary__link:focus-visible,
.production-primary__link.active {
    color: var(--text-primary);
}

.production-primary__link.active::after {
    transform: scaleX(1);
}

.production-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.production-menu-host {
    position: relative;
}

.production-action,
.production-icon-button,
.production-account,
.production-mobile-toggle {
    border: 1px solid transparent;
    color: var(--text-secondary);
    background: transparent;
    font: inherit;
}

.production-action {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
}

.production-action svg {
    width: 16px;
    height: 16px;
}

.production-action--create {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
    color: #fff;
}

.production-action--create:hover,
.production-action--create:focus-visible,
.production-action--create.active {
    border-color: var(--brand-accent-strong);
    background: var(--brand-accent-strong);
    color: #fff;
}

.production-action--quiet {
    border-color: var(--border-subtle);
}

.production-action--quiet:hover,
.production-action--quiet:focus-visible,
.production-action--quiet.active,
.production-menu-host.open > .production-action--quiet {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.production-icon-button,
.production-mobile-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-color: var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.production-icon-button svg,
.production-mobile-toggle svg {
    width: 18px;
    height: 18px;
}

.production-icon-button:hover,
.production-icon-button:focus-visible,
.production-mobile-toggle:hover,
.production-mobile-toggle:focus-visible {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.production-mobile-toggle {
    display: none;
}

.production-account {
    max-width: 190px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 9px 4px 5px;
    border-color: var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.production-account:hover,
.production-account:focus-visible,
.production-menu-host.open > .production-account {
    border-color: var(--border-strong);
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.production-account__avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(var(--brand-accent-rgb), 0.55);
    border-radius: 50%;
    background: rgba(var(--brand-accent-rgb), 0.16);
    color: #9eb6e4;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
}

[data-theme="light"] .production-account__avatar {
    color: #2f4f8e;
}

.production-account__name {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.production-account > svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}

.production-menu {
    position: absolute;
    top: calc(100% + 55px);
    right: 0;
    z-index: 1250;
    max-height: calc(100dvh - var(--topbar-height) - 20px);
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.production-menu[hidden] {
    display: none !important;
}

.production-menu--create {
    width: min(820px, calc(100vw - 40px));
}

.production-menu--more {
    width: min(700px, calc(100vw - 40px));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.production-menu--account {
    width: 278px;
}

.production-menu__intro {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 4px 7px 15px;
    border-bottom: 1px solid var(--border-subtle);
}

.production-menu__intro strong {
    color: var(--text-primary);
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
}

.production-menu__eyebrow,
.production-menu__label {
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.63rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.production-menu__columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding-top: 12px;
}

.production-menu__group {
    min-width: 0;
    padding: 6px;
}

.production-menu__label {
    display: block;
    padding: 2px 7px 8px;
}

.production-menu a,
.production-menu__signout {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 8px;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    text-align: left;
    text-decoration: none;
}

.production-menu a > svg,
.production-menu__signout > svg {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    margin-top: 2px;
    color: var(--brand-muted);
}

.production-menu a span,
.production-menu__signout span {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.production-menu a strong {
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 650;
}

.production-menu a small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.3;
}

.production-menu a:hover,
.production-menu a:focus-visible,
.production-menu__signout:hover,
.production-menu__signout:focus-visible {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    outline: none;
}

.production-menu form {
    margin: 5px 0 0;
    padding-top: 5px;
    border-top: 1px solid var(--border-subtle);
}

.production-menu__signout {
    align-items: center;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 650;
}

.production-account-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: -2px -2px 8px;
    padding: 8px 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.production-account-summary span {
    color: var(--text-muted);
    font-size: 0.68rem;
}

.production-account-summary strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.production-menu--account .sidebar-cost-badge {
    margin: 0 4px 6px !important;
    padding: 8px 7px;
    border-bottom: 1px solid var(--border-subtle);
}

.production-menu--account .sidebar-cost-badge a {
    display: block;
    padding: 2px 0;
    color: var(--text-primary);
}

.production-rail {
    height: 32px;
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 0 clamp(20px, 3vw, 48px);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-base);
}

.production-rail__desk {
    color: var(--brand-muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
}

.production-rail ol {
    position: relative;
    width: min(470px, 52vw);
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.production-rail ol::before {
    content: '';
    position: absolute;
    top: 50%;
    right: 8%;
    left: 8%;
    height: 1px;
    background: rgba(var(--brand-accent-rgb), 0.42);
}

.production-rail li {
    position: relative;
    display: flex;
    justify-content: center;
}

.production-rail li span {
    position: relative;
    padding: 0 8px;
    background: var(--bg-base);
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.61rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.production-rail li.active span {
    color: #91abe0;
}

[data-theme="light"] .production-rail li.active span {
    color: #345695;
}

.production-rail li.active span::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-accent);
    transform: translateY(-50%);
}

.production-job-dock {
    position: relative;
    width: 0;
    height: 0;
}

.production-job-dock .gen-tray {
    position: fixed;
    top: calc(var(--topbar-height) + 10px);
    right: 26px;
    width: 290px;
    margin: 0;
    padding: 9px;
    border-color: var(--border-strong);
    background: var(--bg-surface);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
}

.production-job-dock .gen-tray-item:hover {
    background: var(--bg-surface-hover);
}

.production-drawer {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1190;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(3, 5, 8, 0.72);
    cursor: pointer;
}

.sidebar-overlay.active {
    display: block;
}

.main-content {
    min-height: 100vh;
    min-height: 100dvh;
    margin-left: 0 !important;
    padding-top: var(--topbar-height);
}

body.embed-body .main-content {
    padding-top: 0;
}

.content-wrapper {
    width: 100%;
    max-width: 1440px;
    padding: 42px clamp(24px, 4vw, 58px);
}

body.app-body:has(.chat-layout) .content-wrapper {
    max-width: none;
    height: calc(100vh - var(--topbar-height)) !important;
    height: calc(100dvh - var(--topbar-height)) !important;
}

body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 1279px) {
    .production-header__bar {
        gap: 18px;
        padding-inline: 24px;
    }
    .production-primary__link {
        padding-inline: 9px;
    }
    .production-account__name {
        display: none;
    }
    .production-account {
        width: 44px;
        padding-right: 5px;
    }
    .production-account > svg {
        display: none;
    }
}

@media (max-width: 1099.98px) {
    :root {
        --topbar-height: calc(96px + env(safe-area-inset-top, 0px));
    }

    .production-header__bar {
        height: calc(64px + env(safe-area-inset-top, 0px));
        justify-content: space-between;
        padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
    }

    .production-mobile-toggle {
        display: inline-flex;
    }

    .production-header__bar > .production-logo-link {
        position: absolute;
        left: 50%;
        min-width: 0;
        transform: translateX(-50%);
    }

    .production-logo {
        max-width: 118px;
        height: 30px;
    }

    .production-primary,
    .production-actions {
        display: none;
    }

    .production-job-dock .gen-tray {
        right: 12px;
        width: min(290px, calc(100vw - 24px));
    }

    .production-rail {
        height: 32px;
        justify-content: center;
        padding-inline: 12px;
    }

    .production-rail__desk {
        display: none;
    }

    .production-rail ol {
        width: min(420px, 94vw);
    }

    .production-drawer {
        width: min(var(--sidebar-width), 92vw);
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1200;
        padding: 0 0 env(safe-area-inset-bottom, 0px);
        border: 0;
        border-right: 1px solid var(--border-strong);
        background: var(--bg-surface);
        transform: translateX(-102%);
        transition: transform 220ms ease;
        overscroll-behavior: contain;
    }

    .production-drawer.open {
        transform: translateX(0);
    }

    .production-drawer__header {
        min-height: 68px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: max(14px, env(safe-area-inset-top, 0px)) 18px 12px;
        border-bottom: 1px solid var(--border-subtle);
    }

    .production-drawer__body {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        scrollbar-width: thin;
        scrollbar-color: var(--border-strong) transparent;
    }

    .production-drawer__primary {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--border-subtle);
    }

    .production-drawer .sidebar-link {
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 9px;
        margin: 0;
        padding: 10px 11px;
        border: 1px solid transparent;
        border-radius: var(--radius-md);
        color: var(--text-secondary);
        font-size: 0.84rem;
        font-weight: 600;
        text-decoration: none;
    }

    .production-drawer .sidebar-link svg {
        width: 17px;
        height: 17px;
        flex: 0 0 17px;
        color: var(--text-muted);
    }

    .production-drawer .sidebar-link:hover,
    .production-drawer .sidebar-link:focus-visible {
        border-color: var(--border-subtle);
        background: var(--bg-surface-hover);
        color: var(--text-primary);
    }

    .production-drawer .sidebar-link.active {
        border-color: rgba(var(--brand-accent-rgb), 0.38);
        background: var(--sidebar-active-bg);
        color: #9eb6e4;
        box-shadow: none;
    }

    [data-theme="light"] .production-drawer .sidebar-link.active {
        color: #2f4f8e;
    }

    .production-drawer__section {
        padding: 19px 0 2px;
    }

    .production-drawer__section h2 {
        margin: 0 0 8px;
        padding: 0 10px;
        color: var(--text-muted);
        font-family: 'IBM Plex Mono', monospace;
        font-size: 0.64rem;
        font-weight: 600;
        letter-spacing: 0.09em;
        text-transform: uppercase;
    }

    .production-drawer__grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 3px;
    }

    .production-drawer__footer {
        padding: 13px 16px 16px;
        border-top: 1px solid var(--border-subtle);
    }

    .production-drawer__account {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
    }

    .production-drawer__account .sidebar-user-name {
        flex: 1;
        min-width: 0;
        margin: 0;
        color: var(--text-primary);
        font-size: 0.84rem;
        font-weight: 600;
    }

    .production-drawer__account .production-icon-button {
        width: 34px;
        height: 34px;
    }

    .production-drawer .btn-logout {
        justify-content: center;
        padding: 9px 14px;
        text-align: center;
    }

    .content-wrapper {
        padding: 30px 24px;
    }
}

@media (max-width: 575.98px) {
    .production-rail li span {
        padding-inline: 5px;
        font-size: 0.55rem;
    }

    .production-drawer__grid {
        grid-template-columns: 1fr;
    }

    .production-drawer__primary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-wrapper {
        padding: 24px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .production-primary__link::after,
    .production-drawer {
        transition: none;
    }
}
