/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --accent: #f093fb;
    --bg-dark: #0a0a0a;
    --bg-card: #141414;
    --bg-input: #1e1e1e;
    --bg-hover: #252525;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #666666;
    --border: #2a2a2a;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --gradient-accent: linear-gradient(135deg, #667eea 0%, #f093fb 100%);
    --gradient-text: linear-gradient(135deg, #667eea 0%, #f093fb 50%, #764ba2 100%);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.3);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.98) 0%, rgba(10, 10, 10, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.logo-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    color: white;
    position: relative;
    z-index: 1;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-text .brand {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text .tagline {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.nav {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

/* Mobile Header Styles */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }
    
    .logo-icon svg {
        width: 22px;
        height: 22px;
    }
    
    .logo-text {
        display: none;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 10px;
    }
    
    .nav-btn span {
        display: none;
    }
}

/* Main Content */
.main {
    flex: 1;
    padding: 2rem;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 1rem 4rem;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
}

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

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Models Showcase */
.models-showcase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
}

.models-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}

.models-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.model-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.model-badge:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.model-badge:nth-child(1) {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-color: rgba(102, 126, 234, 0.4);
    color: var(--text-primary);
}

.model-badge:nth-child(2) {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.15) 100%);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--text-primary);
}

.model-badge:nth-child(3) {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.15) 100%);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--text-primary);
}

.model-badge:nth-child(4) {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
    border-color: rgba(59, 130, 246, 0.4);
    color: var(--text-primary);
}

.model-badge:last-child {
    background: var(--bg-input);
    border-style: dashed;
    color: var(--text-muted);
}

/* Generator Section */
.generator {
    margin-bottom: 4rem;
}

.generator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    border: 1px solid var(--border);
}

@media (max-width: 968px) {
    .generator-container {
        grid-template-columns: 1fr;
    }
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prompt-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.prompt-input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 120px;
    transition: all 0.2s ease;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

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

.prompt-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.example-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

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

/* Reference Images Section (Multiple Images) */
.reference-images-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reference-images-section .input-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reference-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.reference-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-input);
}

.reference-upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.reference-upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.upload-placeholder svg {
    opacity: 0.6;
}

.upload-placeholder span {
    font-size: 0.9rem;
}

.upload-subtext {
    font-size: 0.8rem !important;
    opacity: 0.7;
}

.reference-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.reference-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
    transition: all 0.2s ease;
}

.reference-preview-item:hover {
    border-color: var(--primary);
}

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

.reference-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    padding: 0;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.reference-preview-item:hover .reference-preview-remove {
    opacity: 1;
}

.reference-preview-remove:hover {
    background: var(--error);
}

.reference-preview-remove svg {
    width: 12px;
    height: 12px;
}

.reference-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Model Selector */
.model-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-selector .input-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.model-selector .input-label svg {
    opacity: 0.7;
}

.model-select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.model-select:hover {
    border-color: var(--primary);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.model-select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px;
}

/* Advanced Options */
.advanced-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.advanced-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.advanced-toggle svg {
    transition: transform 0.3s ease;
}

.advanced-toggle.active svg {
    transform: rotate(180deg);
}

.advanced-panel {
    display: none;
    padding: 1.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    animation: slideDown 0.3s ease;
}

.advanced-panel.active {
    display: block;
}

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

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.option-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.option-textarea,
.option-input,
.option-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.option-textarea:focus,
.option-input:focus,
.option-select:focus {
    outline: none;
    border-color: var(--primary);
}

.option-textarea {
    resize: vertical;
    min-height: 60px;
}

.option-select {
    cursor: pointer;
}

/* Option hint for size warnings */
.option-hint {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    margin-top: 6px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--warning);
    line-height: 1.4;
}

.option-hint svg {
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0.9;
}

.option-hint.warning-high {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.option-hint.info {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    color: var(--primary);
}

.option-slider {
    width: 100%;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

.option-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--gradient);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.option-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.seed-input-container {
    display: flex;
    gap: 8px;
}

.seed-input-container .option-input {
    flex: 1;
}

.random-btn {
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.random-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

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

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

.generate-btn .btn-loader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.generate-btn.loading .btn-text {
    display: none;
}

.generate-btn.loading .btn-loader {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

/* Output Section */
.output-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.output-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.output-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.output-placeholder svg {
    opacity: 0.5;
}

.output-placeholder p {
    font-size: 0.95rem;
}

.generated-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: center;
    gap: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.output-container:hover .image-overlay {
    opacity: 1;
}

.overlay-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.overlay-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.output-info {
    padding: 1rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.output-prompt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

/* Gallery Section */
.gallery-section {
    margin-top: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

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

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

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

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

.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    padding: 1rem;
}

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

.gallery-item-prompt {
    font-size: 0.8rem;
    color: white;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Gallery Item Delete Button */
.gallery-item-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

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

.gallery-item-delete:hover {
    background: var(--error);
    transform: scale(1.1);
}

.gallery-item-delete:active {
    transform: scale(0.95);
}

.gallery-item-delete svg {
    width: 16px;
    height: 16px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.settings-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.settings-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.password-input-container {
    position: relative;
    display: flex;
}

.password-input-container .settings-input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: var(--text-primary);
}

.settings-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.settings-status {
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    display: none;
}

.settings-status.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.settings-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-secondary,
.btn-primary {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--gradient);
    border: none;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Fullscreen Modal */
.fullscreen-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1001;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.fullscreen-modal.active {
    display: flex;
}

.fullscreen-image {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.fullscreen-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1002;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    max-width: 400px;
}

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

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

.toast.warning {
    border-color: var(--warning);
}

.toast-icon {
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--error);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
}

.toast-close {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .logo span {
        display: none;
    }

    .main {
        padding: 1rem;
    }

    .hero {
        padding: 2rem 0.5rem 3rem;
    }

    .generator-container {
        padding: 1.5rem;
    }

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

    .modal-content {
        margin: 0.5rem;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: none;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}

/* ============================================
   NAVIGATION TABS
   ============================================ */

.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-right: 1rem;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--gradient);
    color: white;
}

.nav-tab svg {
    opacity: 0.8;
}

.nav-tab.active svg {
    opacity: 1;
}

/* Mobile navigation improvements */
@media (max-width: 768px) {
    .nav-tabs {
        margin-right: 0.5rem;
        padding: 3px;
        gap: 2px;
    }
    
    .nav-tab {
        padding: 8px 12px;
        font-size: 0.85rem;
        gap: 6px;
    }
    
    .nav-tab svg {
        width: 16px;
        height: 16px;
    }
    
    .nav-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .nav-btn span {
        display: none;
    }
    
    .settings-btn span {
        display: none;
    }
}

/* ============================================
   CHAT SECTION
   ============================================ */

.chat-section {
    animation: fadeIn 0.3s ease;
}

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

.chat-hero {
    text-align: center;
    padding: 1rem 1rem 1.5rem;
}

.chat-hero .hero-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 0.5rem;
}

.chat-hero .hero-subtitle {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Hide chat hero completely on mobile */
@media (max-width: 768px) {
    .chat-hero {
        display: none;
    }
}

.chat-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    border: 1px solid var(--border);
    min-height: 400px;
    height: calc(100vh - 280px);
    max-height: none;
}

/* MOBILE: Full-screen chat layout */
@media (max-width: 768px) {
    .chat-section {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 70px); /* Full height minus header */
        padding: 0;
    }
    
    .chat-section .main {
        padding: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .chat-container {
        grid-template-columns: 1fr;
        height: 100%;
        max-height: none;
        min-height: 0;
        padding: 0;
        gap: 0;
        border-radius: 0;
        border: none;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .chat-sidebar {
        order: 2;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: 0;
        z-index: 50;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    
    .chat-sidebar.expanded {
        max-height: 70vh;
        padding: 1rem;
        overflow-y: auto;
    }
    
    .chat-main {
        order: 1;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding-bottom: 60px; /* Space for bottom bar */
    }
}

/* Desktop sidebar */
.chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    min-height: 0;
}

@media (max-width: 968px) and (min-width: 769px) {
    .chat-sidebar {
        padding-right: 0;
        border-right: none;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
        gap: 0.75rem;
    }
}

/* Sidebar mobile header */
.sidebar-mobile-header {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
        border-bottom: 1px solid var(--border);
    }
    
    .sidebar-title {
        font-weight: 600;
        font-size: 1rem;
        color: var(--text-primary);
    }
    
    .sidebar-close-btn {
        padding: 8px;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text-secondary);
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .sidebar-close-btn:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }
}

/* Mobile bottom bar for chat settings toggle */
.chat-mobile-bar {
    display: none;
}

@media (max-width: 768px) {
    .chat-mobile-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: 0.75rem 1rem;
        z-index: 60;
        justify-content: flex-start;
        align-items: center;
        gap: 0.75rem;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .chat-mobile-bar::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Opera */
    }
    
    .chat-mobile-model-select {
        flex: 1 1 auto;
        min-width: 150px;
        max-width: calc(100% - 120px);
        padding: 12px 14px;
        background: var(--bg-input);
        border: 2px solid var(--border);
        border-radius: var(--radius);
        color: var(--text-primary);
        font-size: 0.9rem;
        font-weight: 500;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 36px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }
    
    .chat-mobile-model-select:focus {
        outline: none;
        border-color: var(--primary);
    }
    
    .chat-new-chat-mobile-btn {
        flex-shrink: 0;
        padding: 12px 16px;
        background: var(--gradient);
        border: none;
        border-radius: var(--radius);
        color: white;
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s ease;
        white-space: nowrap;
    }
    
    .chat-new-chat-mobile-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }
    
    .chat-new-chat-mobile-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .chat-settings-toggle-btn {
        flex-shrink: 0;
        padding: 12px 16px;
        background: var(--bg-input);
        border: 2px solid var(--border);
        border-radius: var(--radius);
        color: var(--text-secondary);
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s ease;
        white-space: nowrap;
    }
    
    .chat-settings-toggle-btn:hover,
    .chat-settings-toggle-btn.active {
        background: var(--primary);
        border-color: var(--primary);
        color: white;
    }
    
    .chat-settings-toggle-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Adjust chat main padding for bottom bar */
    .chat-main {
        padding-bottom: 70px !important;
    }
    
    /* Chat input adjustments for mobile */
    .chat-input-area {
        padding: 0.75rem;
        background: var(--bg-dark);
    }
    
    .chat-input-container {
        padding: 6px 10px;
    }
    
    .chat-disclaimer {
        display: none;
    }
    
    /* Hide desktop model selector on mobile */
    .chat-model-selector {
        display: none;
    }
    
    /* Show it only when sidebar is expanded */
    .chat-sidebar.expanded .chat-model-selector {
        display: flex;
    }
}

.chat-model-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .model-hint {
        display: none;
    }
}

/* Model Status Section */
.model-status-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Collapsible on mobile */
@media (max-width: 768px) {
    .model-status-section {
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        overflow: hidden;
    }
    
    .model-status-section .input-label {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 12px;
        margin: 0;
        cursor: pointer;
        font-size: 0.85rem;
    }
    
    .model-status-section .input-label::after {
        content: '▼';
        font-size: 0.7rem;
        color: var(--text-muted);
        transition: transform 0.2s ease;
    }
    
    .model-status-section.collapsed .input-label::after {
        transform: rotate(-90deg);
    }
    
    .model-status-section.collapsed .model-status-log,
    .model-status-section.collapsed .model-status-header .refresh-models-btn {
        display: none;
    }
    
    .model-status-header {
        padding: 0 12px;
    }
}

.model-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.refresh-models-btn {
    padding: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-models-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

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

.model-status-log {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    max-height: 100px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.7rem;
}

@media (max-width: 768px) {
    .model-status-log {
        max-height: 100px;
        border: none;
        border-radius: 0;
        border-top: 1px solid var(--border);
        margin: 0;
        font-size: 0.7rem;
    }
}

.log-entry {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .log-time {
        font-size: 0.65rem;
    }
}

.log-message {
    color: var(--text-secondary);
    word-break: break-word;
}

.log-entry.success .log-message {
    color: var(--success);
}

.log-entry.error .log-message {
    color: var(--error);
}

.log-entry.warning .log-message {
    color: var(--warning);
}

.log-entry.info .log-message {
    color: var(--primary);
}

/* Chat Options */
.chat-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (max-width: 768px) {
    .chat-options {
        gap: 0.75rem;
    }
    
    .chat-options .options-title {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--text-secondary);
        margin-bottom: 0.25rem;
    }
    
    /* Compact layout for options on mobile */
    .chat-options .option-group {
        gap: 0.35rem;
    }
    
    .chat-options .option-label {
        font-size: 0.8rem;
    }
    
    .chat-options .option-input,
    .chat-options .option-textarea {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    .chat-options .option-textarea {
        min-height: 50px;
    }
}

/* Desktop label for chat options */
.chat-options-label-desktop {
    display: block;
}

/* Collapsible options panel for mobile */
.chat-options-toggle {
    display: none;
}

/* Chat options content - visible on desktop */
.chat-options-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Chat options row layout */
.chat-options-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (max-width: 768px) {
    /* Hide desktop label on mobile */
    .chat-options-label-desktop {
        display: none;
    }
    
    .chat-options-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 12px;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        color: var(--text-secondary);
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .chat-options-toggle:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }
    
    .chat-options-toggle svg {
        transition: transform 0.2s ease;
    }
    
    .chat-options-toggle.active svg {
        transform: rotate(180deg);
    }
    
    /* On mobile, chat options content should always be visible 
       since the sidebar panel itself is the collapsible element */
    .chat-options-content {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }
    
    /* Two-column layout for temperature and max tokens on mobile */
    .chat-options-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

/* New Chat Button */
.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: auto;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

@media (max-width: 768px) {
    .new-chat-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        margin-top: 0.5rem;
    }
}

/* Chat Main Area */
.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Chat Name Header */
.chat-name-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 0.75rem;
}

.chat-name-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-name-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-name-edit-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-primary);
}

.chat-name-edit-btn:active {
    transform: scale(0.95);
}

.chat-name-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 600;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

@media (max-width: 768px) {
    .chat-name-header {
        padding: 0.75rem 1rem;
        position: relative;
        z-index: 15;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .chat-name-title {
        font-size: 1rem;
        flex: 1;
        margin-right: 10px;
    }
    
    .chat-name-edit-btn {
        width: 36px;
        height: 36px;
        background: var(--gradient);
        border: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        box-shadow: var(--shadow);
        flex-shrink: 0;
    }
    
    .chat-name-edit-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .chat-name-input {
        font-size: 1rem;
        padding: 0.5rem 0.75rem;
        background: var(--bg-input);
        border: 2px solid var(--primary);
        border-radius: 10px;
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
    }
    
    /* Edit name overlay for mobile */
    .chat-name-edit-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 14;
        display: none;
    }
    
    .chat-name-edit-overlay.active {
        display: block;
    }
    
    /* Edit name actions for mobile */
    .chat-name-edit-actions {
        display: flex;
        gap: 8px;
        margin-top: 8px;
    }
    
    .chat-name-save-btn,
    .chat-name-cancel-btn {
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 0.9rem;
        font-weight: 500;
    }
    
    .chat-name-save-btn {
        background: var(--gradient);
        border: none;
        color: white;
    }
    
    .chat-name-cancel-btn {
        background: var(--bg-input);
        border: 1px solid var(--border);
        color: var(--text-secondary);
    }
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    height: 100%;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border-radius: 50%;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.chat-welcome h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.chat-welcome p {
    font-size: 0.95rem;
    max-width: 400px;
    margin-bottom: 1.5rem;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    max-width: 500px;
}

.suggestion-btn {
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .chat-welcome {
        padding: 1.5rem 1rem;
    }
    
    .welcome-icon {
        width: 60px;
        height: 60px;
        margin-bottom: 1rem;
    }
    
    .welcome-icon svg {
        width: 32px;
        height: 32px;
    }
    
    .chat-welcome h3 {
        font-size: 1.1rem;
    }
    
    .chat-welcome p {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }
    
    .welcome-suggestions {
        gap: 0.5rem;
    }
    
    .suggestion-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Chat Message Bubbles */
.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-message.assistant {
    margin-right: auto;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message.user .message-avatar {
    background: var(--gradient);
    color: white;
}

.chat-message.assistant .message-avatar {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--primary);
}

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 8px;
}

.chat-message.user .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Thinking Indicator - shown while waiting for AI response */
.thinking-indicator {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: thinkingPulse 1.4s infinite ease-in-out;
}

.thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

.thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingPulse {
    0%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
}

.thinking-text {
    margin-left: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Thinking State in Chat - shown before first content arrives */
.thinking-state {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.thinking-state .thinking-dots {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.thinking-state .thinking-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: thinkingBounce 1.4s infinite ease-in-out;
}

.thinking-state .thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

.thinking-state .thinking-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.thinking-state .thinking-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes thinkingBounce {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.thinking-state .thinking-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    animation: thinkingFade 2s infinite ease-in-out;
    min-width: 80px;
}

@keyframes thinkingFade {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

/* Streaming message bubble - visual feedback */
.chat-message.streaming .message-bubble {
    border: 1px solid var(--primary);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

/* Smooth transition when switching from thinking to typing */
#thinkingState, #typingState {
    transition: opacity 0.2s ease;
}

/* Chat Input Area */
.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.chat-input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 150px;
    min-height: 24px;
    line-height: 1.5;
    padding: 4px 0;
}

.chat-input:focus {
    outline: none;
}

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

.send-chat-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-chat-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

.send-chat-btn.loading {
    pointer-events: none;
}

.send-chat-btn.loading svg {
    animation: spin 1s linear infinite;
}

/* Voice Input Button */
.voice-input-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.voice-input-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.voice-input-btn.listening {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.2) 100%);
    border-color: var(--error);
    color: var(--error);
    animation: voicePulse 1.5s infinite ease-in-out;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.voice-input-btn .mic-icon,
.voice-input-btn .mic-off-icon {
    width: 20px;
    height: 20px;
}

/* Mobile voice button adjustments */
@media (max-width: 768px) {
    .voice-input-btn {
        width: 44px;
        height: 44px;
        border-radius: 22px;
    }
    
    .voice-input-btn .mic-icon,
    .voice-input-btn .mic-off-icon {
        width: 22px;
        height: 22px;
    }
}

.chat-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

/* Code blocks in chat */
.message-bubble pre {
    background: var(--bg-dark);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
}

.message-bubble code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

/* Message bubble markdown styling */
.message-bubble p {
    margin: 0 0 0.5em 0;
}

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

.message-bubble ul, .message-bubble ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-bubble li {
    margin: 0.25em 0;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble em {
    font-style: italic;
}

/* Error message in chat */
.chat-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.chat-error svg {
    flex-shrink: 0;
}

/* ============================================
   MOBILE CHAT REDESIGN - CHAT FOCUSED UI
   ============================================ */

@media (max-width: 768px) {
    /* Make nav tabs more prominent on mobile */
    .nav-tabs {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
        border: 1px solid rgba(102, 126, 234, 0.3);
        padding: 4px;
        gap: 4px;
    }
    
    .nav-tab {
        padding: 10px 14px;
        font-size: 0.9rem;
        border-radius: 10px;
        font-weight: 600;
    }
    
    .nav-tab span {
        display: inline; /* Show text on mobile for tabs */
    }
    
    .nav-tab svg {
        width: 18px;
        height: 18px;
    }
    
    .nav-tab.active {
        box-shadow: var(--shadow-glow);
    }
    
    /* Full-screen chat experience */
    .chat-section {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        z-index: 10;
        background: var(--bg-dark);
    }
    
    .chat-section .main {
        height: 100%;
        max-width: none;
    }
    
    .chat-container {
        background: transparent;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
    }
    
    /* Chat main takes full space */
    .chat-main {
        background: var(--bg-dark);
        border-radius: 0;
        padding-bottom: 140px !important; /* Space for input + bottom bar */
    }
    
    /* Messages area - full height */
    .chat-messages {
        flex: 1;
        padding: 1rem;
        padding-bottom: 1rem;
        background: var(--bg-dark);
    }
    
    /* Improved welcome screen for mobile */
    .chat-welcome {
        padding: 2rem 1.5rem;
        justify-content: flex-start;
        padding-top: 15vh;
    }
    
    .welcome-icon {
        width: 80px;
        height: 80px;
        background: var(--gradient);
        box-shadow: var(--shadow-glow);
        margin-bottom: 1.5rem;
    }
    
    .welcome-icon svg {
        width: 40px !important;
        height: 40px !important;
        color: white;
    }
    
    .chat-welcome h3 {
        font-size: 1.5rem;
        font-weight: 700;
        margin-bottom: 0.75rem;
    }
    
    .chat-welcome p {
        font-size: 1rem;
        color: var(--text-secondary);
        margin-bottom: 2rem;
        max-width: 300px;
    }
    
    .welcome-suggestions {
        gap: 0.75rem;
        max-width: 100%;
    }
    
    .suggestion-btn {
        padding: 12px 18px;
        font-size: 0.9rem;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 25px;
        transition: all 0.2s ease;
    }
    
    .suggestion-btn:active {
        transform: scale(0.97);
        background: var(--bg-hover);
    }
    
    /* Chat input area - fixed at bottom, above the bar */
    .chat-input-area {
        position: fixed;
        bottom: 70px; /* Above the mobile bar */
        left: 0;
        right: 0;
        padding: 0.75rem 1rem;
        background: linear-gradient(0deg, var(--bg-dark) 85%, transparent 100%);
        border-top: none;
        z-index: 55;
    }
    
    .chat-input-container {
        background: var(--bg-card);
        border: 2px solid var(--border);
        border-radius: 28px;
        padding: 8px 12px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .chat-input-container:focus-within {
        border-color: var(--primary);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3), var(--shadow-glow);
    }
    
    .chat-input {
        font-size: 1rem;
        padding: 8px 4px;
        min-height: 24px;
    }
    
    .send-chat-btn {
        width: 44px;
        height: 44px;
        border-radius: 22px;
        box-shadow: var(--shadow-glow);
    }
    
    /* Mobile bottom bar redesigned */
    .chat-mobile-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 0.5rem 1rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        display: flex;
        gap: 0.5rem;
        z-index: 60;
    }
    
    .chat-mobile-model-select {
        flex: 1;
        padding: 14px 16px;
        background: var(--bg-input);
        border: 2px solid var(--border);
        border-radius: 14px;
        font-size: 0.95rem;
        font-weight: 500;
        padding-right: 40px;
    }
    
    .chat-settings-toggle-btn {
        padding: 14px 18px;
        background: var(--bg-input);
        border: 2px solid var(--border);
        border-radius: 14px;
        font-size: 0.95rem;
        font-weight: 500;
        gap: 8px;
    }
    
    .chat-settings-toggle-btn svg {
        width: 20px;
        height: 20px;
    }
    
    /* Settings panel slides up beautifully */
    .chat-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-radius: 24px 24px 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                    padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    }
    
    .chat-sidebar.expanded {
        max-height: 75vh;
        padding: 1.5rem;
        padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* Ensure content can scroll properly */
        display: flex;
        flex-direction: column;
    }
    
    /* Ensure all sidebar content is visible */
    .chat-sidebar.expanded > * {
        flex-shrink: 0;
    }
    
    .sidebar-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 1rem;
        margin-bottom: 1.25rem;
        border-bottom: 1px solid var(--border);
    }
    
    .sidebar-title {
        font-size: 1.1rem;
        font-weight: 700;
        background: var(--gradient-text);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
    
    .sidebar-close-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: 12px;
    }
    
    /* Settings content in sidebar */
    .chat-sidebar.expanded .chat-model-selector {
        display: flex;
        margin-bottom: 1.25rem;
    }
    
    .chat-sidebar .model-select {
        padding: 14px 16px;
        font-size: 1rem;
        border-radius: 14px;
    }
    
    /* Model status section in sidebar */
    .model-status-section {
        margin-bottom: 1.25rem;
        border-radius: 14px;
    }
    
    .model-status-section .input-label {
        padding: 14px 16px;
        font-size: 0.95rem;
    }
    
    /* Chat options in sidebar */
    .chat-options {
        margin-bottom: 1.25rem;
    }
    
    .chat-options-content.active {
        padding: 1rem;
        border-radius: 0 0 14px 14px;
    }
    
    .chat-options .option-input,
    .chat-options .option-textarea {
        padding: 12px 14px;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    /* New chat button */
    .new-chat-btn {
        padding: 16px 20px;
        font-size: 1rem;
        border-radius: 14px;
        margin-top: 0.5rem;
    }
    
    /* Message bubbles on mobile */
    .chat-message {
        max-width: 90%;
    }
    
    .message-bubble {
        padding: 14px 18px;
        font-size: 1rem;
        border-radius: 20px;
    }
    
    .chat-message.user .message-bubble {
        border-bottom-right-radius: 6px;
    }
    
    .chat-message.assistant .message-bubble {
        border-bottom-left-radius: 6px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    /* Overlay when settings panel is open */
    .chat-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 90;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .chat-sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* Extra small mobile devices */
@media (max-width: 375px) {
    .nav-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .nav-tab span {
        display: none;
    }
    
    .suggestion-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .chat-welcome h3 {
        font-size: 1.25rem;
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-welcome {
        padding-top: 5vh;
    }
    
    .welcome-icon {
        width: 60px;
        height: 60px;
    }
    
    .welcome-icon svg {
        width: 30px !important;
        height: 30px !important;
    }
    
    .chat-sidebar.expanded {
        max-height: 90vh;
    }
}

/* ============================================
   AUTHENTICATION UI
   ============================================ */

/* Auth Modal */
.auth-modal-content {
    max-width: 420px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.auth-tab.active {
    background: var(--gradient);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.auth-status {
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: none;
}

.auth-status.success {
    display: block;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.auth-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.auth-submit-btn {
    width: 100%;
    padding: 14px 24px;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-submit-btn .btn-loader {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-submit-btn .btn-loader .spinner {
    width: 18px;
    height: 18px;
}

/* Account Button in Nav */
.account-btn {
    position: relative;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-color: rgba(102, 126, 234, 0.4);
}

.account-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.25) 100%);
}

.account-username {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Account Dropdown Menu */
.account-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    z-index: 200;
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none;
    animation: menuSlideIn 0.2s ease;
}

.account-menu.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto;
}

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

.account-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
}

.account-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.account-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.account-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.account-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.account-menu-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.account-menu-item svg {
    opacity: 0.7;
}

/* Login Button */
.login-btn {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.15) 100%);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--success);
}

.login-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.25) 100%);
    border-color: var(--success);
}

/* Mobile account styles */
@media (max-width: 768px) {
    .account-btn .account-username {
        display: none;
    }
    
    .account-menu {
        position: fixed;
        top: 60px;
        left: 1rem;
        right: 1rem;
        min-width: auto;
        /* Ensure menu is completely hidden when not active */
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none;
    }
    
    .account-menu.active {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto;
    }
    
    .login-btn span {
        display: none;
    }
    
    /* Account menu overlay for mobile */
    .account-menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .account-menu-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* Improved mobile account menu styling */
    .account-menu {
        z-index: 200;
        border-radius: var(--radius-lg);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .account-menu-header {
        padding: 1.25rem 1.25rem 1rem;
    }
    
    .account-menu-item {
        padding: 14px 1.25rem;
        font-size: 1rem;
    }
    
    .account-menu-item svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   CHAT HISTORY SIDEBAR
   ============================================ */

/* Chat History List */
.chat-history-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    max-height: 200px;
    overflow-y: auto;
}

.chat-history-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.25rem;
}

.chat-history-title span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.chat-history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.chat-history-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-primary);
}

.chat-history-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-color: rgba(102, 126, 234, 0.4);
    color: var(--text-primary);
}

.chat-history-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.chat-history-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item-delete {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    opacity: 1;
    transition: all 0.2s ease;
}

.chat-history-item-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.chat-history-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chat-history-login-prompt {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.chat-history-login-prompt a {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

.chat-history-login-prompt a:hover {
    color: var(--primary-dark);
}

/* Typing cursor animation */
.typing-cursor {
    display: inline-block;
    color: var(--primary);
    animation: blink 0.7s infinite;
    font-weight: bold;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Streaming text container - smooth appearance */
#streamingText {
    display: inline;
}

/* When streaming text is empty, show thinking animation */
#streamingText:empty + .typing-cursor::before {
    content: 'Thinking';
    animation: thinkingText 2s infinite;
    color: var(--text-muted);
    font-style: italic;
    font-weight: normal;
    margin-right: 4px;
}

@keyframes thinkingText {
    0%, 100% {
        content: 'Thinking';
    }
    25% {
        content: 'Thinking.';
    }
    50% {
        content: 'Thinking..';
    }
    75% {
        content: 'Thinking...';
    }
}

/* Alternative: Pulse animation for empty streaming state */
.message-bubble:has(#streamingText:empty) {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
    50% {
        box-shadow: 0 0 15px 2px rgba(102, 126, 234, 0.3);
    }
}

/* Smooth text appearance during streaming */
.chat-message.assistant .message-bubble {
    min-height: 20px;
    transition: min-height 0.2s ease;
}

/* Loading state visual indicator */
.chat-message.assistant.streaming .message-bubble {
    border-color: var(--primary);
}

/* ============================================
   CHAT HISTORY ITEM ACTIONS (Rename/Delete)
   ============================================ */

.chat-history-item {
    position: relative;
}

.chat-history-item-actions {
    display: flex;
    gap: 4px;
    opacity: 1;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.chat-history-item-action {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-history-item-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-history-item-rename:hover {
    color: var(--primary);
}

.chat-history-item-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Mobile: Always show actions */
@media (max-width: 768px) {
    .chat-history-item-actions {
        opacity: 1 !important;
    }
    
    .chat-history-item-action {
        padding: 6px;
        opacity: 1 !important;
    }
    
    .chat-history-item-action svg {
        width: 16px;
        height: 16px;
    }
    
    /* Ensure delete button is visible on mobile */
    .chat-history-item-delete {
        opacity: 1 !important;
        display: flex !important;
        visibility: visible !important;
    }
    
    .chat-history-item-rename {
        opacity: 1 !important;
        display: flex !important;
        visibility: visible !important;
    }
}

/* ============================================
   RENAME MODAL
   ============================================ */

.rename-modal-content {
    max-width: 400px;
}

.rename-modal-content .modal-body {
    padding: 1.5rem;
}

.rename-modal-content .settings-group {
    margin-bottom: 0;
}

#renameInput {
    font-size: 1rem;
}

/* Rename modal responsive */
@media (max-width: 768px) {
    .rename-modal-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
}

/* ============================================
   PDF DOWNLOAD BUTTON
   ============================================ */

.pdf-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    margin-top: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pdf-download-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.pdf-download-btn:active {
    transform: scale(0.98);
}

.pdf-download-btn svg {
    opacity: 0.7;
}

.pdf-download-btn:hover svg {
    opacity: 1;
}

/* Mobile adjustments for PDF button */
@media (max-width: 768px) {
    .pdf-download-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   MOBILE CHAT NAME SECTION
   ============================================ */

/* Desktop: Hide mobile chat name section completely */
.mobile-chat-name-section {
    display: none;
    visibility: hidden;
    height: 0;
    overflow: hidden;
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

/* Mobile: Show mobile chat name section - CRITICAL OVERRIDE */
@media (max-width: 768px) {
    /* Hide the desktop chat name header on mobile */
    .chat-name-header {
        display: none !important;
    }
    
    /* FORCE show the mobile chat name section */
    .mobile-chat-name-section {
        all: unset !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 14px 16px !important;
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important;
        border-bottom: 2px solid #667eea !important;
        position: relative !important;
        z-index: 100 !important;
        gap: 12px !important;
        min-height: 56px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        flex-shrink: 0 !important;
    }
    
    /* Also target by ID for maximum specificity */
    #mobileChatNameSection {
        all: unset !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 14px 16px !important;
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important;
        border-bottom: 2px solid #667eea !important;
        position: relative !important;
        z-index: 100 !important;
        gap: 12px !important;
        min-height: 56px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-chat-name-title,
    #mobileChatNameTitle {
        all: unset !important;
        display: block !important;
        visibility: visible !important;
        font-size: 1.1rem !important;
        font-weight: 600 !important;
        color: #ffffff !important;
        margin: 0 !important;
        flex: 1 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        line-height: 1.3 !important;
    }
    
    .mobile-chat-name-edit-btn,
    #mobileChatNameEditBtn {
        all: unset !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 10px 16px !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        border: none !important;
        border-radius: 24px !important;
        color: white !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4) !important;
        box-sizing: border-box !important;
    }
    
    .mobile-chat-name-edit-btn svg,
    #mobileChatNameEditBtn svg {
        width: 16px !important;
        height: 16px !important;
        display: inline-block !important;
    }
    
    /* Mobile chat name input styling when editing */
    .mobile-chat-name-section .chat-name-input {
        flex: 1;
        padding: 12px 16px !important;
        background: #1e1e1e !important;
        border: 2px solid #667eea !important;
        border-radius: 12px !important;
        color: #ffffff !important;
        font-family: inherit;
        font-size: 1.1rem !important;
        font-weight: 600 !important;
        outline: none;
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2) !important;
    }
    
    /* Mobile edit actions */
    .mobile-chat-name-section .chat-name-edit-actions {
        display: flex !important;
        gap: 8px;
        flex-shrink: 0;
    }
    
    .mobile-chat-name-section .chat-name-save-btn,
    .mobile-chat-name-section .chat-name-cancel-btn {
        padding: 10px 16px !important;
        border-radius: 20px !important;
        font-size: 0.9rem !important;
        font-weight: 500 !important;
        cursor: pointer;
    }
    
    .mobile-chat-name-section .chat-name-save-btn {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        border: none !important;
        color: white !important;
    }
    
    .mobile-chat-name-section .chat-name-cancel-btn {
        background: #1e1e1e !important;
        border: 1px solid #2a2a2a !important;
        color: #b0b0b0 !important;
    }
}
