/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    /* Mobile-specific improvements */
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    /* Safe area support for devices with notches */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height */
    background: #ffffff;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    /* Ensure proper flex behavior */
    min-height: 0;
}

/* Configuration Bar */
.config-bar {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    z-index: 15;
    transition: all 0.3s ease;
}

/* Config Toggle Button */
.config-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.config-toggle:hover {
    background: #f1f5f9;
}

.config-toggle:active {
    background: #e2e8f0;
    transform: scale(0.98);
}

.config-toggle i:first-child {
    color: #667eea;
    margin-right: 0.5rem;
}

.config-toggle span {
    font-weight: 500;
    color: #374151;
    flex: 1;
    text-align: left;
    margin-left: 0.5rem;
}

.config-toggle #configToggleIcon {
    color: #6b7280;
    transition: transform 0.3s ease;
}

.config-bar.collapsed .config-toggle #configToggleIcon {
    transform: rotate(-90deg);
}

.config-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 100%;
    flex-wrap: wrap;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.config-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 100%;
    flex-wrap: wrap;
}

.config-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

.config-group input,
.config-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    min-width: 150px;
}

.config-group input:focus,
.config-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.config-group input[type="password"] {
    min-width: 200px;
}

.config-group select {
    min-width: 150px;
}

.config-group button {
    margin-left: 0.5rem;
}

#saveConfig,
#testApi {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}



/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0; /* Important for flex scrolling */
    /* Remove height: 100% to let flex work properly */
}

/* Header */
.chat-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}



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

.logo i {
    font-size: 1.5rem;
    color: #667eea;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.current-session {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    background: #f9fafb;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    border: 1px solid #e5e7eb;
}

.session-label {
    font-weight: 500;
}

.session-name {
    font-weight: 600;
    color: #374151;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

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

.btn-danger {
    background: #dc2626;
    color: white;
}

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

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #f9fafb;
    scroll-behavior: smooth;
    position: relative;
    /* Ensure proper scrolling on all devices */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
    /* Critical for flex scrolling */
    min-height: 0;
    /* Force a specific height for desktop scrolling */
    height: 0; /* This forces the flex item to respect the flex: 1 */
}

/* Auto-scroll to bottom indicator */
.chat-messages::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: transparent;
    pointer-events: none;
}

/* Ensure messages container takes full height */
.chat-messages > * {
    min-height: 0;
}

/* Improve scrolling for long content */
.chat-messages .message {
    scroll-margin-bottom: 1rem;
}

/* Smooth scroll for anchor links */
.chat-messages a[href^="#"] {
    scroll-margin-top: 2rem;
}

.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
}

.welcome-content {
    max-width: 400px;
    padding: 2rem;
}

.welcome-content i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.welcome-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.welcome-content p {
    color: #6b7280;
    line-height: 1.6;
}

/* Message Styles */
.message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-in;
}

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

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 0.25rem;
}

.message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #667eea;
    color: white;
}

.message.assistant .message-avatar {
    background: #f3f4f6;
    color: #374151;
}

/* Markdown Styles for Assistant Messages */
.message.assistant .message-content {
    /* Base styles for markdown content */
    line-height: 1.6;
}

.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3,
.message.assistant .message-content h4,
.message.assistant .message-content h5,
.message.assistant .message-content h6 {
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
    color: #1f2937;
}

.message.assistant .message-content h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.message.assistant .message-content h2 {
    font-size: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.25rem;
}

.message.assistant .message-content h3 {
    font-size: 1.125rem;
}

.message.assistant .message-content h4,
.message.assistant .message-content h5,
.message.assistant .message-content h6 {
    font-size: 1rem;
}

.message.assistant .message-content p {
    margin: 0.5rem 0;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message.assistant .message-content li {
    margin: 0.25rem 0;
}

.message.assistant .message-content blockquote {
    border-left: 4px solid #667eea;
    margin: 0.5rem 0;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-radius: 0.25rem;
    font-style: italic;
    color: #4b5563;
}

.message.assistant .message-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    color: #dc2626;
}

.message.assistant .message-content pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

.message.assistant .message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.message.assistant .message-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.message.assistant .message-content a:hover {
    border-bottom-color: #667eea;
}

.message.assistant .message-content strong {
    font-weight: 600;
    color: #111827;
}

.message.assistant .message-content em {
    font-style: italic;
    color: #4b5563;
}

.message.assistant .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.message.assistant .message-content th,
.message.assistant .message-content td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    text-align: left;
}

.message.assistant .message-content th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.message.assistant .message-content tr:nth-child(even) {
    background: #f9fafb;
}

.message.assistant .message-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1rem 0;
}

.message.assistant .message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}

.message.assistant .message-content .highlight {
    background: #fef3c7;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* Input Area */
.chat-input-container {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
}

.input-wrapper {
    max-width: 100%;
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.75rem;
    transition: border-color 0.2s ease;
}

.input-box:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #1f2937;
    outline: none;
    min-height: 1.5rem;
    max-height: 120px;
}

#messageInput::placeholder {
    color: #9ca3af;
}

.input-actions {
    display: flex;
    align-items: center;
}

.send-button {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.5;
}

.send-button:enabled {
    opacity: 1;
}

.send-button:enabled:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.close-btn:hover {
    background: #f3f4f6;
}

.modal-body {
    padding: 1.5rem;
}

.setting-group {
    margin-bottom: 1rem;
}

.setting-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.setting-group input,
.setting-group select,
.setting-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.setting-group input:focus,
.setting-group select:focus,
.setting-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}



/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    text-align: center;
    color: #667eea;
}

.loading-spinner i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.loading-spinner p {
    font-size: 0.875rem;
    color: #6b7280;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .current-session {
        display: none;
    }
    
    .config-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .config-group {
        width: 100%;
    }
    
    .config-group input,
    .config-group select {
        flex: 1;
    }
}

/* Enhanced Mobile Design */
@media (max-width: 768px) {
    .app-container {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height for mobile */
    }
    
    /* Mobile Configuration Bar */
    .config-toggle {
        display: flex;
    }
    
    .config-bar {
        position: sticky;
        top: 0;
        z-index: 20;
        background: #f8fafc;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .config-bar.collapsed .config-content {
        max-height: 0;
        padding: 0 1.5rem;
        opacity: 0;
        pointer-events: none;
    }
    
    .config-bar:not(.collapsed) .config-content {
        max-height: 500px;
        opacity: 1;
        pointer-events: auto;
    }
    
    .config-content {
        gap: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }
    
    .config-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        width: 100%;
    }
    
    .config-group label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    .config-group input,
    .config-group select {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        border-radius: 0.5rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        padding: 0.75rem 0;
    }
    
    .header-left {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
    
    .logo h1 {
        font-size: 1.125rem;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .chat-messages {
        padding: 0.75rem;
        /* Enhanced mobile scrolling */
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
    }
    
    .message {
        margin-bottom: 0.75rem;
        gap: 0.5rem;
    }
    
    .message-content {
        max-width: 85%;
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
        line-height: 1.4;
    }
    
    .message-avatar {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
    
    /* Mobile markdown adjustments */
    .message.assistant .message-content h1 {
        font-size: 1.125rem;
        margin: 0.75rem 0 0.375rem 0;
    }
    
    .message.assistant .message-content h2 {
        font-size: 1rem;
        margin: 0.625rem 0 0.25rem 0;
    }
    
    .message.assistant .message-content h3 {
        font-size: 0.9375rem;
        margin: 0.5rem 0 0.25rem 0;
    }
    
    .message.assistant .message-content p {
        margin: 0.375rem 0;
        line-height: 1.5;
    }
    
    .message.assistant .message-content pre {
        font-size: 0.75rem;
        padding: 0.75rem;
        margin: 0.375rem 0;
        border-radius: 0.375rem;
    }
    
    .message.assistant .message-content code {
        font-size: 0.8125rem;
        padding: 0.125rem 0.25rem;
    }
    
    .message.assistant .message-content ul,
    .message.assistant .message-content ol {
        margin: 0.375rem 0;
        padding-left: 1.25rem;
    }
    
    .message.assistant .message-content li {
        margin: 0.125rem 0;
        line-height: 1.4;
    }
    
    .message.assistant .message-content blockquote {
        margin: 0.375rem 0;
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .message.assistant .message-content table {
        font-size: 0.75rem;
        margin: 0.375rem 0;
    }
    
    .message.assistant .message-content th,
    .message.assistant .message-content td {
        padding: 0.375rem 0.5rem;
    }
    
    .chat-input-container {
        padding: 0.75rem 1rem;
        position: sticky;
        bottom: 0;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .input-box {
        padding: 0.625rem;
        border-radius: 0.875rem;
    }
    
    #messageInput {
        font-size: 0.875rem;
        line-height: 1.4;
        min-height: 1.25rem;
        max-height: 100px;
    }
    
    .send-button {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 0.875rem;
    }
    
    .input-footer {
        margin-top: 0.375rem;
        font-size: 0.6875rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
        border-radius: 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
        border-radius: 0.875rem;
    }
    
    .modal-header {
        padding: 1.25rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    .modal-footer {
        padding: 1.25rem;
    }
    
    /* Enhanced mobile scrollbar */
    .chat-messages::-webkit-scrollbar {
        width: 4px;
    }
    
    .chat-messages::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .chat-messages::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }
    
    .chat-messages::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.3);
    }
    
    /* Mobile welcome message */
    .welcome-message {
        padding: 1rem;
    }
    
    .welcome-content {
        max-width: 100%;
        padding: 1.5rem 1rem;
    }
    
    .welcome-content i {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .welcome-content h2 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .welcome-content p {
        font-size: 0.875rem;
        line-height: 1.5;
    }
}

@media (max-width: 768px) {
    .app-container {
        margin: 0;
        border-radius: 0;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .header-left {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    /* Mobile markdown adjustments */
    .message.assistant .message-content h1 {
        font-size: 1.25rem;
    }
    
    .message.assistant .message-content h2 {
        font-size: 1.125rem;
    }
    
    .message.assistant .message-content pre {
        font-size: 0.75rem;
        padding: 0.75rem;
    }
    
    .message.assistant .message-content table {
        font-size: 0.75rem;
    }
    
    .message.assistant .message-content th,
    .message.assistant .message-content td {
        padding: 0.25rem 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    

}

@media (max-width: 480px) {
    .app-container {
        height: 100vh;
        height: 100dvh;
    }
    
    .config-toggle {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .config-toggle i:first-child {
        font-size: 0.875rem;
    }
    
    .config-toggle span {
        font-size: 0.875rem;
    }
    
    .config-bar {
        position: sticky;
        top: 0;
        z-index: 20;
    }
    
    .config-content {
        gap: 0.5rem;
    }
    
    .config-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }
    
    .config-group label {
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
    }
    
    .config-group input,
    .config-group select {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }
    
    .chat-header {
        padding: 0.75rem;
    }
    
    .header-content {
        gap: 0.5rem;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .chat-messages {
        padding: 0.5rem;
    }
    
    .message {
        margin-bottom: 0.5rem;
        gap: 0.375rem;
    }
    
    .message-content {
        max-width: 90%;
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .message-avatar {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.6875rem;
    }
    
    .chat-input-container {
        padding: 0.5rem 0.75rem;
        position: sticky;
        bottom: 0;
    }
    
    .input-box {
        padding: 0.5rem;
    }
    
    #messageInput {
        font-size: 0.8125rem;
        min-height: 1.125rem;
        max-height: 80px;
    }
    
    .send-button {
        width: 2rem;
        height: 2rem;
        font-size: 0.8125rem;
    }
    
    .input-footer {
        font-size: 0.625rem;
        margin-top: 0.25rem;
    }
    
    .btn-primary, .btn-secondary {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
        border-radius: 0.375rem;
    }
    
    /* Extra small screen markdown adjustments */
    .message.assistant .message-content h1,
    .message.assistant .message-content h2 {
        font-size: 0.9375rem;
        margin: 0.5rem 0 0.25rem 0;
    }
    
    .message.assistant .message-content h3 {
        font-size: 0.875rem;
        margin: 0.375rem 0 0.25rem 0;
    }
    
    .message.assistant .message-content p {
        margin: 0.25rem 0;
        line-height: 1.4;
    }
    
    .message.assistant .message-content pre {
        font-size: 0.625rem;
        padding: 0.5rem;
        margin: 0.25rem 0;
    }
    
    .message.assistant .message-content code {
        font-size: 0.75rem;
        padding: 0.125rem 0.25rem;
    }
    
    .message.assistant .message-content ul,
    .message.assistant .message-content ol {
        padding-left: 1rem;
        margin: 0.25rem 0;
    }
    
    .message.assistant .message-content li {
        margin: 0.125rem 0;
        line-height: 1.3;
    }
    
    .message.assistant .message-content blockquote {
        margin: 0.25rem 0;
        padding: 0.25rem 0.5rem;
        font-size: 0.8125rem;
    }
    
    .message.assistant .message-content table {
        font-size: 0.6875rem;
        margin: 0.25rem 0;
    }
    
    .message.assistant .message-content th,
    .message.assistant .message-content td {
        padding: 0.25rem 0.375rem;
    }
    
    /* Mobile modal adjustments */
    .modal-content {
        width: 98%;
        margin: 0.5rem;
        border-radius: 0.75rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        gap: 0.5rem;
    }
    
    /* Enhanced mobile scrollbar for small screens */
    .chat-messages::-webkit-scrollbar {
        width: 3px;
    }
    
    .chat-messages::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.15);
    }
    
    .welcome-content {
        padding: 1rem 0.75rem;
    }
    
    .welcome-content i {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .welcome-content h2 {
        font-size: 1.125rem;
        margin-bottom: 0.375rem;
    }
    
    .welcome-content p {
        font-size: 0.8125rem;
        line-height: 1.4;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar,
.sessions-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.sessions-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.sessions-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sessions-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
