/* --- DESIGN SYSTEM (Neo-Glass Studio / EZ0 v4) --- */
/* === THEME: Lipstick (Default) === */
:root {
    /* Core backgrounds */
    --bg-void: #080808;
    --bg-surface: rgba(255, 255, 255, 0.03);
    --bg-elevated: rgba(255, 255, 255, 0.06);
    --md-sys-color-background: #080808;

    /* Glass system */
    --glass-base: rgba(255, 255, 255, 0.03);
    --glass-strong: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --glass-blur: blur(20px) saturate(1.4);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-active: rgba(220, 38, 38, 0.5);

    /* Accent: Red → Deep Red */
    --accent-primary: #dc2626;
    --accent-secondary: #ef4444;
    --accent-glow: rgba(220, 38, 38, 0.3);
    --accent-gradient: linear-gradient(135deg, #ef4444, #991b1b);

    /* Legacy compat */
    --accent-gold: var(--accent-primary);
    --accent-gold-glow: var(--accent-glow);

    /* Text */
    --text-main: #f5f5f5;
    --text-muted: #9a9a9a;
    --text-dim: #555555;

    /* Status */
    --status-green: #34d399;
    --status-red: #f87171;
    --status-yellow: #fbbf24;

    /* Typography */
    --font-display: 'IBM Plex Mono', monospace;
    --font-sans: 'Outfit', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --font-brand: 'Bodoni Moda', serif;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* === THEME: Neo-Glass === */
[data-theme="neo-glass"] {
    --bg-void: #0a0a12;
    --bg-elevated: rgba(255, 255, 255, 0.07);
    --md-sys-color-background: #0a0a12;
    --glass-base: rgba(255, 255, 255, 0.04);
    --glass-strong: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-active: rgba(139, 92, 246, 0.4);
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --accent-glow: rgba(139, 92, 246, 0.25);
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #06b6d4);
    --text-main: #f0f0f5;
    --text-muted: #9898a8;
    --text-dim: #55556a;
}

/* --- RESET & ANIMATIONS --- */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-void);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-sans);
    margin: 0;
    height: 100vh;
    display: flex;
    overflow: hidden;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Subtle noise overlay for glass texture */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.015;
    z-index: 9999;
}

/* --- LAYOUT --- */
.app-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 240px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px 20px;
    flex-shrink: 0;
    z-index: 10;
}

.brand-section {
    margin-bottom: 28px;
    padding: 0 8px;
}

/* Notes View Styles */
.notes-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 40px 40px;
    width: 100%;
    margin: 0;
    display: none;
    /* Hidden by default */
}

.notes-container.active {
    display: flex;
}

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

.notes-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.6;
    padding: 12px 16px;
    resize: none;
    outline: none;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.15);
}

.notes-textarea:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--accent-glow);
}

.notes-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color 0.3s;
}

.notes-status.saved {
    color: var(--status-green);
}

/* Notes Input Row */
.notes-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.notes-input-row .notes-textarea {
    flex: 1;
}

.notes-add-btn {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    padding: 0 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    transition: opacity 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.notes-add-btn:hover {
    opacity: 0.9;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* Note List */
.notes-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--text-dim) transparent;
}

.note-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, background 0.2s;
}

.note-item:hover {
    border-color: rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.note-text {
    flex: 1;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.note-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 1rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.note-delete-btn:hover {
    color: var(--status-red);
    background: rgba(248, 113, 113, 0.1);
}

.notes-empty {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-align: center;
    padding: 40px 0;
    letter-spacing: 0.02em;
}

.notes-count {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 12px;
    letter-spacing: 0.03em;
}

.brand-logo {
    font-family: var(--font-brand);
    font-weight: 500;
    font-size: 1.4rem;
    color: var(--text-main);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    font-feature-settings: 'lnum' 1;
    display: flex;
    align-items: baseline;
    gap: 0;
    line-height: 1;
}

.brand-beta {
    font-size: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--accent-primary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-left: 5px;
    opacity: 0.8;
    align-self: flex-start;
    margin-top: 4px;
}

.brand-logo span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.project-label {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 6px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nav Items */
.nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    text-decoration: none;
    border: none;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.08);
    border-left-color: var(--accent-primary);
}

/* Sidebar Footer (Status) */
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.system-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s;
    font-family: var(--font-sans);
}

.system-status:hover {
    background: rgba(255, 255, 255, 0.03);
}

.status-dots {
    display: flex;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-dim);
    transition: all 0.3s ease;
}

.status-dot.green {
    background-color: var(--status-green);
    box-shadow: 0 0 6px rgba(90, 158, 111, 0.5);
}

.status-dot.red {
    background-color: var(--status-red);
}

.status-dot.yellow {
    background-color: var(--status-yellow);
}

/* --- MAIN CONTENT & HEADER --- */
.main-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Right aligned controls */
    padding: 0 24px;
    /* Glass header optional, here transparent to blend */
    z-index: 5;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Cloud Sync Icon */
.sync-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.sync-btn:hover {
    color: var(--text-main);
    background: var(--glass-highlight);
}

.sync-status-indicator {
    position: absolute;
    top: 8px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1px solid var(--md-sys-color-background);
    display: none;
    /* Hidden by default */
}

.sync-btn.syncing {
    animation: spin 2s linear infinite;
    color: var(--accent-secondary);
}

.sync-btn.syncing .sync-status-indicator {
    display: block;
    background: var(--status-yellow);
}


/* --- CHAT AREA (Scrollbar on Right Edge) --- */
.scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--text-dim) transparent;
}

.main-content[data-view="notes"] #chat-window-container,
.main-content[data-view="team"] #chat-window-container {
    display: none !important;
}

.scroll-container::-webkit-scrollbar {
    width: 4px;
}

.scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-container::-webkit-scrollbar-thumb {
    background-color: rgba(139, 92, 246, 0.2);
    border-radius: 2px;
}

.scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(139, 92, 246, 0.4);
}

/* Inner container for max-width content */
.chat-stream {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px 120px 24px;
    /* Bottom padding for input */
    display: flex;
    flex-direction: column;
}

/* --- MESSAGES (Glass) --- */
.message-row {
    display: flex;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease-out;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.ai {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 1rem;
    position: relative;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* User Bubble — glass surface */
.message-row.user .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-bottom-right-radius: 2px;
}

/* AI Bubble — violet left-border accent */
.message-row.ai .message-bubble {
    background: transparent;
    border: none;
    border-left: 2px solid var(--accent-primary);
    padding-left: 20px;
    color: var(--text-main);
    border-bottom-left-radius: 0;
    box-shadow: none;
}

/* Streaming cursor — blinks while tokens are being received */
.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent-primary);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: stream-blink 0.7s step-end infinite;
}

@keyframes stream-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Markdown Styling */
.message-bubble h1,
.message-bubble h2 {
    font-family: var(--font-display);
    color: var(--text-main);
    margin-top: 16px;
    font-weight: 600;
}

.message-bubble h1 {
    font-size: 1.4rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--text-muted);
}

.message-bubble pre {
    background: #0d0d0d;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    overflow-x: auto;
    margin: 12px 0;
}

/* --- FEEDBACK ACTIONS --- */

.feedback-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-family: var(--font-sans);
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-btn:hover {
    border-color: var(--border-subtle);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
}

.feedback-btn.active {
    color: #fff;
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    font-weight: 600;
}

/* --- FEEDBACK COMMENT INPUT --- */
.feedback-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    opacity: 1;
    flex-wrap: wrap;
}

.feedback-comment-row {
    display: flex;
    gap: 6px;
    width: 100%;
    margin-top: 6px;
    animation: fadeIn 0.2s ease-out;
}

.feedback-comment-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}

.feedback-comment-input:focus {
    border-color: var(--accent-primary);
}

.feedback-comment-input::placeholder {
    color: var(--text-dim);
}

.feedback-comment-send {
    background: var(--accent-primary);
    border: none;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.feedback-comment-send:hover {
    opacity: 0.85;
}

/* --- REPLY BUBBLE DIFFERENTIATION --- */
.message-bubble.is-reply {
    border-left: 2px solid var(--accent-secondary) !important;
    background: rgba(6, 182, 212, 0.04) !important;
}

.reply-quote {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-secondary);
    opacity: 0.8;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(6, 182, 212, 0.2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* --- SYNC STATUS PANEL --- */
#sync-status-panel {
    position: fixed;
    bottom: 12px;
    right: 20px;
    display: none;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    z-index: 500;
    max-width: 320px;
}

#sync-message {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sync-spinner {
    width: 11px;
    height: 11px;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-top: 1.5px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- GENERATION PROGRESS INDICATOR --- */
.gen-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
}

.gen-progress-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gen-progress-stage {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-main);
    letter-spacing: 0.02em;
    transition: opacity 0.3s ease;
}

.gen-progress-pulse {
    animation: textPulse 1.8s ease-in-out infinite;
}

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

.gen-progress-timer {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-left: auto;
    letter-spacing: 0.04em;
}

.gen-progress-bar-track {
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.gen-progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.gen-progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* --- GENERATION OPTIONS (Aspect Ratio / Resolution) --- */
.gen-options {
    display: flex;
    gap: 4px;
    align-items: center;
}

.gen-option-select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    min-width: 48px;
    text-align: center;
}

.gen-option-select:hover,
.gen-option-select:focus {
    border-color: var(--accent-primary);
    color: var(--text-main);
}

.gen-option-select option {
    background: #1a1a2e;
    color: var(--text-main);
}

.intent-selector {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    padding: 4px 10px;
    border-radius: 16px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    text-align: center;
    margin-right: 4px;
}

.intent-selector:hover,
.intent-selector:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    box-shadow: 0 0 12px var(--accent-glow);
}

.intent-selector.image-active {
    border-color: var(--accent-primary);
    color: var(--text-main);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.4);
}

.intent-selector option {
    background: #1a1a2e;
    color: var(--text-main);
}

/* --- IMAGE OPTIONS BAR (Dynamic, inside .input-wrapper) --- */
.image-options-bar {
    display: none;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 6px 16px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-options-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

/* --- IMAGE WRAPPER & DOWNLOAD --- */
.image-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
}

.download-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    transition: background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    z-index: 10;
}

.regen-btn {
    position: absolute;
    top: 8px;
    right: 110px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    z-index: 10;
    transition: background 0.2s;
}

.image-wrapper:hover .download-btn,
.image-wrapper:hover .regen-btn {
    opacity: 1;
}

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

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

/* Scroll wrapper: grows to fill the flex column, clips + scrolls the grid.
   Keeping scroll here (not on the grid) means the grid has no fixed height,
   so aspect-ratio:1 on .gallery-item resolves correctly at every viewport size. */
.gallery-scroll-wrapper {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Grid has no flex or overflow — it expands to natural height inside the wrapper. */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 24px;
}

/* --- GALLERY FILTER TABS --- */
.gallery-filter-tabs {
    display: flex;
    gap: 6px;
    padding: 16px 24px 0;
    flex-shrink: 0;
}

.gallery-filter-tab {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    padding: 5px 14px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.18s;
    outline: none;
}

.gallery-filter-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.gallery-filter-tab.active {
    background: rgba(139, 92, 246, 0.14);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: 500;
}

/* --- GALLERY LIKED BADGE (corner indicator) --- */
.gallery-liked-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.85rem;
    line-height: 1;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
    pointer-events: none;
    z-index: 2;
}

/* --- GALLERY LIKE BUTTON (inside overlay) --- */
.gallery-like-btn {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 3px 7px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    line-height: 1;
}

.gallery-like-btn:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: var(--accent-primary);
    transform: scale(1.08);
}

.gallery-like-btn.liked {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-primary);
    color: #fff;
}

.gallery-item {
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    aspect-ratio: 1;
    transition: border-color 0.2s;
}

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

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

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

.gallery-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s;
}

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

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

.gallery-prompt {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.3;
    max-width: 85%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- SKELETON LOADING --- */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 25%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 6px;
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

.skeleton-dot {
    background: rgba(255, 255, 255, 0.06) !important;
    box-shadow: none !important;
    animation: shimmer 1.8s ease-in-out infinite;
    background-size: 200% 100%;
}

.gallery-skeleton {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 25%,
            rgba(255, 255, 255, 0.07) 50%,
            rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border: 1px solid var(--border-subtle);
}

/* --- LOADING ANIMATION — pulsing dot --- */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.3;
    animation: violetPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes violetPulse {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    40% {
        opacity: 1;
        transform: scale(1.4);
    }
}

/* --- INPUT AREA (Floating Glass Pill) --- */
.input-region {
    position: absolute;
    bottom: 52px;
    left: 0;
    width: 100%;
    /* Explicit width */
    display: flex;
    justify-content: center;
    padding: 0 24px;
    z-index: 20;
    pointer-events: none;
    box-sizing: border-box;
    /* Critical for padding */
}

.input-container {
    width: 100%;
    max-width: 800px;
    pointer-events: auto;
    /* Re-enable for input */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-wrapper {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

.input-wrapper:focus-within {
    border-color: var(--border-active);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(139, 92, 246, 0.2), 0 0 24px rgba(139, 92, 246, 0.08);
}

.input-row {
    display: flex;
    align-items: center;
    padding: 8px 8px 8px 20px;
}

textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    font-family: var(--font-sans);
    padding: 10px 0;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
}

textarea::placeholder {
    color: var(--text-dim);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Tools */
.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.2s;
}

.tool-btn:hover {
    color: var(--text-main);
    background: var(--glass-highlight);
}

/* --- RESPONSIVE & MOBILE --- */
.mobile-header {
    display: none;
}

/* Default hidden on desktop */

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        z-index: 50;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.03);
        backdrop-filter: blur(24px) saturate(1.3);
        -webkit-backdrop-filter: blur(24px) saturate(1.3);
        border-bottom: 1px solid var(--glass-border);
        z-index: 40;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
    }

    .main-content {
        margin-top: 0;
        padding-top: 60px;
        /* Use padding for fixed header space */
        height: 100dvh;
        /* Ensure it fits viewport exactly */
    }

    .app-header {
        display: none;
        /* Hide desktop header */
    }

    .input-region {
        bottom: 36px;
        padding: 0 16px;
        position: fixed;
        /* fix to viewport to be safe */
        width: 100%;
    }

    .input-wrapper {
        border-radius: 24px;
    }

    .input-row {
        padding: 6px 6px 6px 12px;
    }

    .intent-selector {
        max-width: 88px;
        font-size: 0.75rem;
        padding: 4px 6px;
    }

    .tool-btn {
        padding: 6px;
    }

    /* Add backdrop */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 45;
        display: none;
    }

    .sidebar-backdrop.active {
        display: block;
    }

    /* Gallery: 2-column grid. aspect-ratio:1 works because the grid
       is inside .gallery-scroll-wrapper (no fixed height on the grid). */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 12px;
        gap: 8px;
    }
}

/* Helpers */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.modal {
    background: rgba(20, 20, 30, 0.85);
    backdrop-filter: blur(32px) saturate(1.5);
    -webkit-backdrop-filter: blur(32px) saturate(1.5);
    border: 1px solid var(--glass-border);
    width: 600px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-sidebar {
    width: 170px;
    background: rgba(0, 0, 0, 0.25);
    border-right: 1px solid var(--glass-border);
    padding: 16px;
}

.modal-content {
    flex: 1;
    padding: 22px;
    overflow-y: auto;
}

.modal-layout {
    display: flex;
    height: 400px;
}

.settings-tab {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    border-left: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    cursor: pointer;
    font-size: 0.88rem;
    font-family: var(--font-sans);
    margin-bottom: 2px;
    transition: color 0.2s, background 0.2s;
}

.settings-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.settings-tab.active {
    color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.08);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--border-active);
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* Helpers */
.hidden {
    display: none !important;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: rgba(20, 20, 30, 0.92);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(120%);
    opacity: 0;
    animation: toastIn 0.35s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.toast.toast-out {
    animation: toastOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.toast-success {
    border-left: 3px solid var(--status-green);
}

.toast.toast-error {
    border-left: 3px solid var(--status-red);
}

.toast.toast-warning {
    border-left: 3px solid var(--status-yellow);
}

.toast.toast-info {
    border-left: 3px solid var(--accent-primary);
}

@keyframes toastIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

/* --- IMAGE LIGHTBOX --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn 0.2s;
}

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

.lightbox-img {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: var(--radius-md);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    cursor: grab;
    transition: transform 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-img.zoomed {
    cursor: grabbing;
    max-width: none;
    max-height: none;
}

.lightbox-toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 8010;
}

.lightbox-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
}
