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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* Sidebar Styles */
#sidebar {
    width: 300px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(241, 245, 249, 0.5);
    min-height: 60px;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #475569;
}

#newChatBtn {
    background: linear-gradient(135deg, #0207f7 0%, #8b5cf6 100%);
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    touch-action: manipulation;
}

#newChatBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(9, 13, 246, 0.4);
}

#newChatBtn:active {
    transform: translateY(0);
}

#chatHistory {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.chat-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: #ffffff;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    position: relative;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow: hidden;
}

.chat-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-preview {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.chat-item:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateX(2px);
}

.chat-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.chat-item-delete {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    opacity: 0;
    flex-shrink: 0;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

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

.chat-item-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: scale(1.1);
}

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

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: linear-gradient(135deg, #000007 0%, #010004 100%);
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(114, 114, 114, 0.4);
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
    backdrop-filter: blur(2px);
}

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

/* Main Content */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
    position: relative;
}

header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    min-height: 60px;
    flex-shrink: 0;
    position: relative;
}

.header-left-spacer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-width: 0;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    min-width: 0;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding-right: 10px;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-text {
    min-width: 0;
    text-align: center;
}

.header-text h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-text span {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-btn {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.5rem;
    padding: 0.5rem;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    touch-action: manipulation;
}

.settings-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #6366f1;
}

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

#status {
    font-size: 0.75rem;
    color: #64748b;
    padding: 0.4rem 0.75rem;
    background: rgba(241, 245, 249, 0.8);
    border-radius: 2rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.3s ease;
    min-width: 120px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#status::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

#status.thinking::after {
    animation: statusShimmer 2s infinite;
}

@keyframes statusShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

#status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
}

#status.thinking {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #d97706;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    }
}

#status.thinking::before {
    background: #f59e0b;
    animation: pulse 1s infinite, glow 2s infinite;
}

#status.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

#status.error::before {
    background: #ef4444;
    animation: pulse 1s infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    }
}

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

#chat-container {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    scroll-behavior: smooth;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 3rem 2rem;
    text-align: center;
    color: #64748b;
    min-height: 400px;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 500px;
    margin-bottom: 1.5rem;
}

.empty-state-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    width: 100%;
    max-width: 500px;
}

.suggestion-chip {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 0.9rem;
    color: #475569;
}

.suggestion-chip:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.msg-container {
    max-width: 70%;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    align-items: flex-start;
    animation: slideIn 0.3s ease;
}

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

.msg-container.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-container.bot {
    align-self: flex-start;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.msg-container.user .msg-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.msg-container.bot .msg-avatar {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #6366f1;
    border: 2px solid rgba(99, 102, 241, 0.2);
}

.msg-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.msg {
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: fadeIn 0.4s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin: 0;
    width: 100%;
    position: relative;
}

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

.msg.user {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-bottom-right-radius: 0.25rem;
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25);
}

.msg.bot {
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-bottom-left-radius: 0.25rem;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.msg-timestamp {
    font-size: 0.7rem;
    color: #94a3b8;
    padding: 0 0.5rem;
    margin-top: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.msg-container:hover .msg-timestamp {
    opacity: 1;
}

.msg-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    padding-left: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.msg-container:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.375rem;
    padding: 0.35rem 0.6rem;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.msg-action-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #6366f1;
    transform: translateY(-1px);
}

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

.msg-container.user .msg-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
}

.msg-container.user .msg-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.msg.system {
    align-self: center;
    background: transparent;
    color: #64748b;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 2rem;
    max-width: 100%;
    text-align: center;
}

.msg.streaming::after {
    content: '▋';
    animation: blink 1s infinite;
    margin-left: 3px;
    color: #6366f1;
    display: inline-block;
    font-weight: bold;
    font-size: 1.1em;
}

.msg.bot.streaming::after {
    color: #6366f1;
}

.msg.user.streaming::after {
    color: rgba(255, 255, 255, 0.9);
}

.msg.streaming {
    position: relative;
}

.msg.streaming::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), transparent);
    animation: shimmer 1.5s infinite;
}

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

/* Markdown formatting styles */
.msg h1, .msg h2, .msg h3, .msg h4, .msg h5, .msg h6 {
    margin: 1.25em 0 0.75em 0;
    font-weight: 700;
    line-height: 1.3;
    color: #1e293b;
}

.msg.user h1, .msg.user h2, .msg.user h3, .msg.user h4, .msg.user h5, .msg.user h6 {
    color: white;
}

.msg h1 {
    font-size: 1.75rem;
    border-bottom: 2px solid rgba(148, 163, 184, 0.3);
    padding-bottom: 0.5rem;
}

.msg.user h1 {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.msg h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    padding-bottom: 0.4rem;
}

.msg.user h2 {
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.msg h3 {
    font-size: 1.25rem;
}

.msg h4 {
    font-size: 1.1rem;
}

.msg h5 {
    font-size: 1rem;
}

.msg h6 {
    font-size: 0.9rem;
    color: #64748b;
}

.msg.user h6 {
    color: rgba(255, 255, 255, 0.8);
}

.msg p {
    margin: 0.75em 0;
}

.msg p:first-child {
    margin-top: 0;
}

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

.msg strong {
    font-weight: 700;
    color: #1e293b;
}

.msg.user strong {
    color: white;
}

.msg em {
    font-style: italic;
    color: #475569;
}

.msg.user em {
    color: rgba(255, 255, 255, 0.9);
}

.msg a {
    color: #6366f1;
    text-decoration: underline;
    transition: color 0.2s;
}

.msg.user a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: underline;
}

.msg a:hover {
    color: #4f46e5;
}

.msg.user a:hover {
    color: white;
}

/* Code blocks */
.code-block-wrapper {
    background: #1e293b;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.code-block {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #e2e8f0;
    background: transparent;
    padding: 0;
    margin: 0;
    white-space: pre;
    overflow-x: auto;
    display: block;
}

/* Syntax highlighting colors */
.code-block .keyword {
    color: #c792ea;
    font-weight: 600;
}

.code-block .string {
    color: #c3e88d;
}

.code-block .comment {
    color: #546e7a;
    font-style: italic;
}

.code-block .number {
    color: #f78c6c;
}

.code-block .tag {
    color: #82aaff;
}

.code-block .tag-name {
    color: #ff5370;
}

.code-block .tag-attr {
    color: #c792ea;
}

.code-block .selector {
    color: #82aaff;
}

.code-block .property {
    color: #c792ea;
}

/* Inline code */
.inline-code {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    font-weight: 500;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.msg.user .inline-code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Tables */
.markdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: #ffffff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.msg.user .markdown-table {
    background: rgba(255, 255, 255, 0.1);
}

.markdown-table thead {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.msg.user .markdown-table thead {
    background: rgba(255, 255, 255, 0.15);
}

.markdown-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #1e293b;
    border-bottom: 2px solid rgba(148, 163, 184, 0.2);
}

.msg.user .markdown-table th {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.markdown-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    color: #475569;
}

.msg.user .markdown-table td {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.markdown-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.msg.user .markdown-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

.markdown-table tbody tr:last-child td {
    border-bottom: none;
}

.msg-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    padding-left: 0;
}

.continue-btn {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 0.5rem;
    padding: 0.4rem 0.75rem;
    color: #6366f1;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    font-family: inherit;
}

.continue-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
}

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

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

/* Legacy continue button support */
.msg-actions .continue-btn {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 0.375rem;
    padding: 0.35rem 0.6rem;
    color: #6366f1;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.msg-actions .continue-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

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

#input-bar {
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    padding: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

.input-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#message {
    flex: 1;
    resize: none;
    min-height: 3rem;
    max-height: 12rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    border: 2px solid rgba(148, 163, 184, 0.3);
    background: #ffffff;
    color: #1e293b;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
    -webkit-appearance: none;
    position: relative;
}

#message:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    background: #ffffff;
}

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

.input-char-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.input-hint kbd {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.25rem;
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
    font-family: monospace;
    color: #64748b;
}

#sendBtn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 0.75rem;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    touch-action: manipulation;
    min-width: 80px;
    min-height: 48px;
}

#sendBtn:hover:not([disabled]) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

#sendBtn:active:not([disabled]) {
    transform: translateY(0);
}

#sendBtn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#controls {
    display: none;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

#controls.show {
    display: flex;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

#systemPrompt {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #ffffff;
    color: #1e293b;
    font-family: inherit;
    transition: all 0.2s;
    -webkit-appearance: none;
}

#systemPrompt:focus {
    outline: none;
    border-color: #6366f1;
    background: #ffffff;
}

#tokens {
    width: 6rem;
    background: #ffffff;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #1e293b;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    text-align: right;
    font-family: inherit;
    transition: all 0.2s;
    -webkit-appearance: none;
}

#tokens:focus {
    outline: none;
    border-color: #6366f1;
    background: #ffffff;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
        height: 100%;
    }

    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 999;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    }

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

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        top: 0.75rem;
        left: 0.75rem;
    }

    .sidebar-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    header {
        padding: 0.75rem 1rem;
        min-height: 56px;
        grid-template-columns: 44px 1fr auto;
        gap: 0.5rem;
    }

    .header-left-spacer {
        width: 44px;
        min-width: 44px;
        justify-content: flex-start;
    }

    .header-center {
        justify-content: center;
        gap: 0.5rem;
        overflow: hidden;
    }

    .header-right {
        justify-content: flex-end;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    #controls {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .header-center {
        gap: 0.5rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        padding-right: 8px;
    }

    .header-text h1 {
        font-size: 1rem;
    }

    .header-text span {
        font-size: 0.7rem;
    }

    #status {
        font-size: 0.7rem;
        padding: 0.35rem 0.6rem;
        min-width: 100px;
        display: flex !important;
    }

    #status::before {
        width: 6px;
        height: 6px;
    }

    .chat-item {
        padding: 0.875rem;
        gap: 0.5rem;
    }

    .chat-item-delete {
        opacity: 1 !important;
        min-width: 36px;
        min-height: 36px;
        font-size: 1.1rem;
    }

    #chat-container {
        padding: 1rem 1.25rem;
        gap: 1rem;
    }

    .msg-container {
        max-width: 80%;
        gap: 0.5rem;
    }

    .msg-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .msg {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
    }

    .msg-timestamp {
        font-size: 0.65rem;
    }

    .msg-action-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .empty-state {
        padding: 2rem 1rem;
        min-height: 300px;
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .empty-state h3 {
        font-size: 1.25rem;
    }

    .empty-state p {
        font-size: 0.85rem;
    }

    .suggestion-chip {
        padding: 0.625rem 0.875rem;
        font-size: 0.85rem;
    }

    .input-footer {
        font-size: 0.7rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .input-hint {
        display: none;
    }

    #input-bar {
        padding: 0.875rem;
        gap: 0.625rem;
    }

    .input-row {
        gap: 0.5rem;
    }

    #message {
        min-height: 2.75rem;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    #sendBtn {
        padding: 0.75rem 1.25rem;
        font-size: 0.85rem;
        min-width: 70px;
        min-height: 44px;
    }

    #controls {
        flex-direction: column;
        gap: 0.625rem;
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #ffffff;
        border-top: 1px solid rgba(148, 163, 184, 0.3);
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    #controls.show {
        display: flex;
    }

    .control-group {
        width: 100%;
        min-width: 0;
    }

    label {
        font-size: 0.75rem;
        min-width: 60px;
    }

    #systemPrompt {
        font-size: 0.75rem;
        padding: 0.45rem 0.65rem;
    }

    #tokens {
        width: 100%;
        text-align: left;
        font-size: 0.75rem;
        padding: 0.45rem 0.65rem;
    }

}

/* Small mobile devices */
@media (max-width: 480px) {
    #sidebar {
        width: 100%;
    }

    header {
        grid-template-columns: 44px 1fr auto;
        padding: 0.75rem 0.5rem;
    }

    .header-center {
        gap: 0.4rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
        padding-right: 6px;
    }

    .header-text h1 {
        font-size: 0.9rem;
    }

    .header-text span {
        display: none;
    }

    #status {
        display: none;
    }

    .settings-btn {
        min-width: 32px;
        min-height: 32px;
        padding: 0.4rem;
        font-size: 1rem;
    }

    .msg-container {
        max-width: 85%;
        gap: 0.4rem;
    }

    .msg-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .msg {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .msg-timestamp {
        font-size: 0.6rem;
    }

    .msg-action-btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.65rem;
    }

    #chat-container {
        padding: 0.75rem 1rem;
    }

    .empty-state {
        padding: 1.5rem 0.75rem;
        min-height: 250px;
    }

    .empty-state-icon {
        font-size: 2.5rem;
    }

    .empty-state h3 {
        font-size: 1.1rem;
    }

    .empty-state p {
        font-size: 0.8rem;
    }

    .suggestion-chip {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .input-footer {
        display: none;
    }
}

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

::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4) 0%, rgba(139, 92, 246, 0.4) 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.6) 0%, rgba(139, 92, 246, 0.6) 100%);
}

/* Prevent text selection on buttons for better mobile UX */
button, .chat-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
