/* MHAI CSS 1.5 */

/* Hide scrollbar for Chrome, Safari, Edge, and newer Firefox */
.chat-container {
    /* Hide scrollbar track and thumb */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* --- Chat bubble: Gradient fill (Style 19) --- */
.chat-container .message .message-bubble {
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(59,130,246,0.18)) !important;
    border: 1px solid rgba(34,211,238,0.35) !important;
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.5) !important;
    filter: none !important;
    text-shadow: none !important;
}
.chat-container .message.ai .message-bubble {
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(59,130,246,0.18)) !important;
    border-color: rgba(34,211,238,0.35) !important;
}

/* User bubbles: revert to subtle grey card */
.chat-container .message.user .message-bubble {
    background: rgba(148,163,184,0.06) !important;
    border-color: rgba(148,163,184,0.30) !important;
}

/* Kill any decorative pseudo-elements that might add glow */
.chat-container .message .message-bubble::before,
.chat-container .message .message-bubble::after {
    content: none !important;
    display: none !important;
}

/* Markdown in bubbles */
.chat-container .message .message-bubble pre {
    background: rgba(2,6,23,0.65);
    border: 1px solid rgba(148,163,184,0.15);
    padding: 8px; /* tighter */
    border-radius: 10px;
    overflow: auto;
}
.chat-container .message .message-bubble code:not(pre code) {
    background: rgba(148,163,184,0.12);
    padding: .15em .35em;
    border-radius: 6px;
}
.chat-container .message .message-bubble blockquote {
    margin: 8px 0;
    padding: 6px 10px;
    border-left: 3px solid #94a3b8;
    background: rgba(148,163,184,0.08);
    color: #cbd5e1;
}
.chat-container .message .message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}
.chat-container .message .message-bubble th,
.chat-container .message .message-bubble td {
    border: 1px solid rgba(148,163,184,0.25);
    padding: 6px 8px;
    text-align: left;
}
.chat-container .message .message-bubble th {
    background: rgba(148,163,184,0.12);
}

/* --- Reasoning (compact, no card) --- */
.think-container { background: transparent !important; border: none !important; margin-bottom: 6px; }
.think-header { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px; background: transparent; border: none; }
.think-title { color: #9ec5ff; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.think-toggle { background: transparent; border: none; color: #94D4FF; padding: 0 2px; cursor: pointer; font-size: 0.8rem; }
.think-content { font-size: 0.85rem; line-height: 1.35; color: #cbd5e1; opacity: 0.88; background: transparent !important; border: none !important; box-shadow: none !important; padding: 0; margin-top: 6px; }
.think-content.collapsed { display: none; }

.ai-mode-button {
    background: rgba(0, 122, 204, 0.18);
    border: 1px solid rgba(0, 122, 204, 0.45);
    color: #cfe9ff;
    padding: 6px;
    border-radius: 8px;
    display: none; /* hidden by default; shown on mobile */
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ai-mode-button:hover { background: rgba(0,122,204,0.26); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.modal-content {
    background: #252526;
    border: 1px solid rgba(74,85,104,0.6);
    border-radius: 12px;
    width: calc(100% - 48px);
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.modal-header { padding: 14px 16px; font-weight: 600; color: #e2e8f0; border-bottom: 1px solid rgba(74,85,104,0.6); }
.modal-body { padding: 16px; }
.modal-body .ai-mode-select { display: block !important; width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid rgba(74,85,104,0.6); }
.modal-btn { border: 1px solid rgba(74,85,104,0.6); background: rgba(45,55,72,0.8); color: #e2e8f0; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.modal-btn.apply { background: #007ACC; border-color: #007ACC; }

/* Light theme for modal */
body.theme-light .modal-content { background: #ffffff; border: 1px solid #e5e7eb; box-shadow: 0 10px 30px rgba(2,132,199,0.15); }
body.theme-light .modal-header { color: #0f172a; border-bottom-color: #e5e7eb; }
body.theme-light .modal-actions { border-top-color: #e5e7eb; }
body.theme-light .modal-btn { background: #f8fafc; color: #0f172a; border-color: #e5e7eb; }
body.theme-light .modal-btn.apply { background: #007ACC; border-color: #007ACC; color: #ffffff; }
body.theme-light .modal-body .ai-mode-select { background: #ffffff; border: 1px solid #93c5fd; color: #0f172a; }
body.theme-light .modal-body .ai-mode-select:focus { box-shadow: 0 0 0 2px rgba(147,197,253,0.6); outline: none; }
body.theme-light .modal-body .ai-mode-select option { background: #ffffff; color: #0f172a; }

/* PWA loader overlay */
.pwa-loader {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(60% 60% at 50% 40%, rgba(0,122,204,0.25), rgba(0,0,0,0.65));
    backdrop-filter: blur(10px);
    z-index: 3000;
}
.pwa-loader.active { display: flex; animation: pwaFadeIn 180ms ease-out; }
.pwa-loader.fade-out { animation: pwaFadeOut 260ms ease-in forwards; }
.pwa-loader-inner {
    width: 88px;
    height: 88px;
    border-radius: 20px;
    background: rgba(37, 99, 235, 0.18);
    border: 1px solid rgba(59,130,246,0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    animation: pwaPulse 1.4s ease-in-out infinite;
}
.pwa-loader-inner img { width: 54px; height: 54px; border-radius: 12px; display: block; }
.pwa-spinner { width: 18px; height: 18px; border: 2px solid rgba(59,130,246,0.35); border-top-color: #3b82f6; border-radius: 50%; animation: pwaSpin 0.9s linear infinite; }

@keyframes pwaPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
  50% { transform: scale(1.05); box-shadow: 0 14px 36px rgba(0,0,0,0.45); }
}
@keyframes pwaFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes pwaFadeOut { to { opacity: 0; visibility: hidden } }
@keyframes pwaSpin { to { transform: rotate(360deg); } }

/* Light theme for PWA loader */
body.theme-light .pwa-loader {
    background: radial-gradient(60% 60% at 50% 40%, rgba(147,197,253,0.38), rgba(231,240,255,0.85));
}
body.theme-light .pwa-loader-inner {
    background: #e8f2ff;
    border-color: #93c5fd;
    box-shadow: 0 10px 30px rgba(2,132,199,0.18);
}
body.theme-light .pwa-spinner { border-color: rgba(147,197,253,0.75); border-top-color: #2563eb; }

.disclaimer {
    margin-top: 8px;
    color: #9aa5b1;
    font-size: 0.78rem;
    line-height: 1.0;
    opacity: 0.85;
    text-align: center;
}

/* Inside input bubble: make it a sub-row below controls */
.input-wrapper .disclaimer {
    width: 100%;
    order: 99; /* ensure it sits after buttons */
    margin-top: 0px;
    font-size: 0.7rem;
    opacity: 0.8;
    flex-basis: 100%; /* always take full row under input and buttons */
}

/* Suggested prompts above input */
/* Floating suggested prompts (centered above input) */
.suggested-prompts {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 140px; /* sits above input */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 40px);
    max-width: 800px; /* base */
    z-index: 60;
}

.prompt-chip {
    background: rgba(0, 122, 204, 0.16);
    border: 1px solid rgba(0, 122, 204, 0.35);
    color: #cfe9ff;
    padding: 8px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.prompt-chip:hover {
    background: rgba(0, 122, 204, 0.24);
    border-color: rgba(0, 122, 204, 0.5);
}

.prompt-chip:active {
    transform: translateY(1px);
}

/* Hide scrollbar for WebKit browsers (Chrome, Safari, including iOS/iPadOS) */
.chat-container::-webkit-scrollbar {
    display: none;
}

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

body {
    font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1e1e1e;
    color: #cccccc;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

/* Theme toggle button */
#themeToggleBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(0, 122, 204, 0.45);
    background: rgba(0, 122, 204, 0.18);
    color: #cfe9ff;
    cursor: pointer;
    padding: 0;
}
#themeToggleBtn .material-symbols-outlined { font-size: 20px; line-height: 1; display: block; }
#themeToggleBtn:hover { background: rgba(0,122,204,0.26); }

/* Light theme overrides */
body.theme-light {
    background: #f7f7f8;
    color: #1f2937;
}
body.theme-light .header {
    background: linear-gradient(135deg, #e7f0ff 0%, #dbeafe 100%);
    border-bottom-color: #004ca2;
    box-shadow: 0 4px 14px rgba(30, 58, 138, 0.12);
}
body.theme-light .logo {
    -webkit-text-fill-color: initial;
    color: #0f172a;
}
body.theme-light .ai-mode-select {
    background: #ffffff;
    border: 1px solid #93c5fd;
    color: #0f172a;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23172537' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
}
body.theme-light #themeToggleBtn {
    background: #e8f2ff;
    border: 1px solid #93c5fd;
    color: #0f172a;
}
body.theme-light .chat-container { scrollbar-color: #e5e7eb transparent; }
body.theme-light .welcome-message { background: rgba(2,132,199,0.06); border-color: rgba(2,132,199,0.25); }
body.theme-light .welcome-message h2 { color: #0369a1; }
body.theme-light .warning-text { color: #0f172a !important; background: rgba(2,132,199,0.08) !important; border-color: #93c5fd !important; }

/* Messages */
body.theme-light .message.user .message-bubble {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.28);
}
body.theme-light .message.ai .message-bubble {
    /* Keep gradient consistent with dark mode for AI responses */
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(59,130,246,0.18)) !important;
    color: #0f172a;
    border: 1px solid rgba(34,211,238,0.35) !important;
    box-shadow: 0 8px 18px rgba(0,0,0,0.08) !important;
}
body.theme-light .chat-container .message .message-bubble {
    background: linear-gradient(135deg, rgba(59,130,246,0.10), rgba(34,211,238,0.10)) !important;
    border: 1px solid rgba(59,130,246,0.25) !important;
    box-shadow: 0 8px 18px rgba(0,0,0,0.08) !important;
}
/* Keep same blue gradient for AI responses in light mode */
body.theme-light .chat-container .message.ai .message-bubble {
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(59,130,246,0.18)) !important;
    border: 1px solid rgba(34,211,238,0.35) !important;
    color: #0f172a;
}
body.theme-light .chat-container .message.user .message-bubble {
    background: rgba(100,116,139,0.06) !important;
    border-color: rgba(100,116,139,0.25) !important;
    color: #1f2937;
}

/* Markdown blocks */
body.theme-light .message .message-bubble pre { background: #f3f4f6; border-color: #e5e7eb; }
body.theme-light .message .message-bubble code:not(pre code) { background: #eef2ff; }
body.theme-light .message .message-bubble blockquote { background: #f8fafc; border-left-color: #cbd5e1; color: #334155; }
body.theme-light .message-bubble pre { background: #f3f4f6; border-left-color: #60a5fa; }
body.theme-light .message-bubble code { background: #f3f4f6; }
body.theme-light .message-bubble a { color: #2563eb; }

/* Thinking */
body.theme-light .think-title { color: #0369a1; }
body.theme-light .think-toggle { color: #0ea5e9; }
body.theme-light .think-content { color: #334155; }
body.theme-light .think-content blockquote { color: #334155; border-left-color: #cbd5e1; }
body.theme-light .think-timing { color: #64748b; font-size: 0.75rem; margin-top: 4px; }
body.theme-light .external-typing-indicator .typing-dots span { background-color: #2563eb; }

/* Input area */
/* Match light mode navbar/sidebar blue gradient */
/* Harmonize wrapper with light blue theme */
body.theme-light .input-wrapper { background: #e8f2ff; border: 1px solid #93c5fd; box-shadow: 0 10px 28px rgba(2,132,199,0.18); }
body.theme-light .input-field { background: #ffffff; border-color: #e5e7eb; color: #111827; }
body.theme-light .input-field::placeholder { color: #9ca3af; }
body.theme-light .send-btn, 
body.theme-light .stop-btn { box-shadow: 0 2px 8px rgba(2,132,199,0.25); }

/* Actions */
body.theme-light .message-actions .copy-btn { background: #ffffff; border-color: #e5e7eb; color: #2563eb; }
body.theme-light .message-actions .copy-btn:hover { background: #f8fafc; color: #1d4ed8; }
body.theme-light .message-actions .generation-time { color: #64748b; }

/* Scroll to bottom */
body.theme-light .scroll-to-bottom { background: #ffffff; border-color: #e5e7eb; color: #2563eb; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
body.theme-light .scroll-to-bottom:hover { background: #f8fafc; }

/* Sidebar and overlays */
body.theme-light .sidebar { background: linear-gradient(135deg, #e7f0ff 0%, #dbeafe 100%); border-right: 1px solid #93c5fd; }
body.theme-light .sidebar .brand span { color: #0b1220; }
body.theme-light .sidebar-nav .nav-item { color: #0b1220; border-color: rgba(147,197,253,0.6); background: rgba(255,255,255,0.0); }
body.theme-light .sidebar-overlay { background: rgba(0,0,0,0.25); }
body.theme-light .suggested-prompts { color: #0f172a; }
body.theme-light .prompt-chip { background: #e8f2ff; border-color: #bfdbfe; color: #0f172a; }
body.theme-light .prompt-chip:hover { background: #dbeafe; border-color: #93c5fd; }
body.theme-light .header-title { color: #0f172a; }
body.theme-light .ai-mode-button { border-color: #93c5fd; background: #e8f2ff; color: #0f172a; }
body.theme-light .disclaimer { color: #64748b; }
body.theme-light .welcome-message p { color: #334155; }
body.theme-light .chat-item.active { background: rgba(2,132,199,0.18); border-left-color: #3b82f6; }
body.theme-light .chat-title { color: #0f172a; }
body.theme-light .sidebar-toggle { color: #0f172a; }
body.theme-light .sidebar-toggle:hover { background: rgba(37,99,235,0.12); }
/* New Chat button prominence */
/* Light mode New Chat: same as dark base styling */
body.theme-light .sidebar .nav-new-chat {
    background: linear-gradient(135deg, rgba(0,122,204,0.35), rgba(59,130,246,0.35)) !important;
    border: 1px solid rgba(59,130,246,0.6) !important;
    color: #000000 !important;
}
body.theme-light .sidebar .nav-new-chat:hover {
    background: linear-gradient(135deg, rgba(0,122,204,0.45), rgba(59,130,246,0.45)) !important;
}
body.theme-light .sidebar .nav-new-chat svg { color: #000000 !important; fill: currentColor !important; }

/* Header Styles */
.header {
    background: linear-gradient(135deg, #252526 0%, #1e1e1e 100%);
    padding: 12px 16px;
    border-bottom: 1px solid #007ACC;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    min-height: 56px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #007ACC 0%, #4dabf7 50%, #74c0fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

.logo img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.clear-btn {
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid rgba(74, 85, 104, 0.6);
    color: #ef4444;
    padding: 6px 20px 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    backdrop-filter: blur(10px);
}


.dropdown-wrapper {
    position: relative;
    display: inline-block;
}

/* Custom select control */
.select-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px 0 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 122, 204, 0.45);
    background: rgba(0, 122, 204, 0.18);
    color: #cfe9ff;
    cursor: pointer;
    user-select: none;
}
.select-control:focus { outline: none; box-shadow: 0 0 0 2px rgba(0,122,204,0.35); }
.select-label { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-caret { font-size: 18px; line-height: 1; opacity: 0.9; }
.select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    max-height: 360px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid rgba(59,130,246,0.45);
    background: #1f2937;
    color: #e5e7eb;
    box-shadow: 0 14px 34px rgba(0,0,0,0.35);
    display: none;
    z-index: 2000;
}
.select-option {
    padding: 10px 12px;
    cursor: pointer;
}
.select-option:hover { background: rgba(59,130,246,0.18); }
.select-option[aria-selected="true"] { background: rgba(59,130,246,0.28); }

/* Light theme tweaks for custom select */
body.theme-light .select-control {
    background: #e8f2ff;
    border-color: #93c5fd;
    color: #0f172a;
}
body.theme-light .select-menu {
    background: #ffffff;
    color: #0f172a;
    border-color: #93c5fd;
    box-shadow: 0 14px 34px rgba(2,132,199,0.18);
}
body.theme-light .select-option:hover { background: #e8f2ff; }
body.theme-light .select-option[aria-selected="true"] { background: #dbeafe; }

/* Hide native select on desktop header; show custom control */
.header .ai-mode-select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 768px) {
  .select-control { display: none; }
  .header .ai-mode-select { position: static; width: auto; height: auto; opacity: 1; pointer-events: auto; }
}

.ai-mode-select {
    background: rgba(0, 122, 204, 0.16);
    border: 1px solid rgba(0, 122, 204, 0.45);
    color: #cfe9ff;
    padding: 6px 20px 6px 8px;
    cursor: pointer;
    font-size: 0.85rem;
    outline: none;
    min-width: 30px;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234dabf7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    border-radius: 8px;
    height: 36px;
}

.ai-mode-select:focus {
    color: #4dabf7;
}

.ai-mode-select option {
    background: #2d3748;
    color: #e2e8f0;
    padding: 8px 12px;
    font-size: 0.85rem;
    text-align: left;
    direction: ltr;
}

.ai-mode-select option:hover {
    background: #4a5568;
    color: #e2e8f0;
}

.ai-mode-select option:checked,
.ai-mode-select option:selected {
    background: #007ACC;
    color: white;
}

.ai-mode-select option:focus {
    background: #4a5568;
    color: #e2e8f0;
}

.ai-mode-select:hover {
    cursor: pointer;
}

/* Chat Container */
.chat-container {
    flex: 1;
    padding: 16px;
    padding-bottom: 120px;
    /* Space for floating input */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    /* Hide scrollbars */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.chat-container::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 24px 20px;
    background: rgba(0, 138, 223, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(0, 122, 204, 0.2);
    margin-bottom: 16px;
    max-width: 600px;
    margin: 0 auto 16px auto;
}

.welcome-message h2 {
    color: #007ACC;
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.welcome-message p {
    opacity: 0.8;
    line-height: 1.5;
    font-size: 0.9rem;
}

.welcome-message kbd {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 12px;
    animation: slideIn 0.3s ease-out;
}

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

/* Mobile tweaks for disclaimer */
@media (max-width: 768px) {
    .disclaimer {
        font-size: 0.76rem;
        padding: 0 8px;
    }
}

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

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

.message-bubble {
    max-width: 70%;
    padding: 10px 12px; /* tighter like template */
    border-radius: 14px; /* match bubble gallery style 19 */
    position: relative;
    word-wrap: break-word;
    line-height: 1.45; /* reduce vertical height */
    font-size: 0.95rem; /* match gallery readability */
}

.message.user .message-bubble {
    background: #007ACC;
    color: #e2e8f0;
    border-bottom-right-radius: 14px;
    border-bottom-right-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 122, 204, 0.3)
}

.message.ai .message-bubble {
    background: #4a5568;
    color: #e2e8f0;
    border-top-left-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Avatar Styles */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message.user .avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.message.ai .avatar {
    background: linear-gradient(135deg, #007ACC, #0056b3);
    padding: 0;
}

/* Markdown Content Styles */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin: 8px 0; /* tighter heading spacing */
    color: inherit;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

/* Paragraph spacing inside bubbles */
.message-bubble p {
    margin: 6px 0 8px 0; /* tighter paragraph separation */
}

/* Space between consecutive block elements inside bubbles */
.message-bubble > * + * {
    margin-top: 4px; /* tighter vertical rhythm */
}

/* Markdown table styling */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    background: rgba(255,255,255,0.02);
}

.message-bubble th,
.message-bubble td {
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 6px 8px; /* tighter table cell padding */
    text-align: left;
}

.message-bubble thead th {
    background: rgba(148, 163, 184, 0.12);
    font-weight: 600;
}

.message-bubble tbody tr:nth-child(odd) {
    background: rgba(148, 163, 184, 0.06);
}

.message-bubble li {
    margin: 3px 0; /* tighter list spacing */
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px; /* tighter */
    border-radius: 8px;
    margin: 6px 0; /* tighter */
    overflow-x: auto;
    border-left: 3px solid #007ACC;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 5px; /* slightly tighter */
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

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

.message-bubble strong {
    color: #5BBDFF;
}

.message-bubble a {
    color: #60a5fa;
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: underline;
}

/* Typing Indicator */
/* Typing indicator - horizontally aligned with avatar */
.external-typing-indicator {
    display: flex;
    align-items: center;
    height: 40px;
    /* Match avatar height */
}

.external-typing-indicator .typing-dots {
    display: flex;
    gap: 4px;
}

.external-typing-indicator .typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #007ACC;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 20px;
    min-height: 20px;
}

.typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #007ACC;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
    opacity: 0.4;
}

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

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Loading message bubble specific styling */
.message.ai .message-bubble .typing-indicator {
    padding: 12px 16px;
    background: transparent;
}

/* Message Actions - under bubble, always visible */
.message-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px; /* tighter spacing under bubble */
}

.message-actions .copy-btn {
    background: rgba(45, 55, 72, 0.8);
    border: 1px solid rgba(74, 85, 104, 0.6);
    border-radius: 6px;
    color: #007ACC;
    cursor: pointer;
    padding: 6px;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.message-actions .copy-btn:hover {
    background: rgba(55, 65, 82, 0.9);
    color: #4dabf7;
}

.message-actions .copy-btn.copied {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.6);
}

.message-actions .copy-btn svg {
    width: 14px;
    height: 14px;
}

.message-actions .generation-time {
    font-size: 0.75rem;
    color: #a0aec0;
    font-weight: 500;
}

/* DeepThink thinking collapsible */
.think-container {
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    margin: 6px 0;
    overflow: visible;
}

.think-header {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 6px;
    padding: 0 !important;
    background: transparent !important;
    width: auto;
}

.header-title {
    flex: 1 1 auto;
    text-align: center;
    font-weight: 500;
}

.header-title.hidden {
    display: none;
}

.think-title {
    color: #9ec5ff;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.think-toggle {
    background: transparent;
    color: #94D4FF;
    border: none;
    padding: 0 2px;
    font-size: 0.85rem;
    cursor: pointer;
}

.think-content {
    padding: 0;
    color: #cbd5e1;
    white-space: normal;
    line-height: 1.35;
    margin-top: 6px;
}

.think-content blockquote {
    margin: 4px 0;
    padding: 4px 8px;
    border-left: 3px solid #94a3b8;
    background: transparent;
    color: #cbd5e1;
}

.think-content.collapsed {
    display: none;
}

/* Input Container */
.input-container {
    background: transparent;
    padding: 20px;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 800px;
    z-index: 50;
    transition: left 0.3s ease, transform 0.3s ease, max-width 0.3s ease;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap; /* allow disclaimer to wrap onto new line */
    max-width: 100%;
    margin: 0 auto;
    background: rgba(45, 55, 72, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 16px;
    border: 1px solid rgba(74, 85, 104, 0.6);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.input-field {
    flex: 1;
    background: rgba(26, 26, 46, 0.8);
    border: 1px solid rgba(74, 85, 104, 0.4);
    border-radius: 12px; /* match send button */
    padding: 12px 16px;
    color: #e2e8f0;
    font-size: 16px;
    /* 16px prevents iOS auto-zoom */
    resize: none;
    min-height: 20px;
    max-height: 200px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
}

.input-field:focus {
    border-color: #065799e1;
    box-shadow: 0 0 0 1px #065799e1; /* thinner ring */
    background: rgba(26, 26, 46, 0.9);
    outline: none;
}

.input-field::placeholder {
    color: #a0aec0;
}

.send-btn,
.stop-btn {
    background: #065799e1; /* lighter blue */
    border: none;
    border-radius: 12px;
    width: 48px;
    height: 48px; /* slightly taller to align with textarea */
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(10, 71, 112, 0.3);
    flex-shrink: 0;
}

.send-btn .material-symbols-outlined { font-size: 22px; line-height: 1; }
.stop-btn .material-symbols-outlined { font-size: 22px; line-height: 1; }

.send-btn:hover,
.stop-btn:hover {
    opacity: 0.9;
}

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

.stop-btn { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 2px 8px rgba(239,68,68,0.3); display: none; }

/* Scroll to Bottom Button */
.scroll-to-bottom {
    position: fixed;
    right: 24px;
    bottom: 120px;
    width: 48px;
    height: 48px;
    background: rgba(45, 55, 72, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(74, 85, 104, 0.6);
    border-radius: 50%;
    color: #007ACC;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    z-index: 40;
}

.scroll-to-bottom:hover {
    background: rgba(55, 65, 82, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.scroll-to-bottom svg {
    width: 20px;
    height: 20px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }

    .logo {
        font-size: 1.3rem;
    }

    .header-controls {
        gap: 8px;
    }

    .ai-mode-select {
        min-width: 140px;
        font-size: 0.8rem;
        padding: 5px 18px 5px 8px;
        background-size: 10px;
        background-position: right 4px center;
        height: 34px;
    }
    #themeToggleBtn { width: 34px; height: 34px; }

    .chat-container {
        padding: 16px;
        padding-bottom: 100px;
        max-width: none;
    }

    .message-bubble {
        max-width: 90%;
        padding: 14px 16px;
    }

    .avatar {
        width: 32px;
        height: 32px;
        margin: 0 8px;
        font-size: 1rem;
    }

    .input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        max-width: none;
        padding: 8px 12px 8px 12px;
        /* Reduced padding for smaller screens */
        background: #1a1a2e;
        border-top: 1px solid #2d3748;
    }

    /* Light mode mobile: black top line with soft blue glow */
    body.theme-light .input-container {
        background: #f8fafc;
        border-top: none !important;
        box-shadow: 0 -6px 18px rgba(59,130,246,0.20), 0 -1px 0 rgba(0,0,0,0.04) inset;
    }

    .suggested-prompts {
        margin-bottom: 8px;
    }

    .input-wrapper {
        background: transparent;
        backdrop-filter: none;
        border-radius: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        gap: 8px;
        /* Smaller gap between input and buttons */
    }

    .input-field {
        background: #2d3748;
        border: 1px solid #4a5568;
        border-radius: 10px; /* match mobile send button */
        /* Slightly smaller border radius */
        padding: 12px 16px;
        /* Reduced padding */
        font-size: 16px;
        /* Maintain 16px to prevent iOS zoom */
        line-height: 1.3;
        /* Tighter line height for mobile */
        min-height: 16px;
        /* Smaller min-height */
        max-height: 120px;
        /* Smaller max-height for mobile */
    }

    .send-btn,
    .stop-btn {
        width: 44px;
        height: 44px; /* match input single-line height */
        border-radius: 10px;
        /* Smaller border radius */
    }

    .send-btn svg,
    .stop-btn svg {
        width: 18px;
        /* Smaller icons */
        height: 18px;
    }

    .welcome-message {
        padding: 30px 16px;
        max-width: none;
        margin: 0 0 20px 0;
    }

    .welcome-message h2 {
        font-size: 1.5rem;
    }

    .scroll-to-bottom {
        right: 16px;
        bottom: 100px;
        width: 44px;
        height: 44px;
    }

    .scroll-to-bottom svg {
        width: 18px;
        height: 18px;
    }

    /* Reposition floating suggested prompts for mobile */
    .suggested-prompts {
        left: 50%;
        transform: translateX(-50%);
        bottom: 88px;
        width: calc(100% - 24px);
        max-width: none;
        gap: 6px;
        justify-content: center;
    }
}

/* Desktop Responsive */
@media (min-width: 769px) {
    .header {
        padding: 16px 12px; /* tighter left padding to sit flush with 260px sidebar */
        height: 60px;
    }

    .logo {
        font-size: 1.5rem;
        font-weight: 700;
        letter-spacing: -0.03em;
    }

    .logo img {
        width: 38px;
        height: 38px;
    }

    .chat-container {
        padding: 24px 32px;
        padding-bottom: 110px;
        gap: 16px;
    }

    .message-bubble {
        max-width: 65%;
        padding: 9px 20px;
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .avatar {
        width: 36px;
        height: 36px;
        margin: 0 12px;
        font-size: 1.1rem;
    }

    .input-container {
        bottom: 12px;
        max-width: 900px;
    }

    /* Match floating chips width to input container on desktop */
    .suggested-prompts {
        max-width: 900px;
    }

    .input-field {
        padding: 14px 18px;
        font-size: 0.95rem;
        border-radius: 16px;
        max-height: 150px;
    }

    .send-btn,
    .stop-btn {
        width: 44px;
        height: 44px;
    }

    .welcome-message {
        padding: 24px 28px;
        max-width: 580px;
        margin: 12px auto;
    }

    .welcome-message h2 {
        font-size: 1.4rem;
        margin-bottom: 8px;
    }

    .welcome-message p {
        font-size: 0.9rem;
        max-width: 450px;
        margin: 0 auto;
    }

    .clear-btn {
        padding: 6px 6px;
        font-size: 0.85rem;
    }

    .desktop-shortcuts {
        display: block !important;
    }

    .scroll-to-bottom {
        right: 32px;
        bottom: 100px;
        width: 52px;
        height: 52px;
    }

    .scroll-to-bottom svg {
        width: 22px;
        height: 22px;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    .chat-container {
        padding: 32px 64px;
        padding-bottom: 120px;
        max-width: 1400px;
        margin: 0 auto;
    }

    .input-container {
        bottom: 16px;
        max-width: 1000px;
    }

    /* Large desktop: align chips width with input container */
    .suggested-prompts {
        max-width: 1000px;
    }

    .input-wrapper {
        max-width: 1200px;
        margin: 0 auto;
    }

    .message-bubble {
        max-width: 55%;
        padding: 18px 22px;
        font-size: 0.98rem;
    }

    .welcome-message {
        padding: 32px 36px;
        max-width: 650px;
    }

    .welcome-message h2 {
        font-size: 1.5rem;
    }

    .welcome-message p {
        font-size: 0.95rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .input-container {
        padding: 6px 8px;
        /* Even smaller padding for very small screens */
    }

    .input-field {
        padding: 10px 14px;
        /* Smaller padding */
        border-radius: 8px; /* match xs send button */
        /* Smaller border radius */
        font-size: 16px;
        /* Keep 16px to prevent zoom */
    }

    .send-btn,
    .stop-btn {
        width: 40px;
        height: 40px; /* xs size alignment */
        border-radius: 8px;
    }

    .send-btn svg,
    .stop-btn svg {
        width: 16px;
        /* Smaller icons */
        height: 16px;
    }

    .input-wrapper {
        gap: 6px;
        /* Smaller gap */
    }

    /* Extra small screens: keep chips visible and centered within safe area */
    .suggested-prompts {
        left: 50%;
        transform: translateX(-50%);
        bottom: 84px;
        width: calc(100% - 16px);
        max-width: none;
        gap: 6px;
        justify-content: center;
        min-width: 30px;
        font-size: 0.75rem;
        padding: 4px 16px 4px 6px;
        background-size: 9px;
        background-position: right 3px center;
    }

    .clear-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}

/* Ultra-wide Desktop */
@media (min-width: 1600px) {
    .chat-container {
        padding: 40px 80px;
        padding-bottom: 130px;
        max-width: 1600px;
    }

    .input-container {
        bottom: 20px;
        max-width: 1200px;
    }

    /* Ultra-wide: align chips width with input container */
    .suggested-prompts {
        max-width: 1200px;
    }

    .input-wrapper {
        max-width: 1400px;
    }

    .message-bubble {
        max-width: 50%;
        padding: 7px 24px;
    }
}

/* KaTeX math rendering styles */
.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 1em 0;
    text-align: center;
}

/* Ensure math doesn't break layout */
.katex-display .katex {
    white-space: normal;
}

/* Better spacing for inline math */
.message-bubble .katex {
    margin: 0 2px;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: #252526;
    border-right: 1px solid rgba(0, 122, 204, 0.2);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Open state */
.sidebar.open {
    transform: translateX(0);
}

/* Desktop: open by default */
@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0);
        /* open */
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }
}

.sidebar-top {
    padding: 16px 16px 0 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.brand span {
    font-weight: 700;
    font-size: 1.4rem;
    background: #0081D7;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand .sidebar-close {
    margin-left: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    color: #e2e8f0;
    border: none;
    padding: 10px 10px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(0, 122, 204, 0.12);
}

.nav-item svg {
    width: 18px;
    height: 18px;
}

/* New Chat special styling */
/* removed special .new-chat styling to keep consistency */
.nav-new-chat {
    display: grid; /* right spacer to balance icon width and keep text perfectly centered */
    grid-template-columns: auto 1fr auto; /* icon | centered text | right spacer */
    column-gap: 8px;
    align-items: center;
    position: relative;
    background: linear-gradient(135deg, rgba(0,122,204,0.35), rgba(59,130,246,0.35));
    border: 1px solid rgba(59,130,246,0.6);
    border-radius: 999px;
    padding: 12px 14px;
    margin-top: 17px;
    margin-bottom: 6px;
    color: #eaf5ff;
}

.nav-new-chat:hover {
    background: linear-gradient(135deg, rgba(0,122,204,0.45), rgba(59,130,246,0.45));
}

.nav-new-chat span {
    font-weight: 500;
    text-align: center; /* centered in middle column */
    grid-column: 2;
    justify-self: left !important;
}

.nav-new-chat svg {
    width: 18px;
    height: 18px;
    grid-column: 1; /* icon in first column */
}

.history-header {
    padding: 6px 16px 11px 22px;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: #9aa5b1;
    text-transform: uppercase;
    margin: 0;
    line-height: 1;
}

/* removed divider entirely */

.sidebar-bottom {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-top: 0;
    margin-top: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 122, 204, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Mobile-only close button in sidebar header */
.sidebar-close {
    display: none;
    background: none;
    border: 1px solid rgba(74, 85, 104, 0.6);
    color: #cccccc;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(45, 55, 72, 0.8);
    }
}

.sidebar-header h3 {
    color: #cccccc;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.new-chat-btn {
    background: #007ACC;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-list {
    padding: 0 0 10px 0;
}

.chat-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(74, 85, 104, 0.3);
    transition: all 0.2s ease;
    position: relative;
}

.chat-item:hover {
    background: rgba(0, 122, 204, 0.1);
}

.chat-item.active {
    background: rgba(0, 122, 204, 0.2);
    border-left: 3px solid #007ACC;
}

.chat-title {
    color: #cccccc;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    color: #969696;
    font-size: 0.75rem;
    opacity: 0.8;
}

.chat-item-actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.delete-chat-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.delete-chat-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin-left: 260px !important;
    /* Default desktop state with sidebar open */
}

/* When sidebar is collapsed, remove left margin so content expands */
.main-content.sidebar-collapsed {
    margin-left: 0 !important;
}

/* Overlay for mobile when sidebar is open */
.sidebar-overlay {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

@media (min-width: 769px) {
    .sidebar-overlay {
        display: none !important;
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #252526;
    border-bottom: 1px solid rgba(0, 122, 204, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex; /* visible on desktop too */
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(0, 122, 204, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 320px;
    }

    .sidebar-toggle { display: inline-flex; }

    .ai-mode-select { display: none; }
    .ai-mode-button { display: inline-flex; }

    .main-content {
        margin-left: 0 !important;
        /* Force no margin on mobile */
    }

    .header {
        padding: 12px 16px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .header-controls {
        gap: 8px;
    }

    .ai-mode-select {
        font-size: 0.85rem;
        padding: 6px 8px;
    }

    .clear-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0);
    }

    .main-content { margin-left: 260px !important; }
    .main-content.sidebar-collapsed { margin-left: 0 !important; }
}

/* Sidebar states */
.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* Mobile sidebar behavior */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }

    .main-content.sidebar-open {
        margin-left: 0;
        /* Mobile doesn't adjust margin */
    }
}

/* Input container adjustments for sidebar states */
@media (min-width: 769px) {
    .main-content.sidebar-collapsed .input-container {
        left: 50%;
        transform: translateX(-50%);
        max-width: 1000px;
        /* Wider when sidebar is collapsed */
    }

    .main-content:not(.sidebar-collapsed) .input-container {
        left: calc(50% + 130px);
        /* Adjust for sidebar */
        transform: translateX(-50%);
        max-width: 800px;
    }
}