* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: #1e293b; background: #f8fafc; }

/* Chat page specific */
body.chat-page .container { max-width: 1400px; margin: 0 auto; padding: 16px; }

/* Other pages - normal scrolling */
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.topbar { display: flex; align-items: center; gap: 24px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 2px solid #e2e8f0; }
body.chat-page .topbar { margin-bottom: 12px; padding-bottom: 12px; }
.brand { color: #0f172a; font-weight: 700; font-size: 20px; letter-spacing: 0.3px; display: flex; align-items: center; }
.brand .logo { height: 50px; width: auto; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 16px; border-radius: 8px; text-decoration: none; color: #64748b; font-weight: 500; transition: all 0.2s; }
.nav a:hover { background: #f1f5f9; color: #1e293b; }
.nav a.active { background: #3b82f6; color: #fff; }
.search { display: flex; gap: 8px; margin-left: auto; }
.search input { background: #ffffff; border: 1px solid #cbd5e1; color: #1e293b; padding: 10px 12px; border-radius: 10px; min-width: 280px; }
.search input:focus { outline: none; border-color: #3b82f6; }
.search button { background: #3b82f6; color: #fff; border: 0; padding: 10px 14px; border-radius: 10px; cursor: pointer; font-weight: 500; }
.search button:hover { background: #2563eb; }
.search .clear { color: #3b82f6; text-decoration: none; padding: 10px; }
.search .clear:hover { color: #2563eb; }

.panel { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.panel h2 { color: #0f172a; font-size: 18px; margin: 0 0 16px; font-weight: 600; }
.panel .hint { color: #64748b; font-size: 12px; margin-top: 8px; }

.upload .row { display: flex; gap: 10px; margin-bottom: 10px; }
.upload input[type="file"], .upload input[type="text"], .upload select { flex: 1; background: #ffffff; border: 1px solid #cbd5e1; color: #1e293b; padding: 10px 12px; border-radius: 10px; }
.upload input[type="file"]:focus, .upload input[type="text"]:focus, .upload select:focus { outline: none; border-color: #3b82f6; }
.upload button { background: #10b981; color: #fff; border: 0; padding: 10px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.upload button:hover { background: #059669; }
.upload button:disabled { opacity: 0.5; cursor: not-allowed; background: #94a3b8; }

/* Drag and Drop Zone */
.drag-drop-zone { 
  border: 2px dashed #cbd5e1; 
  border-radius: 12px; 
  padding: 40px 20px; 
  text-align: center; 
  background: #f8fafc; 
  cursor: pointer; 
  transition: all 0.3s ease;
  margin-bottom: 16px;
}
.drag-drop-zone:hover { 
  border-color: #3b82f6; 
  background: #eff6ff; 
}
.drag-drop-zone.drag-over { 
  border-color: #3b82f6; 
  background: #dbeafe; 
  transform: scale(1.02);
}
.drag-drop-content { pointer-events: none; }
.drag-drop-icon { font-size: 48px; margin-bottom: 12px; }
.drag-drop-text { color: #1e293b; font-size: 16px; font-weight: 500; margin: 0 0 8px 0; }
.drag-drop-link { color: #3b82f6; text-decoration: underline; }
.drag-drop-hint { color: #64748b; font-size: 13px; margin: 0; }

/* File List */
.file-list { margin-top: 16px; margin-bottom: 16px; }
.file-list-header { 
  font-size: 14px; 
  font-weight: 600; 
  color: #0f172a; 
  margin-bottom: 12px; 
}
.file-item { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  background: #ffffff; 
  border: 1px solid #e2e8f0; 
  border-radius: 8px; 
  padding: 12px; 
  margin-bottom: 8px; 
  transition: all 0.2s;
}
.file-item:hover { 
  border-color: #3b82f6; 
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}
.file-item-info { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  flex: 1; 
  min-width: 0;
}
.file-item-icon { 
  font-size: 24px; 
  flex-shrink: 0;
}
.file-item-details { 
  flex: 1; 
  min-width: 0;
}
.file-item-name { 
  font-weight: 500; 
  color: #1e293b; 
  font-size: 14px; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap;
}
.file-item-size { 
  color: #64748b; 
  font-size: 12px; 
  margin-top: 2px;
}
.file-item-remove { 
  background: #fee2e2; 
  border: 1px solid #fecaca; 
  color: #dc2626; 
  border-radius: 6px; 
  width: 28px; 
  height: 28px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  font-size: 16px; 
  font-weight: 600; 
  transition: all 0.2s; 
  flex-shrink: 0;
}
.file-item-remove:hover { 
  background: #fecaca; 
  border-color: #fca5a5; 
  transform: scale(1.1);
}

.progress { margin-top: 16px; }
.progress .progress-bar { 
  background: #e2e8f0; 
  height: 8px; 
  border-radius: 4px; 
  overflow: hidden; 
  margin-bottom: 8px;
}
.progress .progress-fill { 
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%); 
  height: 100%; 
  width: 0%; 
  transition: width 0.3s ease;
}
.progress span, 
.progress #progressText { 
  color: #3b82f6; 
  font-weight: 500; 
  font-size: 14px;
  display: block;
}
.hidden { display: none; }

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; padding: 6px 12px; border-radius: 999px; text-decoration: none; font-size: 12px; font-weight: 500; transition: all 0.2s; }
.tag:hover { background: #e2e8f0; border-color: #94a3b8; }
.tag.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.badge { background: #3b82f6; color: #fff; border-radius: 999px; padding: 2px 6px; font-size: 10px; margin-left: 6px; font-weight: 600; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.table thead { background: #f8fafc; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #e2e8f0; color: #1e293b; vertical-align: middle; }
.table th { font-weight: 600; color: #0f172a; }
.table tbody tr:nth-child(even) { background: #fafcff; }
.table tbody tr:hover { background: #f1f5f9; }
.table a { color: #3b82f6; font-weight: 500; text-decoration: none; }
.table a:hover { color: #2563eb; text-decoration: underline; }
.notes { color: #64748b; font-size: 12px; margin-top: 4px; }
.tags-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; line-height: 1; box-shadow: 0 1px 0 rgba(15,23,42,0.04); transition: transform 0.05s ease, box-shadow 0.2s ease; }
.chip:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(15,23,42,0.08); }
/* Color variants (deterministic per tag) */
.chip-1 { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.chip-2 { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.chip-3 { background: #f0fdf4; border-color: #86efac; color: #166534; }
.chip-4 { background: #f5f3ff; border-color: #ddd6fe; color: #4c1d95; }
.chip-5 { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.chip-6 { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.type-badge { display: inline-block; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.size-badge { display: inline-block; background: #f1f5f9; border: 1px solid #cbd5e1; color: #334155; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.actions .secondary { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.actions .secondary:hover { background: #e2e8f0; }
/* Ensure inline layout and equal widths for action buttons */
.actions-row { display: flex; gap: 8px; align-items: center; }
.actions-row form { flex: 1; margin: 0; }
.actions-row form button { width: 100%; }

.toast { position: fixed; right: 20px; bottom: 20px; background: #ffffff; color: #0f172a; border: 1px solid #e2e8f0; padding: 12px 16px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.15); }

.footer { text-align: center; padding: 24px 0; margin-top: 40px; color: #64748b; font-size: 13px; border-top: 1px solid #e2e8f0; }
body.chat-page .footer { padding: 12px 0; margin-top: 20px; font-size: 12px; }
.footer a { color: #3b82f6; text-decoration: none; font-weight: 600; transition: color 0.2s; }
.footer a:hover { color: #2563eb; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger { padding: 8px 16px; border-radius: 8px; text-decoration: none; font-weight: 500; font-size: 14px; border: 0; cursor: pointer; transition: all 0.2s; display: inline-block; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-danger-small { background: #ef4444; color: #fff; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 13px; transition: all 0.2s; }
.btn-danger-small:hover { background: #dc2626; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.2s ease; }
.modal-overlay.hidden { display: none !important; }

/* Model Selection Modal */
.model-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.7); display: flex; align-items: center; justify-content: center; z-index: 2000; animation: fadeIn 0.2s ease; }
.model-modal-overlay.hidden { display: none !important; }
.model-modal { background: #ffffff; border-radius: 16px; padding: 28px; max-width: 500px; width: 90%; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); animation: slideUp 0.3s ease; }
.model-modal h3 { margin: 0 0 12px; font-size: 20px; color: #0f172a; display: flex; align-items: center; gap: 8px; }
.model-modal p { color: #475569; line-height: 1.6; margin: 0 0 20px; font-size: 14px; }
.model-modal-content { margin-bottom: 24px; }
.model-modal-content .filter-section { margin-bottom: 0; }
.model-modal-content .filter-section label { color: #0f172a; font-size: 14px; font-weight: 500; }
.model-modal-content .searchable-select input[type="text"] { background: #f8fafc; border: 1px solid #cbd5e1; color: #1e293b; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.model-modal-content .searchable-select input[type="text"]:focus { outline: none; border-color: #3b82f6; background: #ffffff; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.model-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.model-modal-actions button { padding: 10px 20px; border-radius: 8px; font-weight: 500; font-size: 14px; cursor: pointer; transition: all 0.2s; border: 0; }
.modal { background: #ffffff; border-radius: 16px; padding: 28px; max-width: 500px; width: 90%; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); animation: slideUp 0.3s ease; }
.modal h3 { margin: 0 0 12px; font-size: 20px; color: #0f172a; display: flex; align-items: center; gap: 8px; }
.modal p { color: #475569; line-height: 1.6; margin: 0 0 20px; }
.modal-input { width: 100%; background: #f8fafc; border: 1px solid #cbd5e1; color: #1e293b; padding: 12px; border-radius: 8px; font-family: 'Inter', system-ui, sans-serif; font-size: 14px; margin-bottom: 20px; }
.modal-input:focus { outline: none; border-color: #ef4444; background: #ffffff; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button { padding: 10px 20px; border-radius: 8px; font-weight: 500; font-size: 14px; cursor: pointer; transition: all 0.2s; border: 0; }
.modal-btn-cancel { background: #f1f5f9; color: #475569; }
.modal-btn-cancel:hover { background: #e2e8f0; }
.modal-btn-danger { background: #ef4444; color: #fff; }
.modal-btn-danger:hover { background: #dc2626; }
.modal-btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.warning-icon { font-size: 24px; }

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

/* Model Form */
.model-form { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-weight: 500; color: #0f172a; margin-bottom: 6px; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea { background: #ffffff; border: 1px solid #cbd5e1; color: #1e293b; padding: 10px 12px; border-radius: 8px; font-family: inherit; font-size: 14px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.form-group textarea { resize: vertical; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* Filter Badge */
.filter-badge { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.clear-filter { color: #1e40af; text-decoration: none; font-weight: 700; }
.clear-filter:hover { color: #1e3a8a; }

/* Model Link */
.model-link { color: #3b82f6; font-weight: 500; text-decoration: none; }
.model-link:hover { color: #2563eb; text-decoration: underline; }

/* Chat Interface */
.chat-container { display: grid; grid-template-columns: 280px 1fr 300px; gap: 16px; margin-bottom: 20px; }

/* Conversations Sidebar (Left) */
.conversations-sidebar { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3); height: 600px; }
.conversations-sidebar h3 { margin: 0 0 12px; font-size: 15px; color: #ffffff; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Chat Settings Sidebar (Right) */
.chat-settings-sidebar { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3); height: 600px; }
.chat-settings-sidebar h3 { margin: 0 0 12px; font-size: 15px; color: #ffffff; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-sidebar-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.chat-sidebar-content::-webkit-scrollbar { width: 6px; }
.chat-sidebar-content::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
.chat-sidebar-content::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 3px; }
.chat-sidebar-content::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }
.sidebar-section { background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); border-radius: 10px; padding: 12px; border: 1px solid rgba(255, 255, 255, 0.2); flex-shrink: 0; }
.sidebar-section-title { color: #ffffff; font-weight: 600; font-size: 13px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.filter-section { margin-bottom: 10px; }
.filter-section:last-child { margin-bottom: 0; }
.filter-section label { display: block; font-weight: 500; color: rgba(255, 255, 255, 0.9); font-size: 12px; margin-bottom: 6px; }
.filter-section select { width: 100%; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(255, 255, 255, 0.3); color: #1e293b; padding: 8px 10px; border-radius: 8px; font-size: 13px; transition: all 0.2s; }
.filter-section select:focus { outline: none; border-color: #ffffff; background: #ffffff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); }

/* Searchable Select */
.searchable-select { position: relative; width: 100%; }
.searchable-select input[type="text"] { width: 100%; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(255, 255, 255, 0.3); color: #1e293b; padding: 8px 10px; border-radius: 8px; font-size: 13px; transition: all 0.2s; }
.searchable-select input[type="text"]:focus { outline: none; border-color: #ffffff; background: #ffffff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); }
.searchable-select-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; margin-top: 4px; max-height: 250px; overflow-y: auto; z-index: 1000; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); display: none; }
.searchable-select-dropdown.show { display: block; }
.searchable-select-option { padding: 10px 12px; cursor: pointer; color: #1e293b; font-size: 14px; transition: background 0.15s; }
.searchable-select-option:hover { background: #f1f5f9; }
.searchable-select-option.selected { background: #eff6ff; color: #1e40af; font-weight: 500; }
.searchable-select-option.hidden { display: none; }
.filter-section input[type="checkbox"] { 
  margin-right: 8px; 
  margin-top: 0;
  margin-bottom: 0;
  vertical-align: middle;
  cursor: pointer;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.checkbox-label { 
  color: rgba(255, 255, 255, 0.95); 
  display: flex; 
  align-items: center; 
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  gap: 8px;
}
.checkbox-label input[type="checkbox"] {
  margin: 0;
}

.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px; margin-top: 20px; font-size: 12px; color: #1e40af; }
.info-box strong { display: block; margin-bottom: 8px; }
.info-box ul { margin: 0; padding-left: 18px; }
.info-box li { margin-bottom: 4px; }

.chat-main { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; display: flex; flex-direction: column; height: 600px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; height: 0; }
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: #f8fafc; }
.chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.message { display: flex; gap: 10px; margin-bottom: 14px; animation: fadeIn 0.3s ease-in; align-items: flex-start; }
.message.user { flex-direction: row-reverse; }
.message-avatar { width: 40px; height: 40px; border-radius: 50%; background: #ffffff; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; border: 2px solid #e2e8f0; overflow: hidden; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message.user .message-avatar { background: #3b82f6; color: #ffffff; border-color: #3b82f6; }
.message.error .message-avatar { background: #fee2e2; border-color: #fca5a5; }
.message-content { flex: 1; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.message.user .message-content { background: #eff6ff; border-color: #bfdbfe; }
.message.error .message-content { background: #fef2f2; border-color: #fecaca; }
.message-content strong { display: block; margin-bottom: 8px; color: #0f172a; font-size: 13px; font-weight: 600; }
.message-content p { margin: 0; color: #475569; line-height: 1.6; white-space: pre-wrap; font-size: 14px; }

/* Markdown Content Styling */
.markdown-content { color: #475569; line-height: 1.7; font-size: 14px; }
.markdown-content p { margin: 0 0 12px 0; }
.markdown-content p:last-child { margin-bottom: 0; }
.markdown-content h1, .markdown-content h2, .markdown-content h3 { color: #0f172a; font-weight: 600; margin: 16px 0 8px 0; }
.markdown-content h1 { font-size: 20px; }
.markdown-content h2 { font-size: 18px; }
.markdown-content h3 { font-size: 16px; }
.markdown-content ul, .markdown-content ol { margin: 8px 0 12px 0; padding-left: 24px; }
.markdown-content li { margin-bottom: 4px; }
.markdown-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 13px; color: #e11d48; }
.markdown-content pre { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.markdown-content pre code { background: none; padding: 0; color: #0f172a; }
.markdown-content blockquote { border-left: 3px solid #3b82f6; padding-left: 12px; margin: 12px 0; color: #64748b; font-style: italic; }
.markdown-content strong { font-weight: 600; color: #0f172a; }
.markdown-content em { font-style: italic; }
.markdown-content a { color: #3b82f6; text-decoration: underline; }
.markdown-content a:hover { color: #2563eb; }
.markdown-content hr { border: 0; border-top: 1px solid #e2e8f0; margin: 16px 0; }
.markdown-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.markdown-content th, .markdown-content td { border: 1px solid #e2e8f0; padding: 8px 12px; text-align: left; }
.markdown-content th { background: #f8fafc; font-weight: 600; }

.sources { margin-top: 16px; padding: 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; }
.sources strong { display: block; margin-bottom: 8px; color: #0f172a; }
.sources ul { margin: 0; padding: 0; list-style: none; }
.sources li { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0; }
.sources li:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.source-model { display: inline-block; background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 4px; font-size: 11px; margin-left: 8px; font-weight: 600; }
.source-snippet { color: #64748b; font-size: 12px; margin-top: 4px; font-style: italic; }

.chat-input-form { padding: 12px 16px; border-top: 1px solid #e2e8f0; flex-shrink: 0; background: #ffffff; }
.input-container { 
  display: flex; 
  gap: 8px; 
  align-items: flex-end; 
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  padding: 8px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}
.input-container:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.textarea-wrapper { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  min-height: 24px;
  position: relative; 
}
.chat-input-form textarea { 
  width: 100%; 
  background: transparent; 
  border: none; 
  color: #1e293b; 
  padding: 8px 4px; 
  border-radius: 0;
  font-family: inherit; 
  font-size: 15px; 
  resize: none; 
  max-height: 200px; 
  min-height: 24px;
  line-height: 1.5; 
  box-sizing: border-box;
  overflow-y: auto;
}
.chat-input-form textarea:focus { 
  outline: none; 
  border: none;
  box-shadow: none;
}
.chat-input-form textarea::placeholder {
  color: #9ca3af;
}
.input-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  padding-bottom: 2px;
}
.btn-circle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: #6b7280;
  position: relative;
  box-sizing: border-box;
}
.btn-circle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}
.btn-send {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}
.btn-send:hover:not(:disabled) {
  background: #059669;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.4);
  transform: scale(1.05);
}
.btn-send:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-send:disabled {
  background: #d1d5db;
  color: #9ca3af;
  opacity: 0.7;
  box-shadow: none;
}
.btn-microphone {
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}
.btn-microphone:hover:not(:disabled) {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
  transform: scale(1.05);
}
.btn-microphone:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-microphone.recording {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse-recording 1.5s ease-in-out infinite;
}
.btn-microphone.recording::before,
.btn-microphone.recording::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #ef4444;
  opacity: 0;
  transform: translate(-50%, -50%);
}
.btn-microphone.recording::before {
  animation: sound-wave 1.5s ease-out infinite;
}
.btn-microphone.recording::after {
  animation: sound-wave 1.5s ease-out 0.5s infinite;
}
.btn-microphone.recording:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #ffffff;
  border-color: #dc2626;
  transform: scale(1.05);
}
.btn-circle svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
  display: block;
  margin: auto;
  flex-shrink: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}
.btn-microphone.recording svg {
  animation: mic-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-recording {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7),
                0 0 20px rgba(239, 68, 68, 0.3);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0),
                0 0 30px rgba(239, 68, 68, 0.5);
  }
}
@keyframes sound-wave {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.8;
  }
  100% {
    width: 180%;
    height: 180%;
    opacity: 0;
  }
}
@keyframes mic-pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.1);
  }
}
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Audio Visualizer */
.audio-visualizer-container {
  padding: 10px;
  /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
  border-top: 1px solid #e2e8f0;
  /* display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px; */
  animation: slideDown 0.3s ease;
}
.audio-visualizer-container.hidden {
  display: none;
}
#audioVisualizer {
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
  display: block;
  max-width: 100%;
  width: 100%;
}
.visualizer-label {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: pulse-text 1.5s ease-in-out infinite;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pulse-text {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Attached Files */
.attached-files { 
  position: absolute; 
  bottom: calc(100% + 8px); 
  left: 0; 
  right: 0; 
  display: flex; 
  flex-wrap: wrap; 
  gap: 6px; 
  z-index: 10;
}
.file-chip { display: inline-flex; align-items: center; gap: 6px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 4px 8px; border-radius: 6px; font-size: 12px; }
.file-icon { font-size: 14px; }
.file-name { font-weight: 500; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: #60a5fa; font-size: 11px; }
.remove-file { background: none; border: none; color: #3b82f6; cursor: pointer; padding: 0; margin-left: 4px; font-weight: 700; font-size: 14px; }
.remove-file:hover { color: #1e40af; }

/* User Attachments in Messages */
.user-attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.attachment-badge { display: inline-flex; align-items: center; gap: 4px; background: #dbeafe; border: 1px solid #93c5fd; padding: 3px 8px; border-radius: 4px; font-size: 11px; color: #1e40af; font-weight: 500; }

/* Thinking Animation */
.thinking-text { color: #64748b; font-style: italic; }
.thinking-text .dots {
  animation: blink 1.4s infinite;
  display: inline-block;
}

@keyframes blink {
  0%, 20% { opacity: 0; }
  40% { opacity: 1; }
  60%, 100% { opacity: 0; }
}

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

/* Conversations List */
.btn-new-conversation { width: 100%; background: rgba(255, 255, 255, 0.25); color: #fff; border: 1px solid rgba(255, 255, 255, 0.4); padding: 10px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; margin-bottom: 10px; transition: all 0.2s; backdrop-filter: blur(10px); }
.btn-new-conversation:hover { background: rgba(255, 255, 255, 0.35); border-color: rgba(255, 255, 255, 0.6); transform: translateY(-1px); }
.conversations-list { flex: 1; overflow-y: auto; min-height: 0; max-height: calc(100vh - 200px); }
.conversations-list::-webkit-scrollbar { width: 4px; }
.conversations-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
.conversations-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 2px; }
.conversations-list::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }
.conversation-item { padding: 10px; margin-bottom: 6px; border-radius: 8px; cursor: pointer; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15); transition: all 0.2s; position: relative; }
.conversation-item:hover { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.3); }
.conversation-item.active { background: rgba(255, 255, 255, 0.3); border-color: rgba(255, 255, 255, 0.5); }
.conversation-title { font-size: 13px; font-weight: 500; color: #ffffff; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 50px; }
.conversation-title-input { width: 100%; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(255, 255, 255, 0.5); color: #1e293b; padding: 6px 8px; border-radius: 6px; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.conversation-title-input:focus { outline: none; border-color: #ffffff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3); }
.conversation-meta { font-size: 11px; color: rgba(255, 255, 255, 0.7); }
.conversation-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.conversation-item:hover .conversation-actions { opacity: 1; }
.conversation-action-btn { background: rgba(255, 255, 255, 0.2); border: none; color: #ffffff; cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 4px; transition: all 0.2s; }
.conversation-action-btn:hover { background: rgba(255, 255, 255, 0.3); }
.conversation-action-btn.delete { background: rgba(239, 68, 68, 0.8); }
.conversation-action-btn.delete:hover { background: #dc2626; }

/* AI Model Switch */
.model-switch { display: flex; gap: 6px; margin-bottom: 10px; }
.model-switch-btn { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.8); cursor: pointer; font-size: 11px; font-weight: 600; transition: all 0.2s; text-align: center; }
.model-switch-btn:hover { background: rgba(255, 255, 255, 0.15); }
.model-switch-btn.active { background: rgba(255, 255, 255, 0.95); color: #667eea; border-color: #ffffff; }
.model-badge { display: block; font-size: 10px; font-weight: 500; margin-top: 2px; opacity: 0.8; }

/* Mobile Responsive */
@media (max-width: 1024px) {
  .chat-container { 
    grid-template-columns: 1fr; 
    gap: 12px;
  }
  
  /* Mobile order: 1. Settings, 2. Conversations, 3. Chat */
  .chat-settings-sidebar { order: 1; height: auto; }
  .conversations-sidebar { order: 2; height: auto; }
  .chat-main { order: 3; height: 500px; }
  
  .chat-messages { max-height: 400px; }
}

/* Excel Upload Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.2s ease; }
.modal.hidden { display: none !important; }
.modal-content { background: #ffffff; border-radius: 16px; max-width: 600px; width: 90%; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); animation: slideUp 0.3s ease; overflow: hidden; }
.modal-header { padding: 24px 24px 20px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 20px; color: #0f172a; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 28px; color: #64748b; cursor: pointer; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: all 0.2s; }
.modal-close:hover { background: #f1f5f9; color: #1e293b; }
.modal-body { padding: 24px; max-height: 500px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; }

/* Upload Progress */
.upload-progress { text-align: center; padding: 20px 0; }
.progress-bar { background: #e2e8f0; height: 8px; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%); height: 100%; width: 0%; animation: progressAnimation 2s ease-in-out infinite; }
@keyframes progressAnimation {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}
.progress-text { color: #475569; font-size: 14px; font-weight: 500; }

/* Alert Messages */
.alert { padding: 16px 20px; border-radius: 12px; margin-bottom: 16px; }
.alert h4 { margin: 0 0 8px 0; font-size: 16px; font-weight: 600; }
.alert p { margin: 0; font-size: 14px; line-height: 1.5; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-success h4 { color: #15803d; }
.alert-error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-error h4 { color: #dc2626; }
.alert details { margin-top: 10px; }
.alert summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.alert summary:hover { color: #0f172a; }
.alert ul { margin: 10px 0 0 0; padding-left: 20px; }
.alert li { margin-bottom: 6px; font-size: 13px; line-height: 1.4; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 20px 0 10px; border-top: 1px solid #e2e8f0; margin-top: 20px; }
.pagination-info { color: #64748b; font-size: 14px; font-weight: 500; }
.pagination-controls { display: flex; align-items: center; gap: 6px; }
.pagination-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 12px; background: #ffffff; border: 1px solid #cbd5e1; color: #475569; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 500; transition: all 0.2s; cursor: pointer; }
.pagination-btn:hover:not(.disabled):not(.active) { background: #f8fafc; border-color: #94a3b8; color: #1e293b; }
.pagination-btn.active { background: #3b82f6; border-color: #3b82f6; color: #ffffff; font-weight: 600; cursor: default; }
.pagination-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-ellipsis { color: #94a3b8; font-weight: 600; padding: 0 4px; }