/* Taleclip Web UI Styles */

:root {
    --primary: #a855f7;
    --primary-dark: #9333ea;
    --secondary: #10b981;
    --accent: #eab308;
    --bg: #0f172a;
    --bg-darker: #080c14;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --bg-sidebar: #0c0f14;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --error: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --sidebar-width: 220px;
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --border-color: var(--border);
    --bg-body: var(--bg);
    color-scheme: dark;

    /* Glass design tokens (dark) */
    --tc-glass-bg:          rgba(255, 255, 255, 0.04);
    --tc-glass-bg-hover:    rgba(255, 255, 255, 0.08);
    --tc-glass-bg-active:   rgba(255, 255, 255, 0.12);
    --tc-glass-bg-input:    rgba(255, 255, 255, 0.06);
    --tc-glass-bg-sidebar:  rgba(12, 15, 20, 0.95);
    --tc-glass-bg-topbar:   rgba(15, 23, 42, 0.85);
    --tc-glass-bg-dense:    rgba(15, 15, 30, 0.92);
    --tc-glass-border:      1px solid rgba(255, 255, 255, 0.08);
    --tc-glass-border-hover:1px solid rgba(255, 255, 255, 0.12);
    --tc-glass-border-focus:1px solid rgba(168, 85, 247, 0.5);
    --tc-glass-border-subtle:1px solid rgba(255, 255, 255, 0.04);
    --tc-glass-blur:        12px;
    --tc-glass-blur-light:  8px;
    --tc-glass-blur-heavy:  24px;
    --tc-radius-sm:         6px;
    --tc-radius-md:         10px;
    --tc-radius-lg:         16px;
    --tc-radius-xl:         24px;
    --tc-radius-pill:       9999px;
    --tc-transition-fast:   0.15s ease;
    --tc-transition-normal: 0.2s ease;
    --tc-space-1: 4px;
    --tc-space-2: 8px;
    --tc-space-3: 12px;
    --tc-space-4: 16px;
    --tc-space-6: 24px;
    --tc-space-8: 32px;
    --tc-shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.12);
    --tc-shadow-md:  0 4px 12px rgba(0, 0, 0, 0.1);
    --tc-shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Light Mode */
[data-theme="light"] {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --secondary: #059669;
    --accent: #ca8a04;
    --bg: #f8fafc;
    --bg-darker: #e2e8f0;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --bg-sidebar: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --error: #dc2626;
    --warning: #d97706;
    --success: #059669;
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --border-color: var(--border);
    --bg-body: var(--bg);
    color-scheme: light;

    /* Glass design tokens (light) — stronger borders for visibility */
    --tc-glass-bg:          rgba(255, 255, 255, 0.65);
    --tc-glass-bg-hover:    rgba(255, 255, 255, 0.8);
    --tc-glass-bg-active:   rgba(255, 255, 255, 0.9);
    --tc-glass-bg-input:    rgba(255, 255, 255, 0.7);
    --tc-glass-bg-sidebar:  rgba(241, 245, 249, 0.95);
    --tc-glass-bg-topbar:   rgba(255, 255, 255, 0.8);
    --tc-glass-bg-dense:    rgba(255, 255, 255, 0.95);
    --tc-glass-border:      1px solid #cbd5e1;
    --tc-glass-border-hover:1px solid #94a3b8;
    --tc-glass-border-focus:1px solid var(--primary);
    --tc-glass-border-subtle:1px solid rgba(0, 0, 0, 0.08);
}

/* Light mode: fix hardcoded rgba(255,255,255,...) borders/bgs */
[data-theme="light"] .sidebar {
    border-right: 1px solid var(--border);
}
[data-theme="light"] .sidebar-logo,
[data-theme="light"] .sidebar-section-header {
    border-bottom-color: var(--border);
}
[data-theme="light"] .sidebar-footer {
    border-top-color: var(--border);
}
[data-theme="light"] .nav-item:hover,
[data-theme="light"] .nav-item.active {
    background: rgba(0,0,0,0.06);
}
[data-theme="light"] .top-bar {
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .card,
[data-theme="light"] .dashboard-card {
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Color Themes (accent overrides, work in both light and dark) */
[data-color-theme="ocean"]  { --primary: #3b82f6; --primary-dark: #2563eb; }
[data-color-theme="forest"] { --primary: #22c55e; --primary-dark: #16a34a; }
[data-color-theme="sunset"] { --primary: #f97316; --primary-dark: #ea580c; }
[data-color-theme="rose"]   { --primary: #f43f5e; --primary-dark: #e11d48; }

/* Theme Toggle Switch */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    vertical-align: middle;
}
.theme-toggle input { display: none; }
.toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--tc-glass-bg-input);
    border-radius: 10px;
    border: var(--tc-glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    box-sizing: border-box;
}
.toggle-icon {
    font-size: 10px;
    line-height: 1;
    user-select: none;
}
.toggle-sun  { color: #f59e0b; }
.toggle-moon { color: #94a3b8; }
.toggle-thumb {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    transition: left 0.2s ease;
}
.theme-toggle input:checked + .toggle-track .toggle-thumb {
    left: 18px;
}

/* Color Theme Selector */
.theme-select {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: var(--tc-radius-sm);
    background: var(--tc-glass-bg-input);
    color: var(--text);
    border: var(--tc-glass-border);
    cursor: pointer;
    height: 24px;
}

/* ============================================
   NEW ARTLIST-STYLE LAYOUT
   ============================================ */

/* App Layout - Sidebar + Main */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--tc-glass-bg-sidebar);
    backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    border-right: var(--tc-glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: var(--tc-glass-border);
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.sidebar-nav {
    padding: 12px 8px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--tc-radius-md);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--tc-glass-bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: rgba(168, 85, 247, 0.15);
    color: var(--text);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Collapsible nav groups */
.nav-group-wrap {
    margin-bottom: 2px;
}
.nav-group-wrap:not(.expanded) .nav-group-items {
    display: none;
}
.nav-group-wrap.expanded .nav-group-chevron {
    transform: rotate(180deg);
}
.nav-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--tc-radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.nav-group:hover {
    background: var(--tc-glass-bg-hover);
    color: var(--text);
}
.nav-group:focus {
    outline: none;
}
.nav-group:focus-visible {
    box-shadow: 0 0 0 2px var(--primary);
}
.nav-group-chevron {
    margin-left: auto;
    font-size: 0.65rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}
.nav-group-items {
    padding-left: 12px;
    margin-left: 20px;
    border-left: var(--tc-glass-border-subtle);
}
.nav-item-child {
    padding: 10px 14px 10px 10px;
    margin-bottom: 2px;
}

.sidebar-section {
    padding: 16px;
    border-top: var(--tc-glass-border);
}

.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-add-btn {
    background: none;
    border: var(--tc-glass-border-hover);
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: var(--tc-radius-sm);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-add-btn:hover {
    background: var(--tc-glass-bg-hover);
    color: var(--text);
}

.sidebar-footer {
    padding: 16px;
    border-top: var(--tc-glass-border);
}

.sidebar-footer-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: var(--tc-glass-border);
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: var(--tc-radius-sm);
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.footer-link:hover {
    background: var(--tc-glass-bg-hover);
    color: var(--text);
}

.user-info-compact {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    font-size: 1.2rem;
}

.user-email-short {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 56px; /* Space for fixed header */
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--tc-glass-bg-topbar);
    backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    border-bottom: var(--tc-glass-border);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 56px;
    box-sizing: border-box;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title-header {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

/* Breadcrumb navigation */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
}

.breadcrumb-item:not(:last-child)::after {
    content: "›";
    margin-left: 8px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Breadcrumb on page content */
.breadcrumb-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 8px;
    margin-bottom: 20px;
}

.breadcrumb-page .breadcrumb-item {
    display: inline-flex;
    align-items: center;
    font-size: 1rem;
}

.breadcrumb-page .breadcrumb-item:not(:last-child)::after {
    content: "›";
    margin-left: 8px;
    color: var(--text-muted);
    font-weight: 400;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--tc-radius-sm);
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--tc-glass-bg-hover);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-credits-badge {
    background: rgba(168, 85, 247, 0.2);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-buy-credits {
    background: var(--accent) !important;
    color: #000 !important;
    font-weight: 600;
}

.btn-buy-credits:hover {
    background: #d4a00a !important;
}

/* Header overflow dropdown */
.header-overflow-wrap {
    position: relative;
}
.header-overflow-btn {
    padding: 8px 10px;
    font-size: 1.2rem;
    line-height: 1;
    letter-spacing: 0.05em;
}
.header-overflow-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 220px;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-heavy)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-heavy)) saturate(140%);
    border: var(--tc-glass-border-hover);
    border-radius: var(--tc-radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    padding: 6px 0;
    z-index: 200;
}
.header-overflow-wrap.open .header-overflow-dropdown {
    display: block;
}
.header-overflow-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
    text-decoration: none;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
.header-overflow-item:hover {
    background: var(--tc-glass-bg-hover);
}
.header-overflow-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}
.header-overflow-divider {
    border: none;
    border-top: var(--tc-glass-border);
    margin: 6px 0;
}
.header-overflow-admin {
    display: none;
}
.header-overflow-admin.visible {
    display: flex !important;
}

/* Profile avatar dropdown */
.profile-avatar-wrap {
    position: relative;
}
.profile-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 2px solid transparent;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 36px;
    height: 36px;
    overflow: hidden;
}
.profile-avatar-btn:hover {
    border-color: var(--tc-glass-border-color, rgba(255,255,255,0.15));
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}
.profile-avatar-wrap.open .profile-avatar-btn {
    border-color: var(--tc-primary, #8b5cf6);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.4);
}
.profile-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-avatar-placeholder .tc-avatar {
    width: 32px !important;
    height: 32px !important;
}
.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    background: var(--tc-glass-bg-dense, rgba(15, 15, 30, 0.92));
    backdrop-filter: blur(var(--tc-glass-blur-heavy, 24px)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-heavy, 24px)) saturate(140%);
    border: var(--tc-glass-border-hover, 1px solid rgba(255,255,255,0.12));
    border-radius: var(--tc-radius-lg, 16px);
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
    padding: 8px 0;
    z-index: 300;
}
.profile-avatar-wrap.open .profile-dropdown {
    display: block;
}
.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
}
.profile-dropdown-avatar {
    flex-shrink: 0;
}
.profile-dropdown-info {
    min-width: 0;
    overflow: hidden;
}
.profile-dropdown-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text, #e2e8f0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-dropdown-email {
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-dropdown-divider {
    border: none;
    border-top: var(--tc-glass-border, 1px solid rgba(255,255,255,0.08));
    margin: 4px 0;
}
.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text, #e2e8f0);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background 0.2s;
    min-height: 40px;
}
.profile-dropdown-item:hover {
    background: var(--tc-glass-bg-hover, rgba(255,255,255,0.1));
}
.profile-dropdown-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.profile-dropdown-admin {
    display: none;
}
.profile-dropdown-logout:hover {
    color: #f87171;
}

/* Creator Area */
.creator-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 32px 48px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 24px;
}

/* Creation Card */
.creation-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    border-radius: var(--tc-radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    border: var(--tc-glass-border);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mode-btn {
    background: var(--tc-glass-bg-input);
    border: 1px solid transparent;
    border-radius: var(--tc-radius-md);
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    background: var(--tc-glass-bg-hover);
}

.mode-btn.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--primary);
}

.mode-icon {
    font-size: 1.1rem;
}

.mode-tabs {
    display: flex;
    gap: 16px;
    margin-left: 8px;
}

.mode-tab {
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.mode-tab:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(0, 0, 0, 0.7);
}

.mode-tab.active {
    color: var(--text);
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--primary);
}

/* Image Upload Inline */
.image-upload-inline {
    margin-bottom: 16px;
}

.upload-dropzone {
    background: var(--tc-glass-bg-input);
    border: 2px dashed var(--border);
    border-radius: var(--tc-radius-md);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-dropzone:hover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.upload-placeholder[hidden] {
    display: none !important;
}

.image-preview-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.image-preview-container[hidden] {
    display: none !important;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

.upload-icon {
    font-size: 2rem;
    opacity: 0.6;
}

.upload-text {
    font-size: 0.9rem;
}

.image-preview-thumb {
    max-height: 150px;
    max-width: 100%;
    border-radius: 8px;
    object-fit: contain;
}

/* Override for watermark removal preview - needs larger size for mask painting */
#watermarkImagePreview.image-preview-thumb {
    max-height: none;
    max-width: none;
}

/* Prompt Input */
.prompt-input-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.prompt-input {
    width: 100%;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 16px;
    color: var(--text);
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.prompt-input:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
}

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

/* Settings Bar */
.settings-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: var(--tc-glass-border);
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-select {
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 8px 12px;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 140px;
}

.setting-select-small {
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 8px 10px;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 80px;
}

.setting-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.setting-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--tc-glass-bg-input);
    border-radius: 22px;
    transition: 0.2s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background: white;
}

.settings-spacer {
    flex: 1;
}

/* Credit Estimate Inline */
.credit-estimate-inline {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 8px 16px;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 8px;
}

.credit-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

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

/* Memory Status Indicator (near Generate button) — hidden: queue-based flow, users do not see memory stats */
#memoryStatusBar,
.memory-status-bar {
    display: none !important;
}
.memory-status-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: var(--tc-radius-sm);
    background: var(--tc-glass-bg-sidebar);
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all 0.3s;
}
.memory-status-bar.status-ok { border-left: 3px solid var(--success); }
.memory-status-bar.status-warning { border-left: 3px solid var(--warning); background: rgba(245,158,11,0.08); }
.memory-status-bar.status-critical { border-left: 3px solid var(--error); background: rgba(239,68,68,0.08); }
.memory-status-bar.status-emergency { border-left: 3px solid #dc2626; background: rgba(220,38,38,0.12); animation: memory-pulse 1s infinite; }
.memory-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.memory-status-bar.status-ok .memory-dot { background: var(--success); }
.memory-status-bar.status-warning .memory-dot { background: var(--warning); }
.memory-status-bar.status-critical .memory-dot { background: var(--error); }
.memory-status-bar.status-emergency .memory-dot { background: #dc2626; }
@keyframes memory-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Generate Button */
.btn-generate {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    color: #000;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-generate:hover {
    background: #d4a00a;
    transform: translateY(-1px);
}

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-generate.btn-queued {
    background: var(--accent-muted, #b8860b);
    opacity: 0.85;
    animation: queued-pulse 2s ease-in-out infinite;
}

@keyframes queued-pulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 0.65; }
}

.btn-icon {
    font-size: 1.1rem;
}

/* Progress Card */
.progress-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    border-radius: var(--tc-radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    border: var(--tc-glass-border);
}

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

.progress-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.progress-content {
    margin-bottom: 16px;
}

.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--tc-glass-bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

.progress-percent {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    min-width: 45px;
}

.progress-status {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.progress-segment {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Video creation progress: Elapsed, Remaining, Est. Finish, Credits */
.progress-time-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-top: 12px;
    align-items: flex-start;
}

.progress-time-info > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.progress-time-info > div > div:first-child {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-time-info > div > div:last-child {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ETA and Credit Estimation Display */
.estimation-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 16px;
    margin-top: 12px;
    padding: 12px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    font-size: 0.85rem;
}

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

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

.estimation-value {
    color: var(--text-primary);
    font-weight: 500;
    font-family: monospace;
}

.estimation-row.credits-row .estimation-value {
    color: var(--accent);
    font-weight: 600;
}

/* Result Card */
.result-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    border-radius: var(--tc-radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    border: var(--tc-glass-border);
}

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

.result-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success);
}

.result-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.result-actions .btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 4px 8px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.result-actions .btn-close:hover {
    opacity: 1;
    color: var(--text-primary);
}

.result-video-wrapper {
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 12px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.result-video {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
    max-height: 420px;
    display: block;
    object-fit: contain;
}

.result-ref-image-panel {
    flex: 0 0 38%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    border-left: 1px solid rgba(255,255,255,0.08);
    position: relative;
    overflow: hidden;
}

.result-ref-image-panel[hidden] {
    display: none !important;
}

/* When ref panel is hidden (e.g. text-to-video), video fills the wrapper — no empty black area */
.result-video-wrapper:has(.result-ref-image-panel[hidden]) .result-video,
.result-video-wrapper:not(:has(.result-ref-image-panel:not([hidden]))) .result-video {
    width: 100%;
    max-width: 100%;
}

.result-ref-label {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
    z-index: 1;
}

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

.result-meta {
    display: flex;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Result Prompt Display */
.result-prompt {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    border: var(--tc-glass-border);
}

.result-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.result-prompt-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.result-prompt-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.result-prompt .btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 1rem;
}

.result-prompt .btn-icon:hover {
    background: var(--bg-lighter);
}

/* Result Image - Thumbnail style */
.result-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.result-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.result-content {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
}

.result-content .click-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.result-content:hover .click-hint {
    opacity: 1;
}

.btn-download {
    background: var(--success) !important;
    color: white !important;
}

/* Gallery Section */
.gallery-section {
    margin-top: 32px;
}

.gallery-tabs {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    border-bottom: var(--tc-glass-border);
    padding-bottom: 12px;
}

.gallery-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    position: relative;
    transition: color 0.2s;
}

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

.gallery-tab.active {
    color: var(--text);
}

.gallery-tab.active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.gallery-item {
    position: relative;
    border-radius: var(--tc-radius-md);
    overflow: hidden;
    aspect-ratio: 16/9;
    background: var(--tc-glass-bg);
    cursor: pointer;
    transition: transform 0.2s;
}

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

.gallery-item img,
.gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Admin Drawer */
.admin-drawer {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    padding: 12px 24px;
    border-bottom: var(--tc-glass-border);
}

.admin-drawer-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar .nav-label,
    .sidebar .logo-text,
    .sidebar-section-header span,
    .sidebar-add-btn,
    .user-email-short {
        display: none;
    }

    .sidebar-logo {
        justify-content: center;
        padding: 16px 8px;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 60px;
    }

    .creator-area {
        padding: 20px 16px;
    }

    .settings-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-spacer {
        display: none;
    }

    .btn-generate {
        width: 100%;
        justify-content: center;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 24px 0;
}

header h1 {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ComfyUI Status */
.comfyui-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 14px;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    border-radius: var(--tc-radius-xl);
    font-size: 0.85rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.status-indicator.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-indicator.offline {
    background: var(--error);
}

.status-indicator.starting {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.8rem;
    background: var(--tc-glass-bg);
    color: var(--text);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.btn-small:hover,
.btn-small:active {
    background: var(--tc-glass-bg-hover);
}

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

.btn-small.btn-stop {
    background: var(--error);
    border-color: var(--error);
}

.btn-small.btn-stop:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-small.btn-start {
    background: var(--success);
    border-color: var(--success);
}

.btn-small.btn-start:hover {
    background: #059669;
    border-color: #059669;
}

.btn-small.btn-restart-app {
    background: #a855f7;
    border-color: #a855f7;
    margin-left: 8px;
}

.btn-small.btn-restart-app:hover {
    background: #9333ea;
    border-color: #9333ea;
}

.btn-small.btn-screenshot {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.4);
    padding: 8px 10px;
}

.btn-small.btn-screenshot:hover {
    background: rgba(168, 85, 247, 0.4);
    border-color: rgba(168, 85, 247, 0.6);
}

.btn-small.btn-admin {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #000;
    font-weight: 600;
    text-decoration: none;
}

.btn-small.btn-admin:hover {
    background: #d97706;
    border-color: #d97706;
}

/* Admin System Toggle Button */
.btn-small.btn-system-toggle {
    background: rgba(100, 116, 139, 0.2);
    border-color: rgba(100, 116, 139, 0.4);
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 4px 10px;
}

.btn-small.btn-system-toggle:hover {
    background: rgba(100, 116, 139, 0.3);
    border-color: rgba(100, 116, 139, 0.5);
    color: #cbd5e1;
}

.btn-small.btn-system-toggle.active {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.btn-small.btn-system-toggle .toggle-icon {
    font-size: 0.9rem;
}

.btn-small.btn-system-toggle .toggle-text {
    font-weight: 500;
}

/* Voice select row with preview button */
.voice-select-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.voice-select-row select {
    flex: 1;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--tc-radius-md);
    border: var(--tc-glass-border);
    background: var(--tc-glass-bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

.btn-preview-voice .preview-icon {
    font-size: 12px;
}

.btn-preview-voice.playing {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-preview-voice.playing .preview-icon::before {
    content: "■";
}

/* Label row with clear button */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.label-row label {
    margin-bottom: 0;
}

.btn-clear {
    width: 24px;
    height: 24px;
    font-size: 12px;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
}

.btn-clear:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-clear-all {
    width: 36px;
    height: 36px;
    font-size: 16px;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear-all:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

/* Dashboard */
.dashboard-section {
    margin-bottom: 12px;
}

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

.dashboard-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    border-radius: var(--tc-radius-md);
    padding: 8px;
    border: var(--tc-glass-border);
}

.dashboard-card h3 {
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 4px;
    text-align: center;
}

.gauge-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gauge {
    width: 70px;
    height: 44px;
}

.gauge-value {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    white-space: nowrap;
}

.gauge-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
}

.gauge-unit {
    font-size: 0.5rem;
    color: var(--text-muted);
    margin-left: 1px;
}

.gauge-label {
    margin-top: 1px;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-align: center;
}

.chart-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chart-header {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.chart-card canvas {
    width: 100% !important;
    height: 35px !important;
    background: rgba(0, 100, 200, 0.1);
    border-radius: 4px;
}

/* Tab Navigation - Grouped by Category */
.tab-nav-grouped {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

/* Tab Section */
.tab-section {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tab-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: var(--tc-glass-border);
    margin-bottom: 4px;
}

.section-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tab-section-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Legacy single-row tab nav (kept for compatibility) */
.tab-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    padding: 6px;
    border-radius: var(--tc-radius-md);
    margin-bottom: 20px;
    border: var(--tc-glass-border);
    overflow: visible;
    position: relative;
}

.tab-nav::-webkit-scrollbar {
    display: none;
    height: 0;
}


.tab-btn {
    flex: none;
    min-width: 0;
    padding: 10px 12px;
    background: transparent;
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
}

/* Grouped tabs show full text */
.tab-nav-grouped .tab-btn {
    width: 100%;
    text-align: center;
}

/* Gallery Button - Full Width Below Menu */
.gallery-button-container {
    margin-bottom: 20px;
}

.gallery-tab-btn {
    width: 100%;
    background: var(--tc-glass-bg);
    border: var(--tc-glass-border);
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--tc-radius-md);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.gallery-tab-btn:hover {
    background: var(--tc-glass-bg-hover);
    border: var(--tc-glass-border-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.gallery-tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
}

/* Mobile responsive for grouped navigation */
@media (max-width: 768px) {
    .tab-nav-grouped {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .section-title {
        font-size: 0.75rem;
    }
    
    .tab-btn {
        font-size: 0.8rem;
        padding: 8px 10px;
    }
    
    .gallery-tab-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .tab-nav-grouped {
        grid-template-columns: 1fr;
    }
    
    .tab-section-content {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
}

/* Legacy grid nav uses shortened labels via ::after */
.tab-nav .tab-btn {
    font-size: 0;
}

.tab-nav .tab-btn::after {
    font-size: 0.8rem;
    display: inline-block;
}

.tab-nav .tab-btn[data-tab="create-video"]::after { content: "Create"; }
.tab-nav .tab-btn[data-tab="talking-avatar"]::after { content: "Avatar"; }
.tab-nav .tab-btn[data-tab="edit-image"]::after { content: "Edit"; }
.tab-nav .tab-btn[data-tab="merge-videos"]::after { content: "Merge"; }
.tab-nav .tab-btn[data-tab="gallery"]::after { content: "Gallery"; }
.tab-nav .tab-btn[data-tab="enhance-photo"]::after { content: "Enhance"; }
.tab-nav .tab-btn[data-tab="narrate"]::after { content: "Narrate"; }
.tab-nav .tab-btn[data-tab="prompt-engineer"]::after { content: "Prompt"; }

.tab-btn:hover {
    color: var(--text);
    background: var(--tc-glass-bg-hover);
    border: var(--tc-glass-border-hover);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

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

/* Live Log Section */
.log-section {
    margin-bottom: 16px;
}

.log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.log-header:hover {
    background: var(--tc-glass-bg-hover);
}

.log-header.expanded {
    border-radius: 10px 10px 0 0;
    border-bottom: none;
}

.log-icon {
    font-size: 1.1rem;
}

.log-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}

.log-badge {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.log-toggle {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.log-header.expanded .log-toggle {
    transform: rotate(180deg);
}

.log-content {
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    border: var(--tc-glass-border);
    border-top: none;
    border-radius: 0 0 var(--tc-radius-md) var(--tc-radius-md);
    overflow: hidden;
}

.log-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--tc-glass-bg-sidebar);
    border-bottom: var(--tc-glass-border);
}

.log-autoscroll {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.log-autoscroll input {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.log-output {
    margin: 0;
    padding: 12px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    color: #c9d1d9;
    background: transparent;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-output::-webkit-scrollbar {
    width: 8px;
}

.log-output::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.log-output::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.log-output .log-time {
    color: #6e7681;
}

.log-output .log-info {
    color: #58a6ff;
}

.log-output .log-success {
    color: #3fb950;
}

.log-output .log-warning {
    color: #d29922;
}

.log-output .log-error {
    color: #f85149;
}

.log-output .log-progress {
    color: #a371f7;
}

.card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur)) saturate(140%);
    border-radius: var(--tc-radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: var(--tc-glass-border);
}

.card h2 {
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: var(--text);
}

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

.card-header h2 {
    margin-bottom: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    transition: color 0.2s;
}

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

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
}

/* Two-column equal layout when form-row has form-groups */
.form-row > .form-group {
    margin-bottom: 0;
}

.form-row:has(.form-group + .form-group) {
    grid-template-columns: 1fr 1fr;
}

/* Input row with button */
.input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-row input {
    flex: 1;
}

.input-row .btn {
    white-space: nowrap;
}

/* Field hints */
.field-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
    margin-bottom: 12px;
}

.field-hint.success {
    color: #10b981;
}

input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    color: var(--text);
    font-size: 16px; /* Prevents iOS zoom on focus */
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
textarea:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
}

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

.hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.text-to-video-info {
    display: block;
    padding: 8px 12px;
    margin-top: 8px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 6px;
    color: #a5b4fc;
    font-size: 0.85rem;
}

/* Prompt input with optimize button */
.prompt-input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.prompt-input-wrapper textarea {
    flex: 1;
    padding-right: 50px;
}

.btn-optimize {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-optimize:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-optimize:active {
    transform: scale(0.95);
}

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

.btn-optimize .optimize-icon {
    line-height: 1;
}

.btn-optimize .optimize-loading {
    font-size: 14px;
    animation: pulse 0.5s infinite;
}

/* Upload Area */
.upload-area {
    border: 2px dashed rgba(148,163,184,0.15);
    border-radius: var(--tc-radius-md);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.upload-area:hover,
.upload-area:active {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.1);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.2);
}

.clipboard-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--tc-glass-bg);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clipboard-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(168, 85, 247, 0.3);
}

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

.clipboard-icon {
    font-size: 1.2rem;
    display: block;
}

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

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 10px;
}

.image-preview {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 0;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    padding: 4px;
    width: fit-content;
}

.mode-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--tc-radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

/* Multi-Image Upload */
.multi-image-upload-area {
    border: 2px dashed rgba(148,163,184,0.15);
    border-radius: var(--tc-radius-md);
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.multi-image-upload-area:hover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.1);
}

.multi-image-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.2);
}

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

.multi-image-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.multi-image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--tc-radius-md);
    overflow: hidden;
    background: var(--tc-glass-bg-input);
}

.multi-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.multi-image-item .image-number {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.multi-image-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.multi-image-item:hover .remove-btn {
    opacity: 1;
}

.multi-image-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Audio Options */
.audio-options {
    background: var(--tc-glass-bg-input);
    padding: 16px;
    border-radius: var(--tc-radius-md);
    margin-top: 8px;
}

/* Video Model Selection */
.model-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 10px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-sm);
    font-size: 0.85rem;
}

.model-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-badge.local,
.model-badge.included {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.model-badge.cloud,
.model-badge.premium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.model-specs {
    color: var(--text-muted);
    font-size: 0.8rem;
}

#videoModel optgroup {
    font-weight: 600;
    color: var(--primary);
}

#videoModel option {
    padding: 8px;
}

.audio-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: var(--tc-glass-border);
}

.audio-option-row {
    margin-bottom: 12px;
}

.audio-option-row:last-child {
    margin-bottom: 0;
}

.music-option {
    padding-top: 12px;
    border-top: var(--tc-glass-border);
}

.music-option label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.music-option select {
    width: 100%;
    padding: 10px 12px;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.music-option select:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
}

.music-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    margin-bottom: 0;
    font-style: italic;
}

.lip-sync-option {
    padding: 12px;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.lip-sync-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 6px 0 0 30px;
    font-style: italic;
}

.lip-sync-method-wrapper {
    margin-top: 10px;
    margin-left: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lip-sync-method-wrapper label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.lip-sync-method-wrapper select {
    flex: 1;
    max-width: 300px;
}

/* Talking Avatar Section */
.avatar-section {
    max-width: 800px;
    margin: 0 auto;
}

.avatar-voice-settings h4,
.avatar-lipsync-settings h4 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.voice-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.voice-option {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.voice-option label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.voice-option-wide {
    grid-column: span 2;
}

.avatar-lipsync-settings {
    margin-top: 16px;
    padding-top: 16px;
    border-top: var(--tc-glass-border);
}

.avatar-lipsync-settings select {
    max-width: 400px;
}

.lip-sync-method-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
}

.avatar-progress {
    margin-top: 20px;
}

.avatar-status {
    display: block;
    text-align: center;
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.avatar-result {
    margin-top: 24px;
    padding-top: 24px;
    border-top: var(--tc-glass-border);
}

.avatar-result h3 {
    margin: 0 0 16px 0;
    text-align: center;
}

.avatar-result-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

/* Character Dialogue Section */
.dialogue-section {
    background: var(--tc-glass-bg);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 16px;
    margin-top: 16px;
}

.dialogue-section label {
    color: var(--accent);
    font-weight: 600;
}

.dialogue-section textarea {
    margin-top: 8px;
    margin-bottom: 4px;
}

.dialogue-options {
    margin-top: 12px;
    padding-top: 12px;
    border-top: var(--tc-glass-border);
}

.dialogue-voice-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.dialogue-voice-row .voice-option {
    flex: 1;
    min-width: 120px;
}

.dialogue-voice-row label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.dialogue-voice-row select {
    width: 100%;
}

/* Image analysis status indicator */
.analysis-status {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(168, 85, 247, 0.9);
    color: white;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    animation: pulse 1.5s ease-in-out infinite;
    z-index: 10;
}

.analysis-status.success {
    background: rgba(34, 197, 94, 0.9);
    animation: none;
}

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

@media (max-width: 600px) {
    .voice-options-grid {
        grid-template-columns: 1fr 1fr;
    }

    .voice-option-wide {
        grid-column: span 2;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-text {
    font-size: 0.95rem;
    color: var(--text);
}

.voice-select-wrapper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: var(--tc-glass-border);
}

.voice-select-wrapper label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.voice-select-wrapper select {
    width: 100%;
    padding: 10px 12px;
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.voice-select-wrapper select:focus {
    outline: none;
    border: var(--tc-glass-border-focus);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    min-height: 52px;
}

.btn-primary:hover:not(:disabled),
.btn-primary:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
}

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

.btn-secondary {
    background: var(--tc-glass-bg);
    color: var(--text);
    border: var(--tc-glass-border);
    min-height: 48px;
}

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--tc-glass-bg-hover);
}

.btn-danger {
    display: inline-block;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--error);
    color: white;
    min-height: 48px;
}

.btn-danger:hover,
.btn-danger:active {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

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

.stop-generation {
    margin-top: 20px;
    text-align: center;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-loading[hidden],
.btn-text[hidden] {
    display: none !important;
}

/* Progress Section */
.status-message {
    padding: 14px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    margin-bottom: 16px;
    font-size: 0.95rem;
    word-break: break-word;
}

.progress-container {
    margin-bottom: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 10px;
    background: var(--tc-glass-bg-input);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Completed Scenes Thumbnails (shown during generation) */
.completed-scenes-section {
    margin-bottom: 20px;
}

.completed-scenes-section .card {
    padding: 16px;
}

.completed-scenes-section h3 {
    font-size: 1rem;
    margin: 0 0 8px 0;
    color: var(--secondary);
}

.completed-scenes-section .hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 16px 0;
}

.completed-scenes {
    margin: 16px 0;
    padding: 16px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    border: var(--tc-glass-border);
}

.completed-scenes h3 {
    font-size: 0.95rem;
    margin: 0 0 12px 0;
    color: var(--secondary);
}

.completed-scenes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.completed-scene-card {
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light)) saturate(140%);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    overflow: hidden;
    animation: fadeSlideIn 0.4s ease;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.completed-scene-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(16, 185, 129, 0.15);
    border-bottom: var(--tc-glass-border);
}

.scene-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.scene-status {
    color: var(--secondary);
    font-size: 0.9rem;
}

.completed-scene-video {
    position: relative;
    cursor: pointer;
    aspect-ratio: 16/9;
    background: #000;
}

.completed-scene-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scene-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    transition: all 0.2s;
    pointer-events: none;
}

.completed-scene-video:hover .scene-play-overlay {
    background: rgba(168, 85, 247, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.scene-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 4px;
    pointer-events: none;
}

.completed-scene-desc {
    padding: 8px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    max-height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Live scene feedback buttons */
.live-scene-feedback-btns {
    display: flex;
    gap: 4px;
}

.live-fb-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.7;
}

.live-fb-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.live-fb-btn.thumbs-up.active {
    background: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.6);
    opacity: 1;
}

.live-fb-btn.thumbs-down.active {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
    opacity: 1;
}

.completed-scene-card.approved {
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.2);
}

.completed-scene-card.flagged {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

/* Live scene comment section */
.live-scene-comment {
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.live-scene-comment textarea {
    width: 100%;
    min-height: 50px;
    padding: 6px;
    font-size: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 4px;
    color: var(--text);
    resize: vertical;
    margin-bottom: 6px;
}

.live-scene-comment textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.live-scene-comment .btn-small {
    width: 100%;
    padding: 6px;
    font-size: 0.75rem;
    background: var(--primary);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.live-scene-comment .btn-small:hover {
    background: var(--primary-hover);
}

/* Live feedback toast */
.live-feedback-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(34, 197, 94, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    animation: slideInRight 0.3s ease;
}

.live-feedback-toast.fade-out {
    animation: slideOutRight 0.3s ease forwards;
}

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

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

/* Narrative display */
.narrative-display {
    margin-bottom: 16px;
    padding: 14px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    border-left: 3px solid var(--primary);
}

.narrative-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.narrative-header h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

.narrative-text {
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.btn-copy {
    background: transparent;
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-sm);
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--tc-glass-bg);
    color: var(--text);
    border: var(--tc-glass-border-focus);
}

.btn-copy .copy-success {
    color: var(--success);
}

.scene-list h3,
.current-segment h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.scene-list ul {
    list-style: none;
}

.scene-list li {
    padding: 10px 12px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-sm);
    margin-bottom: 6px;
    font-size: 0.85rem;
    border-left: 3px solid rgba(148,163,184,0.08);
    word-break: break-word;
}

.scene-list li.active {
    border-left-color: var(--primary);
    background: rgba(168, 85, 247, 0.2);
}

.scene-list li.complete {
    border-left-color: var(--success);
}

.current-segment {
    margin-top: 16px;
    padding: 14px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
}

#currentDescription {
    margin-bottom: 10px;
    font-size: 0.9rem;
    word-break: break-word;
}

.sampling-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.mini-progress {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.2s;
    width: 0%;
}

/* Result Section */
.video-container {
    margin-bottom: 14px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

.video-container video {
    width: 100%;
    display: block;
    max-height: 60vh;
}

.video-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.video-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.video-actions .btn-secondary,
.video-actions .btn-primary {
    flex: 1;
    min-width: 120px;
    text-align: center;
    text-decoration: none;
}

.video-actions .btn-primary {
    width: auto;
}

/* Gallery */
.video-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.gallery-item {
    position: relative;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
    touch-action: manipulation;
}

/* Gallery quick action button */
.gallery-item-action {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.25);
  color: #e2e8f0;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.gallery-item-action:hover {
  background: rgba(37, 99, 235, 0.35);
}

/* Gallery item overlay */
.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease;
}

.gallery-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Gallery bulk selection toolbar */
.gallery-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 10px 0 14px 0;
}

.btn-sm {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 0.9rem;
}

/* Gallery selection checkboxes - always visible */
.gallery-item.selected,
.photo-item.selected {
  outline: 2px solid rgba(34, 197, 94, 0.85);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
}

.gallery-select-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid rgba(148, 163, 184, 0.6);
  color: transparent;
  font-size: 12px;
  font-weight: bold;
  z-index: 11;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(6px);
}

.gallery-select-check:hover {
  border-color: rgba(168, 85, 247, 0.8);
  background: rgba(168, 85, 247, 0.2);
}

.gallery-select-check.checked {
  background: rgba(34, 197, 94, 0.95);
  border-color: rgba(34, 197, 94, 1);
  color: #fff;
}

.gallery-item:hover,
.gallery-item:active {
    transform: scale(1.02);
}

.gallery-item video,
.gallery-item .gallery-thumb {
    width: 100%;
    height: 100px;
    object-fit: cover;
    background: #000;
}

.gallery-item-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    touch-action: manipulation;
    z-index: 10;
}

.gallery-item:hover .gallery-item-delete {
    opacity: 1;
}

.gallery-item-delete:hover {
    background: rgba(220, 38, 38, 1);
}

/* Photo Gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.photo-item {
    position: relative;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
    touch-action: manipulation;
    aspect-ratio: 1;
}

.photo-item:hover,
.photo-item:active {
    transform: scale(1.02);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    touch-action: manipulation;
    z-index: 10;
}

.photo-item:hover .photo-item-delete {
    opacity: 1;
}

.photo-item-delete:hover {
    background: rgba(220, 38, 38, 1);
}

.photo-item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    font-size: 0.7rem;
    color: white;
}

/* Audio Assets Gallery — compact accordion list */
.audio-assets-gallery {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audio-asset-item {
    display: flex;
    flex-direction: column;
    background: var(--tc-glass-bg-input, rgba(255,255,255,0.04));
    border-radius: var(--tc-radius-md, 10px);
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.audio-asset-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.audio-asset-item.selected {
    outline: 2px solid rgba(34, 197, 94, 0.85);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
}

/* Compact single-line row */
.audio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 44px;
    min-width: 0;
}

.audio-row .gallery-select-check {
    position: relative;
    top: auto;
    left: auto;
    flex-shrink: 0;
}

/* Circular play / collapse button */
.audio-play-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.25);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #fff;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    padding: 0;
    line-height: 1;
}

.audio-play-btn:hover {
    background: rgba(99, 102, 241, 0.45);
    border-color: rgba(99, 102, 241, 0.7);
}

.audio-play-btn.playing {
    background: rgba(16, 185, 129, 0.3);
    border-color: rgba(16, 185, 129, 0.6);
}

.audio-source-badge {
    flex-shrink: 0;
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.68rem;
    color: #fff;
    font-weight: 500;
}

/* Track name — fills remaining space */
.audio-track-name {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Date + size — right-aligned, de-emphasized */
.audio-track-meta {
    flex-shrink: 0;
    font-size: 0.72rem;
    opacity: 0.55;
    white-space: nowrap;
}

.audio-asset-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.audio-asset-actions .gallery-btn {
    text-decoration: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    border: none;
}

.audio-asset-actions .gallery-btn:hover {
    background: rgba(255,255,255,0.1);
}

.audio-asset-actions .gallery-item-delete {
    position: relative;
    top: auto;
    right: auto;
}

/* Expandable player — shown when a track is opened */
.audio-expand-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.07);
    background: rgba(0,0,0,0.12);
}

.audio-expand-panel audio {
    flex: 1;
    min-width: 0;
    height: 36px;
}

.audio-speed-select {
    flex-shrink: 0;
    width: 62px;
    padding: 3px 4px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: inherit;
    cursor: pointer;
    text-align: center;
}

.audio-speed-select:hover {
    border-color: rgba(255,255,255,0.3);
}

.audio-speed-select:focus {
    outline: 2px solid rgba(99, 102, 241, 0.5);
    outline-offset: 1px;
}

/* Photo lightbox */
.photo-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

/* Video lightbox (gallery) */
.video-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.video-lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 92vw;
    max-height: 92vh;
}

.video-lightbox-content video {
    width: min(1100px, 92vw);
    max-height: calc(92vh - 80px);
    background: rgba(0,0,0,0.6);
    border-radius: 10px;
}

.video-lightbox-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.video-lightbox-actions .btn-primary,
.video-lightbox-actions .btn-secondary {
    min-width: 120px;
}

.photo-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.photo-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--tc-glass-bg);
    backdrop-filter: blur(var(--tc-glass-blur-light));
    -webkit-backdrop-filter: blur(var(--tc-glass-blur-light));
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-lightbox-close:hover {
    background: var(--primary);
}

.photo-lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 90vw;
    max-height: 90vh;
}

.photo-lightbox-content img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: 8px;
}

.photo-lightbox-actions {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
    justify-content: center;
    margin-bottom: 20px;
}

.photo-lightbox-actions .btn-primary,
.photo-lightbox-actions .btn-secondary {
    min-width: 120px;
}

/* Edit Result Lightbox */
.edit-result-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease-in;
}

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

.edit-result-lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-result-lightbox-content img {
    max-width: 100%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.edit-result-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

.edit-result-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.gallery-item-info {
    padding: 8px 10px;
    font-size: 0.8rem;
}

.gallery-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.gallery-item-date {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.empty-message {
    color: var(--text-muted);
    text-align: center;
    padding: 30px 20px;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* Image Edit Section */
.edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.edit-grid.single {
    grid-template-columns: 1fr;
}

.edit-input,
.edit-output {
    display: flex;
    flex-direction: column;
}

.edit-output {
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.edit-output .image-preview {
    max-height: 300px;
    width: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: opacity 0.2s;
}

.edit-output .image-preview:hover {
    opacity: 0.9;
}

.edit-actions {
    margin-bottom: 16px;
}

.edit-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
}

.edit-progress .progress-bar {
    flex: 1;
}

.edit-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.edit-result-actions {
    display: flex;
    gap: 10px;
}

.edit-result-actions .btn-secondary {
    flex: 1;
}

/* Video Concatenation */
.concat-upload-area {
    border: 2px dashed rgba(148,163,184,0.15);
    border-radius: var(--tc-radius-md);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
    touch-action: manipulation;
}

.concat-upload-area:hover,
.concat-upload-area:active,
.concat-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.1);
}

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

.concat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    min-height: 0;
    margin-bottom: 16px;
}

.concat-grid:empty {
    display: none;
}

.concat-item {
    position: relative;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    overflow: hidden;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
    touch-action: none;
}

.concat-item:hover {
    transform: scale(1.02);
}

.concat-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.concat-item.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

.concat-item video {
    width: 100%;
    height: 90px;
    object-fit: cover;
    background: #000;
    pointer-events: none;
}

.concat-item-info {
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.concat-item-order {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.concat-item-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.concat-item-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    touch-action: manipulation;
}

.concat-item:hover .concat-item-remove,
.concat-item:active .concat-item-remove {
    opacity: 1;
}

.concat-info {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--tc-glass-bg-input);
    border-radius: var(--tc-radius-md);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

#concatCount {
    color: var(--text);
    font-weight: 500;
}

#concatDuration {
    color: var(--secondary);
    font-weight: 600;
}

.concat-actions {
    display: flex;
    gap: 10px;
}

.concat-actions .btn-secondary {
    flex: 0 0 auto;
    padding: 12px 16px;
}

.concat-actions .btn-primary {
    flex: 1;
}

/* Drag placeholder */
.concat-placeholder {
    background: rgba(168, 85, 247, 0.2);
    border: 2px dashed var(--primary);
    border-radius: 10px;
    min-height: 130px;
}

/* ==================== VIDEO MAIN MODE TOGGLE ==================== */

.video-main-mode-toggle {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    padding: 8px;
    background: var(--tc-glass-bg);
    border-radius: var(--tc-radius-md);
    border: var(--tc-glass-border);
}

.main-mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--tc-radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.main-mode-btn:hover {
    background: var(--tc-glass-bg-hover);
    color: var(--text);
}

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

.main-mode-btn .mode-icon {
    font-size: 18px;
}

/* ==================== VIDEO ENHANCEMENT ==================== */

.video-enhance-upload {
    margin-bottom: 24px;
}

.video-enhance-upload .upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.video-enhance-upload .upload-dropzone:hover,
.video-enhance-upload .upload-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.1);
}

.video-enhance-upload .upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.video-enhance-upload .upload-hint {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 8px;
}

.video-enhance-preview {
    margin-bottom: 24px;
}

.video-enhance-preview .preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 16px;
}

.video-enhance-preview .preview-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
}

.video-enhance-preview .preview-box h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.video-enhance-preview .preview-box video {
    width: 100%;
    border-radius: 8px;
    background: #000;
}

.video-enhance-preview .preview-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.video-enhance-preview .preview-info {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.video-enhance-options {
    margin-bottom: 24px;
}

.video-enhance-options h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
}

.video-enhance-options .options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.video-enhance-options .option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.video-enhance-options .option-group label {
    font-size: 13px;
    color: var(--text-muted);
}

.video-enhance-options .option-group.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.video-enhance-options .option-group.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.video-enhance-options .option-group.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.video-enhance-options .form-select {
    padding: 10px 12px;
    border-radius: var(--tc-radius-md);
    border: var(--tc-glass-border);
    background: var(--tc-glass-bg-input);
    color: var(--text);
    font-size: 14px;
}

.video-enhance-options .form-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    cursor: pointer;
}

.video-enhance-progress {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.video-enhance-progress .progress-status {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.video-enhance-progress .progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.video-enhance-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.video-enhance-progress .progress-detail {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.video-enhance-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.video-enhance-actions .btn-primary {
    flex: 1;
    min-width: 200px;
}

.video-enhance-actions .btn-secondary {
    flex: 0 0 auto;
}

/* Page subtitle */
.page-subtitle {
    color: var(--text-muted);
    font-size: 16px;
    margin-top: -8px;
    margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .video-enhance-preview .preview-container {
        grid-template-columns: 1fr;
    }

    .video-enhance-options .options-grid {
        grid-template-columns: 1fr;
    }
}

/* Gallery drag hint */
.gallery-item.draggable {
    cursor: grab;
}

.gallery-item.draggable:active {
    cursor: grabbing;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.processing {
    animation: pulse 1.5s infinite;
}

/* ============================================
   TABLET BREAKPOINT (768px and below)
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header {
        padding: 20px 0;
    }

    header h1 {
        font-size: 1.9rem;
    }

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

    .video-gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    /* Tabs - tablet: 4x2 grid layout */
    .tab-nav {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        padding: 5px !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
        overflow-x: visible !important;
    }
    
    .tab-nav::after {
        display: none !important;
    }

    .tab-btn {
        padding: 8px 10px !important;
        font-size: 0 !important;
        flex: none !important;
        min-width: 0 !important;
    }
    
    .tab-btn::after {
        font-size: 0.75rem !important;
        display: inline-block !important;
    }
    
    .tab-btn[data-tab="create-video"]::after { content: "Create" !important; }
    .tab-btn[data-tab="talking-avatar"]::after { content: "Avatar" !important; }
    .tab-btn[data-tab="generate-image"]::after { content: "Generate" !important; }
    .tab-btn[data-tab="edit-image"]::after { content: "Edit" !important; }
    .tab-btn[data-tab="merge-videos"]::after { content: "Merge" !important; }
    .tab-btn[data-tab="gallery"]::after { content: "Gallery" !important; }
    .tab-btn[data-tab="enhance-photo"]::after { content: "Enhance" !important; }
    .tab-btn[data-tab="narrate"]::after { content: "Narrate" !important; }
    .tab-btn[data-tab="prompt-engineer"]::after { content: "Prompt" !important; }
}

/* ============================================
   MOBILE BREAKPOINT (480px and below)
   ============================================ */
@media (max-width: 480px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 12px;
    }

    header {
        padding: 16px 0;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .comfyui-status {
        font-size: 0.8rem;
        padding: 6px 12px;
        gap: 6px;
    }

    #comfyuiStatusText {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Compact dashboard for mobile - 2x2 grid */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .dashboard-card {
        padding: 6px 5px;
        border-radius: 8px;
    }

    .dashboard-card h3 {
        font-size: 0.65rem;
        margin-bottom: 3px;
    }

    .gauge {
        width: 50px;
        height: 31px;
    }

    .gauge-value {
        top: 16px;
    }

    .gauge-number {
        font-size: 0.6rem;
    }

    .gauge-unit {
        font-size: 0.45rem;
    }

    .gauge-label {
        font-size: 0.5rem;
    }

    .chart-card canvas {
        height: 25px !important;
    }

    .chart-header {
        font-size: 0.55rem;
    }

    .card {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 14px;
    }

    .card h2 {
        font-size: 1.1rem;
        margin-bottom: 14px;
    }

    .form-group {
        margin-bottom: 14px;
    }

    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }

    .upload-area {
        padding: 24px 16px;
    }

    .upload-icon {
        font-size: 2rem;
    }

    .image-preview {
        max-height: 200px;
    }

    .mode-toggle {
        width: 100%;
    }

    .mode-btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .multi-image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .multi-image-item .image-number {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
    }

    .multi-image-item .remove-btn {
        width: 18px;
        height: 18px;
        font-size: 12px;
        opacity: 1;
    }

    .btn-primary {
        padding: 14px 20px;
        min-height: 50px;
    }

    .btn-secondary {
        padding: 12px 16px;
        min-height: 46px;
        font-size: 0.9rem;
    }

    .video-actions {
        flex-direction: column;
        gap: 8px;
    }

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

    .gallery-item {
        border-radius: 8px;
    }

    .gallery-item video,
    .gallery-item .gallery-thumb {
        height: 80px;
    }

    .gallery-item-delete {
        opacity: 1;
        width: 22px;
        height: 22px;
    }

    .gallery-item-info {
        padding: 6px 8px;
    }

    .gallery-item-name {
        font-size: 0.75rem;
    }

    .gallery-item-date {
        font-size: 0.7rem;
    }

    /* Edit section mobile */
    .edit-grid {
        grid-template-columns: 1fr;
    }

    .edit-output {
        min-height: 150px;
    }

    .edit-result-actions {
        flex-direction: column;
        gap: 8px;
    }

    /* Concat mobile */
    .concat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .concat-item video {
        height: 70px;
    }

    .concat-item-info {
        padding: 6px;
    }

    .concat-item-order {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .concat-item-remove {
        opacity: 1;
        width: 22px;
        height: 22px;
    }

    .concat-info {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .concat-actions {
        flex-direction: column;
        gap: 8px;
    }

    .concat-actions .btn-secondary,
    .concat-actions .btn-primary {
        flex: none;
        width: 100%;
    }

    .scene-list li {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .status-message {
        padding: 12px;
        font-size: 0.9rem;
    }

    footer {
        padding: 20px 0;
        font-size: 0.75rem;
    }

    /* Tabs - mobile: 2x4 grid layout */
    .tab-nav {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        padding: 4px !important;
        gap: 3px !important;
        border-radius: 10px !important;
        margin-bottom: 14px !important;
        overflow-x: visible !important;
        flex-wrap: nowrap !important;
    }
    
    .tab-nav::after {
        display: none !important;
    }

    .tab-btn {
        padding: 9px 6px !important;
        border-radius: 6px !important;
        min-width: 0 !important;
        font-size: 0 !important; /* Hide original text */
        flex: none !important;
    }
    
    /* Shorter labels for mobile */
    .tab-btn::after {
        font-size: 0.7rem !important;
        line-height: 1.2 !important;
        display: inline-block !important;
    }
    
    .tab-btn[data-tab="create-video"]::after { content: "Create" !important; }
    .tab-btn[data-tab="talking-avatar"]::after { content: "Avatar" !important; }
    .tab-btn[data-tab="generate-image"]::after { content: "Generate" !important; }
    .tab-btn[data-tab="edit-image"]::after { content: "Edit" !important; }
    .tab-btn[data-tab="merge-videos"]::after { content: "Merge" !important; }
    .tab-btn[data-tab="gallery"]::after { content: "Gallery" !important; }
    .tab-btn[data-tab="enhance-photo"]::after { content: "Enhance" !important; }
    .tab-btn[data-tab="narrate"]::after { content: "Narrate" !important; }
    .tab-btn[data-tab="prompt-engineer"]::after { content: "Prompt" !important; }
}

/* ============================================
   LARGE PHONE (iPhone Pro Max, etc - 430px and below)
   ============================================ */
@media (max-width: 430px) {
    .tab-nav {
        padding: 4px !important;
        gap: 3px !important;
    }

    .tab-btn {
        padding: 9px 4px !important;
    }
    
    .tab-btn::after {
        font-size: 0.68rem !important;
    }
}

/* ============================================
   SMALL MOBILE (360px and below)
   ============================================ */
@media (max-width: 360px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .comfyui-status {
        flex-direction: column;
        gap: 4px;
    }

    #comfyuiStatusText {
        max-width: none;
    }

    .dashboard-grid {
        gap: 4px;
    }

    .gauge {
        width: 43px;
        height: 27px;
    }

    .gauge-value {
        top: 14px;
    }

    .gauge-number {
        font-size: 0.5rem;
    }

    .chart-card canvas {
        height: 20px !important;
    }

    .card {
        padding: 12px;
    }

    .video-gallery {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* Tabs - very small mobile */
    .tab-nav {
        padding: 3px !important;
        gap: 2px !important;
    }

    .tab-btn {
        padding: 8px 3px !important;
    }
    
    .tab-btn::after {
        font-size: 0.65rem !important;
    }
}

/* ============================================
   LANDSCAPE MODE ON MOBILE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 10px 0;
    }

    header h1 {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .dashboard-section {
        margin-bottom: 8px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .dashboard-card {
        padding: 5px;
    }

    .gauge {
        width: 40px;
        height: 25px;
    }

    .gauge-value {
        top: 13px;
    }

    .gauge-number {
        font-size: 0.5rem;
    }

    .chart-card canvas {
        height: 20px !important;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .video-container video {
        max-height: 40vh;
    }

    .image-preview {
        max-height: 150px;
    }
}

/* ============================================
   SAFE AREA INSETS (for notched phones)
   ============================================ */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   DARK MODE PREFERENCE (already dark, but ensures consistency)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

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

    .progress-fill,
    .mini-progress-fill {
        transition: none;
    }
}

/* Conversation Section */
#conversationSection {
    margin-top: 20px;
    margin-bottom: 20px;
}

#conversationSection label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

.conversation-messages {
    background: var(--tc-glass-bg-input);
    border: var(--tc-glass-border);
    border-radius: var(--tc-radius-md);
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.conversation-message {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: var(--tc-radius-md);
    animation: fadeIn 0.3s ease-out;
}

.conversation-message:last-child {
    margin-bottom: 0;
}

.conversation-message.ai {
    background: rgba(168, 85, 247, 0.1);
    border-left: 3px solid var(--primary);
}

.conversation-message.user {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--secondary);
    margin-left: 20px;
}

.message-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
    opacity: 0.7;
}

.message-label.ai {
    color: var(--primary);
}

.message-label.user {
    color: var(--secondary);
}

.message-content {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.conversation-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.conversation-input-wrapper textarea {
    flex: 1;
    min-height: 60px;
}

.conversation-input-wrapper button {
    min-width: 120px;
    white-space: nowrap;
}

/* Optimized Prompt Section */
#optimizedPromptSection {
    margin-top: 20px;
    padding: 16px;
    background: rgba(168, 85, 247, 0.05);
    border-radius: var(--tc-radius-md);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

#optimizedPromptSection .label-row {
    margin-bottom: 8px;
}

#optimizedPromptSection label {
    color: var(--primary);
    font-weight: 600;
}

#optimizedPrompt {
    background: var(--tc-glass-bg);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

#optimizedPrompt:focus {
    border: var(--tc-glass-border-focus);
    outline: none;
}

