/* Charm Image Studio - Full Width Layout */

:root {
    --bg-dark: #09090b;
    --bg-panel: #121215;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);
}

/* PWA Window Controls Overlay - Hide Title Bar */
@supports (app-region: drag) {
    body {
        /* Allow window to be dragged from the top area */
        padding-top: env(titlebar-area-height, 0px);
    }

    /* Full-width overlay to HIDE the "Charm Studio" title text */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: env(titlebar-area-height, 0px);
        background: var(--bg-dark);
        -webkit-app-region: drag;
        app-region: drag;
        z-index: 10000;
        pointer-events: auto;
    }
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
}

/* Main Container */
.app-container {
    display: grid;
    /* Default widths */
    --left-w: 340px;
    --right-w: 340px;
    /* 5-column grid: Left | Handle | Center | Handle | Right */
    grid-template-columns: var(--left-w) 4px 1fr 4px var(--right-w);
    height: calc(100vh - 40px);
    /* Subtract status bar height */
    min-width: 0;
    overflow: hidden;
}

/* Resizer Handles */
.resizer {
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s, box-shadow 0.2s;
    z-index: 999;
}

.resizer:hover,
.resizer.dragging {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* Responsive adjustments - Update Variables Only */
@media (min-width: 1400px) {
    .app-container {
        --left-w: 380px;
        --right-w: 380px;
    }
}

@media (max-width: 1100px) {
    .app-container {
        --left-w: 300px;
        --right-w: 300px;
    }
}

@media (max-width: 900px) {
    .app-container {
        --left-w: 260px;
        --right-w: 260px;
    }
}

/* === LEFT PANEL === */
.left-panel {
    /* Modern: Gradient fade from transparent top to panel color */
    background: linear-gradient(180deg,
            rgba(18, 18, 21, 0) 0px,
            rgba(18, 18, 21, 0.3) 60px,
            rgba(18, 18, 21, 0.95) 120px,
            var(--bg-panel) 150px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0 1.25rem 1.5rem 1.25rem;
    gap: 0;
    overflow: hidden;
    height: 100%;
    min-width: 0;
}

.header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    padding: 0 0 0 0;
    /* Only top padding for alignment, no bottom */
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    text-align: center;
    margin: 0;
    letter-spacing: -0.02em;
}

.footer .credit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Control Groups */
.control-group {
    display: flex;
    flex-direction: column;
}

/* Make the prompt control-group grow to fill available space - REMOVED */
.tab-content .control-group:nth-child(2) {
    display: flex;
    flex-direction: column;
}

.control-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

textarea#prompt {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 0.75rem;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 140px;
}

textarea#prompt:focus {
    outline: none;
    border-color: var(--accent);
}

.dropdown-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.dropdown-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Model Selector - iOS Segmented Control Style */
.model-selector {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 0;
}

.model-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 0.4rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

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

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

.model-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(168, 85, 247, 0.3) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.unload-btn {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.unload-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.unload-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Spinner for buttons */
.spinner-tiny {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Prompt Enhancer */
.prompt-wrapper {
    position: relative;
    width: 100%;
}

.prompt-wrapper textarea {
    width: 100%;
    min-height: 140px;
}

/* Music Studio Textareas - match dark theme */
#music-title,
#music-prompt,
#music-lyrics,
#video-prompt {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.dropdown-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.video-aspect-ratio-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 480px) {
    .video-aspect-ratio-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.video-aspect-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    min-height: 64px;
}

.video-ratio-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.video-ratio-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

#video-tab .video-aspect-btn span:last-child {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    line-height: 1;
}

.video-resolution-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.video-resolution-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 8px 10px;
}

.video-resolution-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.video-resolution-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

#video-tab .video-resolution-btn span:last-child {
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    line-height: 1;
}

#music-title {
    min-height: 36px;
    max-height: 36px;
    resize: none;
}

#music-prompt {
    min-height: 80px;
}

#music-lyrics {
    min-height: 160px;
}

#music-title:focus,
#music-prompt:focus,
#music-lyrics:focus {
    outline: none;
    border-color: var(--accent);
}

.enhance-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid var(--accent);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
    z-index: 10;
}

.enhance-btn:hover {
    background: var(--accent);
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 0 15px var(--accent);
}

.enhance-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.enhance-btn.spinning {
    animation: magic-spin 1s infinite linear;
}

@keyframes magic-spin {
    from {
        transform: rotate(0deg) scale(1.1);
    }

    to {
        transform: rotate(360deg) scale(1.1);
    }
}

.generate-btn {
    width: 100%;
    padding: 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.generate-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
}

.generate-btn:disabled {
    background: var(--accent);
    color: white;
    opacity: 1;
    cursor: wait;
}

/* Generate Row - for button + style indicator */
.generate-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* Live Prompt Preview */
.prompt-preview {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 8px;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-height: 60px;
    overflow-y: auto;
}

.prompt-preview .preview-label {
    color: var(--accent);
    font-weight: 600;
    margin-right: 6px;
}

.prompt-preview .preview-text {
    color: var(--text-primary);
    word-break: break-word;
}

/* Active Style Indicator */
.style-indicator {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(168, 85, 247, 0.2));
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.style-indicator:hover {
    background: rgba(139, 92, 246, 0.5);
    transform: scale(1.05);
}

/* Tabs */
.tabs-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    /* Required for flex scrolling */
}

.tab-header {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    margin: 1rem auto 1.5rem auto;
    width: fit-content;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 7px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.tab-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.18s ease, filter 0.18s ease;
}

.tab-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.tab-label {
    letter-spacing: 0.01em;
}

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

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

.tab-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(168, 85, 247, 0.3) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.tab-btn.active .tab-icon {
    transform: scale(1.06);
    filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.45));
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding-right: 1rem;
    margin-right: 0.5rem;
    flex-direction: column;
    gap: 2rem;
    min-height: 0;
}

.tab-content.active {
    display: flex;
}

/* Section Labels */
.section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

/* Prompt Group (Prompt + Generate tightly coupled) */
.prompt-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prompt-group .generate-btn {
    margin-top: 0;
}

/* Settings Styling */
/* Settings Styling */
.setting-row {
    margin-bottom: 1.25rem;
}

/* Compact Controls Row - Steps/CFG/Seed - iOS Style Container */
.controls-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
}

.control-compact {
    flex: 1;
    min-width: 0;
}

.control-compact label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.control-compact input[type="range"] {
    width: 100%;
    margin: 0;
}

/* Seed Control */
.seed-control {
    flex: 1.2;
}

.seed-input-row {
    display: flex;
    gap: 4px;
}

.seed-input-row input[type="number"] {
    flex: 1;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    -moz-appearance: textfield;
    appearance: textfield;
}

.seed-input-row input[type="number"]::-webkit-outer-spin-button,
.seed-input-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.seed-input-row input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.seed-random-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.seed-random-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent);
}

.seed-random-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

.setting-row label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}



.value-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
}

/* Style Presets (Sidebar) - iOS Style */
.style-presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
}

.style-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

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

.style-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(168, 85, 247, 0.3) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

input[type="range"] {
    width: calc(100% - 8px);
    margin-left: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
    margin-top: 8px;
    margin-bottom: 8px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.size-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-wrapper {
    position: relative;
    flex: 1;
}

.input-wrapper span {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 0.4rem 0.4rem 1.4rem;
    color: white;
    font-size: 0.85rem;
}

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



/* Gallery Grid */
.gallery-header {
    margin-bottom: 12px;
    display: flex;
    justify-content: flex-end;
}

.sync-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sync-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: var(--accent);
}

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

.gallery-item {
    aspect-ratio: 1;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid transparent;
}

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

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

.empty-gallery {
    grid-column: span 2;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2rem 0;
}

/* Footer (Left Panel) */
.footer {
    margin-top: auto;
    padding: 1rem 1.5rem 0.5rem 0;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.footer-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    margin: 0 0 0.5rem 0;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.footer p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0.25rem 0;
}

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

/* Unified Panel Header (Used across Left, Center, Right) */
.brand-header-unified {
    height: 90px;
    min-height: 90px;
    max-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 10px;
    margin-bottom: 5px;
    align-items: center;
    text-align: center;
    /* Modern: Subtle gradient fade instead of solid border */
    border-bottom: none;
    background: transparent;
    width: 100%;
    margin: 0;
    padding: 15px 0 10px 0;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Subtle bottom fade instead of hard line */
    position: relative;
}

.brand-header-unified h2 {
    font-size: 1.75rem;
    margin-bottom: 2px;
}

.brand-header-unified p {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

/* Center panel header needs extra room for title + creation tabs above divider */
.center-brand-header {
    height: auto;
    min-height: 130px;
    max-height: none;
    justify-content: flex-start;
    gap: 10px;
    padding-top: 12px;
}

.center-header-top-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 16px;
}

.center-header-top-row .footer-title {
    justify-self: center;
}

.center-header-spacer {
    justify-self: start;
}

.top-signout-btn {
    justify-self: end;
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(220, 38, 38, 0.45);
    color: #fecaca;
    border-radius: 10px;
    height: 34px;
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.top-signout-btn:hover {
    background: rgba(220, 38, 38, 0.28);
    color: #fff;
    border-color: rgba(239, 68, 68, 0.7);
    box-shadow: 0 6px 18px rgba(220, 38, 38, 0.24);
}

.top-signout-btn:active {
    transform: translateY(1px);
}

.center-brand-header .tab-header {
    margin: 0 auto;
}

@media (max-width: 900px) {
    .center-header-top-row {
        grid-template-columns: auto 1fr;
        gap: 10px;
        padding: 0 10px;
    }

    .center-header-spacer {
        display: none;
    }

    .center-header-top-row .footer-title {
        justify-self: start;
        text-align: left;
    }

    .top-signout-btn {
        padding: 0 10px;
        font-size: 0.78rem;
        height: 32px;
    }
}

.panel-header-compact {
    align-items: flex-start;
    text-align: left;
    padding: 14px 18px 8px 18px;
    justify-content: center;
    gap: 2px;
}

.panel-header-right {
    padding-left: 24px;
}

.panel-kicker {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    font-weight: 700;
    opacity: 0.8;
}

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

.panel-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.panel-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #d7ccff;
    border: 1px solid rgba(139, 92, 246, 0.45);
    background: rgba(139, 92, 246, 0.14);
}

.panel-chip-live {
    color: #b9ffd5;
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.12);
}

/* In normal chat show online pulse; show LIVE chip only when live mode is active */
.panel-header-right .status-dot.online {
    display: inline-block;
}

.panel-header-right .panel-chip-live {
    display: none;
}

.chat-sidebar.live-active .panel-header-right .panel-chip-live {
    display: inline-flex;
}

.chat-fullscreen-btn {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.chat-fullscreen-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.15);
}

body.chat-fullscreen-active .chat-sidebar.chat-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    z-index: 110000;
    border-left: none;
    padding: 0 1.25rem 1rem 1.25rem;
    overflow: hidden;
    background: linear-gradient(180deg,
            rgba(18, 18, 21, 0.95) 0px,
            rgba(18, 18, 21, 0.98) 120px,
            var(--bg-panel) 200px);
}

body.chat-fullscreen-active #status-bar {
    display: none;
}

body.chat-fullscreen-active .chat-sidebar.chat-fullscreen .chat-log {
    min-height: 0;
}

/* Fullscreen chat: keep model selector compact inside the toolbox row */
body.chat-fullscreen-active .chat-sidebar.chat-fullscreen .chat-tools-row {
    justify-content: flex-end;
}

body.chat-fullscreen-active .chat-sidebar.chat-fullscreen .model-select-tool {
    flex: 0 0 auto;
    width: min(280px, 30vw);
    min-width: 180px;
}

body.chat-fullscreen-active .chat-sidebar.chat-fullscreen .hf-chat-model-container {
    left: auto;
    right: 0;
    width: min(520px, 58vw);
    max-width: 100%;
    padding: 8px;
}

/* Terminal Header Enhancements */
.terminal-title {
    opacity: 0.8;
    letter-spacing: 0.02em;
}

.terminal-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.terminal-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

.terminal-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: #888;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.terminal-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.unload-vram-btn {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.05);
}

.unload-vram-btn:hover {
    color: #ff5555;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.vram-icon {
    font-size: 14px;
}



.brand-header-unified .footer-title {
    margin: 0 0 2px 0 !important;
    line-height: 1.1;
    display: block;
}

.brand-header-unified p {
    margin: 0 !important;
    font-size: 0.8rem;
    opacity: 0.7;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Status Indicator Light */
.status-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    /* Default Red (Offline) */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    display: inline-block;
    transition: all 0.5s ease;
}

.status-light.online {
    background: #10b981;
    /* Green (Online) */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
    animation: pulse-green 2s infinite;
}

.status-light.loading {
    background: #f59e0b;
    /* Amber (Loading) */
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
    animation: pulse-amber 1.5s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes pulse-amber {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.footer.brand-header {
    margin-top: 0;
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0 1rem 0;
    margin-bottom: 0.5rem;
}

.center-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    /* Center Canvas */
    height: 100%;
}

/* === RIGHT PANEL (Chat) === */
.right-panel {
    display: flex;
    flex-direction: column;
    /* Modern: Gradient fade from transparent top to panel color */
    background: linear-gradient(180deg,
            rgba(18, 18, 21, 0) 0px,
            rgba(18, 18, 21, 0.3) 60px,
            rgba(18, 18, 21, 0.95) 120px,
            var(--bg-panel) 150px);
    border-left: 1px solid var(--border-color);
    height: 100%;
    min-width: 0;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 0 1.25rem 1.5rem 1.25rem;
    gap: 0;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s;
}

/* Chat panel should sit flush to the bottom edge above the global status bar. */
.chat-sidebar {
    padding-bottom: 0.2rem;
}

.right-panel.drag-active {
    background: rgba(139, 92, 246, 0.05);
    border-left: 2px solid var(--accent);
    box-shadow: inset 10px 0 30px rgba(139, 92, 246, 0.1);
}

.canvas-container {
    width: 100%;
    flex: 1;
    /* Fill remaining space below header */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.canvas-container img {
    max-width: 100%;
    max-height: 80vh !important;
    /* Strictly limit height to leave room for toolbar */
    object-fit: contain;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    z-index: 10;
    /* Checkerboard pattern for transparent images */
    background-image:
        linear-gradient(45deg, #333 25%, transparent 25%),
        linear-gradient(-45deg, #333 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #333 75%),
        linear-gradient(-45deg, transparent 75%, #333 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #444;
}

/* Wrapper for Image + Overlays */
.image-wrapper {
    position: relative;
    display: inline-block;
    /* Hugs the image size */
    max-width: 100%;
    line-height: 0;
}

.image-wrapper img {
    display: block;
    /* Ensure existing styles apply nicely */
    max-width: 100%;
    max-height: 80vh !important;
    border-radius: 4px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.image-overlays {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    z-index: 20;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
}

.image-wrapper:hover .image-overlays {
    opacity: 1;
    transform: translateY(0);
}

.overlay-btn {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 48px;
    /* Increased size */
    height: 48px;
    /* Increased size */
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.5rem;
    /* Larger icons */
    margin-left: 8px;
}

/* Save Button - Green */
.overlay-btn:first-child {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.5);
}

.overlay-btn:first-child:hover {
    background: rgba(16, 185, 129, 0.9);
    border-color: #10b981;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

/* Delete Button - Red */
.overlay-btn:last-child {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

.overlay-btn:last-child:hover {
    background: rgba(239, 68, 68, 0.9);
    border-color: #ef4444;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.placeholder-content {
    text-align: center;
    color: var(--text-muted);
    opacity: 0.5;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* Generating State - No animation, just static style */
.generate-btn.generating {
    animation: none;
    /* Explicitly disable pulsing animation */
}

/* Floating Elements */
.floating-progress {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 21, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    min-width: 120px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.2s ease-out;
}

#progress-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.floating-actions {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.badge {
    background: rgba(0, 0, 0, 0.6);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.action-btn {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}

.action-btn.danger:hover {
    background: #dc2626;
    border-color: #ef4444;
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.3);
}

.seed-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-label-icon {
    font-size: 0.8rem;
    opacity: 0.7;
}

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

/* Scrollbars - Unified Global Style */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    /* Increased visibility */
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background 0.2s;
    min-height: 50px;
    /* Enforce consistent handle size */
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
    background-clip: content-box;
}

/* Floating Toolbar (Bottom Center) - Anchored to bottom bar */
.floating-toolbar {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 21, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 8px 16px;
    border-radius: 12px 12px 0 0;
    /* Rounded top only */
    border: 1px solid var(--border-color);
    border-bottom: none;
    /* No bottom border - touches status bar */
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
    z-index: 9999 !important;
    max-width: calc(100% - 2rem);
    flex-wrap: wrap;
    justify-content: center;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Aspect + Size Grouped Together */
.aspect-size-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Reference Images Section */
.ref-images-section {
    margin-bottom: 12px;
}

.ref-images-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

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

.ref-label-right {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.cloud-count-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
}

.cloud-count-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cloud-count-btn {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cloud-count-btn:hover {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.18);
}

.cloud-count-value {
    min-width: 16px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ref-images-area {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.ref-images-grid {
    display: flex;
    gap: 8px;
}

.ref-thumb {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

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

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

.ref-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ref-remove:hover {
    background: rgba(239, 68, 68, 0.9);
}

.add-ref-btn {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.add-ref-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.add-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.add-text {
    font-size: 8px;
    font-weight: 500;
}

.ref-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: center;
    font-style: italic;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-divider {
    width: 100%;
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* Aspect Icons in Toolbar */
/* Unified Aspect Ratio Dropdown */
.aspect-selector {
    /* position: relative; Removed to center dropdown on parent toolbar */
}

.aspect-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.aspect-toggle:hover {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
}

.aspect-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.aspect-icon svg {
    stroke: var(--accent);
}

.aspect-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 2px;
}

.aspect-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 21, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    min-width: 160px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.aspect-dropdown.open {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.dropdown-item svg {
    stroke: var(--text-muted);
    flex-shrink: 0;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.dropdown-item:hover svg {
    stroke: var(--text-primary);
}

.dropdown-item.active {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent);
}

.dropdown-item.active svg {
    stroke: var(--accent);
}

.ratio-desc {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: auto;
}

/* Resolution Selector (Pro model) */
.resolution-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.res-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.res-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.res-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

/* Compact Inputs */
.size-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.compact-input input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 6px 6px;
    width: 70px;
    /* Increased from 54px to fit 4-digit numbers */
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.compact-input input:focus {
    border-color: var(--accent);
    outline: none;
}

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

/* Compact Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.compact-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compact-slider-row label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    width: 45px;
    display: flex;
    justify-content: space-between;
}

.compact-slider-row input[type="range"] {
    flex: 1;
    height: 3px;
    margin: 0;
}

.compact-slider-row input[type="range"]::-webkit-slider-thumb {
    width: 10px;
    height: 10px;
}

/* Integrated Progress in Toolbar */
.progress-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

/* Pulsing glow effect for progress area during generation */
.progress-group.pulsing {
    animation: progress-pulse 1.5s ease-in-out infinite;
    background: rgba(139, 92, 246, 0.1);
}

@keyframes progress-pulse {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
        background: rgba(139, 92, 246, 0.1);
    }

    50% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.6), 0 0 30px rgba(139, 92, 246, 0.3);
        background: rgba(139, 92, 246, 0.2);
    }
}

/* Gallery Info Bar (Shown when viewing gallery images) */
.gallery-info-bar {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-info-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    overflow: hidden;
}

.gallery-info-prompt {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: color 0.2s;
}

.gallery-info-prompt:hover {
    color: var(--accent);
}

.gallery-info-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.info-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    white-space: nowrap;
}

.info-tag.model {
    color: var(--accent);
}

.info-tag.size {
    color: #10b981;
}

.info-tag.seed {
    color: #f59e0b;
}

#progress-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.mini-progress-track {
    width: 60px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

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

/* Floating Controls - Bottom Left */
.floating-controls-left {
    position: absolute;
    bottom: 1.5rem;
    left: 1.5rem;
    background: rgba(18, 18, 21, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 180px;
}

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

.floating-controls-left label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    min-width: 50px;
}

.floating-controls-left input[type="range"] {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
}

.floating-controls-left input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.floating-controls-left input[type="number"] {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 6px 8px;
    width: 70px;
    text-align: center;
    font-size: 0.8rem;
}

.floating-controls-left input[type="number"]:focus {
    border-color: var(--accent);
    outline: none;
}

.value-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 24px;
    text-align: right;
}

/* Bigger Aspect Buttons */
.aspect-group .aspect-icon-btn {
    padding: 8px 10px;
}

/* ============================================
   LIGHTBOX VIEWER
   ============================================ */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
}

.lightbox-container.dragging {
    cursor: grabbing;
}

.lightbox-container.zoomed-out {
    cursor: default;
}

.lightbox-image-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    transition: transform 0.15s ease-out;
    will-change: transform;
}

.lightbox-image-wrapper.no-transition {
    transition: none;
}

.lightbox-image-wrapper img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    user-select: none;
    -webkit-user-drag: none;
}

/* Lightbox Toolbar */
.lightbox-toolbar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 21, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.lightbox-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Audiobook Workspace Specifics */
.panel-box {
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel-box:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Chapter list and Textarea now use global scrollbar styles */

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

.lightbox-btn.primary:hover {
    background: var(--accent-hover);
}

.lightbox-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.5);
}

.lightbox-zoom-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 50px;
    text-align: center;
}

.lightbox-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

/* Lightbox Close Button */
.lightbox-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background: rgba(18, 18, 21, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: scale(1.05);
}

/* Lightbox Navigation */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2002;
    /* Above image */
    backdrop-filter: blur(4px);
}

.lightbox-nav:hover {
    background: rgba(139, 92, 246, 0.5);
    border-color: var(--accent);
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

/* Lightbox Close Button */
.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2002;
    backdrop-filter: blur(4px);
}

.lightbox-close:hover {
    background: rgba(239, 68, 68, 0.5);
    border-color: #ef4444;
}

/* Lightbox Metadata */
.lightbox-meta {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(18, 18, 21, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    max-width: 350px;
    z-index: 1001;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.lightbox-meta.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.meta-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
}

.lightbox-meta:hover .meta-close {
    opacity: 1;
}

.meta-close:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.lightbox-meta-prompt {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.lightbox-meta-details {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lightbox-meta-details span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   CONSENT MODAL
   ============================================ */
.consent-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.consent-overlay.active {
    opacity: 1;
    visibility: visible;
}

.consent-modal {
    background: linear-gradient(145deg, rgba(30, 30, 35, 0.98), rgba(18, 18, 21, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(139, 92, 246, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.consent-overlay.active .consent-modal {
    transform: scale(1) translateY(0);
}

.consent-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.consent-modal h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(90deg, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.consent-modal p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.consent-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.consent-btn {
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

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

.consent-btn.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.consent-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.consent-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Gallery Item Enhancement for persistence indicator */
.gallery-item.saved::after {
    content: '💾';
    position: absolute;
    bottom: 6px;
    right: 6px;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    padding: 2px 4px;
}

.gallery-item {
    position: relative;
}

/* === CHAT TAB STYLES === */
.chat-log {
    flex: 1;
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    /* Removed background/border to be seamless */
    background: transparent;
    border: none;
    border-radius: 0;
    /* Custom Scrollbar for Chat Log */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* Items start from top, fill down */
    overflow-anchor: auto;
    /* Browser scroll anchoring */
    gap: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
    scroll-behavior: smooth;
}

/* Failsafe: prevent any rogue images from breaking layout */
.chat-log img {
    max-width: 180px;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
}

.chat-message {
    padding: 0.4rem 0;
    word-wrap: break-word;
}

.chat-message strong {
    color: var(--accent);
    margin-right: 0.4rem;
    font-weight: 700;
}

.user-message {
    color: var(--text-primary);
}

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

.model-message {
    color: #e9d5ff;
    /* Light purple for Charm */
}

.system-message {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    text-align: center;
    margin: 1rem 0;
}

.chat-input-area {
    position: relative;
    display: flex;
    flex-direction: column;
    margin-top: auto;
    /* Anchor to bottom */
    gap: 0.75rem;
    /* Restore gap to prevent overlap */
    padding-top: 5px;
    /* Minimal top padding to compensate for gap */
    border-top: 1px solid var(--border-color);
    width: 100%;
}

.chat-tools-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
    padding: 0 1px;
    /* minimal padding to prevent clipping but stay flush */
    overflow: visible;
}

.model-select-tool {
    flex: 1;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    padding: 0 12px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    appearance: none;
    /* simple styling */
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%239CA3AF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
    padding-right: 32px;
    /* space for arrow */
    min-width: 130px;
    /* Keep readable while allowing tools row to fit on smaller sidebars */
}

.model-select-tool:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.model-select-tool:focus {
    border-color: var(--accent);
    color: white;
}

/* HuggingFace Chat Model Input (appears as drop-up above the tools row) */
.hf-chat-model-container {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 8px;
    padding: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.hf-model-input {
    width: 100%;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0 12px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s;
}

.hf-model-input:focus {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
}

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

.tools-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}



#chat-input {
    flex: 1;
    background: transparent !important;
    /* Force transparent */
    border: none !important;
    /* Force no border */
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0;
    padding: 0 0 0.5rem 0;
    /* No top padding (match flush), add bottom padding */
    color: color-mix(in srgb, var(--text-primary), white 10%);
    /* Brighter text */
    font-size: 0.95rem;
    transition: none;
    /* Remove border transition */
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    /* Allow scroll if it hits max-height */
    min-height: 86px;
    /* Start at 3 lines height */
    max-height: 300px;
    /* Increased from 200px */
    line-height: 1.5;
}

#chat-input:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    min-width: 40px;
    max-width: 40px;
    min-height: 40px;
    max-height: 40px;
    line-height: 1;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

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

.send-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}



/* Chat Image Preview (Pasted/Attached) */
.chat-image-preview {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
    max-width: 100%;
}

.chat-image-preview img {
    max-height: 100px;
    max-width: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.remove-image-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    position: absolute;
    top: -8px;
    right: -8px;
}

.remove-image-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

/* Chat Log Attached Image */
.chat-attached-image {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: 8px;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
}

/* Animated Typing Dots */
.typing-dots::after {
    content: '';
    animation: typingDots 1.4s infinite;
}

@keyframes typingDots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75% {
        content: '...';
    }

    100% {
        content: '';
    }
}

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

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(16px);
}

/* Mic Button Styling */
.mic-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mic-btn.recording {
    color: var(--text-secondary);
    border-color: rgba(239, 68, 68, 0.85) !important;
    background: rgba(239, 68, 68, 0.06) !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.45);
    animation: none !important;
}

@keyframes mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
        text-shadow: 0 0 0 rgba(239, 68, 68, 0);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.0);
        text-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        text-shadow: 0 0 0 rgba(239, 68, 68, 0);
    }
}

.mic-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 86%;
    height: 86%;
    background: rgba(239, 68, 68, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s ease;
    z-index: -1;
}

.mic-btn.recording::after {
    display: none;
}

.mic-btn.transcribing {
    color: var(--text-secondary) !important;
    border-color: rgba(34, 197, 94, 0.75) !important;
    background: rgba(34, 197, 94, 0.06) !important;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.45);
    animation: none !important;
}

.mic-btn.transcribing::after {
    display: none;
}

/* Gemini Live Mode Styles */
.live-btn {
    transition: all 0.3s ease;
    position: relative;
}

.live-btn.active {
    color: #fff !important;
    background: var(--accent) !important;
    animation: live-pulse-btn 2s infinite ease-in-out;
}

@keyframes live-pulse-btn {

    0%,
    100% {
        box-shadow: 0 0 10px var(--accent);
    }

    50% {
        box-shadow: 0 0 25px var(--accent), 0 0 40px var(--accent);
    }
}

.live-switcher {
    position: relative;
    display: inline-flex;
}

.provider-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    font-size: 0.58rem;
    line-height: 16px;
    font-weight: 700;
    text-align: center;
    color: #fff;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.35);
    pointer-events: auto;
    cursor: pointer;
}

.provider-overlay {
    position: absolute;
    right: 0;
    bottom: 48px;
    display: none;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(10, 10, 14, 0.98);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
    z-index: 200;
}

.provider-overlay.active {
    display: flex;
}

.provider-option {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.18s ease;
}

.provider-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.provider-option.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent);
    color: #fff;
}

.live-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.chat-sidebar.live-active .live-overlay {
    opacity: 1;
}

.live-visualizer {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    z-index: 10;
}

.chat-sidebar.live-active .live-visualizer {
    display: flex;
}

/* Hide placeholder text when live mode is active */
.chat-sidebar.live-active #chat-input::placeholder {
    color: transparent;
}

.viz-bar {
    width: 4px;
    height: 10px;
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.1s ease;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Custom Confirmation Modal */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.custom-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.custom-modal {
    background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 16px;
    width: 300px;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.custom-modal.signout-modal {
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    border-radius: 16px;
    width: min(340px, 90vw);
    padding: 14px 16px 18px 16px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 40px rgba(139, 92, 246, 0.3),
        0 0 80px rgba(139, 92, 246, 0.15);
}

.custom-modal.signout-modal h3 {
    font-size: 1.65rem;
    font-weight: 700;
    margin: 12px 0 6px 0;
}

.custom-modal.signout-modal p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 14px 0;
}

.custom-modal.signout-modal .confirm-icon-wrap {
    width: min(170px, 48vw);
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
}

.custom-modal.signout-modal .confirm-icon-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: none;
    border-radius: 10px;
    box-shadow: none;
}

.custom-modal.signout-modal .modal-actions {
    margin-top: auto;
}

.custom-modal-overlay.active .custom-modal {
    transform: scale(1);
}

.custom-modal h3 {
    margin: 0 0 0.5rem 0;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
}

.custom-modal p {
    margin: 0 0 1.5rem 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.confirm-icon-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.confirm-icon-wrap img {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

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

.modal-btn {
    flex: 1;
    padding: 0.7rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.modal-btn.cancel {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.12);
}

.modal-btn.confirm {
    background: rgba(220, 38, 38, 0.2);
    color: #f87171;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.modal-btn.confirm:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* Voice Toggle Icon */
.voice-toggle-icon {
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.3;
    filter: grayscale(100%);
    transition: all 0.2s ease;
    user-select: none;
}

.voice-toggle-icon:hover {
    opacity: 0.6;
}

#chat-auto-read:checked+.voice-toggle-icon {
    opacity: 1;
    filter: none;
    transform: scale(1.05);
}

/* Animated Generation Placeholder */
/* Animated Generation Placeholder (Cyber Scan Effect) */
.generation-placeholder {
    /* Aspect ratio is set via JS for reference, but dimensions are calculated explicitly */
    aspect-ratio: var(--gen-aspect, 16 / 9);
    /* Dimensions are set explicitly via JavaScript based on container size */
    background-color: #1a1a1a;
    /* Cyber grid pattern */
    background-image:
        linear-gradient(rgba(139, 92, 246, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 92, 246, 0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    background-position: center;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.15), inset 0 0 20px rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.4);
    margin: auto;
    position: relative;
    overflow: hidden;
}

/* The neon scanline */
.generation-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(139, 92, 246, 0.1) 40%,
            rgba(139, 92, 246, 0.6) 50%,
            rgba(139, 92, 246, 0.1) 60%,
            transparent 100%);
    animation: cyber-scan 2s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
    filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0.8));
}

@keyframes cyber-scan {
    0% {
        transform: translateY(-120%);
    }

    100% {
        transform: translateY(120%);
    }
}

/* Terminal Input Area */
.terminal-input-area {
    background: #0a0a0a;
    border-top: 1px solid #333;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    box-sizing: border-box;
}

.terminal-prompt {
    color: #0f0;
    font-weight: bold;
    font-family: inherit;
    user-select: none;
}

#terminal-input {
    background: transparent;
    border: none;
    color: #0f0;
    font-family: inherit;
    font-size: 13px;
    flex: 1;
    outline: none;
    padding: 0;
    line-height: normal;
}

#terminal-input::placeholder {
    color: rgba(0, 255, 0, 0.2);
}

.terminal-panel:not(.collapsed) .terminal-content {
    /* Adjust content height to account for input */
    height: calc(100% - 80px);
    /* 40px header + 40px input */
}

/* HuggingFace Modal Styles */
.hf-params-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.hf-param-row {
    display: flex;
    align-items: baseline;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.hf-param-row:last-child {
    border-bottom: none;
}

.hf-param-label {
    width: 140px;
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.hf-param-value {
    flex: 1;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ============================================
   EDITING SIDEBAR (Gallery mode right panel)
   ============================================ */
/* Editing Sidebar - replaces chat panel in gallery mode */
.editing-sidebar {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg,
            rgba(18, 18, 21, 0) 0px,
            rgba(18, 18, 21, 0.3) 60px,
            rgba(18, 18, 21, 0.95) 120px,
            var(--bg-panel) 150px);
    border-left: 1px solid var(--border-color);
    height: 100%;
    width: var(--right-w, 340px);
    overflow-y: auto;
    padding: 0 1.25rem 1rem 1.25rem;
    gap: 20px;
}

/* Edit Info Section - fixed top section */
.edit-info-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.edit-prompt-display {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.edit-prompt-display:hover {
    color: var(--accent);
}

.edit-meta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.edit-meta-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Editing Tabs */
.editing-tabs {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    flex-shrink: 0;
}

.edit-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 7px;
    transition: all 0.25s ease;
}

.edit-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.edit-tab-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(168, 85, 247, 0.3) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Editing Content Container */
.editing-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

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

.edit-tab-content.active {
    display: block;
}

/* Slider Rows - Vertical Layout */
.edit-slider-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.edit-slider-row label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.edit-slider-row input[type="range"] {
    width: 100%;
    margin: 0;
}

.edit-slider-row .edit-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

/* Enhance Sections */
.enhance-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.enhance-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

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

.enhance-row input[type="range"] {
    flex: 1;
    margin: 0;
}

.enhance-row .edit-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    width: 30px;
    text-align: right;
}

.edit-action-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-action-btn.full-width {
    width: 100%;
}

.edit-action-btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent);
}

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

.coming-soon {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

/* Style Grid - Vertical */
.style-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.style-preset-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.style-preset-btn:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent);
    color: var(--text-primary);
}

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

.coming-soon-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* Edit Action Buttons - Sticky Footer */
.edit-actions {
    display: flex;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    flex-shrink: 0;
}

.edit-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.edit-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.edit-btn.primary {
    background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
    border: none;
    color: white;
}

.edit-btn.primary:hover {
    background: linear-gradient(135deg, #9b7cf8 0%, #8b5cf6 100%);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

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

/* ============================================
   ABOUT MODAL (Easter Egg)
   ============================================ */
.about-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.about-modal-overlay.active {
    display: flex;
}

.about-modal {
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    border-radius: 16px;
    padding: 14px 16px 18px 16px;
    text-align: center;
    width: min(340px, 90vw);
    box-shadow:
        0 0 40px rgba(139, 92, 246, 0.3),
        0 0 80px rgba(139, 92, 246, 0.15);
    animation: aboutModalIn 0.3s ease-out;
}

@keyframes aboutModalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.about-modal h2 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 12px 0 6px 0;
}

.about-modal .about-version {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.about-modal .about-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 14px 0;
}

.about-modal .about-copyright {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.about-art-wrap {
    width: min(170px, 48vw);
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    border: none;
    background: transparent;
}

.about-art {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.about-art-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
}

.about-fallback-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    opacity: 0.95;
}

.about-fallback-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.25;
}

/* Status Dot Indicator */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.status-dot.offline {
    background: #ef4444;
}

@keyframes pulse-glow {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 0 16px rgba(34, 197, 94, 1);
        opacity: 0.85;
    }
}

/* === MUSIC STUDIO === */
.music-player-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 600px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.premium-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.music-visualizer-bars {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 6px;
    height: 60px;
    margin-bottom: 25px;
}

.m-bar {
    width: 8px;
    height: 20px;
    background: var(--accent);
    border-radius: 4px;
    animation: music-bounce 1s ease-in-out infinite;
    box-shadow: 0 0 15px var(--accent);
}

.m-bar:nth-child(2) {
    height: 40px;
    animation-delay: 0.1s;
}

.m-bar:nth-child(3) {
    height: 60px;
    animation-delay: 0.2s;
}

.m-bar:nth-child(4) {
    height: 35px;
    animation-delay: 0.3s;
}

.m-bar:nth-child(5) {
    height: 25px;
    animation-delay: 0.4s;
}

@keyframes music-bounce {

    0%,
    100% {
        transform: scaleY(1);
        opacity: 0.7;
    }

    50% {
        transform: scaleY(1.5);
        opacity: 1;
    }
}

#main-music-player::-webkit-media-controls-panel {
    background: rgba(0, 0, 0, 0.5);
}

#main-music-player::-webkit-media-controls-play-button,
#main-music-player::-webkit-media-controls-current-time-display,
#main-music-player::-webkit-media-controls-time-remaining-display,
#main-music-player::-webkit-media-controls-timeline,
#main-music-player::-webkit-media-controls-volume-slider {
    filter: invert(1);
}

.music-vocal-presets {
    margin-top: 5px;
}

.music-vocal-presets .style-btn {
    padding: 8px;
}

/* 3D Camera Angle Transform Styles */
.enhance-row-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 2px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#apply-camera-btn:disabled {
    opacity: 0.5;
    cursor: wait;
    filter: grayscale(1);
}

.badge {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}
