:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-sidebar: #fafafa;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --user-msg-bg: #e3f2fd;
    --assistant-msg-bg: #f0f0f0;
    --accent: #1e3a8a;
    --accent-hover: #1e40af;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --status-offline: #9ca3af;
    --status-online: #10b981;
    --status-streaming: #f59e0b;
}
[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-sidebar: #1a1a1a;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --border-color: #2c2c2c;
    --user-msg-bg: #1e3a8a;
    --assistant-msg-bg: #2a2a2a;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.2s;
    display: flex;
    flex-direction: column;
}
.app-container {
    display: flex;
    height: calc(100% - 50px);
}
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    gap: 1.5rem;
    overflow-y: auto;
    transition: width 0.2s ease, padding 0.2s ease;
    flex-shrink: 0;
}
.app-container.sidebar-hidden .sidebar { width: 0; padding: 0; overflow: hidden; min-width: 0; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.sidebar-header h2 { font-size: 1.25rem; font-weight: 600; }
.icon-btn { background: none; border: none; font-size: 1.25rem; cursor: pointer; padding: 0.25rem; border-radius: 4px; transition: background 0.2s; line-height: 1; }
.icon-btn:hover { background: var(--border-color); }
.burger { font-size: 1.4rem; }
.settings-section { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-section h3 { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.history-header { display: flex; justify-content: space-between; align-items: center; }
.search-input { padding: 0.4rem; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-primary); color: var(--text-primary); }
.chat-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 250px; overflow-y: auto; }
.chat-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; border-radius: 6px; cursor: pointer; background: var(--bg-primary); border: 1px solid transparent; transition: background 0.2s; }
.chat-item:hover { background: var(--border-color); }
.chat-item.active { background: var(--accent); color: white; border-color: var(--accent); }
.chat-name { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-actions { display: flex; gap: 0.25rem; opacity: 0; transition: opacity 0.2s; }
.chat-item:hover .chat-actions { opacity: 1; }
.chat-actions button { background: none; border: none; cursor: pointer; font-size: 0.8rem; padding: 0.2rem; border-radius: 4px; }
.primary-btn, .secondary-btn { padding: 0.5rem; border-radius: 6px; border: none; cursor: pointer; font-weight: 500; transition: background 0.2s; }
.primary-btn { background: var(--accent); color: white; }
.secondary-btn { background: var(--border-color); color: var(--text-primary); }
.danger-btn { background: var(--danger); color: white; border: none; padding: 0.5rem; border-radius: 6px; cursor: pointer; font-weight: 500; transition: background 0.2s; }
.danger-btn:hover { background: var(--danger-hover); }
.status-badge { margin-top: auto; display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; padding-top: 1rem; border-top: 1px solid var(--border-color); }
.status { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status.online { background: var(--status-online); box-shadow: 0 0 4px var(--status-online); }
.status.offline { background: var(--status-offline); }
.status.streaming { background: var(--status-streaming); }
.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border-color); background: var(--bg-primary); }
.chat-title { font-weight: 500; font-size: 1rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.welcome-message { text-align: center; padding: 2rem; background: var(--bg-secondary); border-radius: 12px; margin: auto; max-width: 400px; }
.welcome-icon { font-size: 3rem; margin-bottom: 1rem; }
.message { display: flex; gap: 1rem; max-width: 85%; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }
.message-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.message-content { background: var(--assistant-msg-bg); padding: 0.75rem 1rem; border-radius: 12px; line-height: 1.5; word-wrap: break-word; max-width: 100%; }
.message.user .message-content { background: var(--user-msg-bg); }
.message-content p { margin: 0; }
.input-area { padding: 1rem 1.5rem 1.5rem; border-top: 1px solid var(--border-color); background: var(--bg-primary); }
.input-wrapper { display: flex; gap: 0.75rem; align-items: flex-end; }
.input-wrapper textarea { flex: 1; padding: 0.75rem; font-size: 0.95rem; resize: none; max-height: 150px; border-radius: 20px; background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border-color); }
.send-btn { background: var(--accent); color: white; border: none; padding: 0.5rem 1.25rem; border-radius: 20px; font-weight: 600; cursor: pointer; transition: background 0.2s; height: 42px; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.typing-indicator { font-size: 0.75rem; color: var(--text-secondary); padding-left: 0.5rem; min-height: 20px; }
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; }
.modal-content { background: var(--bg-primary); padding: 2rem; border-radius: 12px; width: 350px; max-width: 90%; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.close { float: right; font-size: 1.5rem; cursor: pointer; }
.auth-tabs { display: flex; gap: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.auth-tab { background: none; border: none; padding: 0.5rem 1rem; cursor: pointer; font-weight: 500; color: var(--text-secondary); }
.auth-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.auth-form { display: none; flex-direction: column; gap: 1rem; }
.auth-form.active { display: flex; }
.auth-form input { padding: 0.6rem; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-secondary); color: var(--text-primary); }
.error-msg { color: var(--danger); font-size: 0.8rem; text-align: center; }
.footer {
    text-align: center;
    padding: 0.75rem;
    font-size: 0.8rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.footer a {
    color: var(--accent);
    text-decoration: none;
}
.footer a:hover {
    text-decoration: underline;
}
.file-label {
    cursor: pointer;
    font-size: 1.3rem;
    padding: 0.5rem;
    border-radius: 20px;
    background: var(--border-color);
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.file-label:hover {
    background: var(--accent);
    color: white;
}
.file-preview-list {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.file-preview-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.file-preview-item button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 0.2rem;
    color: var(--danger);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }